12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355 |
- /* ===========================================================
- * trumbowyg.pasteImageKiss.js v1.0 basé sur trumbowyg.pasteImage.js v1.0
- * Basic base64 paste plugin for Trumbowyg
- * http://alex-d.github.com/Trumbowyg
- * ===========================================================
- * Author : Valentin CARRUESCO depuis Alexandre Demode (Alex-D)
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- plugins: {
- pasteImageKiss: {
- init: function (trumbowyg) {
- trumbowyg.pasteHandlers.push(function (pasteEvent) {
- try {
- var items = (pasteEvent.originalEvent || pasteEvent).clipboardData.items,
- mustPreventDefault = false,
- reader;
- for (var i = items.length - 1; i >= 0; i -= 1) {
- if (items[i].type.match(/^image\//)) {
- var file = items[i].getAsFile();
- if(file.size > 5000 && !trumbowyg.o.allowBigPaste){
- //mode upload, fichier lourd
- if(trumbowyg.o.uploadAction){
-
- $.action({
- action : trumbowyg.o.uploadAction,
- stream : file,
- name : Date.now().getTime()+(Math.floor(Math.random() * Math.floor(1000)))+'.png'
- },function(response){
-
- trumbowyg.execCmd('insertHtml',response.html, false, true);
- });
- }else{
- //Si aucune action d'upload prévue
- trumbowyg.execCmd('insertHtml','<span class="text-danger">Image Trop lourde ('+file.size+' octets) et upload non implémenté</span>', false, true);
- }
- }else{
- //mode base 64 fichier léger
- reader = new FileReader();
- reader.onloadend = function (event) {
- var base64 = event.target.result;
- trumbowyg.execCmd('insertImage',base64, false, true);
- };
- reader.readAsDataURL(file);
-
- }
-
- mustPreventDefault = true;
- }
- }
- if (mustPreventDefault) {
- pasteEvent.stopPropagation();
- pasteEvent.preventDefault();
- }
- } catch (c) {
- }
- });
- }
- }
- }
- });
- })(jQuery);
- /* ===========================================================
- * trumbowyg.core.cleanpaste.js v1.0
- * Clean les balises word
- * ===========================================================
- * Authors : Valentin CARRUESCO
- */
- (function ($) {
- 'use strict';
- // clean editor
- // this will clean the inserted contents
- // it does a compare, before and after paste to determine the
- // pasted contents
- $.extend(true, $.trumbowyg, {
- plugins: {
- cleanPaste: {
- init: function (trumbowyg) {
- trumbowyg.pasteHandlers.push(function () {
- setTimeout(function () {
- try {
- trumbowyg.$ed.find("*").filter(function(){
- return /([^><]*):([^>]*)/i.test(this.nodeName);
- }).remove();
- } catch (c) {
- }
- }, 0);
- });
- }
- }
- }
- });
- })(jQuery);
- /* ===========================================================
- * trumbowyg drag & drop
- * Permet l'upload en drag & drop
- * ===========================================================
- * Authors : Valentin CARRUESCO
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- plugins: {
- dragAndDrop: {
- init: function (trumbowyg) {
-
- //Attens que le dom soit chargé (sinon trumbowyg.$ed n'est pas accessible)
- trumbowyg.$c.on('tbwinit', function () {
-
- //test if d&d is enabled n browser
- var div = document.createElement('div');
- var dragAndDropEnabled = (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && 'FormData' in window && 'FileReader' in window;
- if (!dragAndDropEnabled) return;
- trumbowyg.$ed
- .off('click drag dragstart dragend dragenter dragleave drop dragover').on('click', function (e) {
- e.preventDefault();
- e.stopPropagation();
- })
- .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
- e.preventDefault();
- e.stopPropagation();
- })
- .on('dragover dragenter', function () {
- trumbowyg.$ed.addClass('wysiwyg-dragover');
- })
- .on('dragleave dragend drop', function () {
- trumbowyg.$ed.removeClass('wysiwyg-dragover');
- })
- .on('drop', function (e) {
- var droppedFiles = e.originalEvent.dataTransfer.files;
-
- if(trumbowyg.o.uploadAction){
- $.each(droppedFiles, function (i, file) {
- var uid = btoa(file.name);
- trumbowyg.execCmd('insertHtml','<span class="text-muted wysiwyg-upload" data-uid="'+uid+'"><i class="fas fa-circle-notch fa-spin"></i> '+file.name+' envois en cours...</span>', false, true);
-
- $.action({
- action : trumbowyg.o.uploadAction,
- stream : file,
- name : file.name
- },function(response){
- $('.wysiwyg-upload[data-uid="'+uid+'"]').remove();
- trumbowyg.execCmd('insertHtml',response.html, false, true);
- },function(error){
- $('.wysiwyg-upload[data-uid="'+uid+'"]').remove();
- });
- });
- }else{
- //Si aucune action d'upload prévue
- trumbowyg.execCmd('insertHtml','<span class="text-danger">Upload non implémenté dans ce composant</span>', false, true);
- }
- });
- });
-
- }
- }
- }
- });
- })(jQuery);
- /**/
- /* ===========================================================
- * resize image
- * Permet le resize des images
- * ===========================================================
- * Authors : Valentin CARRUESCO
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- plugins: {
- resizeImage: {
- init: function (trumbowyg) {
-
- //Attens que le dom soit chargé (sinon trumbowyg.$ed n'est pas accessible)
- trumbowyg.$c.on('tbwinit', function () {
-
- trumbowyg.$ed.on('click','img',function(){
- $(this).resizable({
- aspectRatio : true,
- resize : function(event, ui ){
-
- ui.originalElement.css({
- height : ui.size.height+'px',
- width : ui.size.width+'px'
- });
- }
- });
- });
- trumbowyg.$ed.click(function(e){
- if($(e.target).hasClass('ui-resizable')) return;
- trumbowyg.$ed.find('.ui-resizable').resizable('destroy');
- });
- });
- }
- }
- }
- });
- })(jQuery);
- /* ===========================================================
- * trumbowyg.fontfamily.js v1.2
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- langs: {
- // jshint camelcase:false
- en: {
- fontFamily: 'Font'
- },
- da: {
- fontFamily: 'Skrifttype'
- },
- fr: {
- fontFamily: 'Police'
- },
- de: {
- fontFamily: 'Schriftart'
- },
- nl: {
- fontFamily: 'Lettertype'
- },
- tr: {
- fontFamily: 'Yazı Tipi'
- },
- zh_tw: {
- fontFamily: '字體',
- },
- pt_br: {
- fontFamily: 'Fonte',
- },
- ko: {
- fontFamily: '글꼴'
- },
- }
- });
- // jshint camelcase:true
- var defaultOptions = {
- fontList: [
- {name: 'Arial', family: 'Arial, Helvetica, sans-serif'},
- {name: 'Arial Black', family: 'Arial Black, Gadget, sans-serif'},
- {name: 'Comic Sans', family: 'Comic Sans MS, Textile, cursive, sans-serif'},
- {name: 'Courier New', family: 'Courier New, Courier, monospace'},
- {name: 'Georgia', family: 'Georgia, serif'},
- {name: 'Impact', family: 'Impact, Charcoal, sans-serif'},
- {name: 'Lucida Console', family: 'Lucida Console, Monaco, monospace'},
- {name: 'Lucida Sans', family: 'Lucida Sans Uncide, Lucida Grande, sans-serif'},
- {name: 'Palatino', family: 'Palatino Linotype, Book Antiqua, Palatino, serif'},
- {name: 'Tahoma', family: 'Tahoma, Geneva, sans-serif'},
- {name: 'Times New Roman', family: 'Times New Roman, Times, serif'},
- {name: 'Trebuchet', family: 'Trebuchet MS, Helvetica, sans-serif'},
- {name: 'Verdana', family: 'Verdana, Geneva, sans-serif'}
- ]
- };
- // Add dropdown with web safe fonts
- $.extend(true, $.trumbowyg, {
- plugins: {
- fontfamily: {
- init: function (trumbowyg) {
- trumbowyg.o.plugins.fontfamily = $.extend({},
- defaultOptions,
- trumbowyg.o.plugins.fontfamily || {}
- );
- trumbowyg.addBtnDef('fontfamily', {
- dropdown: buildDropdown(trumbowyg),
- hasIcon: false,
- text: trumbowyg.lang.fontFamily
- });
- }
- }
- }
- });
- function buildDropdown(trumbowyg) {
- var dropdown = [];
- $.each(trumbowyg.o.plugins.fontfamily.fontList, function (index, font) {
- trumbowyg.addBtnDef('fontfamily_' + index, {
- title: '<span style="font-family: ' + font.family + ';">' + font.name + '</span>',
- hasIcon: false,
- fn: function () {
- trumbowyg.execCmd('fontName', font.family, false);
- }
- });
- dropdown.push('fontfamily_' + index);
- });
- return dropdown;
- }
- })(jQuery);
- /* ===========================================================
- * trumbowyg.mention.js v1.0
- * Allow mention with @,# or any key
- * ===========================================================
- * Authors : Valentin CARRUESCO
- */
- (function ($) {
- 'use strict';
- var o = {
- //Supprime la totalité du mention si un backspace entame le mention
- autoDelete : true,
- //Ne déclenche la touche que si elle est précédée d'un espace, d'un saut de ligne ou d'une nouvelle balise
- triggerBreak : true
- };
- $.extend(true, $.trumbowyg, {
- plugins: {
- mention: {
- init: function (trumbowyg) {
- var object = this;
- object.altGrPressed = false;
- trumbowyg.o.plugins.mention = $.extend(true, {},o,trumbowyg.o.plugins.mention || {});
-
- var keyMap = {
- 48 : {
- label : '@',
- check : function(event){
- return object.altGrPressed;
- }
- },
- 51 : {
- label : '#',
- check : function(event){
- return object.altGrPressed;
- }
- }
- }
- $(trumbowyg.$ta).parent().on('keydown', function (e) {
- var code = e.which || e.keyCode ;
- //verifie si alt+gr est enfoncé
- if(code==18){
- object.altGrPressed = true;
- return;
- }
-
- //Supprime les mentions en totalité sur un backspace
- if(trumbowyg.o.plugins.mention.autoDelete && code==8){
- var editor = trumbowyg.$ed;
- var textarea = trumbowyg.$ta;
- textarea.trumbowyg('saveRange');
- if(!textarea.trumbowyg('getRange') || !textarea.trumbowyg('getRange').endContainer) return;
-
- var parent = $(textarea.trumbowyg('getRange').endContainer.parentElement);
- if(parent.attr('data-mention-type')!= null){
- parent.remove();
- editor.trigger('keyup');
- }
- }
- //if(Object.keys(trumbowyg.o.plugins.mention.keys).indexOf(""+code) == -1) return;
- if(keyMap[code] == null) return;
-
- var char = keyMap[code].label;
- if(!trumbowyg.o.plugins.mention.keys || Object.keys(trumbowyg.o.plugins.mention.keys).indexOf(char) == -1) return;
-
- if(keyMap[code].check && !keyMap[code].check(event)) return;
-
-
- var editor = trumbowyg.$ed;
- var textarea = trumbowyg.$ta;
- var range = trumbowyg.$ta.trumbowyg('getRange');
- var lastChar = !range || !range.startContainer || !range.startContainer.data ? '' : range.startContainer.data;
- lastChar = lastChar.length>0 ? lastChar.substring(lastChar.length-1) : '';
-
- //si le caractere trigger n'est pas lancé apres un espace ou un saut de ligne on ne fait rien
- if(trumbowyg.o.plugins.mention.triggerBreak && lastChar != '' && lastChar != ' ') return;
-
- var key = trumbowyg.o.plugins.mention.keys[char];
- if(!key.load) return;
- var data = {
- editor : editor,
- event : e,
- textarea : textarea,
- lastChar : lastChar
- }
- data.textarea.trumbowyg('saveRange');
- key.load(data);
- }).on('keyup', function (e) {
- var code = e.which || e.keyCode ;
- //désactive le altgr mode si relaché
- if(code==18){
- object.altGrPressed = false;
- return;
- }
- });
- }
-
- }
- }
- })
- })(jQuery);
- /**
- Font size core, ne pas upgrade !!
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- langs: {
- fr: {
- fontsize: 'Taille de la police',
- fontsizes: {
- 'x-small': 'Très petit',
- 'small': 'Petit',
- 'medium': 'Normal',
- 'large': 'Grand',
- 'x-large': 'Très grand',
- 'custom': 'Taille personnalisée'
- },
- fontCustomSize: {
- title: 'Taille de police personnalisée',
- label: 'Taille de la police',
- value: '48px'
- }
- }
- }
- });
- // Add dropdown with font sizes
- $.extend(true, $.trumbowyg, {
- plugins: {
- fontsize: {
- init: function (trumbowyg) {
- trumbowyg.o.plugins.fontsize = $.extend({},
- {
- sizeList: [
- '8px',
- '9px',
- '10px',
- '11px',
- '12px',
- '14px',
- '16px',
- '18px',
- '20px',
- '22px',
- '24px',
- '26px',
- '28px',
- '36px',
- '48px',
- '72px'
- ],
- allowCustomSize: true
- },
- trumbowyg.o.plugins.fontsize || {}
- );
- trumbowyg.addBtnDef('fontsize', {
- dropdown: buildDropdown(trumbowyg)
- });
- }
- }
- }
- });
- function setFontSize(trumbowyg, size) {
- trumbowyg.$ed.focus();
- trumbowyg.saveRange();
- // Temporary size
- trumbowyg.execCmd('fontSize', '1');
- // Find <font> elements that were added and change to <span> with chosen size
- trumbowyg.$ed.find('font[size="1"]').replaceWith(function() {
- return $('<span/>', {
- css: { 'font-size': size },
- html: this.innerHTML,
- });
- });
- // Remove and leftover <span> elements
- $(trumbowyg.range.startContainer.parentElement).find('span[style=""]').contents().unwrap();
- trumbowyg.restoreRange();
- trumbowyg.syncCode();
- trumbowyg.$c.trigger('tbwchange');
- }
- function buildDropdown(trumbowyg) {
- var dropdown = [];
- $.each(trumbowyg.o.plugins.fontsize.sizeList, function (index, size) {
- trumbowyg.addBtnDef('fontsize_' + size, {
- text: '<span style="">' + (trumbowyg.lang.fontsizes[size] || size) + '</span>',
- hasIcon: false,
- fn: function () {
- setFontSize(trumbowyg, size);
- }
- });
- dropdown.push('fontsize_' + size);
- });
- if (trumbowyg.o.plugins.fontsize.allowCustomSize) {
- var customSizeButtonName = 'fontsize_custom';
- var customSizeBtnDef = {
- fn: function () {
- trumbowyg.openModalInsert(trumbowyg.lang.fontCustomSize.title,
- {
- size: {
- label: trumbowyg.lang.fontCustomSize.label,
- value: trumbowyg.lang.fontCustomSize.value
- }
- },
- function (form) {
- setFontSize(trumbowyg, form.size);
- return true;
- }
- );
- },
- text: '<span style="font-size: medium;">' + trumbowyg.lang.fontsizes.custom + '</span>',
- hasIcon: false
- };
- trumbowyg.addBtnDef(customSizeButtonName, customSizeBtnDef);
- dropdown.push(customSizeButtonName);
- }
- return dropdown;
- }
- })(jQuery);
- /* ===========================================================
- * trumbowyg.colors.js v1.2
- * Colors picker plugin for Trumbowyg
- * http://alex-d.github.com/Trumbowyg
- * ===========================================================
- * Author : Alexandre Demode (Alex-D)
- * Twitter : @AlexandreDemode
- * Website : alex-d.fr
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- langs: {
- // jshint camelcase:false
- cs: {
- foreColor: 'Barva textu',
- backColor: 'Barva pozadí'
- },
- en: {
- foreColor: 'Text color',
- backColor: 'Background color'
- },
- fr: {
- foreColor: 'Couleur du texte',
- backColor: 'Couleur de fond'
- },
- nl: {
- foreColor: 'Tekstkleur',
- backColor: 'Achtergrondkleur'
- },
- sk: {
- foreColor: 'Farba textu',
- backColor: 'Farba pozadia'
- },
- zh_cn: {
- foreColor: '文字颜色',
- backColor: '背景颜色'
- },
- ru: {
- foreColor: 'Цвет текста',
- backColor: 'Цвет выделения текста'
- },
- ja: {
- foreColor: '文字色',
- backColor: '背景色'
- },
- tr: {
- foreColor: 'Yazı rengi',
- backColor: 'Arkaplan rengi'
- }
- }
- });
- // jshint camelcase:true
- function hex(x) {
- return ('0' + parseInt(x).toString(16)).slice(-2);
- }
- function colorToHex(rgb) {
- if (rgb.search('rgb') === -1) {
- return rgb.replace('#', '');
- } else if (rgb === 'rgba(0, 0, 0, 0)') {
- return 'transparent';
- } else {
- rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
- return hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
- }
- }
- function colorTagHandler(element, trumbowyg) {
- var tags = [];
- if (!element.style) {
- return tags;
- }
- // background color
- if (element.style.backgroundColor !== '') {
- var backColor = colorToHex(element.style.backgroundColor);
- if (trumbowyg.o.plugins.colors.colorList.indexOf(backColor) >= 0) {
- tags.push('backColor' + backColor);
- } else {
- tags.push('backColorFree');
- }
- }
- // text color
- var foreColor;
- if (element.style.color !== '') {
- foreColor = colorToHex(element.style.color);
- } else if (element.hasAttribute('color')) {
- foreColor = colorToHex(element.getAttribute('color'));
- }
- if (foreColor) {
- if (trumbowyg.o.plugins.colors.colorList.indexOf(foreColor) >= 0) {
- tags.push('foreColor' + foreColor);
- } else {
- tags.push('foreColorFree');
- }
- }
- return tags;
- }
- var defaultOptions = {
- colorList: ['ffffff', '000000', 'eeece1', '1f497d', '4f81bd', 'c0504d', '9bbb59', '8064a2', '4bacc6', 'f79646', 'ffff00', 'f2f2f2', '7f7f7f', 'ddd9c3', 'c6d9f0', 'dbe5f1', 'f2dcdb', 'ebf1dd', 'e5e0ec', 'dbeef3', 'fdeada', 'fff2ca', 'd8d8d8', '595959', 'c4bd97', '8db3e2', 'b8cce4', 'e5b9b7', 'd7e3bc', 'ccc1d9', 'b7dde8', 'fbd5b5', 'ffe694', 'bfbfbf', '3f3f3f', '938953', '548dd4', '95b3d7', 'd99694', 'c3d69b', 'b2a2c7', 'b7dde8', 'fac08f', 'f2c314', 'a5a5a5', '262626', '494429', '17365d', '366092', '953734', '76923c', '5f497a', '92cddc', 'e36c09', 'c09100', '7f7f7f', '0c0c0c', '1d1b10', '0f243e', '244061', '632423', '4f6128', '3f3151', '31859b', '974806', '7f6000']
- };
- // Add all colors in two dropdowns
- $.extend(true, $.trumbowyg, {
- plugins: {
- color: {
- init: function (trumbowyg) {
- trumbowyg.o.plugins.colors = trumbowyg.o.plugins.colors || defaultOptions;
- var foreColorBtnDef = {
- dropdown: buildDropdown('foreColor', trumbowyg)
- },
- backColorBtnDef = {
- dropdown: buildDropdown('backColor', trumbowyg)
- };
- trumbowyg.addBtnDef('foreColor', foreColorBtnDef);
- trumbowyg.addBtnDef('backColor', backColorBtnDef);
- },
- tagHandler: colorTagHandler
- }
- }
- });
- function buildDropdown(fn, trumbowyg) {
- var dropdown = [];
- $.each(trumbowyg.o.plugins.colors.colorList, function (i, color) {
- var btn = fn + color,
- btnDef = {
- fn: fn,
- forceCss: true,
- param: '#' + color,
- style: 'background-color: #' + color + ';'
- };
- trumbowyg.addBtnDef(btn, btnDef);
- dropdown.push(btn);
- });
- var removeColorButtonName = fn + 'Remove',
- removeColorBtnDef = {
- fn: 'removeFormat',
- param: fn,
- style: 'background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAG0lEQVQIW2NkQAAfEJMRmwBYhoGBYQtMBYoAADziAp0jtJTgAAAAAElFTkSuQmCC);'
- };
- trumbowyg.addBtnDef(removeColorButtonName, removeColorBtnDef);
- dropdown.push(removeColorButtonName);
- // add free color btn
- var freeColorButtonName = fn + 'Free',
- freeColorBtnDef = {
- fn: function () {
- trumbowyg.openModalInsert(trumbowyg.lang[fn],
- {
- color: {
- label: fn,
- value: '#FFFFFF'
- }
- },
- // callback
- function (values) {
- trumbowyg.execCmd(fn, values.color);
- return true;
- }
- );
- },
- text: '#',
- // style adjust for displaying the text
- style: 'text-indent: 0;line-height: 20px;padding: 0 5px;'
- };
- trumbowyg.addBtnDef(freeColorButtonName, freeColorBtnDef);
- dropdown.push(freeColorButtonName);
- return dropdown;
- }
- })(jQuery);
- /* ===========================================================
- * trumbowyg.table.custom.js v2.0
- * Table plugin for Trumbowyg
- * http://alex-d.github.com/Trumbowyg
- * ===========================================================
- * Author : Sven Dunemann [dunemann@forelabs.eu]
- */
- (function ($) {
- 'use strict';
- var defaultOptions = {
- rows: 8,
- columns: 8,
- styler: 'table'
- };
- $.extend(true, $.trumbowyg, {
- langs: {
- // jshint camelcase:false
- en: {
- table: 'Insert table',
- tableAddRow: 'Add row',
- tableAddRowAbove: 'Add row above',
- tableAddColumnLeft: 'Add column to the left',
- tableAddColumn: 'Add column to the right',
- tableDeleteRow: 'Delete row',
- tableDeleteColumn: 'Delete column',
- tableDestroy: 'Delete table',
- error: 'Error'
- },
- da: {
- table: 'Indsæt tabel',
- tableAddRow: 'Tilføj række',
- tableAddRowAbove: 'Tilføj række',
- tableAddColumnLeft: 'Tilføj kolonne',
- tableAddColumn: 'Tilføj kolonne',
- tableDeleteRow: 'Slet række',
- tableDeleteColumn: 'Slet kolonne',
- tableDestroy: 'Slet tabel',
- error: 'Fejl'
- },
- de: {
- table: 'Tabelle einfügen',
- tableAddRow: 'Zeile hinzufügen',
- tableAddRowAbove: 'Zeile hinzufügen',
- tableAddColumnLeft: 'Spalte hinzufügen',
- tableAddColumn: 'Spalte hinzufügen',
- tableDeleteRow: 'Zeile löschen',
- tableDeleteColumn: 'Spalte löschen',
- tableDestroy: 'Tabelle löschen',
- error: 'Error'
- },
- sk: {
- table: 'Vytvoriť tabuľky',
- tableAddRow: 'Pridať riadok',
- tableAddRowAbove: 'Pridať riadok',
- tableAddColumnLeft: 'Pridať stĺpec',
- tableAddColumn: 'Pridať stĺpec',
- error: 'Chyba'
- },
- fr: {
- table: 'Insérer un tableau',
- tableAddRow: 'Ajouter un ligne en dessous',
- tableAddRowAbove: 'Ajouter une ligne au dessus',
- tableAddColumnLeft: 'Ajouter une colonne à gauche',
- tableAddColumn: 'Ajouter une colonne à droite',
- tableDeleteRow: 'Effacer la ligne',
- tableDeleteColumn: 'Effacer la colonne',
- tableDestroy: 'Effacer le tableau',
- error: 'Erreur'
- },
- cs: {
- table: 'Vytvořit příkaz Table',
- tableAddRow: 'Přidat řádek',
- tableAddRowAbove: 'Přidat řádek',
- tableAddColumnLeft: 'Přidat sloupec',
- tableAddColumn: 'Přidat sloupec',
- error: 'Chyba'
- },
- ru: {
- table: 'Вставить таблицу',
- tableAddRow: 'Добавить строку',
- tableAddRowAbove: 'Добавить строку',
- tableAddColumnLeft: 'Добавить столбец',
- tableAddColumn: 'Добавить столбец',
- tableDeleteRow: 'Удалить строку',
- tableDeleteColumn: 'Удалить столбец',
- tableDestroy: 'Удалить таблицу',
- error: 'Ошибка'
- },
- ja: {
- table: '表の挿入',
- tableAddRow: '行の追加',
- tableAddRowAbove: '行の追加',
- tableAddColumnLeft: '列の追加',
- tableAddColumn: '列の追加',
- error: 'エラー'
- },
- tr: {
- table: 'Tablo ekle',
- tableAddRow: 'Satır ekle',
- tableAddRowAbove: 'Satır ekle',
- tableAddColumnLeft: 'Kolon ekle',
- tableAddColumn: 'Kolon ekle',
- error: 'Hata'
- },
- zh_tw: {
- table: '插入表格',
- tableAddRow: '加入行',
- tableAddRowAbove: '加入行',
- tableAddColumnLeft: '加入列',
- tableAddColumn: '加入列',
- tableDeleteRow: '刪除行',
- tableDeleteColumn: '刪除列',
- tableDestroy: '刪除表格',
- error: '錯誤'
- },
- id: {
- table: 'Sisipkan tabel',
- tableAddRow: 'Sisipkan baris',
- tableAddRowAbove: 'Sisipkan baris',
- tableAddColumnLeft: 'Sisipkan kolom',
- tableAddColumn: 'Sisipkan kolom',
- tableDeleteRow: 'Hapus baris',
- tableDeleteColumn: 'Hapus kolom',
- tableDestroy: 'Hapus tabel',
- error: 'Galat'
- },
- pt_br: {
- table: 'Inserir tabela',
- tableAddRow: 'Adicionar linha',
- tableAddRowAbove: 'Adicionar linha',
- tableAddColumnLeft: 'Adicionar coluna',
- tableAddColumn: 'Adicionar coluna',
- tableDeleteRow: 'Deletar linha',
- tableDeleteColumn: 'Deletar coluna',
- tableDestroy: 'Deletar tabela',
- error: 'Erro'
- },
- ko: {
- table: '표 넣기',
- tableAddRow: '줄 추가',
- tableAddRowAbove: '줄 추가',
- tableAddColumnLeft: '칸 추가',
- tableAddColumn: '칸 추가',
- tableDeleteRow: '줄 삭제',
- tableDeleteColumn: '칸 삭제',
- tableDestroy: '표 지우기',
- error: '에러'
- },
- // jshint camelcase:true
- },
- plugins: {
- table: {
- init: function (t) {
- t.o.plugins.table = $.extend(true, {}, defaultOptions, t.o.plugins.table || {});
- var buildButtonDef = {
- fn: function () {
- t.saveRange();
- var btnName = 'table';
- var dropdownPrefix = t.o.prefix + 'dropdown',
- dropdownOptions = { // the dropdown
- class: dropdownPrefix + '-' + btnName + ' ' + dropdownPrefix + ' ' + t.o.prefix + 'fixed-top'
- };
- dropdownOptions['data-' + dropdownPrefix] = btnName;
- var $dropdown = $('<div/>', dropdownOptions);
- if (t.$box.find('.' + dropdownPrefix + '-' + btnName).length === 0) {
- t.$box.append($dropdown.hide());
- } else {
- $dropdown = t.$box.find('.' + dropdownPrefix + '-' + btnName);
- }
- // clear dropdown
- $dropdown.html('');
- // when active table show AddRow / AddColumn
- if (t.$box.find('.' + t.o.prefix + 'table-button').hasClass(t.o.prefix + 'active-button')) {
- $dropdown.append(t.buildSubBtn('tableAddRowAbove'));
- $dropdown.append(t.buildSubBtn('tableAddRow'));
- $dropdown.append(t.buildSubBtn('tableAddColumnLeft'));
- $dropdown.append(t.buildSubBtn('tableAddColumn'));
- $dropdown.append(t.buildSubBtn('tableDeleteRow'));
- $dropdown.append(t.buildSubBtn('tableDeleteColumn'));
- $dropdown.append(t.buildSubBtn('tableDestroy'));
- } else {
- var tableSelect = $('<table/>');
- $('<tbody/>').appendTo(tableSelect);
- for (var i = 0; i < t.o.plugins.table.rows; i += 1) {
- var row = $('<tr/>').appendTo(tableSelect);
- for (var j = 0; j < t.o.plugins.table.columns; j += 1) {
- $('<td/>').appendTo(row);
- }
- }
- tableSelect.find('td').on('mouseover', tableAnimate);
- tableSelect.find('td').on('mousedown', tableBuild);
- $dropdown.append(tableSelect);
- $dropdown.append($('<div class="trumbowyg-table-size">1x1</div>'));
- }
- t.dropdown(btnName);
- }
- };
- var tableAnimate = function(columnEvent) {
- var column = $(columnEvent.target),
- table = column.closest('table'),
- colIndex = this.cellIndex,
- rowIndex = this.parentNode.rowIndex;
- // reset all columns
- table.find('td').removeClass('active');
- for (var i = 0; i <= rowIndex; i += 1) {
- for (var j = 0; j <= colIndex; j += 1) {
- table.find('tr:nth-of-type('+(i+1)+')').find('td:nth-of-type('+(j+1)+')').addClass('active');
- }
- }
- // set label
- table.next('.trumbowyg-table-size').html((colIndex+1) + 'x' + (rowIndex+1));
- };
- var tableBuild = function() {
- t.saveRange();
- var tabler = $('<table/>');
- $('<tbody/>').appendTo(tabler);
- if (t.o.plugins.table.styler) {
- tabler.attr('class', t.o.plugins.table.styler);
- }
- var colIndex = this.cellIndex,
- rowIndex = this.parentNode.rowIndex;
- for (var i = 0; i <= rowIndex; i += 1) {
- var row = $('<tr></tr>').appendTo(tabler);
- for (var j = 0; j <= colIndex; j += 1) {
- $('<td/>').appendTo(row);
- }
- }
- t.range.deleteContents();
- t.range.insertNode(tabler[0]);
- t.$c.trigger('tbwchange');
- };
- var addRow = {
- title: t.lang.tableAddRow,
- text: t.lang.tableAddRow,
- ico: 'row-below',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode;
- var focusedRow = $(node).closest('tr');
- var table = $(node).closest('table');
- if(table.length > 0) {
- var row = $('<tr/>');
- // add columns according to current columns count
- for (var i = 0; i < table.find('tr')[0].childElementCount; i += 1) {
- $('<td/>').appendTo(row);
- }
- // add row to table
- focusedRow.after(row);
- }
- t.syncCode();
- }
- };
- var addRowAbove = {
- title: t.lang.tableAddRowAbove,
- text: t.lang.tableAddRowAbove,
- ico: 'row-above',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode;
- var focusedRow = $(node).closest('tr');
- var table = $(node).closest('table');
- if(table.length > 0) {
- var row = $('<tr/>');
- // add columns according to current columns count
- for (var i = 0; i < table.find('tr')[0].childElementCount; i += 1) {
- $('<td/>').appendTo(row);
- }
- // add row to table
- focusedRow.before(row);
- }
- t.syncCode();
- }
- };
- var addColumn = {
- title: t.lang.tableAddColumn,
- text: t.lang.tableAddColumn,
- ico: 'col-right',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode;
- var focusedCol = $(node).closest('td');
- var table = $(node).closest('table');
- var focusedColIdx = focusedCol.index();
- if(table.length > 0) {
- $(table).find('tr').each(function() {
- $($(this).children()[focusedColIdx]).after('<td></td>');
- });
- }
- t.syncCode();
- }
- };
- var addColumnLeft = {
- title: t.lang.tableAddColumnLeft,
- text: t.lang.tableAddColumnLeft,
- ico: 'col-left',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode;
- var focusedCol = $(node).closest('td');
- var table = $(node).closest('table');
- var focusedColIdx = focusedCol.index();
- if(table.length > 0) {
- $(table).find('tr').each(function() {
- $($(this).children()[focusedColIdx]).before('<td></td>');
- });
- }
- t.syncCode();
- }
- };
- var destroy = {
- title: t.lang.tableDestroy,
- text: t.lang.tableDestroy,
- ico: 'table-delete',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode,
- table = $(node).closest('table');
- table.remove();
- t.syncCode();
- }
- };
- var deleteRow = {
- title: t.lang.tableDeleteRow,
- text: t.lang.tableDeleteRow,
- ico: 'row-delete',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode,
- row = $(node).closest('tr');
- row.remove();
- t.syncCode();
- }
- };
- var deleteColumn = {
- title: t.lang.tableDeleteColumn,
- text: t.lang.tableDeleteColumn,
- ico: 'col-delete',
- fn: function () {
- t.saveRange();
- var node = t.doc.getSelection().focusNode,
- table = $(node).closest('table'),
- td = $(node).closest('td'),
- cellIndex = td.index();
- $(table).find('tr').each(function() {
- $(this).find('td:eq(' + cellIndex + ')').remove();
- });
- t.syncCode();
- }
- };
- t.addBtnDef('table', buildButtonDef);
- t.addBtnDef('tableAddRowAbove', addRowAbove);
- t.addBtnDef('tableAddRow', addRow);
- t.addBtnDef('tableAddColumnLeft', addColumnLeft);
- t.addBtnDef('tableAddColumn', addColumn);
- t.addBtnDef('tableDeleteRow', deleteRow);
- t.addBtnDef('tableDeleteColumn', deleteColumn);
- t.addBtnDef('tableDestroy', destroy);
- }
- }
- }
- });
- })(jQuery);
- /**
- Vertical align custom, NE PAS UPGRADE !!
- */
- (function ($) {
- 'use strict';
- //Création d'un boutton spécial pour les sauts de page
- $.extend(true, $.trumbowyg, {
- plugins: {
- alignDropdown: {
- init: function (trumbowyg) {
- var dropdownButtonName = {
- dropdown: ['alignTop', 'alignBottom', 'alignMiddle'],
- title: 'Alignement vertical',
- // ico: 'iconName',
- text: '<strong>↨</strong>',
- hasIcon: false
- }
- var alignTopBtnDef = {
- fn: function () {
- trumbowyg.saveRange();
- $(trumbowyg.range.startContainer.parentElement).css('vertical-align', 'top');
- trumbowyg.syncCode();
- },
- title: 'Alignement en haut',
- class: 'trumbowyg-aligntop-button fas fa-long-arrow-alt-up',
- text: '<strong>↑</strong> Aligné en haut',
- hasIcon: false
- };
- var alignBottomBtnDef = {
- fn: function () {
- trumbowyg.saveRange();
- $(trumbowyg.range.startContainer.parentElement).css('vertical-align', 'bottom');
- trumbowyg.syncCode();
- },
- title: 'Alignement en bas',
- class: 'trumbowyg-aligntop-button fas fa-long-arrow-alt-up',
- text: '<strong>↓</strong> Aligné en bas',
- hasIcon: false
- };
- var alignMiddleBtnDef = {
- fn: function () {
- trumbowyg.saveRange();
- $(trumbowyg.range.startContainer.parentElement).css('vertical-align', 'middle');
- trumbowyg.syncCode();
- },
- title: 'Alignement au milieu',
- class: 'trumbowyg-aligntop-button fas fa-long-arrow-alt-up',
- text: '<strong>↔</strong> Aligné au milieu',
- hasIcon: false
- };
-
- trumbowyg.addBtnDef('alignDropdown',dropdownButtonName);
- trumbowyg.addBtnDef('alignTop',alignTopBtnDef);
- trumbowyg.addBtnDef('alignBottom',alignBottomBtnDef);
- trumbowyg.addBtnDef('alignMiddle',alignMiddleBtnDef);
- }
- }
- }
- });
- })(jQuery);
- /**
- Line height custom, NE PAS UPGRADE !!
- */
- (function ($) {
- 'use strict';
- $.extend(true, $.trumbowyg, {
- langs: {
- en: {
- lineheight: 'Line height',
- lineheights: {
- '0.4': 'Extra small',
- '0.9': 'Small',
- 'normal': 'Regular',
- '1.5': 'Large',
- '2.0': 'Extra large'
- }
- },
- fr: {
- lineheight: 'Hauteur de ligne',
- lineheights: {
- '0.5': 'Très petite',
- '0.9': 'Petite',
- 'normal': 'Normale',
- '1.5': 'Grande',
- '2.0': 'Très grande'
- }
- },
- }
- });
- var defaultOptions = {
- sizeList: [
- '0.5',
- '0.9',
- 'normal',
- '1.5',
- '2.0'
- ]
- };
- $.extend(true, $.trumbowyg, {
- plugins: {
- lineheight: {
- init: function (trumbowyg) {
- trumbowyg.o.plugins.lineheight = $.extend({},
- defaultOptions,
- trumbowyg.o.plugins.lineheight || {}
- );
- trumbowyg.addBtnDef('lineheight', {
- dropdown: buildDropdown(trumbowyg)
- });
- }
- }
- }
- });
- // Build the dropdown
- function buildDropdown(trumbowyg) {
- var dropdown = [];
- $.each(trumbowyg.o.plugins.lineheight.sizeList, function(index, size) {
- trumbowyg.addBtnDef('lineheight_' + size, {
- text: trumbowyg.lang.lineheights[size] || size,
- hasIcon: false,
- fn: function(){
- trumbowyg.saveRange();
- var text = trumbowyg.getRangeText();
- if (text.replace(/\s/g, '') !== '') {
- var parent = trumbowyg.doc.getSelection().getRangeAt(0).commonAncestorContainer;
- $(parent).css('lineHeight', size);
- try {
- var parent = trumbowyg.doc.getSelection().getRangeAt(0).commonAncestorContainer;
- $(parent).css('lineHeight', size);
- } catch (e) {
- }
- }
- }
- });
- dropdown.push('lineheight_' + size);
- });
- return dropdown;
- }
- })(jQuery);
|