editor.js/codex-editor.js
khaydarov f5314dfab6 Prepare plugins (#148)
* prepare plugins improvements

* prepare plugins asyncronically

* update version

* restore data from cache when plugin is unavailable

* added comments to the complicated solution

* new module tools.js for methods working with plugins

* remove ArrayOfCachedData

* build updated

* remove trash
2017-02-05 17:50:48 +03:00

3 lines
42 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var codex=codex||{};codex.editor=function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return e[n].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(e,t,o){"use strict";e.exports=function(e){e.version="1.4.3";var t=function(){e.core=o(1),e.tools=o(2),e.ui=o(3),e.transport=o(4),e.renderer=o(5),e.saver=o(6),e.content=o(7),e.toolbar=o(8),e.callback=o(12),e.draw=o(13),e.caret=o(14),e.notifications=o(15),e.parser=o(16),e.sanitizer=o(17)};return e.settings={tools:["paragraph","header","picture","list","quote","code","twitter","instagram","smile"],textareaId:"codex-editor",uploadImagesUrl:"/editor/transport/",initialBlockPlugin:"paragraph"},e.nodes={textarea:null,wrapper:null,toolbar:null,inlineToolbar:{wrapper:null,buttons:null,actions:null},toolbox:null,notifications:null,plusButton:null,showSettingsButton:null,showTrashButton:null,blockSettings:null,pluginSettings:null,defaultSettings:null,toolbarButtons:{},redactor:null},e.state={jsonOutput:[],blocks:[],inputs:[]},e.tools={},e.start=function(o){t(),e.core.prepare(o).then(e.ui.make).then(e.ui.addTools).then(e.ui.bindEvents).then(e.tools.prepare).then(e.transport.prepare).then(e.renderer.makeBlocksFromData).then(e.ui.saveInputs).catch(function(t){e.core.log("Initialization failed with error: %o","warn",t)})},e}({})},function(e,t){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=codex.editor;e.exports=function(e){return e.prepare=function(e){return new Promise(function(t,r){e&&(n.settings.tools=e.tools||n.settings.tools),e.data&&(n.state.blocks=e.data),e.initialBlockPlugin&&(n.settings.initialBlockPlugin=e.initialBlockPlugin),e.uploadImagesUrl&&(n.settings.uploadImagesUrl=e.uploadImagesUrl),n.nodes.textarea=document.getElementById(e.textareaId||n.settings.textareaId),void 0===o(n.nodes.textarea)||null===n.nodes.textarea?r(Error("Textarea wasn't found by ID: #"+e.textareaId)):t()})},e.log=function(e,t,o){t=t||"log",o?e="[codex-editor]: "+e:(o=e||"undefined",e="[codex-editor]: %o");try{"console"in window&&window.console[t]&&(o?window.console[t](e,o):window.console[t](e))}catch(e){}},e.insertAfter=function(e,t){e.parentNode.insertBefore(t,e.nextSibling)},e.nodeTypes={TAG:1,TEXT:3,COMMENT:8},e.keys={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,LEFT:37,UP:38,DOWN:40,RIGHT:39,DELETE:46,META:91},e.isDomNode=function(e){return e&&"object"===("undefined"==typeof e?"undefined":o(e))&&e.nodeType&&e.nodeType==this.nodeTypes.TAG},e.isEmpty=function(e){return 0===Object.keys(e).length},e.ajax=function(e){if(e&&e.url){var t,o=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),n=function(){},r="";if(e.async=!0,e.type=e.type||"GET",e.data=e.data||"",e["content-type"]=e["content-type"]||"application/json; charset=utf-8",n=e.success||n,"GET"==e.type&&e.data)e.url=/\?/.test(e.url)?e.url+"&"+e.data:e.url+"?"+e.data;else for(t in e.data)r+=t+"="+encodeURIComponent(e.data[t])+"&";e.withCredentials&&(o.withCredentials=!0),e.beforeSend&&"function"==typeof e.beforeSend&&e.beforeSend.call(),o.open(e.type,e.url,e.async),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.onreadystatechange=function(){4==o.readyState&&200==o.status&&n(o.responseText)},o.send(r)}},e.importScript=function(e,t){return new Promise(function(o,n){var r="cdx-script-",i=void 0;t?document.getElementById(r+t)&&o(e):n("Instance name is missed"),i=document.createElement("SCRIPT"),i.async=!0,i.defer=!0,i.id=r+t,i.onload=function(){o(e)},i.onerror=function(){n(e)},i.src=e,document.head.appendChild(i)})},e}({})},function(e,t){"use strict";e.exports=function(){function e(){return new Promise(function(e,n){Promise.resolve().then(function(){var e=[],t=o.tools;for(var n in t){var r=t[n];r.prepare&&"function"!=typeof r.prepare||!r.prepare||e.push(r)}return e}).then(t).then(function(){o.core.log("Plugins loaded","info"),e()}).catch(function(e){n(e)})})}function t(e){return new Promise(function(t){e.reduce(function(r,i,a){return r.then(function(){return new Promise(function(r){n(i).then(r).then(function(){i.available=!0}).catch(function(e){o.core.log("Plugin «"+i.type+"» was not loaded. Preparation failed because %o","warn",e),i.available=!1,i.loadingMessage=e,r()}).then(function(){a==e.length-1&&t()})})})},Promise.resolve())})}var o=codex.editor,n=function(e){return e.prepare(e.config||{})};return{prepare:e}}()},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.className={BLOCK_CLASSNAME:"ce-block",BLOCK_CONTENT:"ce-block__content",BLOCK_STRETCHED:"ce-block--stretched",BLOCK_HIGHLIGHTED:"ce-block--focused",BLOCK_IN_FEED_MODE:"ce-block--feed-mode",SETTINGS_ITEM:"ce-settings__item"},e.make=function(){var e,t,n,r,i,a,s,c,l,d,u;e=o.draw.wrapper(),o.core.insertAfter(o.nodes.textarea,e),i=o.draw.alertsHolder(),o.nodes.notifications=document.body.appendChild(i),t=o.draw.toolbar(),n=o.draw.toolbarContent(),u=o.draw.plusButton(),c=o.draw.settingsButton(),l=o.toolbar.settings.makeRemoveBlockButton(),s=o.draw.blockSettings(),a=o.draw.blockButtons(),d=o.draw.toolbox(),r=o.draw.redactor();var p=o.draw.defaultSettings(),f=o.draw.pluginsSettings();s.appendChild(f),s.appendChild(p),a.appendChild(c),a.appendChild(l),a.appendChild(s),n.appendChild(u),n.appendChild(d),t.appendChild(a),t.appendChild(n),e.appendChild(t),e.appendChild(r),o.nodes.wrapper=e,o.nodes.toolbar=t,o.nodes.plusButton=u,o.nodes.toolbox=d,o.nodes.blockSettings=s,o.nodes.pluginSettings=f,o.nodes.defaultSettings=p,o.nodes.showSettingsButton=c,o.nodes.showTrashButton=l,o.nodes.redactor=r,o.ui.makeInlineToolbar(),o.toolbar.settings.addDefaultSettings()},e.makeInlineToolbar=function(){var e=o.draw.inlineToolbar();o.nodes.inlineToolbar.wrapper=e,o.nodes.inlineToolbar.buttons=o.draw.inlineToolbarButtons(),o.nodes.inlineToolbar.actions=o.draw.inlineToolbarActions(),o.nodes.inlineToolbar.wrapper.appendChild(o.nodes.inlineToolbar.buttons),o.nodes.inlineToolbar.wrapper.appendChild(o.nodes.inlineToolbar.actions),o.nodes.wrapper.appendChild(o.nodes.inlineToolbar.wrapper)},e.addTools=function(){var e,t,n;for(t in o.settings.tools)e=o.settings.tools[t],o.tools[t]=e,e.iconClassname?"function"==typeof e.render?e.displayInToolbox&&(n=o.draw.toolbarButton(t,e.iconClassname),o.nodes.toolbox.appendChild(n),o.nodes.toolbarButtons[t]=n):o.core.log("render method missed. Tool %o skipped","warn",t):o.core.log("Toolbar icon classname missed. Tool %o skipped","warn",t);o.ui.addInlineToolbarTools()},e.addInlineToolbarTools=function(){var e,t,n={bold:{icon:"ce-icon-bold",command:"bold"},italic:{icon:"ce-icon-italic",command:"italic"},underline:{icon:"ce-icon-underline",command:"underline"},link:{icon:"ce-icon-link",command:"createLink"}};for(var r in n)t=n[r],e=o.draw.toolbarButtonInline(r,t.icon),o.nodes.inlineToolbar.buttons.appendChild(e),o.ui.setInlineToolbarButtonBehaviour(e,t.command)},e.bindEvents=function(){o.core.log("ui.bindEvents fired","info"),document.addEventListener("keydown",o.callback.globalKeydown,!1),o.nodes.redactor.addEventListener("keydown",o.callback.redactorKeyDown,!1),document.addEventListener("keyup",o.callback.globalKeyup,!1),o.nodes.redactor.addEventListener("click",o.callback.redactorClicked,!1),o.nodes.plusButton.addEventListener("click",o.callback.plusButtonClicked,!1),o.nodes.showSettingsButton.addEventListener("click",o.callback.showSettingsButtonClicked,!1);for(var e in o.nodes.toolbarButtons)o.nodes.toolbarButtons[e].addEventListener("click",o.callback.toolbarButtonClicked,!1)},e.addBlockHandlers=function(e){e&&(e.addEventListener("keydown",o.callback.blockKeydown,!1),e.addEventListener("paste",o.callback.blockPasteCallback,!1),e.addEventListener("mouseup",o.toolbar.inline.show,!1))},e.saveInputs=function(){var e=o.nodes.redactor;o.state.inputs=e.querySelectorAll("[contenteditable], input")},e.addInitialBlock=function(){var e,t=o.settings.initialBlockPlugin;return o.tools[t]?(e=o.tools[t].render(),e.setAttribute("data-placeholder","Расскажите свою историю..."),o.content.insertBlock({type:t,block:e}),void o.content.workingNodeChanged(e)):void o.core.log("Plugin %o was not implemented and can't be used as initial block","warn",t)},e.setInlineToolbarButtonBehaviour=function(e,t){e.addEventListener("mousedown",function(e){o.toolbar.inline.toolClicked(e,t)},!1)},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.input=null,e.arguments=null,e.prepare=function(){var e=document.createElement("INPUT");e.type="file",e.addEventListener("change",o.transport.fileSelected),o.transport.input=e},e.clearInput=function(){this.input=null,this.prepare()},e.fileSelected=function(){var e=this,t=e.files,n=new FormData;n.append("files",t[0],t[0].name),o.transport.ajax({data:n,beforeSend:o.transport.arguments.beforeSend,success:o.transport.arguments.success,error:o.transport.arguments.error})},e.selectAndUpload=function(e){this.arguments=e,this.input.click()},e.ajax=function(e){var t=new XMLHttpRequest,n="function"==typeof e.beforeSend?e.beforeSend:function(){},r="function"==typeof e.success?e.success:function(){},i="function"==typeof e.error?e.error:function(){};n(),t.open("POST",o.settings.uploadImagesUrl,!0),t.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.onload=function(){200===t.status?r(t.responseText):(o.core.log("request error: %o",t),i())},t.send(e.data),this.clearInput()},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.makeBlocksFromData=function(){return o.core.isEmpty(o.state.blocks)||!o.state.blocks.items.length?void o.ui.addInitialBlock():void Promise.resolve().then(function(){return o.state.blocks}).then(o.renderer.appendBlocks).catch(function(e){o.core.log("Error while parsing JSON: %o","error",e)})},e.appendBlocks=function(e){for(var t=e.items,n=Promise.resolve(),r=0;r<t.length;r++)o.renderer.appendNodeAtIndex(n,t,r)},e.appendNodeAtIndex=function(e,t,n){e.then(function(){return o.renderer.getNodeAsync(t,n)}).then(o.renderer.createBlockFromData).then(function(e){return o.content.insertBlock(e),e.block}).catch(function(e){o.core.log("Node skipped while parsing because %o","error",e)})},e.getNodeAsync=function(e,t){return Promise.resolve().then(function(){return{tool:e[t],position:t}})},e.createBlockFromData=function(e){var t,n=e.tool,r=n.type,i=n.cover;if(!o.tools[r])throw Error("Plugin «"+r+"» not found");if("function"!=typeof o.tools[r].render)throw Error("Plugin «"+r+"» must have «render» method");o.tools[r].available===!1?(t=o.draw.unavailableBlock(),t.innerHTML=o.tools[r].loadingMessage,t.dataset.inputPosition=e.position):t=o.tools[r].render(n.data);var a=o.tools[r].isStretched||!1;return{type:r,block:t,stretched:a,cover:i}},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.saveBlocks=function(){o.state.html=o.nodes.redactor.innerHTML,o.state.jsonOutput=[],Promise.resolve().then(function(){return o.nodes.redactor.childNodes}).then(o.saver.makeQueue).then(function(){}).catch(function(e){o.core.log(e)})},e.makeQueue=function(e){for(var t=Promise.resolve(),n=0;n<e.length;n++)o.saver.getBlockData(t,e,n)},e.getBlockData=function(e,t,n){e.then(function(){return o.saver.getNodeAsync(t,n)}).then(o.saver.makeFormDataFromBlocks)},e.getNodeAsync=function(e,t){return Promise.resolve().then(function(){return e[t]})},e.makeFormDataFromBlocks=function(e){var t=e.dataset.tool;if(!o.tools[t])throw Error("Plugin «"+t+"» not found");if("function"!=typeof o.tools[t].save)throw Error("Plugin «"+t+"» must have save method");var n,r,i,a=e.childNodes[0],s=a.childNodes[0],c=!1;if(o.tools[t].available===!1)r=s.dataset.inputPosition,n=codex.editor.state.blocks.items[r].data,c=codex.editor.state.blocks.items[r].cover;else if(n=o.tools[t].save(s),c=e.classList.contains(o.ui.className.BLOCK_IN_FEED_MODE),o.tools[t].validate){var l=o.tools[t].validate(n);if(!l)return}i={type:t,data:n},i.cover=c,o.state.jsonOutput.push(i)},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){e.currentNode=null,e.editorAreaHightlighted=null,e.sync=function(){o.core.log("syncing..."),o.state.html=o.nodes.redactor.innerHTML},e.getNodeFocused=function(){var e,t=window.getSelection();if(null===t.anchorNode)return null;if(e=t.anchorNode.nodeType==o.core.nodeTypes.TAG?t.anchorNode:t.focusNode.parentElement,!o.parser.isFirstLevelBlock(e)){for(var n=e.parentNode;n&&!o.parser.isFirstLevelBlock(n);)n=n.parentNode;e=n}return e!=o.nodes.redactor?e:null},e.markBlock=function(){o.content.currentNode.classList.add(o.ui.className.BLOCK_HIGHLIGHTED)},e.clearMark=function(){o.content.currentNode&&o.content.currentNode.classList.remove(o.ui.className.BLOCK_HIGHLIGHTED)},e.getFirstLevelBlock=function(e){if(o.core.isDomNode(e)||(e=e.parentNode),e===o.nodes.redactor||e===document.body)return null;for(;!e.classList.contains(o.ui.className.BLOCK_CLASSNAME);)e=e.parentNode;return e},e.workingNodeChanged=function(e){o.content.clearMark(),e&&(this.currentNode=this.getFirstLevelBlock(e))},e.replaceBlock=function(e,t){if(!e||!t)return void o.core.log("replaceBlock: missed params");for(;!e.classList.contains(o.ui.className.BLOCK_CLASSNAME);)e=e.parentNode;e.classList.contains(o.ui.className.BLOCK_IN_FEED_MODE)&&t.classList.add(o.ui.className.BLOCK_IN_FEED_MODE),o.nodes.redactor.replaceChild(t,e),o.content.workingNodeChanged(t),o.ui.addBlockHandlers(t),o.ui.saveInputs()},e.insertBlock=function(t,n){var r=o.content.currentNode,i=t.block,a=t.type,s=t.cover,c=t.stretched,l=o.content.composeNewBlock(i,a,c);if(s===!0&&l.classList.add(o.ui.className.BLOCK_IN_FEED_MODE),r?o.core.insertAfter(r,l):o.nodes.redactor.appendChild(l),o.ui.addBlockHandlers(l),o.content.workingNodeChanged(l),o.ui.saveInputs(),n){var d=o.caret.getCurrentInputIndex()||-1;if(d==-1){var u=l.querySelector("[contenteditable]"),p=document.createTextNode("");u.appendChild(p),o.caret.set(u,0,0),o.toolbar.move(),o.toolbar.showPlusButton()}else{if(d===o.state.inputs.length-1)return;window.setTimeout(function(){o.caret.setToNextBlock(d),o.toolbar.move(),o.toolbar.open()},10)}}e.editorAreaHightlighted=!1},e.switchBlock=function(e,t,n){var r=o.content.composeNewBlock(t,n);o.content.replaceBlock(e,r),o.ui.saveInputs()},e.getDeepestTextNodeFromPosition=function(e,t){var n,r,i,a=e.childNodes;for(n=0;n<a.length;n++)r=a[n],r.nodeType==o.core.nodeTypes.TEXT&&(i=r.textContent.trim(),""===i&&(e.removeChild(r),t--));if(0===e.childNodes.length)return document.createTextNode("");t<0&&(t=1);var s=!1;for(0===t&&(s=!0,t=1);t;)e=s?e.childNodes[0]:e.childNodes[t-1],e.nodeType==o.core.nodeTypes.TAG?t=e.childNodes.length:e.nodeType==o.core.nodeTypes.TEXT&&(t=0);return e},e.composeNewBlock=function(e,t,n){var r=o.draw.node("DIV",o.ui.className.BLOCK_CLASSNAME,{}),i=o.draw.node("DIV",o.ui.className.BLOCK_CONTENT,{});return i.appendChild(e),r.appendChild(i),n&&i.classList.add(o.ui.className.BLOCK_STRETCHED),r.dataset.tool=t,r},e.getRange=function(){var e=window.getSelection().getRangeAt(0);return e},e.splitBlock=function(e){var t,n,r,i,a=window.getSelection(),s=a.anchorNode,c=s.textContent,l=a.anchorOffset,d=o.content.currentNode.querySelector("[contentEditable]");t=c.substring(0,l),r=c.substring(l),n=document.createTextNode(t),r&&(i=document.createTextNode(r));var u=[],p=[],f=!1;i&&p.push(i);for(var g,b=0;g=d.childNodes[b];b++)g!=s?f?p.push(g):u.push(g):f=!0;o.state.inputs[e].innerHTML="";var h=u.length;for(b=0;b<h;b++)o.state.inputs[e].appendChild(u[b]);o.state.inputs[e].appendChild(n);var v=p.length,m=document.createElement("div");for(b=0;b<v;b++)m.appendChild(p[b]);m=m.innerHTML;var k=o.settings.initialBlockPlugin;o.content.insertBlock({type:k,block:o.tools[k].render({text:m})},!0)},e.mergeBlocks=function(e,t){if(0!==e){var n,r=o.state.inputs[e].innerHTML;n=t?o.state.inputs[t]:o.state.inputs[e-1],n.innerHTML+=r}},e.paste=function(e){var t=o.content.currentNode,n=t.dataset.tool;o.tools[n].allowedToPaste?o.content.sanitize.call(this,e.target):o.content.pasteTextContent(e.addedNodes)},e.pasteTextContent=function(e){var t,n=e[0];n&&(t=n.nodeType==o.core.nodeTypes.TEXT?document.createTextNode(n):document.createTextNode(n.textContent),o.core.isDomNode(n)&&n.parentNode.replaceChild(t,n))},e.sanitize=function(e){if(e){var t=e[0];if(t&&(this.disconnect(),t.nodeType!=o.core.nodeTypes.TEXT)){var n=o.sanitizer.init(o.satinizer.Config.BASIC),r=n.clean(e.outerHTML),i=o.draw.node("DIV",[],{innerHTML:r});t.replaceWith(i.childNodes[0])}}},e.isLastNode=function(e){for(var n=!1;!n;){if(!t(e))return!1;e=e.parentNode,e.classList.contains(o.ui.className.BLOCK_CONTENT)&&(n=!0)}return!0};var t=function(e){for(var t=e.nextSibling;t;){if(t.textContent.length)return!1;t=t.nextSibling}return!0};return e.wrapTextWithParagraphs=function(e){var t,o,n,r,i=document.createElement("DIV"),a=document.createElement("DIV"),s=["DIV","P"];for(i.innerHTML=e,o=document.createElement("P"),t=0;t<i.childNodes.length;t++)r=i.childNodes[t],n=s.indexOf(r.tagName)!=-1,n?(o.childNodes.length&&(a.appendChild(o.cloneNode(!0)),o=null,o=document.createElement("P")),a.appendChild(r.cloneNode(!0))):(o.appendChild(r.cloneNode(!0)),t==i.childNodes.length-1&&a.appendChild(o.cloneNode(!0)));return a.innerHTML},e}({})},function(e,t,o){"use strict";var n=codex.editor;e.exports=function(e){return e.settings=o(9),e.inline=o(10),e.toolbox=o(11),e.defaultToolbarHeight=49,e.defaultOffset=34,e.opened=!1,e.current=null,e.open=function(){n.nodes.toolbar.classList.add("opened"),this.opened=!0},e.close=function(){n.nodes.toolbar.classList.remove("opened"),e.opened=!1,e.current=null;for(var t in n.nodes.toolbarButtons)n.nodes.toolbarButtons[t].classList.remove("selected");n.toolbar.toolbox.close(),n.toolbar.settings.close()},e.toggle=function(){this.opened?this.close():this.open()},e.hidePlusButton=function(){n.nodes.plusButton.classList.add("hide")},e.showPlusButton=function(){n.nodes.plusButton.classList.remove("hide")},e.move=function(){if(n.toolbar.toolbox.close(),n.content.currentNode){var e=n.content.currentNode.offsetTop-n.toolbar.defaultToolbarHeight/2+n.toolbar.defaultOffset;n.nodes.toolbar.style.transform="translate3D(0, "+Math.floor(e)+"px, 0)",n.toolbar.settings.hideRemoveActions()}},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.opened=!1,e.setting=null,e.actions=null,e.cover=null,e.open=function(e){if(o.tools[e]&&o.tools[e].makeSettings){var t=o.tools[e].makeSettings();o.nodes.pluginSettings.appendChild(t)}else o.core.log("Plugin «"+e+"» has no settings","warn");o.nodes.blockSettings.classList.add("opened"),o.toolbar.settings.addDefaultSettings(),this.opened=!0},e.close=function(){o.nodes.blockSettings.classList.remove("opened"),o.nodes.pluginSettings.innerHTML="",this.opened=!1},e.toggle=function(e){this.opened?this.close():this.open(e)},e.addDefaultSettings=function(){var e;o.nodes.defaultSettings.innerHTML="",e=o.toolbar.settings.makeFeedModeToggler(),o.nodes.defaultSettings.appendChild(e)},e.makeFeedModeToggler=function(){var e,t,n=o.toolbar.settings.isFeedModeActivated();return t=n?{innerHTML:'<i class="ce-icon-newspaper"></i>Не выводить в ленте'}:{innerHTML:'<i class="ce-icon-newspaper"></i>Вывести в ленте'},e=o.draw.node("DIV",o.ui.className.SETTINGS_ITEM,t),e.addEventListener("click",o.toolbar.settings.updateFeedMode,!1),e},e.updateFeedMode=function(){var e=o.content.currentNode;e.classList.toggle(o.ui.className.BLOCK_IN_FEED_MODE),o.toolbar.settings.close()},e.isFeedModeActivated=function(){var e=o.content.currentNode;return!!e&&e.classList.contains(o.ui.className.BLOCK_IN_FEED_MODE)},e.makeRemoveBlockButton=function(){var e=o.draw.node("SPAN","ce-toolbar__remove-btn",{}),t=o.draw.node("SPAN","ce-toolbar__remove-setting",{innerHTML:'<i class="ce-icon-trash"></i>'}),n=o.draw.node("DIV","ce-toolbar__remove-confirmation",{}),r=o.draw.node("DIV","ce-toolbar__remove-confirm",{textContent:"Удалить блок"}),i=o.draw.node("DIV","ce-toolbar__remove-cancel",{textContent:"Отмена"});return t.addEventListener("click",o.toolbar.settings.removeButtonClicked,!1),r.addEventListener("click",o.toolbar.settings.confirmRemovingRequest,!1),i.addEventListener("click",o.toolbar.settings.cancelRemovingRequest,!1),n.appendChild(r),n.appendChild(i),e.appendChild(t),e.appendChild(n),o.toolbar.settings.setting=t,o.toolbar.settings.actions=n,e},e.removeButtonClicked=function(){var e=o.toolbar.settings.actions;e.classList.contains("opened")?o.toolbar.settings.hideRemoveActions():o.toolbar.settings.showRemoveActions(),o.toolbar.toolbox.close(),o.toolbar.settings.close()},e.cancelRemovingRequest=function(){o.toolbar.settings.actions.classList.remove("opened")},e.confirmRemovingRequest=function(){var e,t=o.content.currentNode;t.remove(),e=o.nodes.redactor.childNodes.length,0===e&&(o.content.currentNode=null,o.ui.addInitialBlock()),o.ui.saveInputs(),o.toolbar.close()},e.showRemoveActions=function(){o.toolbar.settings.actions.classList.add("opened")},e.hideRemoveActions=function(){o.toolbar.settings.actions.classList.remove("opened")},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){e.buttonsOpened=null,e.actionsOpened=null,e.wrappersOffset=null,e.storedSelection=null,e.show=function(){var t,n=o.content.currentNode,r=n.dataset.tool;if(t=o.tools[r],t.showInlineToolbar){var i=e.getSelectionText(),a=o.nodes.inlineToolbar.wrapper;i.length>0&&(o.toolbar.inline.move(),a.classList.add("opened"),o.toolbar.inline.showButtons())}},e.close=function(){var e=o.nodes.inlineToolbar.wrapper;e.classList.remove("opened")},e.move=function(){this.wrappersOffset||(this.wrappersOffset=this.getWrappersOffset());var e,t,n=this.getSelectionCoords(),r=0,i=o.nodes.inlineToolbar.wrapper;0===i.offsetHeight&&(r=40),e=n.x-this.wrappersOffset.left,t=n.y+window.scrollY-this.wrappersOffset.top-r-i.offsetHeight,i.style.transform="translate3D("+Math.floor(e)+"px, "+Math.floor(t)+"px, 0)",o.toolbar.inline.closeButtons(),o.toolbar.inline.closeAction()},e.toolClicked=function(e,t){switch(t){case"createLink":o.toolbar.inline.createLinkAction(e,t);break;default:o.toolbar.inline.defaultToolAction(t)}o.nodes.inlineToolbar.buttons.childNodes.forEach(o.toolbar.inline.hightlight)},e.getWrappersOffset=function(){var e=o.nodes.wrapper,t=this.getOffset(e);return this.wrappersOffset=t,t},e.getOffset=function(e){for(var t=0,o=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)t+=e.offsetLeft+e.clientLeft,o+=e.offsetTop+e.clientTop,e=e.offsetParent;return{top:o,left:t}},e.getSelectionCoords=function(){var e,t=document.selection,o=0,n=0;if(t)"Control"!=t.type&&(e=t.createRange(),e.collapse(!0),o=e.boundingLeft,n=e.boundingTop);else if(window.getSelection&&(t=window.getSelection(),t.rangeCount&&(e=t.getRangeAt(0).cloneRange(),e.getClientRects))){e.collapse(!0);var r=e.getClientRects()[0];if(!r)return;o=r.left,n=r.top}return{x:o,y:n}},e.getSelectionText=function(){var e="";return window.getSelection&&(e=window.getSelection().toString()),e},e.showButtons=function(){var e=o.nodes.inlineToolbar.buttons;e.classList.add("opened"),o.toolbar.inline.buttonsOpened=!0,o.nodes.inlineToolbar.buttons.childNodes.forEach(o.toolbar.inline.hightlight)},e.closeButtons=function(){var e=o.nodes.inlineToolbar.buttons;e.classList.remove("opened"),o.toolbar.inline.buttonsOpened=!1},e.showActions=function(){var e=o.nodes.inlineToolbar.actions;e.classList.add("opened"),o.toolbar.inline.actionsOpened=!0},e.closeAction=function(){var e=o.nodes.inlineToolbar.actions;e.innerHTML="",e.classList.remove("opened"),o.toolbar.inline.actionsOpened=!1};var t=function(e){if(e.keyCode==o.core.keys.ENTER){var t=o.content.currentNode,n=o.toolbar.inline.storedSelection;o.toolbar.inline.restoreSelection(t,n),o.toolbar.inline.setAnchor(this.value),e.preventDefault(),e.stopImmediatePropagation(),o.toolbar.inline.clearRange()}};return e.createLinkAction=function(e){var n=this.isLinkActive(),r=o.content.currentNode,i=o.toolbar.inline.saveSelection(r);if(o.toolbar.inline.storedSelection=i,n)o.toolbar.inline.restoreSelection(r,i),o.toolbar.inline.defaultToolAction("unlink");else{var a=o.draw.inputForLink();o.nodes.inlineToolbar.actions.appendChild(a),o.toolbar.inline.closeButtons(),o.toolbar.inline.showActions(),a.focus(),e.preventDefault(),a.addEventListener("keydown",t,!1)}},e.isLinkActive=function(){var e=!1;return o.nodes.inlineToolbar.buttons.childNodes.forEach(function(t){var o=t.dataset.type;"link"==o&&t.classList.contains("hightlighted")&&(e=!0)}),e},e.defaultToolAction=function(e){document.execCommand(e,!1,null)},e.setAnchor=function(e){document.execCommand("createLink",!1,e),o.toolbar.inline.closeAction()},e.saveSelection=function(e){var t,o=window.getSelection().getRangeAt(0),n=o.cloneRange();return n.selectNodeContents(e),n.setEnd(o.startContainer,o.startOffset),t=n.toString().length,{start:t,end:t+o.toString().length}},e.restoreSelection=function(e,t){var o=document.createRange(),n=0;o.setStart(e,0),o.collapse(!0);for(var r,i,a=[e],s=!1,c=!1;!c&&(r=a.pop());)if(3==r.nodeType)i=n+r.length,!s&&t.start>=n&&t.start<=i&&(o.setStart(r,t.start-n),s=!0),s&&t.end>=n&&t.end<=i&&(o.setEnd(r,t.end-n),c=!0),n=i;else for(var l=r.childNodes.length;l--;)a.push(r.childNodes[l]);var d=window.getSelection();d.removeAllRanges(),d.addRange(o)},e.clearRange=function(){var e=window.getSelection();e.removeAllRanges()},e.hightlight=function(e){var t=e.dataset.type;document.queryCommandState(t)?o.toolbar.inline.setButtonHighlighted(e):o.toolbar.inline.removeButtonsHighLight(e);var n=window.getSelection(),r=n.anchorNode.parentNode;"A"==r.tagName&&"link"==t&&o.toolbar.inline.setButtonHighlighted(e)},e.setButtonHighlighted=function(e){if(e.classList.add("hightlighted"),"link"==e.dataset.type){var t=e.childNodes[0];t.classList.remove("ce-icon-link"),t.classList.add("ce-icon-unlink")}},e.removeButtonsHighLight=function(e){if(e.classList.remove("hightlighted"),"link"==e.dataset.type){var t=e.childNodes[0];t.classList.remove("ce-icon-unlink"),t.classList.add("ce-icon-link")}},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.opened=!1,e.open=function(){o.toolbar.settings.opened&&o.toolbar.settings.close(),o.nodes.toolbox.classList.add("opened"),o.nodes.plusButton.classList.add("clicked"),o.toolbar.toolbox.opened=!0},e.close=function(){o.nodes.toolbox.classList.remove("opened"),o.nodes.plusButton.classList.remove("clicked"),o.toolbar.toolbox.opened=!1},e.leaf=function(){var e=o.toolbar.current,t=Object.keys(o.tools),n=o.nodes.toolbarButtons,r=0,i=void 0,a=void 0,s=void 0;if(e)for(r=t.indexOf(e)+1,a=t[r];!o.tools[a].displayInToolbox;)r++,a=t[r],r==t.length&&(r=0,a=t[r]);else for(s in o.tools){if(o.tools[s].displayInToolbox)break;r++}i=t[r];for(var c in n)n[c].classList.remove("selected");n[i].classList.add("selected"),o.toolbar.current=i},e.toolClicked=function(e){var t,n,r,i=["image","link","list","instagram","twitter","embed"],a=o.tools[o.toolbar.current],s=o.content.currentNode,c=o.caret.inputIndex;t=a.render(),r={block:t,type:a.type,stretched:!1},s&&i.indexOf(s.dataset.tool)===-1&&""===s.textContent.trim()?o.content.switchBlock(s,t,a.type):(o.content.insertBlock(r),c++),n=a.appendCallback,n&&"function"==typeof n&&n.call(e),window.setTimeout(function(){o.caret.setToBlock(c)},10),o.content.workingNodeChanged(),o.toolbar.move()},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.globalKeydown=function(e){switch(e.keyCode){case o.core.keys.ENTER:o.callback.enterKeyPressed(e)}},e.redactorKeyDown=function(e){switch(e.keyCode){case o.core.keys.TAB:o.callback.tabKeyPressed(e);break;case o.core.keys.ENTER:o.callback.enterKeyPressedOnRedactorZone(e);break;case o.core.keys.ESC:o.callback.escapeKeyPressed(e);break;default:o.callback.defaultKeyPressed(e)}},e.globalKeyup=function(e){switch(e.keyCode){case o.core.keys.UP:case o.core.keys.LEFT:case o.core.keys.RIGHT:case o.core.keys.DOWN:o.callback.arrowKeyPressed(e)}},e.tabKeyPressed=function(e){o.toolbar.opened||o.toolbar.open(),o.toolbar.opened&&!o.toolbar.toolbox.opened?o.toolbar.toolbox.open():o.toolbar.toolbox.leaf(),e.preventDefault()},e.enterKeyPressed=function(){o.content.editorAreaHightlighted&&(o.caret.inputIndex=-1,o.callback.enterPressedOnBlock())},e.enterKeyPressedOnRedactorZone=function(e){"true"==e.target.contentEditable&&o.caret.saveCurrentInputIndex();var t=o.caret.getCurrentInputIndex()||0,n=o.content.currentNode,r=n.dataset.tool,i=o.toolbar.opened&&o.toolbar.current&&e.target==o.state.inputs[t],a=o.tools[r].enableLineBreaks,s=o.settings.initialBlockPlugin;if(i)return e.preventDefault(),o.toolbar.toolbox.toolClicked(e),o.toolbar.close(),e.stopPropagation(),void e.stopImmediatePropagation();if(e.shiftKey||a)return e.stopPropagation(),void e.stopImmediatePropagation();var c=window.getSelection(),l=c.anchorNode,d=o.caret.position.atTheEnd(),u=!1;if(e.shiftKey&&!a)return o.callback.enterPressedOnBlock(o.content.currentBlock,e),void e.preventDefault();if(u=l&&"true"!=l.parentNode.contentEditable,l.nodeType!=o.core.nodeTypes.TEXT||u||d){var p=o.content.isLastNode(l);p&&d&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),o.core.log("ENTER clicked in last textNode. Create new BLOCK"),o.content.insertBlock({type:s,block:o.tools[s].render()},!0),o.toolbar.move(),o.toolbar.open(),o.toolbar.showPlusButton())}else e.preventDefault(),o.core.log("Splitting Text node..."),o.content.splitBlock(t),o.state.inputs[t+1].textContent.trim()||o.toolbar.showPlusButton();o.ui.saveInputs()},e.escapeKeyPressed=function(e){o.toolbar.close(),o.toolbar.toolbox.close(),e.preventDefault()},e.arrowKeyPressed=function(){o.content.workingNodeChanged(),o.toolbar.close(),o.toolbar.move()},e.defaultKeyPressed=function(){o.toolbar.close(),o.toolbar.inline.actionsOpened||(o.toolbar.inline.close(),o.content.clearMark())},e.redactorClicked=function(t){e.detectWhenClickedOnFirstLevelBlockArea(),o.content.workingNodeChanged(t.target),o.ui.saveInputs();var n,r=o.toolbar.inline.getSelectionText();if(0===r.length&&o.toolbar.inline.close(),"true"==t.target.contentEditable&&o.caret.saveCurrentInputIndex(),null===o.content.currentNode){var i=o.state.inputs.length>0?o.state.inputs.length-1:0;if(o.state.inputs.length&&(n=o.content.getFirstLevelBlock(o.state.inputs[i])),o.state.inputs.length&&""===o.state.inputs[i].textContent&&n.dataset.tool==o.settings.initialBlockPlugin)o.caret.setToBlock(i);else{var a=o.settings.initialBlockPlugin;o.content.insertBlock({type:a,block:o.tools[a].render()}),1===o.state.inputs.length?o.caret.setToBlock(i):o.caret.setToNextBlock(i)}o.toolbar.move(),o.toolbar.open()}else o.toolbar.move(),o.toolbar.open(),o.toolbar.settings.close(),o.toolbar.toolbox.close();var s=!o.content.currentNode.textContent.trim(),c=o.content.currentNode.dataset.tool,l=c==o.settings.initialBlockPlugin;o.toolbar.hidePlusButton(),o.content.markBlock(),l&&s&&o.toolbar.showPlusButton()},e.detectWhenClickedOnFirstLevelBlockArea=function(){var e=window.getSelection(),t=e.anchorNode,n=!1;if(0===e.rangeCount)o.content.editorAreaHightlighted=!0;else{for(o.core.isDomNode(t)||(t=t.parentNode),"true"==t.contentEditable&&(n=!0);"true"!=t.contentEditable&&(t=t.parentNode,"true"==t.contentEditable&&(n=!0),t!=document.body););o.content.editorAreaHightlighted=!n}},e.toolbarButtonClicked=function(e){var t=this;o.toolbar.current=t.dataset.type,o.toolbar.toolbox.toolClicked(e),o.toolbar.close()},e.plusButtonClicked=function(){o.nodes.toolbox.classList.contains("opened")?o.toolbar.toolbox.close():o.toolbar.toolbox.open()},e.blockKeydown=function(e){var t=this;switch(e.keyCode){case o.core.keys.DOWN:case o.core.keys.RIGHT:o.callback.blockRightOrDownArrowPressed();break;case o.core.keys.BACKSPACE:o.callback.backspacePressed(t,e);break;case o.core.keys.UP:case o.core.keys.LEFT:o.callback.blockLeftOrUpArrowPressed();
}},e.blockRightOrDownArrowPressed=function(){var e,t=window.getSelection(),n=o.state.inputs,r=t.anchorNode;if(!r)return!1;for(;"true"!=r.contentEditable;)e=r.parentNode,r=e;for(var i=0;r!=n[i];)i++;if(!r.textContent)return void o.caret.setToNextBlock(i);var a,s,c=!1,l=!1;return a=r.childNodes[r.childNodes.length-1],s=o.core.isDomNode(a)?o.content.getDeepestTextNodeFromPosition(a,a.childNodes.length):a,c=t.anchorNode==s,l=s.length==t.anchorOffset,c&&l?void o.caret.setToNextBlock(i):(o.core.log("arrow [down|right] : caret does not reached the end"),!1)},e.blockLeftOrUpArrowPressed=function(){var e,t=window.getSelection(),n=o.state.inputs,r=t.anchorNode;if(!r)return!1;if(0!==t.anchorOffset)return!1;for(;"true"!=r.contentEditable;)e=r.parentNode,r=e;for(var i=0;r!=n[i];)i++;var a,s,c=!1,l=!1;return r.textContent?(a=r.childNodes[0],s=o.core.isDomNode(a)?o.content.getDeepestTextNodeFromPosition(a,0):a,c=t.anchorNode==s,l=0===t.anchorOffset,void(c&&l&&o.caret.setToPreviousBlock(i))):void o.caret.setToPreviousBlock(i)},e.enterPressedOnBlock=function(){var e=o.settings.initialBlockPlugin;o.content.insertBlock({type:e,block:o.tools[e].render()},!0),o.toolbar.move(),o.toolbar.open()},e.backspacePressed=function(e,t){var n,r,i,a=o.caret.getCurrentInputIndex();if(e.textContent.trim()){if(n=o.content.getRange(),r=n.endOffset-n.startOffset,!o.caret.position.atStart()||r||!o.state.inputs[a-1])return;o.content.mergeBlocks(a)}r||e.remove(),i=o.nodes.redactor.childNodes.length,0===i?(o.content.currentNode=null,o.ui.addInitialBlock(),o.ui.saveInputs(),window.setTimeout(function(){o.caret.setToPreviousBlock(1)},10)):0!==o.caret.inputIndex?o.caret.setToPreviousBlock(o.caret.inputIndex):o.caret.setToNextBlock(o.caret.inputIndex),o.toolbar.move(),o.toolbar.opened||o.toolbar.open(),o.ui.saveInputs(),t.preventDefault()},e._blockPasteCallback=function(){var e=o.caret.getCurrentInputIndex(),t=new MutationObserver(o.callback.handleMutationsOnPaste),n={attributes:!0,childList:!1,characterData:!1,subtree:!0};t.observe(o.state.inputs[e],n)},e.blockPasteCallback=function(e){if(e.preventDefault(),"true"==e.target.contentEditable){var t,n,r=e.clipboardData.getData("text/html")||e.clipboardData.getData("text/plain"),i=o.draw.node("DIV","",{}),a=new o.sanitizer.init(o.sanitizer.Config.BASIC);n=document.createDocumentFragment(),t=a.clean(r),i.innerHTML=t;for(var s,c;s=i.firstChild;)c=n.appendChild(s);var l,d;l=window.getSelection(),d=l.getRangeAt(0),d.deleteContents(),d.insertNode(n),c&&(d=d.cloneRange(),d.setStartAfter(c),d.collapse(!0),l.removeAllRanges(),l.addRange(d))}},e.handleMutationsOnPaste=function(e){var t=this;e.forEach(function(e){o.content.paste.call(t,e)})},e.showSettingsButtonClicked=function(){var e=o.content.currentNode.dataset.tool;o.toolbar.settings.toggle(e),o.toolbar.toolbox.close(),o.toolbar.settings.hideRemoveActions()},e}({})},function(e,t){"use strict";e.exports=function(e){return e.wrapper=function(){var e=document.createElement("div");return e.className+="codex-editor",e},e.redactor=function(){var e=document.createElement("div");return e.className+="ce-redactor",e},e.ceBlock=function(){var e=document.createElement("DIV");return e.className+="ce_block",e},e.toolbar=function(){var e=document.createElement("div");return e.className+="ce-toolbar",e},e.toolbarContent=function(){var e=document.createElement("DIV");return e.classList.add("ce-toolbar__content"),e},e.inlineToolbar=function(){var e=document.createElement("DIV");return e.className+="ce-toolbar-inline",e},e.inlineToolbarButtons=function(){var e=document.createElement("DIV");return e.className+="ce-toolbar-inline__buttons",e},e.inlineToolbarActions=function(){var e=document.createElement("DIV");return e.className+="ce-toolbar-inline__actions",e},e.inputForLink=function(){var e=document.createElement("INPUT");return e.type="input",e.className+="inputForLink",e.placeholder="Вставьте ссылку ...",e.setAttribute("form","defaultForm"),e.setAttribute("autofocus","autofocus"),e},e.alertsHolder=function(){var e=document.createElement("div");return e.classList.add("ce_notifications-block"),e},e.blockButtons=function(){var e=document.createElement("div");return e.className+="ce-toolbar__actions",e},e.blockSettings=function(){var e=document.createElement("div");return e.className+="ce-settings",e},e.defaultSettings=function(){var e=document.createElement("div");return e.classList.add("ce-settings_default"),e},e.pluginsSettings=function(){var e=document.createElement("div");return e.classList.add("ce-settings_plugin"),e},e.plusButton=function(){var e=document.createElement("span");return e.className="ce-toolbar__plus",e},e.settingsButton=function(){var e=document.createElement("span");return e.className="ce-toolbar__settings-btn",e.innerHTML='<i class="ce-icon-cog"></i>',e},e.toolbox=function(){var e=document.createElement("div");return e.className="ce-toolbar__tools",e},e.toolbarButton=function(e,t){var o=document.createElement("li"),n=document.createElement("i"),r=document.createElement("span");return o.dataset.type=e,o.setAttribute("title",e),n.classList.add(t),r.classList.add("ce_toolbar_tools--title"),o.appendChild(n),o.appendChild(r),o},e.toolbarButtonInline=function(e,t){var o=document.createElement("BUTTON"),n=document.createElement("I");return o.type="button",o.dataset.type=e,n.classList.add(t),o.appendChild(n),o},e.block=function(e,t){var o=document.createElement(e);return o.innerHTML=t||"",o},e.node=function(e,t,o){var n=document.createElement(e);if(t&&(n.className=t),o)for(var r in o)n[r]=o[r];return n},e.unavailableBlock=function(){var e=document.createElement("DIV");return e.classList.add("cdx-unavailable-block"),e},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.inputIndex=null,e.offset=null,e.focusedNodeIndex=null,e.set=function(t,n,r){r=r||e.offset||0,n=n||e.focusedNodeIndex||0;var i,a=t.childNodes;if(i=0===a.length?t:a[n],"INPUT"==t.tagName)return void t.focus();o.core.isDomNode(i)&&(i=o.content.getDeepestTextNodeFromPosition(i,i.childNodes.length));var s=document.createRange(),c=window.getSelection();window.setTimeout(function(){s.setStart(i,r),s.setEnd(i,r),c.removeAllRanges(),c.addRange(s),o.caret.saveCurrentInputIndex()},20)},e.saveCurrentInputIndex=function(){var t,n=window.getSelection(),r=o.state.inputs,i=n.anchorNode;if(i){for(;"true"!=i.contentEditable;)t=i.parentNode,i=t;for(var a=0;i!=r[a];)a++;e.inputIndex=a}},e.getCurrentInputIndex=function(){return e.inputIndex},e.setToNextBlock=function(e){var t=o.state.inputs,n=t[e+1];if(!n)return void o.core.log("We are reached the end");if(!n.childNodes.length){var r=document.createTextNode("");n.appendChild(r)}o.caret.inputIndex=e+1,o.caret.set(n,0,0),o.content.workingNodeChanged(n)},e.setToBlock=function(e){var t=o.state.inputs,n=t[e];if(n){if(!n.childNodes.length){var r=document.createTextNode("");n.appendChild(r)}o.caret.inputIndex=e,o.caret.set(n,0,0),o.content.workingNodeChanged(n)}},e.setToPreviousBlock=function(e){e=e||0;var t,n,r,i=o.state.inputs,a=i[e-1];return a?(t=o.content.getDeepestTextNodeFromPosition(a,a.childNodes.length),n=t.length,a.childNodes.length||(r=document.createTextNode(""),a.appendChild(r)),o.caret.inputIndex=e-1,o.caret.set(a,a.childNodes.length-1,n),void o.content.workingNodeChanged(i[e-1])):void o.core.log("We are reached first node")},e.position={atStart:function(){var e=window.getSelection(),t=e.anchorOffset,n=e.anchorNode,r=o.content.getFirstLevelBlock(n),i=r.childNodes[0];o.core.isDomNode(n)||(n=n.parentNode);var a=n===i.childNodes[0],s=0===t;return a&&s},atTheEnd:function(){var e=window.getSelection(),t=e.anchorOffset,o=e.anchorNode;return!o||!o.length||t===o.length}},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.errorThrown=function(e,t){o.notifications.send("This action is not available currently",t.type,!1)},e.send=function(e,t,n){var r=o.draw.block("div");r.textContent=e,r.classList.add("ce_notification-item","ce_notification-"+t,"flipInX"),n||(o.nodes.notifications.innerHTML=""),o.nodes.notifications.appendChild(r),window.setTimeout(function(){r.remove()},3e3)},e}({})},function(e,t){"use strict";var o=codex.editor;e.exports=function(e){return e.insertPastedContent=function(e,t){o.content.insertBlock({type:e.type,block:e.render({text:t.innerHTML})})},e.isFirstLevelBlock=function(e){return e.nodeType==o.core.nodeTypes.TAG&&e.classList.contains(o.ui.className.BLOCK_CLASSNAME)},e}({})},function(e,t,o){"use strict";var n=o(18);e.exports=function(e){var t={BASIC:{tags:{p:{},a:{href:!0,target:"_blank",rel:"nofollow"},i:{},b:{},strong:{},em:{},span:{}}}};return e.Config=t,e.init=n,e}({})},function(e,t,o){var n,r;!function(i,a){n=a,r="function"==typeof n?n.call(t,o,t,e):n,!(void 0!==r&&(e.exports=r))}(this,function(){function e(e){var t=e.tags,o=Object.keys(t),n=o.map(function(e){return typeof t[e]}).every(function(e){return"object"===e||"boolean"===e||"function"===e});if(!n)throw new Error("The configuration was invalid");this.config=e}function t(e){return s.indexOf(e.nodeName)!==-1}function o(e){return c.indexOf(e.nodeName)!==-1}function n(e){return document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,null,!1)}function r(e,t,o){return"function"==typeof e.tags[t]?e.tags[t](o):e.tags[t]}function i(e,t){return"undefined"==typeof t||"boolean"==typeof t&&!t}function a(e,t,o){var n=e.name.toLowerCase();return t!==!0&&("function"==typeof t[n]?!t[n](e.value,o):"undefined"==typeof t[n]||(t[n]===!1||"string"==typeof t[n]&&t[n]!==e.value))}var s=["P","LI","TD","TH","DIV","H1","H2","H3","H4","H5","H6","PRE"],c=["A","B","STRONG","I","EM","SUB","SUP","U","STRIKE"];return e.prototype.clean=function(e){var t=document.createElement("div");return t.innerHTML=e,this._sanitize(t),t.innerHTML},e.prototype._sanitize=function(e){var s=n(e),c=s.firstChild();if(c)do if(!c._sanitized)if(c.nodeType!==Node.TEXT_NODE){if(c.nodeType===Node.COMMENT_NODE){e.removeChild(c),this._sanitize(e);break}var l,d=o(c);d&&(l=Array.prototype.some.call(c.childNodes,t));var u=!!e.parentNode,p=t(e)&&t(c)&&u,f=c.nodeName.toLowerCase(),g=r(this.config,f,c),b=d&&l;if(b||i(c,g)||!this.config.keepNestedBlockElements&&p){if("SCRIPT"!==c.nodeName&&"STYLE"!==c.nodeName)for(;c.childNodes.length>0;)e.insertBefore(c.childNodes[0],c);e.removeChild(c),this._sanitize(e);break}for(var h=0;h<c.attributes.length;h+=1){var v=c.attributes[h];a(v,g,c)&&(c.removeAttribute(v.name),h-=1)}this._sanitize(c),c._sanitized=!0}else if(""===c.data.trim()&&(c.previousElementSibling&&t(c.previousElementSibling)||c.nextElementSibling&&t(c.nextElementSibling))){e.removeChild(c),this._sanitize(e);break}while(c=s.nextSibling())},e})}]);
//# sourceMappingURL=codex-editor.js.map