/*! * froala_editor v3.0.3 (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(ge){"use strict";ge=ge&&ge.hasOwnProperty("default")?ge["default"]:ge,Object.assign(ge.POPUP_TEMPLATES,{"table.insert":"[_BUTTONS_][_ROWS_COLUMNS_]","table.edit":"[_BUTTONS_]","table.colors":"[_BUTTONS_][_COLORS_][_CUSTOM_COLOR_]"}),Object.assign(ge.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}),ge.PLUGINS.table=function(R){var O,f,n,r,a,s,A,x=R.$;function h(){var e=_();if(e){var t=R.popups.get("table.edit");if(t||(t=p()),t){R.popups.setContainer("table.edit",R.$sc);var l=S(e),a=l.left+(l.right-l.left)/2,n=l.bottom;R.popups.show("table.edit",a,n,l.bottom-l.top,!0),R.edit.isDisabled()&&(1");var t="";R.opts.colorsHEXInput&&(t='
");var l={buttons:e,colors:function n(){for(var e='
',t=0;t"),"REMOVE"!=R.opts.tableColors[t]?e+=''+R.language.translate("Color")+" "+R.opts.tableColors[t]+"   ":e+=''+R.icon.create("tableColorRemove")+''+R.language.translate("Clear Formatting")+"";return e+="
"}(),custom_color:t},a=R.popups.create("table.colors",l);return R.events.$on(R.$wp,"scroll.table-colors",function(){R.popups.isVisible("table.colors")&&o()}),function r(u){R.events.on("popup.tab",function(e){var t=x(e.currentTarget);if(!R.popups.isVisible("table.colors")||!t.is("span"))return!0;var l=e.which,a=!0;if(ge.KEYCODE.TAB==l){var n=u.find(".fr-buttons");a=!R.accessibility.focusToolbar(n,!!e.shiftKey)}else if(ge.KEYCODE.ARROW_UP==l||ge.KEYCODE.ARROW_DOWN==l||ge.KEYCODE.ARROW_LEFT==l||ge.KEYCODE.ARROW_RIGHT==l){var r=t.parent().find("span.fr-command"),s=r.index(t),o=R.opts.colorsStep,i=Math.floor(r.length/o),f=s%o,c=Math.floor(s/o),d=c*o+f,p=i*o;ge.KEYCODE.ARROW_UP==l?d=((d-o)%p+p)%p:ge.KEYCODE.ARROW_DOWN==l?d=(d+o)%p:ge.KEYCODE.ARROW_LEFT==l?d=((d-1)%p+p)%p:ge.KEYCODE.ARROW_RIGHT==l&&(d=(d+1)%p);var h=x(r.get(d));R.events.disableBlur(),h.focus(),a=!1}else ge.KEYCODE.ENTER==l&&(R.button.exec(t),a=!1);return!1===a&&(e.preventDefault(),e.stopPropagation()),a},!0)}(a),a}()),R.popups.setContainer("table.colors",R.$sc);var l=S(e),a=(l.left+l.right)/2,n=l.bottom;!function r(){var e=R.popups.get("table.colors"),t=R.$el.find(".fr-selected-cell").first(),l=R.helpers.RGBToHex(t.css("background-color")),a=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="'+l+'"]').addClass("fr-selected-color fr-active-item"),a.val(l).trigger("change")}(),R.popups.show("table.colors",a,n,l.bottom-l.top,!0)}}function i(){0===Z().length&&R.toolbar.enable()}function c(e){if(e)return R.popups.onHide("table.insert",function(){R.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'+R.button.buildList(R.opts.tableInsertButtons)+"");var l={buttons:t,rows_columns:function r(){for(var e='
1 × 1
',t=1;t<=R.opts.tableInsertMaxSize;t++){for(var l=1;l<=R.opts.tableInsertMaxSize;l++){var a="inline-block";2'+t+" × "+l+"   "}e+='
'}return e+="
"}()},a=R.popups.create("table.insert",l);return R.events.$on(a,"mouseover",".fr-table-size .fr-select-table-size .fr-table-cell",function(e){d(x(e.currentTarget))},!0),function n(e){R.events.$on(e,"focus","[tabIndex]",function(e){var t=x(e.currentTarget);d(t)}),R.events.on("popup.tab",function(e){var t=x(e.currentTarget);if(!R.popups.isVisible("table.insert")||!t.is("span, a"))return!0;var l,a=e.which;if(ge.KEYCODE.ARROW_UP==a||ge.KEYCODE.ARROW_DOWN==a||ge.KEYCODE.ARROW_LEFT==a||ge.KEYCODE.ARROW_RIGHT==a){if(t.is("span.fr-table-cell")){var n=t.parent().find("span.fr-table-cell"),r=n.index(t),s=R.opts.tableInsertMaxSize,o=r%s,i=Math.floor(r/s);ge.KEYCODE.ARROW_UP==a?i=Math.max(0,i-1):ge.KEYCODE.ARROW_DOWN==a?i=Math.min(R.opts.tableInsertMaxSize-1,i+1):ge.KEYCODE.ARROW_LEFT==a?o=Math.max(0,o-1):ge.KEYCODE.ARROW_RIGHT==a&&(o=Math.min(R.opts.tableInsertMaxSize-1,o+1));var f=i*s+o,c=x(n.get(f));d(c),R.events.disableBlur(),c.focus(),l=!1}}else ge.KEYCODE.ENTER==a&&(R.button.exec(t),l=!1);return!1===l&&(e.preventDefault(),e.stopPropagation()),l},!0)}(a),a}function d(e){var t=e.data("row");null!==t&&(t=parseInt(t));var l=e.data("col");null!==l&&(l=parseInt(l));var a=e.parent();a.siblings(".fr-table-size-info").html(t+" × "+l),a.find("> span").removeClass("hover fr-active-item");for(var n=1;n<=R.opts.tableInsertMaxSize;n++)for(var r=0;r<=R.opts.tableInsertMaxSize;r++){var s=a.find('> span[data-row="'+n+'"][data-col="'+r+'"]');n<=t&&r<=l?s.addClass("hover"):n<=t+1||n<=2&&!R.helpers.isMobile()?s.css("display","inline-block"):2'.concat(R.button.buildList(R.opts.tableEditButtons),"")},l=R.popups.create("table.edit",t);return R.events.$on(R.$wp,"scroll.table-edit",function(){R.popups.isVisible("table.edit")&&h()}),l}return!1}function u(){if(0
'}o+="",n=0 table tbody"))):x(t.find("tr").not(t.find("> table tr")).get(a)),"below"==e?"TBODY"==n.attr("tagName")?n.prepend(o):n[0].parentNode&&n[0].insertAdjacentHTML("afterend",o):"above"==e&&(n.before(o),R.popups.isVisible("table.edit")&&h())}}function g(e,t,l){var a,n,r,s,o,i=0,f=_(l);if(e<(t=Math.min(t,f[0].length-1)))for(n=e;n<=t;n++)if(!(e table tr")).each(function(o,e){var t=x(e),i=0;t.find("> th, > td").each(function(e,t){for(var l=x(t),a=parseInt(l.attr("colspan"),10)||1,n=parseInt(l.attr("rowspan"),10)||1,r=o;r")),O=R.shared.$table_resizer,R.events.$on(O,"mousedown",function(e){return!R.core.sameInstance(O)||(0l-R.opts.tableResizerOffset?O.css("left",l-R.opts.tableResizerOffset-R.$wp.offset().left):a'),R.events.bindClick(R.shared.$ti_helper,"a",function(){var e=f.data("selected-cell"),t=f.data("position"),l=f.data("instance")||R;"before"==t?(R.undo.saveStep(),e.addClass("fr-selected-cell"),l.table.insertColumn(t),e.removeClass("fr-selected-cell"),R.undo.saveStep()):"after"==t?(R.undo.saveStep(),e.addClass("fr-selected-cell"),l.table.insertColumn(t),e.removeClass("fr-selected-cell"),R.undo.saveStep()):"above"==t?(R.undo.saveStep(),e.addClass("fr-selected-cell"),l.table.insertRow(t),e.removeClass("fr-selected-cell"),R.undo.saveStep()):"below"==t&&(R.undo.saveStep(),e.addClass("fr-selected-cell"),l.table.insertRow(t),e.removeClass("fr-selected-cell"),R.undo.saveStep()),W()}),R.events.on("shared.destroy",function(){R.shared.$ti_helper.html("").removeData().remove(),R.shared.$ti_helper=null},!0),R.events.$on(R.shared.$ti_helper,"mousemove",function(e){e.stopPropagation()},!0),R.events.$on(x(R.o_win),"scroll",function(){W()},!0),R.events.$on(R.$wp,"scroll",function(){W()},!0)),f=R.shared.$ti_helper,R.events.on("destroy",function(){f=null}),R.tooltip.bind(R.$box,".fr-insert-helper > a.fr-floating-btn")}function J(){a=null,clearTimeout(s)}function Z(){return R.el.querySelectorAll(".fr-selected-cell")}function Q(){var e=Z();if(e.length){for(var t=e[0];t&&"TABLE"!=t.tagName&&t.parentNode!=R.el;)t=t.parentNode;return t&&"TABLE"==t.tagName?x(t):x([])}return x([])}return{_init:function ee(){if(!R.$wp)return!1;if(!R.helpers.isMobile()){A=n=r=!1,R.events.$on(R.$el,"mousedown",e),R.popups.onShow("image.edit",function(){E(),n=r=!1}),R.popups.onShow("link.edit",function(){E(),n=r=!1}),R.events.on("commands.mousedown",function(e){0"),l==t.length-1&&x(t[l]).prepend(ge.MARKERS);return R.selection.restore(),R.undo.saveStep(),!(t=[])}if(1',r=100/t;for(l=0;l",a=0;a",0===l&&0===a&&(n+=ge.MARKERS),n+="
";n+=""}n+="",R.html.insert(n),R.selection.restore();var s=R.$el.find(".fr-inserted-table");s.removeClass("fr-inserted-table"),R.events.trigger("table.inserted",[s.get(0)])},remove:u,insertRow:b,deleteRow:function le(){var e=Q();if(0=r.min_i;t--){for(a=x(e.find("tr").not(e.find("> table tr")).get(t)),l=0;l table tr")).get(t+1)).prepend(i):x(n[t+1][f-1])[0].parentNode&&x(n[t+1][f-1])[0].insertAdjacentElement("afterend",i)}}var c=a.parent();a.remove(),0===c.find("tr").length&&c.remove(),n=_(e)}w(0,n.length-1,0,n[0].length-1,e),0 table tr")).each(function(e){for(var t,l=x(this),a=0,n=0;a-1 th, > td").get(n))){t=null;break}t==c[e][a]?(a+=parseInt(x(t).attr("colspan"),10)||1,n++):(a+=parseInt(x(c[e][a]).attr("colspan"),10)||1,"after"==i&&(t=0===n?-1:l.find("> th, > td").get(n-1)))}var r,s=x(t);if("after"==i&&f
':'
',-1==t?l.prepend(r):null==t?l.append(r):"before"==i?s.before(r):"after"==i&&s[0].parentNode&&s[0].insertAdjacentHTML("afterend",r)}),e.find("th, td").each(function(){(l=x(this)).data("old-width")&&(l.css("width",(l.data("old-width")*p/d).toFixed(4)+"%"),l.removeData("old-width"))}),R.popups.isVisible("table.edit")&&h()}},deleteColumn:function ne(){var e=Q();if(0r.max_j)&&(s+=a.outerWidth()/e.outerWidth()*100));for(s/=n.length,l=r.max_j;l>=r.min_j;l--)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,n.length-1,0,n[0].length-1,e),0"!=(t=x(a[e])).html()&&""!==t.html()&&(o+="
"+t.html()),t.remove();n.html(o),R.selection.setAtEnd(n.get(0)),R.selection.restore(),R.toolbar.enable(),m(l.min_i,l.max_i,s);var f=s.find("tr:empty");for(e=f.length-1;0<=e;e--)x(f[e]).remove();g(l.min_j,l.max_j,s),h()}},splitCellVertically:function se(){if(1==Z().length){var e=R.$el.find(".fr-selected-cell"),t=parseInt(e.attr("colspan"),10)||1,l=e.parent().outerWidth(),a=e.outerWidth(),n=e.clone().html("
"),r=_(),s=$(e.get(0),r);if(1");if(1 table tr")).get(i)).prepend(s):x(n[i][f])[0].parentNode&&x(n[i][f])[0].insertAdjacentElement("afterend",s[0])}else{var c,d=x(document.createElement("tr")).append(s);for(c=0;c td").each(function(){var e=x(this);a+=parseInt(e.attr("colspan"),10)||1}),t=0;t
";l+="",e.prepend(l),h()}},removeHeader:function fe(){var e=Q(),t=e.find("thead");if(0'+this.language.translate(t[l])+"");return e+=""},callback:function(e,t){"above"==t||"below"==t?this.table.insertRow(t):this.table.deleteRow()}}),ge.DefineIcon("tableColumns",{NAME:"bars fa-rotate-90",SVG_KEY:"columns"}),ge.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()}}),ge.DefineIcon("tableCells",{NAME:"square-o",FA5NAME:"square",SVG_KEY:"cellOptions"}),ge.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[l])+"");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 l=this.$,a=this.$el.find(".fr-selected-cell").closest("table");a&&t.find(".fr-command").each(function(){var e=l(this).data("param1"),t=a.hasClass(e);l(this).toggleClass("fr-active",t).attr("aria-selected",t)})}}),ge.DefineIcon("tableCellBackground",{NAME:"tint",SVG_KEY:"cellBackground"}),ge.RegisterCommand("tableCellBackground",{title:"Cell Background",focus:!1,popup:!0,callback:function(){this.table.showColorsPopup()}}),ge.RegisterCommand("tableCellBackgroundColor",{undo:!0,focus:!1,callback:function(e,t){this.table.setBackground(t)}}),ge.DefineIcon("tableBack",{NAME:"arrow-left",SVG_KEY:"back"}),ge.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"))}}),ge.DefineIcon("tableCellVerticalAlign",{NAME:"arrows-v",FA5NAME:"arrows-alt-v",SVG_KEY:"verticalAlignMiddle"}),ge.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)}}),ge.DefineIcon("tableCellHorizontalAlign",{NAME:"align-left",SVG_KEY:"alignLeft"}),ge.DefineIcon("align-left",{NAME:"align-left",SVG_KEY:"alignLeft"}),ge.DefineIcon("align-right",{NAME:"align-right",SVG_KEY:"alignRight"}),ge.DefineIcon("align-center",{NAME:"align-center",SVG_KEY:"alignCenter"}),ge.DefineIcon("align-justify",{NAME:"align-justify",SVG_KEY:"alignJustify"}),ge.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(),l=this.$;t.length&&e.find("> *").first().replaceWith(this.icon.create("align-"+this.helpers.getAlignment(l(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)}}),ge.DefineIcon("tableCellStyle",{NAME:"magic",SVG_KEY:"cellStyle"}),ge.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 l=this.$,a=this.$el.find(".fr-selected-cell").first();a&&t.find(".fr-command").each(function(){var e=l(this).data("param1"),t=a.hasClass(e);l(this).toggleClass("fr-active",t).attr("aria-selected",t)})}}),ge.RegisterCommand("tableCellBackgroundCustomColor",{title:"OK",undo:!0,callback:function(){this.table.customColor()}}),ge.DefineIcon("tableColorRemove",{NAME:"eraser",SVG_KEY:"remove"})});