/*! * froala_editor v3.0.0-beta.2-1 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms/ * Copyright 2014-2019 Froala Labs */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("froala-editor")):"function"==typeof define&&define.amd?define(["froala-editor"],t):t(e.FroalaEditor)}(this,function(ee){"use strict";ee=ee&&ee.hasOwnProperty("default")?ee["default"]:ee,Object.assign(ee.POPUP_TEMPLATES,{"table.insert":"[_BUTTONS_][_ROWS_COLUMNS_]","table.edit":"[_BUTTONS_]","table.colors":"[_BUTTONS_][_COLORS_][_CUSTOM_COLOR_]"}),Object.assign(ee.DEFAULTS,{tableInsertMaxSize:10,tableEditButtons:["tableHeader","tableRemove","tableRows","tableColumns","tableStyle","-","tableCells","tableCellBackground","tableCellVerticalAlign","tableCellHorizontalAlign","tableCellStyle"],tableInsertButtons:["tableBack","|"],tableResizer:!0,tableDefaultWidth:"100%",tableResizerOffset:5,tableResizingLimit:30,tableColorsButtons:["tableBack","|"],tableColors:["#61BD6D","#1ABC9C","#54ACD2","#2C82C9","#9365B8","#475577","#CCCCCC","#41A85F","#00A885","#3D8EB9","#2969B0","#553982","#28324E","#000000","#F7DA64","#FBA026","#EB6B56","#E25041","#A38F84","#EFEFEF","#FFFFFF","#FAC51C","#F37934","#D14841","#B8312F","#7C706B","#D1D5D8","REMOVE"],tableColorsStep:7,tableCellStyles:{"fr-highlighted":"Highlighted","fr-thick":"Thick"},tableStyles:{"fr-dashed-borders":"Dashed Borders","fr-alternate-rows":"Alternate Rows"},tableCellMultipleStyles:!0,tableMultipleStyles:!0,tableInsertHelper:!0,tableInsertHelperOffset:15}),ee.PLUGINS.table=function(E){var R,f,r,n,l,s,A,O=E.$;function h(){var e=_();if(e){var t=E.popups.get("table.edit");if(t||(t=p()),t){E.popups.setContainer("table.edit",E.$sc);var a=I(e),l=a.left+(a.right-a.left)/2,r=a.bottom;E.popups.show("table.edit",l,r,a.bottom-a.top,!0),E.edit.isDisabled()&&(1");var t="";E.opts.colorsHEXInput&&(t='
");var a={buttons:e,colors:function(){for(var e='
',t=0;t"),"REMOVE"!=E.opts.tableColors[t]?e+=''+E.language.translate("Color")+" "+E.opts.tableColors[t]+"   ":e+=''+E.icon.create("tableColorRemove")+''+E.language.translate("Clear Formatting")+"";return e+="
"}(),custom_color:t},l=E.popups.create("table.colors",a);return E.events.$on(E.$wp,"scroll.table-colors",function(){E.popups.isVisible("table.colors")&&d()}),u=l,E.events.on("popup.tab",function(e){var t=O(e.currentTarget);if(!E.popups.isVisible("table.colors")||!t.is("span"))return!0;var a=e.which,l=!0;if(ee.KEYCODE.TAB==a){var r=u.find(".fr-buttons");l=!E.accessibility.focusToolbar(r,!!e.shiftKey)}else if(ee.KEYCODE.ARROW_UP==a||ee.KEYCODE.ARROW_DOWN==a||ee.KEYCODE.ARROW_LEFT==a||ee.KEYCODE.ARROW_RIGHT==a){var n=t.parent().find("span.fr-command"),s=n.index(t),o=E.opts.colorsStep,i=Math.floor(n.length/o),f=s%o,d=Math.floor(s/o),c=d*o+f,p=i*o;ee.KEYCODE.ARROW_UP==a?c=((c-o)%p+p)%p:ee.KEYCODE.ARROW_DOWN==a?c=(c+o)%p:ee.KEYCODE.ARROW_LEFT==a?c=((c-1)%p+p)%p:ee.KEYCODE.ARROW_RIGHT==a&&(c=(c+1)%p);var h=O(n.get(c));E.events.disableBlur(),h.focus(),l=!1}else ee.KEYCODE.ENTER==a&&(E.button.exec(t),l=!1);return!1===l&&(e.preventDefault(),e.stopPropagation()),l},!0),l;var u}()),E.popups.setContainer("table.colors",E.$sc);var s=I(r),o=(s.left+s.right)/2,i=s.bottom;e=E.popups.get("table.colors"),t=E.$el.find(".fr-selected-cell").first(),a=E.helpers.RGBToHex(t.css("background-color")),l=e.find(".fr-table-colors-hex-layer input"),e.find(".fr-selected-color").removeClass("fr-selected-color fr-active-item"),e.find('span[data-param1="'+a+'"]').addClass("fr-selected-color fr-active-item"),l.val(a).trigger("change"),E.popups.show("table.colors",o,i,s.bottom-s.top,!0)}}function o(){0===Z().length&&E.toolbar.enable()}function i(e){if(e)return E.popups.onHide("table.insert",function(){E.popups.get("table.insert").find('.fr-table-size .fr-select-table-size > span[data-row="1"][data-col="1"]').trigger("mouseover")}),!0;var t="";0'+E.button.buildList(E.opts.tableInsertButtons)+"");var a,l={buttons:t,rows_columns:function(){for(var e='
1 × 1
',t=1;t<=E.opts.tableInsertMaxSize;t++){for(var a=1;a<=E.opts.tableInsertMaxSize;a++){var l="inline-block";2'+t+" × "+a+"   "}e+='
'}return e+="
"}()},r=E.popups.create("table.insert",l);return E.events.$on(r,"mouseover",".fr-table-size .fr-select-table-size .fr-table-cell",function(e){c(O(e.currentTarget))},!0),a=r,E.events.$on(a,"focus","[tabIndex]",function(e){var t=O(e.currentTarget);c(t)}),E.events.on("popup.tab",function(e){var t=O(e.currentTarget);if(!E.popups.isVisible("table.insert")||!t.is("span, a"))return!0;var a,l=e.which;if(ee.KEYCODE.ARROW_UP==l||ee.KEYCODE.ARROW_DOWN==l||ee.KEYCODE.ARROW_LEFT==l||ee.KEYCODE.ARROW_RIGHT==l){if(t.is("span.fr-table-cell")){var r=t.parent().find("span.fr-table-cell"),n=r.index(t),s=E.opts.tableInsertMaxSize,o=n%s,i=Math.floor(n/s);ee.KEYCODE.ARROW_UP==l?i=Math.max(0,i-1):ee.KEYCODE.ARROW_DOWN==l?i=Math.min(E.opts.tableInsertMaxSize-1,i+1):ee.KEYCODE.ARROW_LEFT==l?o=Math.max(0,o-1):ee.KEYCODE.ARROW_RIGHT==l&&(o=Math.min(E.opts.tableInsertMaxSize-1,o+1));var f=i*s+o,d=O(r.get(f));c(d),E.events.disableBlur(),d.focus(),a=!1}}else ee.KEYCODE.ENTER==l&&(E.button.exec(t),a=!1);return!1===a&&(e.preventDefault(),e.stopPropagation()),a},!0),r}function c(e){var t=e.data("row");null!==t&&(t=parseInt(t));var a=e.data("col");null!==a&&(a=parseInt(a));var l=e.parent();l.siblings(".fr-table-size-info").html(t+" × "+a),l.find("> span").removeClass("hover fr-active-item");for(var r=1;r<=E.opts.tableInsertMaxSize;r++)for(var n=0;n<=E.opts.tableInsertMaxSize;n++){var s=l.find('> span[data-row="'+r+'"][data-col="'+n+'"]');r<=t&&n<=a?s.addClass("hover"):r<=t+1||r<=2&&!E.helpers.isMobile()?s.css("display","inline-block"):2'.concat(E.button.buildList(E.opts.tableEditButtons),"")},a=E.popups.create("table.edit",t);return E.events.$on(E.$wp,"scroll.table-edit",function(){E.popups.isVisible("table.edit")&&h()}),a}return!1}function u(){if(0 table tbody"))):O(t.find("tr").not(t.find("> table tr")).get(l)),"below"==e?"TBODY"==r.attr("tagName")?r.prepend(o):r[0].parentNode&&r[0].insertAdjacentHTML("afterend",o):"above"==e&&(r.before(o),E.popups.isVisible("table.edit")&&h())}}function g(e,t,a){var l,r,n,s,o,i=0,f=_(a);if(e<(t=Math.min(t,f[0].length-1)))for(r=e;r<=t;r++)if(!(e table tr")).each(function(o,e){var t=O(e),i=0;t.find("> th, > td").each(function(e,t){for(var a=O(t),l=parseInt(a.attr("colspan"),10)||1,r=parseInt(a.attr("rowspan"),10)||1,n=o;n")),R=E.shared.$table_resizer,E.events.$on(R,"mousedown",function(e){return!E.core.sameInstance(R)||(0a-E.opts.tableResizerOffset?R.css("left",a-E.opts.tableResizerOffset-E.$wp.offset().left):l'),E.events.bindClick(E.shared.$ti_helper,"a",function(){var e=f.data("selected-cell"),t=f.data("position"),a=f.data("instance")||E;"before"==t?(E.undo.saveStep(),e.addClass("fr-selected-cell"),a.table.insertColumn(t),e.removeClass("fr-selected-cell"),E.undo.saveStep()):"after"==t?(E.undo.saveStep(),e.addClass("fr-selected-cell"),a.table.insertColumn(t),e.removeClass("fr-selected-cell"),E.undo.saveStep()):"above"==t?(E.undo.saveStep(),e.addClass("fr-selected-cell"),a.table.insertRow(t),e.removeClass("fr-selected-cell"),E.undo.saveStep()):"below"==t&&(E.undo.saveStep(),e.addClass("fr-selected-cell"),a.table.insertRow(t),e.removeClass("fr-selected-cell"),E.undo.saveStep()),W()}),E.events.on("shared.destroy",function(){E.shared.$ti_helper.html("").removeData().remove(),E.shared.$ti_helper=null},!0),E.events.$on(E.shared.$ti_helper,"mousemove",function(e){e.stopPropagation()},!0),E.events.$on(O(E.o_win),"scroll",function(){W()},!0),E.events.$on(E.$wp,"scroll",function(){W()},!0)),f=E.shared.$ti_helper,E.events.on("destroy",function(){f=null}),E.tooltip.bind(E.$box,".fr-insert-helper > a.fr-floating-btn")}function J(){l=null,clearTimeout(s)}function Z(){return E.el.querySelectorAll(".fr-selected-cell")}function Q(){var e=Z();if(e.length){for(var t=e[0];t&&"TABLE"!=t.tagName&&t.parentNode!=E.el;)t=t.parentNode;return t&&"TABLE"==t.tagName?O(t):O([])}return O([])}return{_init:function(){if(!E.$wp)return!1;if(!E.helpers.isMobile()){A=r=n=!1,E.events.$on(E.$el,"mousedown",e),E.popups.onShow("image.edit",function(){D(),r=n=!1}),E.popups.onShow("link.edit",function(){D(),r=n=!1}),E.events.on("commands.mousedown",function(e){0"),a==t.length-1&&O(t[a]).prepend(ee.MARKERS);return E.selection.restore(),E.undo.saveStep(),!(t=[])}if(1',n=100/t;for(a=0;a",l=0;l",0===a&&0===l&&(r+=ee.MARKERS),r+="
";r+=""}r+="",E.html.insert(r),E.selection.restore();var s=E.$el.find(".fr-inserted-table");s.removeClass("fr-inserted-table"),E.events.trigger("table.inserted",[s.get(0)])},remove:u,insertRow:b,deleteRow:function(){var e=Q();if(0=n.min_i;t--){for(l=O(e.find("tr").not(e.find("> table tr")).get(t)),a=0;a table tr")).get(t+1)).prepend(i):O(r[t+1][f-1])[0].parentNode&&O(r[t+1][f-1])[0].insertAdjacentElement("afterend",i)}}var d=l.parent();l.remove(),0===d.find("tr").length&&d.remove(),r=_(e)}w(0,r.length-1,0,r[0].length-1,e),0 table tr")).each(function(e){for(var t,a=O(this),l=0,r=0;l-1 th, > td").get(r))){t=null;break}t==d[e][l]?(l+=parseInt(O(t).attr("colspan"),10)||1,r++):(l+=parseInt(O(d[e][l]).attr("colspan"),10)||1,"after"==i&&(t=0===r?-1:a.find("> th, > td").get(r-1)))}var n,s=O(t);if("after"==i&&f
':'
',-1==t?a.prepend(n):null==t?a.append(n):"before"==i?s.before(n):"after"==i&&s[0].parentNode&&s[0].insertAdjacentHTML("afterend",n)}),e.find("th, td").each(function(){(a=O(this)).data("old-width")&&(a.css("width",(a.data("old-width")*p/c).toFixed(4)+"%"),a.removeData("old-width"))}),E.popups.isVisible("table.edit")&&h()}},deleteColumn:function(){var e=Q();if(0n.max_j)&&(s+=l.outerWidth()/e.outerWidth()*100));for(s/=r.length,a=n.max_j;a>=n.min_j;a--)for(t=0;t th, > td").length&&(0===i.prev().length||0===i.next().length||i.prev().find("> th[rowspan], > td[rowspan]").length th, > td").length)&&i.remove()}w(0,r.length-1,0,r[0].length-1,e),0"!=(t=O(l[e])).html()&&""!==t.html()&&(o+="
"+t.html()),t.remove();r.html(o),E.selection.setAtEnd(r.get(0)),E.selection.restore(),E.toolbar.enable(),m(a.min_i,a.max_i,s);var f=s.find("tr:empty");for(e=f.length-1;0<=e;e--)O(f[e]).remove();g(a.min_j,a.max_j,s),h()}},splitCellVertically:function(){if(1==Z().length){var e=E.$el.find(".fr-selected-cell"),t=parseInt(e.attr("colspan"),10)||1,a=e.parent().outerWidth(),l=e.outerWidth(),r=e.clone().html("
"),n=_(),s=x(e.get(0),n);if(1");if(1 table tr")).get(i)).prepend(s):O(r[i][f])[0].parentNode&&O(r[i][f])[0].insertAdjacentElement("afterend",s[0])}else{var d,c=O(document.createElement("tr")).append(s);for(d=0;d td").each(function(){var e=O(this);l+=parseInt(e.attr("colspan"),10)||1}),t=0;t
";a+="",e.prepend(a),h()}},removeHeader:function(){var e=Q(),t=e.find("thead");if(0'+this.language.translate(t[a])+"");return e+=""},callback:function(e,t){"above"==t||"below"==t?this.table.insertRow(t):this.table.deleteRow()}}),ee.DefineIcon("tableColumns",{NAME:"bars fa-rotate-90",SVG_KEY:"columns"}),ee.RegisterCommand("tableColumns",{type:"dropdown",focus:!1,title:"Column",options:{before:"Insert column before",after:"Insert column after","delete":"Delete column"},html:function(){var e='"},callback:function(e,t){"before"==t||"after"==t?this.table.insertColumn(t):this.table.deleteColumn()}}),ee.DefineIcon("tableCells",{NAME:"square-o",FA5NAME:"square",SVG_KEY:"cellOptions"}),ee.RegisterCommand("tableCells",{type:"dropdown",focus:!1,title:"Cell",options:{merge:"Merge cells","vertical-split":"Vertical split","horizontal-split":"Horizontal split"},html:function(){var e='"},callback:function(e,t){"merge"==t?this.table.mergeCells():"vertical-split"==t?this.table.splitCellVertically():this.table.splitCellHorizontally()},refreshOnShow:function(e,t){1'+this.language.translate(t[a])+"");return e+=""},callback:function(e,t){this.table.applyStyle(t,this.$el.find(".fr-selected-cell").closest("table"),this.opts.tableMultipleStyles,this.opts.tableStyles)},refreshOnShow:function(e,t){var a=this.$,l=this.$el.find(".fr-selected-cell").closest("table");l&&t.find(".fr-command").each(function(){var e=a(this).data("param1"),t=l.hasClass(e);a(this).toggleClass("fr-active",t).attr("aria-selected",t)})}}),ee.DefineIcon("tableCellBackground",{NAME:"tint",SVG_KEY:"cellBackground"}),ee.RegisterCommand("tableCellBackground",{title:"Cell Background",focus:!1,popup:!0,callback:function(){this.table.showColorsPopup()}}),ee.RegisterCommand("tableCellBackgroundColor",{undo:!0,focus:!1,callback:function(e,t){this.table.setBackground(t)}}),ee.DefineIcon("tableBack",{NAME:"arrow-left",SVG_KEY:"back"}),ee.RegisterCommand("tableBack",{title:"Back",undo:!1,focus:!1,back:!0,callback:function(){this.table.back()},refresh:function(e){0!==this.table.selectedCells().length||this.opts.toolbarInline?(e.removeClass("fr-hidden"),e.next(".fr-separator").removeClass("fr-hidden")):(e.addClass("fr-hidden"),e.next(".fr-separator").addClass("fr-hidden"))}}),ee.DefineIcon("tableCellVerticalAlign",{NAME:"arrows-v",FA5NAME:"arrows-alt-v",SVG_KEY:"verticalAlignMiddle"}),ee.RegisterCommand("tableCellVerticalAlign",{type:"dropdown",focus:!1,title:"Vertical Align",options:{Top:"Align Top",Middle:"Align Middle",Bottom:"Align Bottom"},html:function(){var e='"},callback:function(e,t){this.table.verticalAlign(t)},refreshOnShow:function(e,t){t.find('.fr-command[data-param1="'+this.$el.find(".fr-selected-cell").css("vertical-align")+'"]').addClass("fr-active").attr("aria-selected",!0)}}),ee.DefineIcon("tableCellHorizontalAlign",{NAME:"align-left",SVG_KEY:"alignLeft"}),ee.DefineIcon("align-left",{NAME:"align-left",SVG_KEY:"alignLeft"}),ee.DefineIcon("align-right",{NAME:"align-right",SVG_KEY:"alignRight"}),ee.DefineIcon("align-center",{NAME:"align-center",SVG_KEY:"alignCenter"}),ee.DefineIcon("align-justify",{NAME:"align-justify",SVG_KEY:"alignJustify"}),ee.RegisterCommand("tableCellHorizontalAlign",{type:"dropdown",focus:!1,title:"Horizontal Align",options:{left:"Align Left",center:"Align Center",right:"Align Right",justify:"Align Justify"},html:function(){var e='"},callback:function(e,t){this.table.horizontalAlign(t)},refresh:function(e){var t=this.table.selectedCells(),a=this.$;t.length&&e.find("> *").first().replaceWith(this.icon.create("align-"+this.helpers.getAlignment(a(t[0]))))},refreshOnShow:function(e,t){t.find('.fr-command[data-param1="'+this.helpers.getAlignment(this.$el.find(".fr-selected-cell").first())+'"]').addClass("fr-active").attr("aria-selected",!0)}}),ee.DefineIcon("tableCellStyle",{NAME:"magic",SVG_KEY:"cellStyle"}),ee.RegisterCommand("tableCellStyle",{title:"Cell Style",type:"dropdown",focus:!1,html:function(){var e='"},callback:function(e,t){this.table.applyStyle(t,this.$el.find(".fr-selected-cell"),this.opts.tableCellMultipleStyles,this.opts.tableCellStyles)},refreshOnShow:function(e,t){var a=this.$,l=this.$el.find(".fr-selected-cell").first();l&&t.find(".fr-command").each(function(){var e=a(this).data("param1"),t=l.hasClass(e);a(this).toggleClass("fr-active",t).attr("aria-selected",t)})}}),ee.RegisterCommand("tableCellBackgroundCustomColor",{title:"OK",undo:!0,callback:function(){this.table.customColor()}}),ee.DefineIcon("tableColorRemove",{NAME:"eraser",SVG_KEY:"remove"})});