Ext.namespace("Zarafa.plugins.jodit");Zarafa.plugins.jodit.ABOUT='<h2>htmleditor-jodit plugin</h2><p>Copyright (C) 2020 Kopano and its licensors</p><p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p><p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.</p><p>You should have received a copy of the GNU Affero General Public License along with this program.  If not, see <a href="http://www.gnu.org/licenses/" target="_blank">http://www.gnu.org/licenses/</a>.</p><p>htmleditor-jodit plugin contains the following third-party components:</p><h2>Jodit - Licensed under the MIT License</h2>Copyright (c) 2013-2020 http://xdsoft.net <p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p><p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p><p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p><p>\u00a9 2020 GitHub, Inc.</p>';
Ext.namespace("Zarafa.plugins.jodit");var editorPlugin={};Ext.isDefined(Zarafa.core.HtmlEditorPlugin)?editorPlugin=Zarafa.core.HtmlEditorPlugin:(Zarafa.plugins.htmleditor&&Zarafa.plugins.htmleditor.Plugin&&(editorPlugin=Zarafa.plugins.htmleditor.Plugin),console.warn("Please upgrade Kopano WebApp to use the Jodit plugin"));Zarafa.plugins.jodit.JoditPlugin=Ext.extend(editorPlugin,{editorXType:"plugins.joditeditor"});editorPlugin=void 0;
if(!Ext.isIE)Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"jodit",about:Zarafa.plugins.jodit.ABOUT,allowUserDisable:!1,allowUserVisible:!1,displayName:_("Jodit Editor"),pluginConstructor:Zarafa.plugins.jodit.JoditPlugin}))});Ext.namespace("Zarafa.plugins.jodit.ui");var joditIdGen=0;
Zarafa.plugins.jodit.ui.JoditEditor=Ext.extend(Ext.Container,{editor:void 0,lastCursorPosition:void 0,constructor:function(a){this.id="k-joditeditor-"+joditIdGen++;a=Ext.applyIf(a||{},{xtype:"plugins.joditeditor",cls:"k-jodittextarea",enableSystemContextMenu:!0});Zarafa.plugins.jodit.ui.JoditEditor.superclass.constructor.call(this,a);this.initEvents()},initEvents:function(){this.on("activate",this.onActivateEditor,this);this.on("deactivate",this.onDeactivateEditor,this)},bindRecord:function(a){this.record=
a},afterRender:function(){Zarafa.plugins.jodit.ui.JoditEditor.superclass.afterRender.call(this,arguments);var a=container.getSettingsModel().get("zarafa/v1/contexts/mail/dialogs/mailcreate/use_html_editor");Ext.isDefined(this.dialog)&&!1===this.dialog.isXType("zarafa.mailcreatecontentpanel")||!1===a||(this.createEditorInstance(),this.editor.container.classList.contains("k-signature-editor")&&this.disable())},onDeactivateEditor:function(){var a=this.editor.container,b=this.editor.toolbar.container;
!1===a.classList.contains("x-hide-display")&&a.setAttribute("class",a.getAttribute("class")+" x-hide-display");!1===b.classList.contains("x-hide-display")&&b.setAttribute("class",b.getAttribute("class")+" x-hide-display")},onActivateEditor:function(){if(this.editor){var a=this.editor.toolbar.container;this.editor.container.classList.remove("x-hide-display");a.classList.remove("x-hide-display")}else this.createEditorInstance()},createEditorInstance:function(){this.getFontFamilies().map(function(a){return a.name});
Zarafa.common.ui.htmleditor.Fonts.getFontSizeString().split(" ");var a=this.getActiveWindow();this.activeWindow=a;var b=this.id,b=!1===Zarafa.core.BrowserWindowMgr.isMainWindowActive()?a.document.getElementById(b):"#"+b;this.editor=new a.Jodit(b,{toolbarButtonSize:"medium",buttons:"bold italic underline ul ol image table link".split(" "),enableDragAndDropFileToEditor:!0,tabIndex:0,theme:"summer",style:{fontFamily:this.getDefaultFontFormatting().fontFamily,fontSize:this.getDefaultFontFormatting().fontSize},
uploader:{url:"https://xdsoft.net/jodit/connector/index.php?action=fileUpload",insertImageAsBase64URI:!0},showTooltip:!0,showPlaceholder:!1,askBeforePasteHTML:!1,askBeforePasteFromWord:!1,defaultActionOnPaste:"insert_only_html",addNewLineOnDBLClick:!1,link:{noFollowCheckbox:!1,openInNewTabCheckbox:!1},disablePlugins:"cleanhtml"});this.editor.statusbar.hide();this.editor.container.classList.contains("zarafa-contextmenu-enabled")||this.editor.container.classList.add("zarafa-contextmenu-enabled");this.editor.registerCommand("tabindent",
{hotkeys:"TAB",exec:this.execTabIndent.bind(this)});this.editor.events.on("beforeEnter",function(a){if(a.ctrlKey&&"disabled"!==container.getSettingsModel().get("zarafa/v1/main/keycontrols"))return this.dialog.sendRecord(),!1}.bind(this));this.editor.events.on("beforePasteInsert",function(a){return" "+a});this.editor.editor.addEventListener("focus",function(){this.lastCursorPosition&&this.editor.selection.restore(this.lastCursorPosition)}.bind(this));this.editor.events.on("change",this.onTextChange.bind(this));
this.editor.editor.addEventListener("focusout",this.onFocusOutHandler.bind(this))},closest:function(a,b,c){do{if((new RegExp("^("+a+")$","i")).test(b.nodeName))return b;b=b.parentElement}while(b&&b!==c.editor);return null},execTabIndent:function(){function a(){var a=b.selection.save(),c=b.createInside.element("p");c.insertHTML="&nbsp;&nbsp;&nbsp;&nbsp;";b.editor.appendChild(c);b.selection.restore(a);b.selection.setCursorIn(c)}var b=this.editor,c=b.selection.current(!1);if(!c||!Ext.isDefined(c.closest))return b.selection.sel.getRangeAt(0).startContainer===
b.editor?a():this.insertAtCursor("&nbsp;&nbsp;&nbsp;&nbsp;"),!1;c=this.closest("li",c,b);if(!c)return b.selection.sel.getRangeAt(0).startContainer===b.editor?a():this.insertAtCursor("&nbsp;&nbsp;&nbsp;&nbsp;"),!1;var f=this.closest("ul|ol",c,b);if(f){var e=c.previousElementSibling;if(e){var g=b.selection.save(),d=e.querySelector("ol,ul"),d=d||b.createInside.element(f.nodeName);d.appendChild(c);e.appendChild(d);b.selection.restore(g)}}},onTextChange:function(a,b){this.fireEvent("keypress",this,Ext.EventObject)},
onFocusOutHandler:function(a){a=this.editor.s.sel.focusNode;"#text"===a.nodeName&&(a=a.parentNode);0===a.querySelectorAll("span").length&&(this.lastCursorPosition=this.editor.selection.save())},setValue:function(a){a=this.removeInternalStyleTags(a);this.editor.setEditorValue(a);this.checkValueCorrection(this,a)},removeInternalStyleTags:function(a){if(a)return a.replace(/<style>[\d\w\s"-{}!]*<\/style>/ig,"")},checkValueCorrection:function(a,b){var c=a.getValue();b!==c&&a.fireEvent("valuecorrection",
a,c,b)},getDefaultFontFormatting:function(){var a=container.getSettingsModel().get("zarafa/v1/main/default_font").split(",")[0];switch(a){case "courier new":a="Courier New";break;case "times new roman":a="Times New Roman";break;case "tahoma":a="Tahoma";break;case "verdana":a="Verdana";break;default:a="Arial"}return{fontSize:Zarafa.common.ui.htmleditor.Fonts.getDefaultFontSize(),fontFamily:a}},getFontFamilies:function(){return Zarafa.common.ui.htmleditor.Fonts.getFontFamilies().split(";").map(function(a){return{name:a.split("=")[0],
value:a.split("=")[1].toLowerCase()}})},getActiveWindow:function(){return Zarafa.core.BrowserWindowMgr.getActive()},disable:function(){this.editor||this.createEditorInstance();this.editor.setReadOnly(!0)},enable:function(){this.editor.setReadOnly(!1)},focus:function(){this.editor.selection.focus()},getValue:function(){return this.editor.getEditorValue()},insertAtCursor:function(a){this.editor.selection.insertHTML(a)},setCursorLocation:Ext.emptyFn});Ext.reg("plugins.joditeditor",Zarafa.plugins.jodit.ui.JoditEditor);//# sourceMappingURL=htmleditor-jodit.js.map
