diff --git a/.babelrc b/.babelrc index 3906e7a5..93be4658 100644 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,8 @@ { - "presets": [ + "presets": [ ["@babel/preset-env", { - "modules": "umd" + "modules": "umd", + "useBuiltIns": "entry" }] ], "plugins": [ diff --git a/.eslintrc b/.eslintrc index b159306a..2f369b0c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -85,6 +85,8 @@ "$": true, "_": true, "setTimeout": true, + "process": true, + "__dirname": true, "Map": true } } diff --git a/.gitignore b/.gitignore index 3c8ec3b7..72938961 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Thumbs.db node_modules/* npm-debug.log +yarn-error.log diff --git a/README.md b/README.md index e5a92255..5aeeec37 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ Welcome to testing stage. Please, join a [public Telegram-chat](//t.me/codex_edi - `New` Added `onChange`-callback, fired after any modifications at the Editor. See [documentation](https://github.com/codex-team/codex.editor/blob/master/docs/installation.md#features). - `New` New Inline Tool example — [Marker](https://github.com/codex-editor/marker) - `New` New Inline Tool example — [Code](https://github.com/codex-editor/code) -- `New` New [CodeX Editor PHP](http://github.com/codex-team/codex.editor.backend) — example of server-side implementation with HTML purifying and data validation. -- `Improvements` - Improvements of Toolbar's position calculation. +- `New` New [CodeX Editor PHP](http://github.com/codex-team/codex.editor.backend) — example of server-side implementation with HTML purifying and data validation. +- `Improvements` - Improvements of Toolbar's position calculation. - `Improvements` — Improved zero-configuration initialization. -- and many little improvements. +- and many little improvements. ## Documentation @@ -28,7 +28,7 @@ While we develop the new Documentation Site with all stuff, you can check some a - [How to use](docs/usage.md) - [How to create a Block Tool Plugin](docs/tools.md) - [How to create an Inline Tool Plugin](docs/tools-inline.md) -- [API for Tools](src/components/interfaces/api.ts) +- [API for Tools](docs/api.md) Sorry if we missed something. You can join a [Telegram-chat](//t.me/codex_editor) and ask a question. @@ -38,8 +38,8 @@ Sorry if we missed something. You can join a [Telegram-chat](//t.me/codex_editor ## Basics -CodeX Editor is a Block-Styled editor. Blocks is a structural units, of which the Entry is composed. -For example, `Paragraph`, `Heading`, `Image`, `Video`, `List` are Blocks. Each Block is represented by a Plugin. +CodeX Editor is a Block-Styled editor. Blocks are structural units, of which the Entry is composed. +For example, `Paragraph`, `Heading`, `Image`, `Video`, `List` are Blocks. Each Block is represented by Plugin. We have [many](http://github.com/codex-editor) ready-to-use Plugins and the [simple API](docs/tools.md) for creation new ones. So how to use the Editor after [Installation](docs/installation.md). @@ -50,21 +50,21 @@ So how to use the Editor after [Installation](docs/installation.md).  - + - Select text fragment and apply a style or insert a link from the Inline Toolbar  -- Use «three-dots» button on the right to open Block Settings. From here, you can move and delete a Block +- Use «three-dots» button on the right to open Block Settings. From here, you can move and delete a Block or apply Tool's settings, if it provided. For example, set a Heading level or List style. - + ## Shortcuts -We really appreciate shortcuts. So there are few presets. +We really appreciate shortcuts. So there are few presets. -Action | Shortcut | Restrictions +Shortcut | Action | Restrictions -- | -- | -- `TAB` | Show/leaf a Toolbox. | On empty block `SHIFT+TAB` | Leaf back a Toolbox. | While Toolbox is opened @@ -72,7 +72,7 @@ Action | Shortcut | Restrictions `CMD+B` | Bold style | On selection `CMD+I` | Italic style | On selection `CMD+K` | Insert a link | On selection - + Also we support shortcuts on the all type of Tools. Specify a shortcut with the Tools configuration. For example: ```js @@ -104,7 +104,7 @@ There are few steps to run CodeX Editor on your site. ## Load Editor's core -Firstly you need to get CodeX Editor itself. It is a [minified script](build/codex-editor.js) with minimal available +Firstly you need to get CodeX Editor itself. It is a [minified script](build/codex-editor.js) with Editor's core and some default must-have tools. Choose the most usable method of getting Editor for you. @@ -120,7 +120,7 @@ Install the package via NPM or Yarn npm i codex.editor --save-dev ``` -Include module at your application +Include module in your application ```javascript const CodexEditor = require('codex.editor'); @@ -164,7 +164,7 @@ Check [CodeX Editor's community](https://github.com/codex-editor) to see more re ## Create Editor instance -Create an instance of CodeX Editor and pass [Configuration Object](src/components/interfaces/editor-config.ts) with `holderId` and tools list. +Create an instance of CodeX Editor and pass [Configuration Object](types/configs/editor-config.d.ts) with `holderId` and tools list. ```html
@@ -217,7 +217,7 @@ editor.saver.save() .then((savedData) => { console.log(savedData); }); -``` +``` ## Example diff --git a/build/codex-editor.js b/build/codex-editor.js index 6c898389..527cf7a6 100644 --- a/build/codex-editor.js +++ b/build/codex-editor.js @@ -2,11 +2,15 @@ /*!**************************!*\ !*** ./build/sprite.svg ***! \**************************/ -/*! no static exports found */function(e,o){e.exports='\n'},"./node_modules/@babel/polyfill/lib/index.js": -/*!***************************************************!*\ - !*** ./node_modules/@babel/polyfill/lib/index.js ***! - \***************************************************/ -/*! no static exports found */function(e,o,t){"use strict";(function(e){t(/*! core-js/es6 */"./node_modules/core-js/es6/index.js"),t(/*! core-js/fn/array/includes */"./node_modules/core-js/fn/array/includes.js"),t(/*! core-js/fn/string/pad-start */"./node_modules/core-js/fn/string/pad-start.js"),t(/*! core-js/fn/string/pad-end */"./node_modules/core-js/fn/string/pad-end.js"),t(/*! core-js/fn/symbol/async-iterator */"./node_modules/core-js/fn/symbol/async-iterator.js"),t(/*! core-js/fn/object/get-own-property-descriptors */"./node_modules/core-js/fn/object/get-own-property-descriptors.js"),t(/*! core-js/fn/object/values */"./node_modules/core-js/fn/object/values.js"),t(/*! core-js/fn/object/entries */"./node_modules/core-js/fn/object/entries.js"),t(/*! core-js/fn/promise/finally */"./node_modules/core-js/fn/promise/finally.js"),t(/*! core-js/web */"./node_modules/core-js/web/index.js"),t(/*! regenerator-runtime/runtime */"./node_modules/regenerator-runtime/runtime.js"),e._babelPolyfill&&"undefined"!=typeof console&&console.warn&&console.warn("@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended and may have consequences if different versions of the polyfills are applied sequentially. If you do need to load the polyfill more than once, use @babel/polyfill/noConflict instead to bypass the warning."),e._babelPolyfill=!0}).call(this,t(/*! ./../../../webpack/buildin/global.js */"./node_modules/webpack/buildin/global.js"))},"./node_modules/@babel/register/lib/browser.js": +/*! no static exports found */function(e,o){e.exports='\n'},"./node_modules/@babel/polyfill/lib/noConflict.js": +/*!********************************************************!*\ + !*** ./node_modules/@babel/polyfill/lib/noConflict.js ***! + \********************************************************/ +/*! no static exports found */function(e,o,t){"use strict";t(/*! core-js/es6 */"./node_modules/core-js/es6/index.js"),t(/*! core-js/fn/array/includes */"./node_modules/core-js/fn/array/includes.js"),t(/*! core-js/fn/string/pad-start */"./node_modules/core-js/fn/string/pad-start.js"),t(/*! core-js/fn/string/pad-end */"./node_modules/core-js/fn/string/pad-end.js"),t(/*! core-js/fn/symbol/async-iterator */"./node_modules/core-js/fn/symbol/async-iterator.js"),t(/*! core-js/fn/object/get-own-property-descriptors */"./node_modules/core-js/fn/object/get-own-property-descriptors.js"),t(/*! core-js/fn/object/values */"./node_modules/core-js/fn/object/values.js"),t(/*! core-js/fn/object/entries */"./node_modules/core-js/fn/object/entries.js"),t(/*! core-js/fn/promise/finally */"./node_modules/core-js/fn/promise/finally.js"),t(/*! core-js/web */"./node_modules/core-js/web/index.js"),t(/*! regenerator-runtime/runtime */"./node_modules/regenerator-runtime/runtime.js")},"./node_modules/@babel/polyfill/noConflict.js": +/*!****************************************************!*\ + !*** ./node_modules/@babel/polyfill/noConflict.js ***! + \****************************************************/ +/*! no static exports found */function(e,o,t){t(/*! ./lib/noConflict */"./node_modules/@babel/polyfill/lib/noConflict.js")},"./node_modules/@babel/register/lib/browser.js": /*!*****************************************************!*\ !*** ./node_modules/@babel/register/lib/browser.js ***! \*****************************************************/ @@ -94,7 +98,7 @@ /*!*********************************************************************************!*\ !*** ./node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js ***! \*********************************************************************************/ -/*! no static exports found */function(e,o){!function(o){"use strict";var t,n=Object.prototype,s=n.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",l=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag",d="object"==typeof e,c=o.regeneratorRuntime;if(c)d&&(e.exports=c);else{(c=o.regeneratorRuntime=d?e.exports:{}).wrap=g;var a="suspendedStart",f="suspendedYield",m="executing",p="completed",h={},j={};j[i]=function(){return this};var _=Object.getPrototypeOf,v=_&&_(_(N([])));v&&v!==n&&s.call(v,i)&&(j=v);var b=w.prototype=k.prototype=Object.create(j);x.prototype=b.constructor=w,w.constructor=x,w[u]=x.displayName="GeneratorFunction",c.isGeneratorFunction=function(e){var o="function"==typeof e&&e.constructor;return!!o&&(o===x||"GeneratorFunction"===(o.displayName||o.name))},c.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,u in e||(e[u]="GeneratorFunction")),e.prototype=Object.create(b),e},c.awrap=function(e){return{__await:e}},E(S.prototype),S.prototype[l]=function(){return this},c.AsyncIterator=S,c.async=function(e,o,t,n){var s=new S(g(e,o,t,n));return c.isGeneratorFunction(o)?s:s.next().then(function(e){return e.done?e.value:s.next()})},E(b),b[u]="Generator",b[i]=function(){return this},b.toString=function(){return"[object Generator]"},c.keys=function(e){var o=[];for(var t in e)o.push(t);return o.reverse(),function t(){for(;o.length;){var n=o.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},c.values=N,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(B),!e)for(var o in this)"t"===o.charAt(0)&&s.call(this,o)&&!isNaN(+o.slice(1))&&(this[o]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var o=this;function n(n,s){return l.type="throw",l.arg=e,o.next=n,s&&(o.method="next",o.arg=t),!!s}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],l=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=s.call(i,"catchLoc"),d=s.call(i,"finallyLoc");if(u&&d){if(this.prev"+(i.trim()?i:s)+"
"),l=Object.keys(this.toolsTags).reduce(function(e,o){return e[o.toLowerCase()]=!0,e},{}),d=Object.assign({},l,n.getAllInlineToolsConfig()),(c=n.clean(i,d)).trim()&&c.trim()!==s&&r.isHTMLString(c)){e.next=17;break}return e.next=15,this.processText(s);case 15:e.next=19;break;case 17:return e.next=19,this.processText(c,!0);case 19:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"setCallback",value:function(){var e=this.Editor,o=e.Listeners,t=e.UI;o.on(t.nodes.redactor,"paste",this.handlePasteEvent)}},{key:"processTools",value:function(){var e=this.Editor.Tools.blockTools;Object.entries(e).forEach(this.processTool)}},{key:"getTagsConfig",value:function(e,o){var t=this;if(this.config.initialBlock!==e||o.handler||s.log("«".concat(e,"» Tool must provide a paste handler."),"warn"),o.handler)if("function"==typeof o.handler){var n=o.tags||[];n.forEach(function(n){t.toolsTags.hasOwnProperty(n)?s.log("Paste handler for «".concat(e,"» Tool on «").concat(n,"» tag is skipped ")+"because it is already used by «".concat(t.toolsTags[n].tool,"» Tool."),"warn"):t.toolsTags[n.toUpperCase()]={handler:o.handler,tool:e}}),this.tagsByTool[e]=n.map(function(e){return e.toUpperCase()})}else s.log("Paste handler for «".concat(e,"» Tool should be a function."),"warn")}},{key:"getFilesConfig",value:function(e,o){var t=o.fileHandler,n=o.files,r=void 0===n?{}:n,i=r.extensions,l=r.mimeTypes;t&&(i||l)&&("function"==typeof t?(i&&!Array.isArray(i)&&(s.log("«extensions» property of the onDrop config for «".concat(e,"» Tool should be an array")),i=[]),l&&!Array.isArray(l)&&(s.log("«mimeTypes» property of the onDrop config for «".concat(e,"» Tool should be an array")),l=[]),l&&(l=l.filter(function(o){return!!s.isValidMimeType(o)||(s.log("MIME type value «".concat(o,"» for the «").concat(e,"» Tool is not a valid MIME type"),"warn"),!1)})),this.toolsFiles[e]={extensions:i||[],mimeTypes:l||[],handler:t}):s.log("Drop handler for «".concat(e,"» Tool should be a function.")))}},{key:"getPatternsConfig",value:function(e,o){var t=this;o.patternHandler&&!s.isEmpty(o.patterns)&&("function"==typeof o.patternHandler?Object.entries(o.patterns).forEach(function(n){var r=(0,c.default)(n,2),i=r[0],l=r[1];l instanceof RegExp||s.log("Pattern ".concat(l," for «").concat(e,"» Tool is skipped because it should be a Regexp instance."),"warn"),t.toolsPatterns.push({key:i,pattern:l,handler:o.patternHandler,tool:e})}):s.log("Pattern parser for «".concat(e,"» Tool should be a function."),"warn"))}},{key:"isNativeBehaviour",value:function(e){var o=this.Editor.BlockManager;if(r.isNativeInput(e))return!0;var t=o.getBlock(e);return!t}},{key:"processFiles",value:function(){var e=(0,d.default)(u.default.mark(function e(o){var t,n=this;return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.Editor.BlockManager,e.next=3,Promise.all(Array.from(o).map(function(e){return n.processFile(e)}));case 3:e.sent.filter(function(e){return!!e}).forEach(function(e,o){0===o&&t.currentBlock&&t.currentBlock.isEmpty?t.replace(e.type,e.data):t.insert(e.type,e.data)});case 6:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"processFile",value:function(){var e=(0,d.default)(u.default.mark(function e(o){var t,n,r,i,l,d;return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!==o.kind){e.next=2;break}return e.abrupt("return");case 2:if(t=o.getAsFile(),n=s.getFileExtension(t),r=Object.entries(this.toolsFiles).find(function(e){var o=(0,c.default)(e,2),s=(o[0],o[1]),r=s.mimeTypes,i=s.extensions,l=t.type.split("/"),u=(0,c.default)(l,2),d=u[0],a=u[1],f=i.find(function(e){return e.toLowerCase()===n.toLowerCase()}),m=r.find(function(e){var o=e.split("/"),t=(0,c.default)(o,2),n=t[0],s=t[1];return n===d&&(s===a||"*"===s)});return!!f||!!m})){e.next=7;break}return e.abrupt("return");case 7:return i=(0,c.default)(r,2),l=i[0],d=i[1].handler,e.next=10,d(t);case 10:return e.t0=e.sent,e.t1=l,e.abrupt("return",{data:e.t0,type:e.t1});case 13:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"processText",value:function(){var e=(0,d.default)(u.default.mark(function e(o){var t,n,s,r,i,l=this,c=arguments;return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>1&&void 0!==c[1]&&c[1],n=this.Editor,s=n.Caret,r=n.BlockManager,(i=t?this.processHTML(o):this.processPlain(o)).length){e.next=5;break}return e.abrupt("return");case 5:if(1!==i.length||i[0].isBlock){e.next=8;break}return this.processSingleBlock(i.pop()),e.abrupt("return");case 8:return v.default.isAtEditor&&!s.isAtEnd&&v.default.isCollapsed&&this.splitBlock(),e.next=11,Promise.all(i.map(function(){var e=(0,d.default)(u.default.mark(function e(o,t){return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l.insertBlock(o,0===t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}));return function(o,t){return e.apply(this,arguments)}}()));case 11:s.setToBlock(r.currentBlock,_.default.positions.END);case 12:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"processHTML",value:function(e){var o=this,t=this.Editor,n=t.Tools,s=t.Sanitizer,i=this.config.initialBlock,l=r.make("DIV");l.innerHTML=e;var u=this.getNodes(l);return u.map(function(e){var t,l=i,u=!1;switch(e.nodeType){case Node.DOCUMENT_FRAGMENT_NODE:(t=r.make("div")).appendChild(e);break;case Node.ELEMENT_NODE:t=e,u=!0,o.toolsTags[t.tagName]&&(l=o.toolsTags[t.tagName].tool)}var d=n.blockTools[l].onPaste,c=d.handler,a=d.tags,f=a.reduce(function(e,o){return e[o.toLowerCase()]={},e},{}),m=Object.assign({},f,s.getInlineToolsConfig(l));return t.innerHTML=s.clean(t.innerHTML,m),{content:t,isBlock:u,handler:c,tool:l}}).filter(function(e){return!r.isNodeEmpty(e.content)||r.isSingleTag(e.content)})}},{key:"processPlain",value:function(e){var o=this.config.initialBlock,t=this.Editor.Tools;if(!e)return[];var n=o,s=t.blockTools[n].onPaste.handler;return e.split(/\r?\n/).filter(function(e){return e.trim()}).map(function(e){var o=r.make("div");return o.innerHTML=e,{content:o,tool:n,isBlock:!1,handler:s}})}},{key:"processSingleBlock",value:function(){var e=(0,d.default)(u.default.mark(function e(t){var n,r,i,l,d,c,a,f,m,p,h;return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.config.initialBlock,r=this.Editor,i=r.BlockManager,l=r.Caret,d=r.Sanitizer,c=t.content,!((a=t.tool)===n&&c.textContent.length"+(i.trim()?i:s)+"
"),l=Object.keys(this.toolsTags).reduce(function(e,o){return e[o.toLowerCase()]=!0,e},{}),u=Object.assign({},l,n.getAllInlineToolsConfig()),(d=n.clean(i,u)).trim()&&d.trim()!==s&&j.default.isHTMLString(d)){e.next=17;break}return e.next=15,this.processText(s);case 15:e.next=19;break;case 17:return e.next=19,this.processText(d,!0);case 19:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"setCallback",value:function(){var e=this.Editor,o=e.Listeners,t=e.UI;o.on(t.nodes.redactor,"paste",this.handlePasteEvent)}},{key:"processTools",value:function(){var e=this.Editor.Tools.blockTools;Object.entries(e).forEach(this.processTool)}},{key:"getTagsConfig",value:function(e,o){var t=this;if(this.config.initialBlock!==e||o.handler||_.default.log("«".concat(e,"» Tool must provide a paste handler."),"warn"),o.handler)if("function"==typeof o.handler){var n=o.tags||[];n.forEach(function(n){t.toolsTags.hasOwnProperty(n)?_.default.log("Paste handler for «".concat(e,"» Tool on «").concat(n,"» tag is skipped ")+"because it is already used by «".concat(t.toolsTags[n].tool,"» Tool."),"warn"):t.toolsTags[n.toUpperCase()]={handler:o.handler,tool:e}}),this.tagsByTool[e]=n.map(function(e){return e.toUpperCase()})}else _.default.log("Paste handler for «".concat(e,"» Tool should be a function."),"warn")}},{key:"getFilesConfig",value:function(e,o){var t=o.fileHandler,n=o.files,s=void 0===n?{}:n,r=s.extensions,i=s.mimeTypes;t&&(r||i)&&("function"==typeof t?(r&&!Array.isArray(r)&&(_.default.log("«extensions» property of the onDrop config for «".concat(e,"» Tool should be an array")),r=[]),i&&!Array.isArray(i)&&(_.default.log("«mimeTypes» property of the onDrop config for «".concat(e,"» Tool should be an array")),i=[]),i&&(i=i.filter(function(o){return!!_.default.isValidMimeType(o)||(_.default.log("MIME type value «".concat(o,"» for the «").concat(e,"» Tool is not a valid MIME type"),"warn"),!1)})),this.toolsFiles[e]={extensions:r||[],mimeTypes:i||[],handler:t}):_.default.log("Drop handler for «".concat(e,"» Tool should be a function.")))}},{key:"getPatternsConfig",value:function(e,o){var t=this;o.patternHandler&&!_.default.isEmpty(o.patterns)&&("function"==typeof o.patternHandler?Object.entries(o.patterns).forEach(function(n){var s=(0,l.default)(n,2),r=s[0],i=s[1];i instanceof RegExp||_.default.log("Pattern ".concat(i," for «").concat(e,"» Tool is skipped because it should be a Regexp instance."),"warn"),t.toolsPatterns.push({key:r,pattern:i,handler:o.patternHandler,tool:e})}):_.default.log("Pattern parser for «".concat(e,"» Tool should be a function."),"warn"))}},{key:"isNativeBehaviour",value:function(e){var o=this.Editor.BlockManager;if(j.default.isNativeInput(e))return!0;var t=o.getBlock(e);return!t}},{key:"processFiles",value:function(){var e=(0,i.default)(r.default.mark(function e(o){var t,n=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.Editor.BlockManager,e.next=3,Promise.all(Array.from(o).map(function(e){return n.processFile(e)}));case 3:e.sent.filter(function(e){return!!e}).forEach(function(e,o){0===o&&t.currentBlock&&t.currentBlock.isEmpty?t.replace(e.type,e.data):t.insert(e.type,e.data)});case 6:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"processFile",value:function(){var e=(0,i.default)(r.default.mark(function e(o){var t,n,s,i,u,d;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!==o.kind){e.next=2;break}return e.abrupt("return");case 2:if(t=o.getAsFile(),n=_.default.getFileExtension(t),s=Object.entries(this.toolsFiles).find(function(e){var o=(0,l.default)(e,2),s=(o[0],o[1]),r=s.mimeTypes,i=s.extensions,u=t.type.split("/"),d=(0,l.default)(u,2),a=d[0],c=d[1],f=i.find(function(e){return e.toLowerCase()===n.toLowerCase()}),m=r.find(function(e){var o=e.split("/"),t=(0,l.default)(o,2),n=t[0],s=t[1];return n===a&&(s===c||"*"===s)});return!!f||!!m})){e.next=7;break}return e.abrupt("return");case 7:return i=(0,l.default)(s,2),u=i[0],d=i[1].handler,e.next=10,d(t);case 10:return e.t0=e.sent,e.t1=u,e.abrupt("return",{data:e.t0,type:e.t1});case 13:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"processText",value:function(){var e=(0,i.default)(r.default.mark(function e(o){var t,n,s,l,u,d=this,a=arguments;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>1&&void 0!==a[1]&&a[1],n=this.Editor,s=n.Caret,l=n.BlockManager,(u=t?this.processHTML(o):this.processPlain(o)).length){e.next=5;break}return e.abrupt("return");case 5:if(1!==u.length||u[0].isBlock){e.next=8;break}return this.processSingleBlock(u.pop()),e.abrupt("return");case 8:return p.default.isAtEditor&&!s.isAtEnd&&p.default.isCollapsed&&this.splitBlock(),e.next=11,Promise.all(u.map(function(){var e=(0,i.default)(r.default.mark(function e(o,t){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.insertBlock(o,0===t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},e,this)}));return function(o,t){return e.apply(this,arguments)}}()));case 11:s.setToBlock(l.currentBlock,m.default.positions.END);case 12:case"end":return e.stop()}},e,this)}));return function(o){return e.apply(this,arguments)}}()},{key:"processHTML",value:function(e){var o=this,t=this.Editor,n=t.Tools,s=t.Sanitizer,r=this.config.initialBlock,i=j.default.make("DIV");i.innerHTML=e;var l=this.getNodes(i);return l.map(function(e){var t,i=r,l=!1;switch(e.nodeType){case Node.DOCUMENT_FRAGMENT_NODE:(t=j.default.make("div")).appendChild(e);break;case Node.ELEMENT_NODE:t=e,l=!0,o.toolsTags[t.tagName]&&(i=o.toolsTags[t.tagName].tool)}var u=n.blockTools[i].onPaste,d=u.handler,a=u.tags,c=a.reduce(function(e,o){return e[o.toLowerCase()]={},e},{}),f=Object.assign({},c,s.getInlineToolsConfig(i));return t.innerHTML=s.clean(t.innerHTML,f),{content:t,isBlock:l,handler:d,tool:i}}).filter(function(e){return!j.default.isNodeEmpty(e.content)||j.default.isSingleTag(e.content)})}},{key:"processPlain",value:function(e){var o=this.config.initialBlock,t=this.Editor.Tools;if(!e)return[];var n=o,s=t.blockTools[n].onPaste.handler;return e.split(/\r?\n/).filter(function(e){return e.trim()}).map(function(e){var o=j.default.make("div");return o.innerHTML=e,{content:o,tool:n,isBlock:!1,handler:s}})}},{key:"processSingleBlock",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n,s,i,l,u,d,a,c,f,p,h;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.config.initialBlock,s=this.Editor,i=s.BlockManager,l=s.Caret,u=s.Sanitizer,d=t.content,!((a=t.tool)===n&&d.textContent.length...); if\n // they are, we want to unwrap the inner block element.\n var isNotTopContainer = !! parentNode.parentNode;\n var isNestedBlockElement =\n isBlockElement(parentNode) &&\n isBlockElement(node) &&\n isNotTopContainer;\n\n var nodeName = node.nodeName.toLowerCase();\n\n var allowedAttrs = getAllowedAttrs(this.config, nodeName, node);\n\n var isInvalid = isInline && containsBlockElement;\n\n // Drop tag entirely according to the whitelist *and* if the markup\n // is invalid.\n if (isInvalid || shouldRejectNode(node, allowedAttrs)\n || (!this.config.keepNestedBlockElements && isNestedBlockElement)) {\n // Do not keep the inner text of SCRIPT/STYLE elements.\n if (! (node.nodeName === 'SCRIPT' || node.nodeName === 'STYLE')) {\n while (node.childNodes.length > 0) {\n parentNode.insertBefore(node.childNodes[0], node);\n }\n }\n parentNode.removeChild(node);\n\n this._sanitize(parentNode);\n break;\n }\n\n // Sanitize attributes\n for (var a = 0; a < node.attributes.length; a += 1) {\n var attr = node.attributes[a];\n\n if (shouldRejectAttr(attr, allowedAttrs, node)) {\n node.removeAttribute(attr.name);\n // Shift the array to continue looping.\n a = a - 1;\n }\n }\n\n // Sanitize children\n this._sanitize(node);\n\n // Mark node as sanitized so it's ignored in future runs\n node._sanitized = true;\n } while ((node = treeWalker.nextSibling()));\n };\n\n function createTreeWalker(node) {\n return document.createTreeWalker(node,\n NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT,\n null, false);\n }\n\n function getAllowedAttrs(config, nodeName, node){\n if (typeof config.tags[nodeName] === 'function') {\n return config.tags[nodeName](node);\n } else {\n return config.tags[nodeName];\n }\n }\n\n function shouldRejectNode(node, allowedAttrs){\n if (typeof allowedAttrs === 'undefined') {\n return true;\n } else if (typeof allowedAttrs === 'boolean') {\n return !allowedAttrs;\n }\n\n return false;\n }\n\n function shouldRejectAttr(attr, allowedAttrs, node){\n var attrName = attr.name.toLowerCase();\n\n if (allowedAttrs === true){\n return false;\n } else if (typeof allowedAttrs[attrName] === 'function'){\n return !allowedAttrs[attrName](attr.value, node);\n } else if (typeof allowedAttrs[attrName] === 'undefined'){\n return true;\n } else if (allowedAttrs[attrName] === false) {\n return true;\n } else if (typeof allowedAttrs[attrName] === 'string') {\n return (allowedAttrs[attrName] !== attr.value);\n }\n\n return false;\n }\n\n return HTMLJanitor;\n\n}));\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n!(function(global) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n runtime.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration. If the Promise is rejected, however, the\n // result for this iteration will be rejected with the same\n // reason. Note that rejections of yielded Promises are not\n // thrown back into the generator function, as is the case\n // when an awaited Promise is rejected. This difference in\n // behavior between yield and await is important, because it\n // allows the consumer to decide what to do with the yielded\n // rejection (swallow it and continue, manually .throw it back\n // into the generator, abandon iteration, whatever). With\n // await, by contrast, there is no opportunity to examine the\n // rejection reason outside the generator function, so the\n // only option is to throw it from the await expression, and\n // let the generator function handle the exception.\n result.value = unwrapped;\n resolve(result);\n }, reject);\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n runtime.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n if (delegate.iterator.return) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n})(\n // In sloppy mode, unbound `this` refers to the global object, fallback to\n // Function constructor if we're in global strict mode. That is sadly a form\n // of indirect eval which violates Content Security Policy.\n (function() { return this })() || Function(\"return this\")()\n);\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","'use strict';\n\n/**\n * Apply polyfills\n */\nimport '@babel/register';\nif (!window || !window._babelPolyfill) require('@babel/polyfill');\nimport 'components/polyfills';\nimport Core from './components/core';\n\n/**\n * Codex Editor\n *\n * Short Description (눈_눈;)\n * @version 2.0\n *\n * @author CodeX-Team tag that holds clean HTML\n */\n const cleanHTML = Sanitizer.clean(block.holder.innerHTML, this.sanitizerConfig);\n const fragment = $.make('p');\n\n fragment.innerHTML = cleanHTML;\n fakeClipboard.appendChild(fragment);\n });\n\n _.copyTextToClipboard(fakeClipboard.innerHTML);\n }\n\n /**\n * Select All Blocks\n * Each Block has selected setter that makes Block copyable\n */\n private selectAllBlocks() {\n const { BlockManager } = this.Editor;\n\n BlockManager.blocks.forEach( (block) => block.selected = true);\n }\n\n /**\n * select Block\n * @param {number?} index - Block index according to the BlockManager's indexes\n */\n private selectBlockByIndex(index?) {\n const { BlockManager } = this.Editor;\n\n /**\n * Remove previous focused Block's state\n */\n BlockManager.clearFocused();\n\n let block;\n\n if (isNaN(index)) {\n block = BlockManager.currentBlock;\n } else {\n block = BlockManager.getBlockByIndex(index);\n }\n\n /** Save selection */\n this.selection.save();\n SelectionUtils.get()\n .removeAllRanges();\n\n block.selected = true;\n }\n\n /**\n * Sanitizer Config\n * @return {SanitizerConfig}\n */\n private get sanitizerConfig() {\n return {\n p: {},\n h1: {},\n h2: {},\n h3: {},\n h4: {},\n h5: {},\n h6: {},\n ol: {},\n ul: {},\n li: {},\n br: true,\n img: {\n src: true,\n width: true,\n height: true,\n },\n a: {\n href: true,\n },\n b: {},\n i: {},\n u: {},\n };\n }\n}\n","/**\n * @class Caret\n * @classdesc Contains methods for working Caret\n *\n * Uses Range methods to manipulate with caret\n *\n * @module Caret\n *\n * @version 2.0.0\n */\n\nimport Selection from '../selection';\n\n/**\n * @typedef {Caret} Caret\n */\nexport default class Caret extends Module {\n /**\n * @constructor\n */\n constructor({config}) {\n super({config});\n }\n\n /**\n * Elements styles that can be useful for Caret Module\n */\n static get CSS() {\n return {\n shadowCaret: 'cdx-shadow-caret'\n };\n };\n\n /**\n * Allowed caret positions in input\n *\n * @static\n * @returns {{START: string, END: string, DEFAULT: string}}\n */\n static get positions() {\n return {\n START: 'start',\n END: 'end',\n DEFAULT: 'default'\n };\n }\n\n /**\n * Method gets Block instance and puts caret to the text node with offset\n * There two ways that method applies caret position:\n * - first found text node: sets at the beginning, but you can pass an offset\n * - last found text node: sets at the end of the node. Also, you can customize the behaviour\n *\n * @param {Block} block - Block class\n * @param {String} position - position where to set caret. If default - leave default behaviour and apply offset if it's passed\n * @param {Number} offset - caret offset regarding to the text node\n */\n setToBlock(block, position = Caret.positions.DEFAULT, offset = 0) {\n const {BlockManager} = this.Editor;\n let element;\n\n switch(position) {\n case Caret.positions.START:\n element = block.firstInput;\n break;\n case Caret.positions.END:\n element = block.lastInput;\n break;\n default:\n element = block.currentInput;\n }\n\n if (!element) {\n return;\n }\n\n const nodeToSet = $.getDeepestNode(element, position === Caret.positions.END);\n const contentLength = $.getContentLength(nodeToSet);\n\n switch (true) {\n case position === Caret.positions.START:\n offset = 0;\n break;\n case position === Caret.positions.END:\n case offset > contentLength:\n offset = contentLength;\n break;\n }\n\n /**\n * @todo try to fix via Promises or use querySelectorAll to not to use timeout\n */\n _.delay( () => {\n this.set(nodeToSet, offset);\n }, 20)();\n\n BlockManager.setCurrentBlockByChildNode(block.holder);\n BlockManager.currentBlock.currentInput = element;\n }\n\n /**\n * Set caret to the current input of current Block.\n *\n * @param {HTMLElement} input - input where caret should be set\n * @param {String} position - position of the caret. If default - leave default behaviour and apply offset if it's passed\n * @param {number} offset - caret offset regarding to the text node\n */\n setToInput(input, position = Caret.positions.DEFAULT, offset = 0) {\n const {currentBlock} = this.Editor.BlockManager;\n const nodeToSet = $.getDeepestNode(input);\n\n switch (position) {\n case Caret.positions.START:\n this.set(nodeToSet, 0);\n break;\n\n case Caret.positions.END:\n const contentLength = $.getContentLength(nodeToSet);\n\n this.set(nodeToSet, contentLength);\n break;\n\n default:\n if (offset) {\n this.set(nodeToSet, offset);\n }\n }\n\n currentBlock.currentInput = input;\n }\n\n /**\n * Creates Document Range and sets caret to the element with offset\n * @param {Element} element - target node.\n * @param {Number} offset - offset\n */\n set( element, offset = 0) {\n const range = document.createRange(),\n selection = Selection.get();\n\n /** if found deepest node is native input */\n if ($.isNativeInput(element)) {\n element.focus();\n element.selectionStart = element.selectionEnd = offset;\n return;\n }\n\n range.setStart(element, offset);\n range.setEnd(element, offset);\n\n selection.removeAllRanges();\n selection.addRange(range);\n\n\n /** If new cursor position is not visible, scroll to it */\n const {top, bottom} = range.getBoundingClientRect();\n const {innerHeight} = window;\n\n if (top < 0) window.scrollBy(0, top);\n if (bottom > innerHeight) window.scrollBy(0, bottom - innerHeight);\n };\n\n /**\n * Set Caret to the last Block\n * If last block is not empty, append another empty block\n */\n setToTheLastBlock() {\n let lastBlock = this.Editor.BlockManager.lastBlock;\n\n if (!lastBlock) return;\n\n /**\n * If last block is empty and it is an initialBlock, set to that.\n * Otherwise, append new empty block and set to that\n */\n if (lastBlock.isEmpty) {\n this.setToBlock(lastBlock);\n } else {\n const newBlock = this.Editor.BlockManager.insertAtEnd();\n\n this.setToBlock(newBlock);\n }\n }\n\n /**\n * Extract content fragment of current Block from Caret position to the end of the Block\n */\n extractFragmentFromCaretPosition() {\n let selection = Selection.get();\n\n if (selection.rangeCount) {\n const selectRange = selection.getRangeAt(0);\n const currentBlockInput = this.Editor.BlockManager.currentBlock.currentInput;\n\n\n selectRange.deleteContents();\n\n if (currentBlockInput) {\n let range = selectRange.cloneRange(true);\n\n range.selectNodeContents(currentBlockInput);\n range.setStart(selectRange.endContainer, selectRange.endOffset);\n return range.extractContents();\n }\n }\n }\n\n /**\n * Get all first-level (first child of [contenteditabel]) siblings from passed node\n * Then you can check it for emptiness\n *\n * @example\n * <-- first (and deepest) node is \n * |adaddad <-- anchor node\n * <-- first (and deepest) node is \n * ' + ( htmlData.trim() ? htmlData : plainData ) + ' ...); if\n // they are, we want to unwrap the inner block element.\n var isNotTopContainer = !! parentNode.parentNode;\n var isNestedBlockElement =\n isBlockElement(parentNode) &&\n isBlockElement(node) &&\n isNotTopContainer;\n\n var nodeName = node.nodeName.toLowerCase();\n\n var allowedAttrs = getAllowedAttrs(this.config, nodeName, node);\n\n var isInvalid = isInline && containsBlockElement;\n\n // Drop tag entirely according to the whitelist *and* if the markup\n // is invalid.\n if (isInvalid || shouldRejectNode(node, allowedAttrs)\n || (!this.config.keepNestedBlockElements && isNestedBlockElement)) {\n // Do not keep the inner text of SCRIPT/STYLE elements.\n if (! (node.nodeName === 'SCRIPT' || node.nodeName === 'STYLE')) {\n while (node.childNodes.length > 0) {\n parentNode.insertBefore(node.childNodes[0], node);\n }\n }\n parentNode.removeChild(node);\n\n this._sanitize(document, parentNode);\n break;\n }\n\n // Sanitize attributes\n for (var a = 0; a < node.attributes.length; a += 1) {\n var attr = node.attributes[a];\n\n if (shouldRejectAttr(attr, allowedAttrs, node)) {\n node.removeAttribute(attr.name);\n // Shift the array to continue looping.\n a = a - 1;\n }\n }\n\n // Sanitize children\n this._sanitize(document, node);\n\n } while ((node = treeWalker.nextSibling()));\n };\n\n function createTreeWalker(document, node) {\n return document.createTreeWalker(node,\n NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT,\n null, false);\n }\n\n function getAllowedAttrs(config, nodeName, node){\n if (typeof config.tags[nodeName] === 'function') {\n return config.tags[nodeName](node);\n } else {\n return config.tags[nodeName];\n }\n }\n\n function shouldRejectNode(node, allowedAttrs){\n if (typeof allowedAttrs === 'undefined') {\n return true;\n } else if (typeof allowedAttrs === 'boolean') {\n return !allowedAttrs;\n }\n\n return false;\n }\n\n function shouldRejectAttr(attr, allowedAttrs, node){\n var attrName = attr.name.toLowerCase();\n\n if (allowedAttrs === true){\n return false;\n } else if (typeof allowedAttrs[attrName] === 'function'){\n return !allowedAttrs[attrName](attr.value, node);\n } else if (typeof allowedAttrs[attrName] === 'undefined'){\n return true;\n } else if (allowedAttrs[attrName] === false) {\n return true;\n } else if (typeof allowedAttrs[attrName] === 'string') {\n return (allowedAttrs[attrName] !== attr.value);\n }\n\n return false;\n }\n\n return HTMLJanitor;\n\n}));\n","/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n!(function(global) {\n \"use strict\";\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n var inModule = typeof module === \"object\";\n var runtime = global.regeneratorRuntime;\n if (runtime) {\n if (inModule) {\n // If regeneratorRuntime is defined globally and we're in a module,\n // make the exports object identical to regeneratorRuntime.\n module.exports = runtime;\n }\n // Don't bother evaluating the rest of this file if the runtime was\n // already defined globally.\n return;\n }\n\n // Define the runtime globally (as expected by generated code) as either\n // module.exports (if we're in a module) or a new, empty object.\n runtime = global.regeneratorRuntime = inModule ? module.exports : {};\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n runtime.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunctionPrototype[toStringTagSymbol] =\n GeneratorFunction.displayName = \"GeneratorFunction\";\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n prototype[method] = function(arg) {\n return this._invoke(method, arg);\n };\n });\n }\n\n runtime.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n runtime.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n if (!(toStringTagSymbol in genFun)) {\n genFun[toStringTagSymbol] = \"GeneratorFunction\";\n }\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n runtime.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return Promise.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return Promise.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration. If the Promise is rejected, however, the\n // result for this iteration will be rejected with the same\n // reason. Note that rejections of yielded Promises are not\n // thrown back into the generator function, as is the case\n // when an awaited Promise is rejected. This difference in\n // behavior between yield and await is important, because it\n // allows the consumer to decide what to do with the yielded\n // rejection (swallow it and continue, manually .throw it back\n // into the generator, abandon iteration, whatever). With\n // await, by contrast, there is no opportunity to examine the\n // rejection reason outside the generator function, so the\n // only option is to throw it from the await expression, and\n // let the generator function handle the exception.\n result.value = unwrapped;\n resolve(result);\n }, reject);\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new Promise(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n runtime.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList)\n );\n\n return runtime.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n if (delegate.iterator.return) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n Gp[toStringTagSymbol] = \"Generator\";\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n runtime.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n runtime.values = values;\n\n function doneResult() {\n return { value: undefined, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined;\n }\n\n return ContinueSentinel;\n }\n };\n})(\n // In sloppy mode, unbound `this` refers to the global object, fallback to\n // Function constructor if we're in global strict mode. That is sadly a form\n // of indirect eval which violates Content Security Policy.\n (function() { return this })() || Function(\"return this\")()\n);\n","'use strict';\r\n\r\nimport {EditorConfig} from '../types';\r\n\r\ndeclare const VERSION: string;\r\n\r\n/**\r\n * Apply polyfills\r\n */\r\nimport '@babel/register';\r\n\r\nimport 'components/polyfills';\r\nimport Core from './components/core';\r\n\r\n/**\r\n * Codex Editor\r\n *\r\n * Short Description (눈_눈;)\r\n * @version 2.0\r\n *\r\n * @author CodeX-Team tag that holds clean HTML\r\n */\r\n const cleanHTML = Sanitizer.clean(block.holder.innerHTML, this.sanitizerConfig);\r\n const fragment = $.make('p');\r\n\r\n fragment.innerHTML = cleanHTML;\r\n fakeClipboard.appendChild(fragment);\r\n });\r\n\r\n _.copyTextToClipboard(fakeClipboard.innerHTML);\r\n }\r\n\r\n /**\r\n * Select All Blocks\r\n * Each Block has selected setter that makes Block copyable\r\n */\r\n private selectAllBlocks() {\r\n const { BlockManager } = this.Editor;\r\n\r\n BlockManager.blocks.forEach( (block) => block.selected = true);\r\n }\r\n\r\n /**\r\n * select Block\r\n * @param {number?} index - Block index according to the BlockManager's indexes\r\n */\r\n private selectBlockByIndex(index?) {\r\n const { BlockManager } = this.Editor;\r\n\r\n /**\r\n * Remove previous focused Block's state\r\n */\r\n BlockManager.clearFocused();\r\n\r\n let block;\r\n\r\n if (isNaN(index)) {\r\n block = BlockManager.currentBlock;\r\n } else {\r\n block = BlockManager.getBlockByIndex(index);\r\n }\r\n\r\n /** Save selection */\r\n this.selection.save();\r\n SelectionUtils.get()\r\n .removeAllRanges();\r\n\r\n block.selected = true;\r\n }\r\n\r\n /**\r\n * Sanitizer Config\r\n * @return {SanitizerConfig}\r\n */\r\n private get sanitizerConfig() {\r\n return {\r\n p: {},\r\n h1: {},\r\n h2: {},\r\n h3: {},\r\n h4: {},\r\n h5: {},\r\n h6: {},\r\n ol: {},\r\n ul: {},\r\n li: {},\r\n br: true,\r\n img: {\r\n src: true,\r\n width: true,\r\n height: true,\r\n },\r\n a: {\r\n href: true,\r\n },\r\n b: {},\r\n i: {},\r\n u: {},\r\n };\r\n }\r\n}\r\n","/**\n * @class Caret\n * @classdesc Contains methods for working Caret\n *\n * Uses Range methods to manipulate with caret\n *\n * @module Caret\n *\n * @version 2.0.0\n */\n\nimport Selection from '../selection';\nimport Module from '../__module';\nimport Block from '../block';\nimport $ from '../dom';\nimport _ from '../utils';\n\n/**\n * @typedef {Caret} Caret\n */\nexport default class Caret extends Module {\n\n /**\n * Allowed caret positions in input\n *\n * @static\n * @returns {{START: string, END: string, DEFAULT: string}}\n */\n public static get positions(): {START: string, END: string, DEFAULT: string} {\n return {\n START: 'start',\n END: 'end',\n DEFAULT: 'default',\n };\n }\n\n /**\n * Elements styles that can be useful for Caret Module\n */\n private static get CSS(): {shadowCaret: string} {\n return {\n shadowCaret: 'cdx-shadow-caret',\n };\n }\n\n /**\n * Get's deepest first node and checks if offset is zero\n * @return {boolean}\n */\n public get isAtStart(): boolean {\n /**\n * Don't handle ranges\n */\n if (!Selection.isCollapsed) {\n return false;\n }\n\n const selection = Selection.get(),\n anchorNode = selection.anchorNode,\n firstNode = $.getDeepestNode(this.Editor.BlockManager.currentBlock.currentInput);\n\n /** In case lastNode is native input */\n if ($.isNativeInput(firstNode)) {\n return (firstNode as HTMLInputElement).selectionEnd === 0;\n }\n\n /**\n * Workaround case when caret in the text like \" |Hello!\"\n * selection.anchorOffset is 1, but real caret visible position is 0\n * @type {number}\n */\n let firstLetterPosition = anchorNode.textContent.search(/\\S/);\n\n if (firstLetterPosition === -1) { // empty text\n firstLetterPosition = 0;\n }\n\n /**\n * In case of\n * <-- first (and deepest) node is \n * |adaddad <-- anchor node\n * <-- first (and deepest) node is \n * ' + ( htmlData.trim() ? htmlData : plainData ) + ' <-- first (and deepest) node is
+ * |adaddad <-- anchor node
+ * <-- first (and deepest) node is
+ * <-- first (and deepest) node is
- * |adaddad <-- anchor node
- * <-- first (and deepest) node is
- * where line breaks should be handled by default behaviour.\n */\n if (tool && tool[this.Editor.Tools.apiSettings.IS_ENABLED_LINE_BREAKS]) {\n return;\n }\n\n if (this.Editor.Toolbox.opened && this.Editor.Toolbox.getActiveTool) {\n event.preventDefault();\n event.stopPropagation();\n event.stopImmediatePropagation();\n this.Editor.Toolbox.toolButtonActivate(event, this.Editor.Toolbox.getActiveTool);\n return;\n }\n\n /**\n * Allow to create linebreaks by Shift+Enter\n */\n if (event.shiftKey) {\n return;\n }\n /**\n * Split the Current Block into two blocks\n * Renew local current node after split\n */\n const newCurrent = this.Editor.BlockManager.split();\n\n this.Editor.Caret.setToBlock(newCurrent);\n\n /**\n * If new Block is empty\n */\n if (this.Editor.Tools.isInitial(newCurrent.tool) && newCurrent.isEmpty) {\n /**\n * Show Toolbar\n */\n this.Editor.Toolbar.open();\n\n /**\n * Show Plus Button\n */\n this.Editor.Toolbar.plusButton.show();\n }\n\n event.preventDefault();\n event.stopPropagation();\n event.stopImmediatePropagation();\n }\n\n /**\n * Handle backspace keydown on Block\n * @param {KeyboardEvent} event - keydown\n */\n private backspace(event: KeyboardEvent): void {\n const BM = this.Editor.BlockManager;\n const currentBlock = this.Editor.BlockManager.currentBlock,\n tool = this.Editor.Tools.toolsAvailable[currentBlock.name];\n\n /**\n * Don't handle Backspaces when Tool sets enableLineBreaks to true.\n * Uses for Tools like where line breaks should be handled by default behaviour.\n */\n if (tool && tool[this.Editor.Tools.apiSettings.IS_ENABLED_LINE_BREAKS]) {\n return;\n }\n\n const isFirstBlock = BM.currentBlockIndex === 0,\n canMergeBlocks = this.Editor.Caret.isAtStart && !isFirstBlock;\n\n /** If current Block is empty just remove this Block */\n if (this.Editor.BlockManager.currentBlock.isEmpty) {\n this.Editor.BlockManager.removeBlock();\n\n /**\n * in case of last block deletion\n * Insert new initial empty block\n */\n if (this.Editor.BlockManager.blocks.length === 0) {\n this.Editor.BlockManager.insert();\n }\n\n /**\n * In case of deletion first block we need to set caret to the current Block\n * After BlockManager removes the Block (which is current now),\n * pointer that references to the current Block, now points to the Next\n */\n if (this.Editor.BlockManager.currentBlockIndex === 0) {\n this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock);\n } else {\n this.Editor.Caret.navigatePrevious(true);\n }\n\n this.Editor.Toolbar.close();\n return;\n }\n\n if (!canMergeBlocks) {\n return;\n }\n\n // preventing browser default behaviour\n event.preventDefault();\n\n const targetBlock = BM.getBlockByIndex(BM.currentBlockIndex - 1),\n blockToMerge = BM.currentBlock;\n\n /**\n * Blocks that can be merged:\n * 1) with the same Name\n * 2) Tool has 'merge' method\n *\n * other case will handle as usual ARROW LEFT behaviour\n */\n if (blockToMerge.name !== targetBlock.name || !targetBlock.mergeable) {\n if (this.Editor.Caret.navigatePrevious()) {\n this.Editor.Toolbar.close();\n }\n\n return;\n }\n\n this.Editor.Caret.createShadow(targetBlock.pluginsContent);\n BM.mergeBlocks(targetBlock, blockToMerge)\n .then( () => {\n /** Restore caret position after merge */\n this.Editor.Caret.restoreCaret(targetBlock.pluginsContent);\n targetBlock.pluginsContent.normalize();\n this.Editor.Toolbar.close();\n });\n }\n\n /**\n * Handle right and down keyboard keys\n */\n private arrowRightAndDown(event: KeyboardEvent): void {\n if (this.Editor.Caret.navigateNext()) {\n /**\n * Default behaviour moves cursor by 1 character, we need to prevent it\n */\n event.preventDefault();\n }\n }\n\n /**\n * Handle left and up keyboard keys\n */\n private arrowLeftAndUp(event: KeyboardEvent): void {\n if (this.Editor.Caret.navigatePrevious()) {\n /**\n * Default behaviour moves cursor by 1 character, we need to prevent it\n */\n event.preventDefault();\n }\n }\n\n /**\n * Default keydown handler\n */\n private defaultHandler(): void {}\n\n /**\n * Cases when we need to close Toolbar\n */\n private needToolbarClosing(event) {\n const toolboxItemSelected = (event.keyCode === _.keyCodes.ENTER && this.Editor.Toolbox.opened),\n flippingToolboxItems = event.keyCode === _.keyCodes.TAB;\n\n return !(event.shiftKey || flippingToolboxItems || toolboxItemSelected);\n }\n\n}\n","/**\n * @class BlockManager\n * @classdesc Manage editor`s blocks storage and appearance\n *\n * @module BlockManager\n *\n * @version 2.0.0\n */\n\nimport Block from '../block';\n\n/**\n * @typedef {BlockManager} BlockManager\n * @property {Number} currentBlockIndex - Index of current working block\n * @property {Proxy} _blocks - Proxy for Blocks instance {@link Blocks}\n */\nexport default class BlockManager extends Module {\n /**\n * @constructor\n * @param {EditorConfig} config\n */\n constructor({config}) {\n super({config});\n\n /**\n * Proxy for Blocks instance {@link Blocks}\n *\n * @type {Proxy}\n * @private\n */\n this._blocks = null;\n\n /**\n * Index of current working block\n *\n * @type {number}\n * @private\n */\n this.currentBlockIndex = -1;\n }\n\n /**\n * Should be called after Editor.UI preparation\n * Define this._blocks property\n *\n * @returns {Promise}\n */\n prepare() {\n return new Promise(resolve => {\n let blocks = new Blocks(this.Editor.UI.nodes.redactor);\n\n /**\n * We need to use Proxy to overload set/get [] operator.\n * So we can use array-like syntax to access blocks\n *\n * @example\n * this._blocks[0] = new Block(...);\n *\n * block = this._blocks[0];\n *\n * @todo proxy the enumerate method\n *\n * @type {Proxy}\n * @private\n */\n this._blocks = new Proxy(blocks, {\n set: Blocks.set,\n get: Blocks.get\n });\n\n resolve();\n });\n }\n\n /**\n * Creates Block instance by tool name\n *\n * @param {String} toolName - tools passed in editor config {@link EditorConfig#tools}\n * @param {Object} data - constructor params\n * @param {Object} settings - block settings\n *\n * @return {Block}\n */\n composeBlock(toolName, data, settings) {\n let toolInstance = this.Editor.Tools.construct(toolName, data),\n toolClass = this.Editor.Tools.available[toolName],\n block = new Block(toolName, toolInstance, toolClass, settings, this.Editor.API.methods);\n\n this.bindEvents(block);\n return block;\n }\n\n /**\n * Bind Events\n * @param {Object} block\n */\n bindEvents(block) {\n this.Editor.Listeners.on(block.holder, 'keydown', (event) => this.Editor.BlockEvents.keydown(event), true);\n this.Editor.Listeners.on(block.holder, 'mouseup', (event) => this.Editor.BlockEvents.mouseUp(event));\n this.Editor.Listeners.on(block.holder, 'keyup', (event) => this.Editor.BlockEvents.keyup(event));\n this.Editor.Listeners.on(block.holder, 'dragover', (event) => this.Editor.BlockEvents.dragOver(event));\n this.Editor.Listeners.on(block.holder, 'dragleave', (event) => this.Editor.BlockEvents.dragLeave(event));\n }\n\n /**\n * Insert new block into _blocks\n *\n * @param {String} toolName — plugin name, by default method inserts initial block type\n * @param {Object} data — plugin data\n * @param {Object} settings - default settings\n *\n * @return {Block}\n */\n insert(toolName = this.config.initialBlock, data = {}, settings = {}) {\n // Increment index before construct,\n // because developers can use API/Blocks/getCurrentInputIndex on the render() method\n const newIndex = ++this.currentBlockIndex;\n const block = this.composeBlock(toolName, data, settings);\n\n this._blocks[newIndex] = block;\n return block;\n }\n\n /**\n * Always inserts at the end\n * @return {Block}\n */\n insertAtEnd() {\n /**\n * Define new value for current block index\n */\n this.currentBlockIndex = this.blocks.length - 1;\n\n /**\n * Insert initial typed block\n */\n return this.insert();\n }\n\n /**\n * Merge two blocks\n * @param {Block} targetBlock - previous block will be append to this block\n * @param {Block} blockToMerge - block that will be merged with target block\n *\n * @return {Promise} - the sequence that can be continued\n */\n mergeBlocks(targetBlock, blockToMerge) {\n let blockToMergeIndex = this._blocks.indexOf(blockToMerge);\n\n return Promise.resolve()\n .then( () => {\n if (blockToMerge.isEmpty) {\n return;\n }\n\n return blockToMerge.data\n .then((blockToMergeInfo) => {\n targetBlock.mergeWith(blockToMergeInfo.data);\n });\n })\n .then( () => {\n this.removeBlock(blockToMergeIndex);\n this.currentBlockIndex = this._blocks.indexOf(targetBlock);\n });\n }\n\n /**\n * Remove block with passed index or remove last\n * @param {Number|null} index\n */\n removeBlock(index) {\n if (!index) {\n index = this.currentBlockIndex;\n }\n this._blocks.remove(index);\n\n /**\n * If first Block was removed, insert new Initial Block and set focus on it`s first input\n */\n if (!this.blocks.length) {\n this.currentBlockIndex = -1;\n this.insert();\n this.currentBlock.firstInput.focus();\n }\n }\n\n /**\n * Split current Block\n * 1. Extract content from Caret position to the Block`s end\n * 2. Insert a new Block below current one with extracted content\n *\n * @return {Block}\n */\n split() {\n let extractedFragment = this.Editor.Caret.extractFragmentFromCaretPosition(),\n wrapper = $.make('div');\n\n wrapper.append(extractedFragment);\n\n /**\n * @todo make object in accordance with Tool\n */\n let data = {\n text: $.isEmpty(wrapper) ? '' : wrapper.innerHTML,\n };\n\n /**\n * Renew current Block\n * @type {Block}\n */\n return this.insert(this.config.initialBlock, data);\n }\n\n /**\n * Replace current working block\n *\n * @param {String} toolName — plugin name\n * @param {Object} data — plugin data\n *\n * @return {Block}\n */\n replace(toolName, data = {}) {\n let block = this.composeBlock(toolName, data);\n\n this._blocks.insert(this.currentBlockIndex, block, true);\n\n return block;\n }\n\n /**\n * returns last Block\n * @return {Block}\n */\n get lastBlock() {\n return this._blocks[this._blocks.length - 1];\n }\n\n /**\n * Returns Block by passed index\n * @param {Number} index\n * @return {Block}\n */\n getBlockByIndex(index) {\n return this._blocks[index];\n }\n\n /**\n * Get Block instance by html element\n * @param {Node} element\n * @returns {Block}\n */\n getBlock(element) {\n if (!$.isElement(element)) {\n element = element.parentNode;\n }\n\n let nodes = this._blocks.nodes,\n firstLevelBlock = element.closest(`.${Block.CSS.wrapper}`),\n index = nodes.indexOf(firstLevelBlock);\n\n if (index >= 0) {\n return this._blocks[index];\n }\n }\n\n /**\n * Get current Block instance\n *\n * @return {Block}\n */\n get currentBlock() {\n return this._blocks[this.currentBlockIndex];\n }\n\n /**\n * Returns next Block instance\n * @return {Block|null}\n */\n get nextBlock() {\n let isLastBlock = this.currentBlockIndex === (this._blocks.length - 1);\n\n if (isLastBlock) {\n return null;\n }\n\n return this._blocks[this.currentBlockIndex + 1];\n }\n\n /**\n * Return first Block with inputs after current Block\n *\n * @returns {Block | undefined}\n */\n get nextContentfulBlock() {\n const nextBlocks = this.blocks.slice(this.currentBlockIndex + 1);\n\n return nextBlocks.find(block => !!block.inputs.length);\n }\n\n /**\n * Return first Block with inputs before current Block\n *\n * @returns {Block | undefined}\n */\n get previousContentfulBlock() {\n const previousBlocks = this.blocks.slice(0, this.currentBlockIndex).reverse();\n\n return previousBlocks.find(block => !!block.inputs.length);\n }\n\n /**\n * Returns previous Block instance\n * @return {Block|null}\n */\n get previousBlock() {\n let isFirstBlock = this.currentBlockIndex === 0;\n\n if (isFirstBlock) {\n return null;\n }\n\n return this._blocks[this.currentBlockIndex - 1];\n }\n\n /**\n * Remove selection from all Blocks then highlight only Current Block\n */\n highlightCurrentNode() {\n /**\n * Remove previous selected Block's state\n */\n this.clearFocused();\n\n /**\n * Mark current Block as selected\n * @type {boolean}\n */\n this.currentBlock.focused = true;\n }\n\n /**\n * Remove selection from all Blocks\n */\n clearFocused() {\n this.blocks.forEach( block => block.focused = false);\n }\n\n /**\n * Get array of Block instances\n *\n * @returns {Block[]} {@link Blocks#array}\n */\n get blocks() {\n return this._blocks.array;\n }\n\n /**\n * 1) Find first-level Block from passed child Node\n * 2) Mark it as current\n *\n * @param {Element|Text} childNode - look ahead from this node.\n * @param {string} caretPosition - position where to set caret\n * @throws Error - when passed Node is not included at the Block\n */\n setCurrentBlockByChildNode(childNode, caretPosition = 'default') {\n /**\n * If node is Text TextNode\n */\n if (!$.isElement(childNode)) {\n childNode = childNode.parentNode;\n }\n\n const parentFirstLevelBlock = childNode.closest(`.${Block.CSS.wrapper}`);\n\n if (parentFirstLevelBlock) {\n /**\n * Update current Block's index\n * @type {number}\n */\n this.currentBlockIndex = this._blocks.nodes.indexOf(parentFirstLevelBlock);\n\n this.Editor.Caret.setToInput(childNode, caretPosition);\n } else {\n throw new Error('Can not find a Block from this child Node');\n }\n }\n\n /**\n * Return block which contents passed node\n *\n * @param {Node} childNode\n * @return {Block}\n */\n getBlockByChildNode(childNode) {\n /**\n * If node is Text TextNode\n */\n if (!$.isElement(childNode)) {\n childNode = childNode.parentNode;\n }\n\n const firstLevelBlock = childNode.closest(`.${Block.CSS.wrapper}`);\n\n return this.blocks.find(block => block.holder === firstLevelBlock);\n }\n\n /**\n * Swap Blocks Position\n * @param {Number} fromIndex\n * @param {Number} toIndex\n */\n swap(fromIndex, toIndex) {\n /** Move up current Block */\n this._blocks.swap(fromIndex, toIndex);\n\n /** Now actual block moved up so that current block index decreased */\n this.currentBlockIndex = toIndex;\n }\n\n /**\n * Sets current Block Index -1 which means unknown\n * and clear highlightings\n */\n dropPointer() {\n this.currentBlockIndex = -1;\n this.clearFocused();\n }\n\n /**\n * Clears Editor\n * @param {boolean} needAddInitialBlock - 1) in internal calls (for example, in api.blocks.render)\n * we don't need to add empty initial block\n * 2) in api.blocks.clear we should add empty block\n */\n clear(needAddInitialBlock = false) {\n this._blocks.removeAll();\n this.dropPointer();\n\n if (needAddInitialBlock) {\n this.insert(this.config.initialBlock);\n }\n }\n};\n\n/**\n * @class Blocks\n * @classdesc Class to work with Block instances array\n *\n * @private\n *\n * @property {HTMLElement} workingArea — editor`s working node\n *\n */\nclass Blocks {\n /**\n * @constructor\n *\n * @param {HTMLElement} workingArea — editor`s working node\n */\n constructor(workingArea) {\n this.blocks = [];\n this.workingArea = workingArea;\n }\n\n /**\n * Push back new Block\n *\n * @param {Block} block\n */\n push(block) {\n this.blocks.push(block);\n this.workingArea.appendChild(block.holder);\n }\n\n /**\n * Swaps blocks with indexes first and second\n * @param {Number} first - first block index\n * @param {Number} second - second block index\n */\n swap(first, second) {\n let secondBlock = this.blocks[second];\n\n /**\n * Change in DOM\n */\n $.swap(this.blocks[first].holder, secondBlock.holder);\n\n /**\n * Change in array\n */\n this.blocks[second] = this.blocks[first];\n this.blocks[first] = secondBlock;\n }\n\n /**\n * Insert new Block at passed index\n *\n * @param {Number} index — index to insert Block\n * @param {Block} block — Block to insert\n * @param {Boolean} replace — it true, replace block on given index\n */\n insert(index, block, replace = false) {\n if (!this.length) {\n this.push(block);\n return;\n }\n\n if (index > this.length) {\n index = this.length;\n }\n\n if (replace) {\n this.blocks[index].holder.remove();\n }\n\n let deleteCount = replace ? 1 : 0;\n\n this.blocks.splice(index, deleteCount, block);\n\n if (index > 0) {\n let previousBlock = this.blocks[index - 1];\n\n previousBlock.holder.insertAdjacentElement('afterend', block.holder);\n } else {\n let nextBlock = this.blocks[index + 1];\n\n if (nextBlock) {\n nextBlock.holder.insertAdjacentElement('beforebegin', block.holder);\n } else {\n this.workingArea.appendChild(block.holder);\n }\n }\n }\n\n /**\n * Remove block\n * @param {Number|null} index\n */\n remove(index) {\n if (isNaN(index)) {\n index = this.length - 1;\n }\n\n this.blocks[index].holder.remove();\n this.blocks.splice(index, 1);\n }\n\n /**\n * Remove all blocks\n */\n removeAll() {\n this.workingArea.innerHTML = '';\n this.blocks.length = 0;\n }\n\n /**\n * Insert Block after passed target\n *\n * @todo decide if this method is necessary\n *\n * @param {Block} targetBlock — target after wich Block should be inserted\n * @param {Block} newBlock — Block to insert\n */\n insertAfter(targetBlock, newBlock) {\n let index = this.blocks.indexOf(targetBlock);\n\n this.insert(index + 1, newBlock);\n }\n\n /**\n * Get Block by index\n *\n * @param {Number} index — Block index\n * @returns {Block}\n */\n get(index) {\n return this.blocks[index];\n }\n\n /**\n * Return index of passed Block\n *\n * @param {Block} block\n * @returns {Number}\n */\n indexOf(block) {\n return this.blocks.indexOf(block);\n }\n\n /**\n * Get length of Block instances array\n *\n * @returns {Number}\n */\n get length() {\n return this.blocks.length;\n }\n\n /**\n * Get Block instances array\n *\n * @returns {Block[]}\n */\n get array() {\n return this.blocks;\n }\n\n /**\n * Get blocks html elements array\n *\n * @returns {HTMLElement[]}\n */\n get nodes() {\n return _.array(this.workingArea.children);\n }\n\n /**\n * Proxy trap to implement array-like setter\n *\n * @example\n * blocks[0] = new Block(...)\n *\n * @param {Blocks} instance — Blocks instance\n * @param {Number|String} index — block index\n * @param {Block} block — Block to set\n * @returns {Boolean}\n */\n static set(instance, index, block) {\n if (isNaN(Number(index))) {\n return false;\n }\n\n instance.insert(index, block);\n\n return true;\n }\n\n /**\n * Proxy trap to implement array-like getter\n *\n * @param {Blocks} instance — Blocks instance\n * @param {Number|String} index — Block index\n * @returns {Block|*}\n */\n static get(instance, index) {\n if (isNaN(Number(index))) {\n return instance[index];\n }\n\n return instance.get(index);\n }\n}\n","/**\n * @class BlockSelection\n * @classdesc Manages Block selection with shortcut CMD+A and with mouse\n *\n * @module BlockSelection\n * @version 1.0.0\n */\ndeclare var Module: any;\ndeclare var _: any;\ndeclare var $: any;\n\nimport SelectionUtils from '../selection';\n\nexport default class BlockSelection extends Module {\n /**\n * Flag used to define block selection\n * First CMD+A defines it as true and then second CMD+A selects all Blocks\n * @type {boolean}\n */\n private needToSelectAll: boolean = false;\n\n /**\n * SelectionUtils instance\n * @type {SelectionUtils}\n */\n private selection: SelectionUtils;\n\n /**\n * Module Preparation\n * Registers Shortcuts CMD+A and CMD+C\n * to select all and copy them\n */\n public prepare(): void {\n const { Shortcuts } = this.Editor;\n\n /** Selection shortcut */\n Shortcuts.add({\n name: 'CMD+A',\n handler: (event) => {\n this.handleCommandA(event);\n },\n });\n\n /** shortcut to copy all selected blocks */\n Shortcuts.add({\n name: 'CMD+C',\n handler: (event) => {\n this.handleCommandC(event);\n },\n });\n\n this.selection = new SelectionUtils();\n }\n\n /**\n * Clear selection from Blocks\n */\n public clearSelection(restoreSelection = false) {\n const { BlockManager } = this.Editor;\n const anyBlockSelected = BlockManager.blocks.findIndex( (block) => block.selected === true) !== -1;\n\n if (!anyBlockSelected) {\n return;\n }\n\n this.needToSelectAll = false;\n BlockManager.blocks.forEach( (block) => block.selected = false);\n\n /**\n * restore selection when Block is already selected\n * but someone tries to write something.\n */\n if (restoreSelection) {\n this.selection.restore();\n }\n }\n\n /**\n * First CMD+A Selects current focused blocks,\n * and consequent second CMD+A keypress selects all blocks\n *\n * @param {keydown} event\n */\n private handleCommandA(event): void {\n /** Prevent default selection */\n event.preventDefault();\n\n if (this.needToSelectAll) {\n this.selectAllBlocks();\n this.needToSelectAll = false;\n } else {\n this.selectBlockByIndex();\n this.needToSelectAll = true;\n }\n }\n\n /**\n * Copying selected blocks\n * Before putting to the clipboard we sanitize all blocks and then copy to the clipboard\n *\n * @param event\n */\n private handleCommandC(event): void {\n const { BlockManager, Sanitizer } = this.Editor;\n const anyBlockSelected = BlockManager.blocks.some( (block) => block.selected === true);\n\n if (!anyBlockSelected) {\n return;\n }\n\n const fakeClipboard = $.make('div');\n\n BlockManager.blocks.filter( (block) => block.selected )\n .forEach( (block) => {\n /**\n * Make adaddad
<-- passed node for example \n * |\n * | right first-level siblings\n * |\n *
where line breaks should be handled by default behaviour.\r\n */\r\n if (tool && tool[this.Editor.Tools.apiSettings.IS_ENABLED_LINE_BREAKS]) {\r\n return;\r\n }\r\n\r\n if (this.Editor.Toolbox.opened && this.Editor.Toolbox.getActiveTool) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n event.stopImmediatePropagation();\r\n this.Editor.Toolbox.toolButtonActivate(event, this.Editor.Toolbox.getActiveTool);\r\n return;\r\n }\r\n\r\n /**\r\n * Allow to create linebreaks by Shift+Enter\r\n */\r\n if (event.shiftKey) {\r\n return;\r\n }\r\n /**\r\n * Split the Current Block into two blocks\r\n * Renew local current node after split\r\n */\r\n const newCurrent = this.Editor.BlockManager.split();\r\n\r\n this.Editor.Caret.setToBlock(newCurrent);\r\n\r\n /**\r\n * If new Block is empty\r\n */\r\n if (this.Editor.Tools.isInitial(newCurrent.tool) && newCurrent.isEmpty) {\r\n /**\r\n * Show Toolbar\r\n */\r\n this.Editor.Toolbar.open();\r\n\r\n /**\r\n * Show Plus Button\r\n */\r\n this.Editor.Toolbar.plusButton.show();\r\n }\r\n\r\n event.preventDefault();\r\n event.stopPropagation();\r\n event.stopImmediatePropagation();\r\n }\r\n\r\n /**\r\n * Handle backspace keydown on Block\r\n * @param {KeyboardEvent} event - keydown\r\n */\r\n private backspace(event: KeyboardEvent): void {\r\n const BM = this.Editor.BlockManager;\r\n const currentBlock = this.Editor.BlockManager.currentBlock,\r\n tool = this.Editor.Tools.available[currentBlock.name];\r\n\r\n /**\r\n * Don't handle Backspaces when Tool sets enableLineBreaks to true.\r\n * Uses for Tools like where line breaks should be handled by default behaviour.\r\n */\r\n if (tool && tool[this.Editor.Tools.apiSettings.IS_ENABLED_LINE_BREAKS]) {\r\n return;\r\n }\r\n\r\n const isFirstBlock = BM.currentBlockIndex === 0,\r\n canMergeBlocks = this.Editor.Caret.isAtStart && !isFirstBlock;\r\n\r\n /** If current Block is empty just remove this Block */\r\n if (this.Editor.BlockManager.currentBlock.isEmpty) {\r\n this.Editor.BlockManager.removeBlock();\r\n\r\n /**\r\n * in case of last block deletion\r\n * Insert new initial empty block\r\n */\r\n if (this.Editor.BlockManager.blocks.length === 0) {\r\n this.Editor.BlockManager.insert();\r\n }\r\n\r\n /**\r\n * In case of deletion first block we need to set caret to the current Block\r\n * After BlockManager removes the Block (which is current now),\r\n * pointer that references to the current Block, now points to the Next\r\n */\r\n if (this.Editor.BlockManager.currentBlockIndex === 0) {\r\n this.Editor.Caret.setToBlock(this.Editor.BlockManager.currentBlock);\r\n } else {\r\n this.Editor.Caret.navigatePrevious(true);\r\n }\r\n\r\n this.Editor.Toolbar.close();\r\n return;\r\n }\r\n\r\n if (!canMergeBlocks) {\r\n return;\r\n }\r\n\r\n // preventing browser default behaviour\r\n event.preventDefault();\r\n\r\n const targetBlock = BM.getBlockByIndex(BM.currentBlockIndex - 1),\r\n blockToMerge = BM.currentBlock;\r\n\r\n /**\r\n * Blocks that can be merged:\r\n * 1) with the same Name\r\n * 2) Tool has 'merge' method\r\n *\r\n * other case will handle as usual ARROW LEFT behaviour\r\n */\r\n if (blockToMerge.name !== targetBlock.name || !targetBlock.mergeable) {\r\n if (this.Editor.Caret.navigatePrevious()) {\r\n this.Editor.Toolbar.close();\r\n }\r\n\r\n return;\r\n }\r\n\r\n this.Editor.Caret.createShadow(targetBlock.pluginsContent);\r\n BM.mergeBlocks(targetBlock, blockToMerge)\r\n .then( () => {\r\n /** Restore caret position after merge */\r\n this.Editor.Caret.restoreCaret(targetBlock.pluginsContent as HTMLElement);\r\n targetBlock.pluginsContent.normalize();\r\n this.Editor.Toolbar.close();\r\n });\r\n }\r\n\r\n /**\r\n * Handle right and down keyboard keys\r\n */\r\n private arrowRightAndDown(event: KeyboardEvent): void {\r\n if (this.Editor.Caret.navigateNext()) {\r\n /**\r\n * Default behaviour moves cursor by 1 character, we need to prevent it\r\n */\r\n event.preventDefault();\r\n }\r\n }\r\n\r\n /**\r\n * Handle left and up keyboard keys\r\n */\r\n private arrowLeftAndUp(event: KeyboardEvent): void {\r\n if (this.Editor.Caret.navigatePrevious()) {\r\n /**\r\n * Default behaviour moves cursor by 1 character, we need to prevent it\r\n */\r\n event.preventDefault();\r\n }\r\n }\r\n\r\n /**\r\n * Default keydown handler\r\n */\r\n private defaultHandler(): void {}\r\n\r\n /**\r\n * Cases when we need to close Toolbar\r\n */\r\n private needToolbarClosing(event) {\r\n const toolboxItemSelected = (event.keyCode === _.keyCodes.ENTER && this.Editor.Toolbox.opened),\r\n flippingToolboxItems = event.keyCode === _.keyCodes.TAB;\r\n\r\n return !(event.shiftKey || flippingToolboxItems || toolboxItemSelected);\r\n }\r\n\r\n}\r\n","/**\n * @class BlockManager\n * @classdesc Manage editor`s blocks storage and appearance\n *\n * @module BlockManager\n *\n * @version 2.0.0\n */\nimport Block from '../block';\nimport Module from '../__module';\nimport $ from '../dom';\nimport Blocks from '../blocks';\nimport {BlockTool, BlockToolConstructable, BlockToolData, ToolConfig} from '../../../types';\nimport Caret from './caret';\n\n/**\n * @typedef {BlockManager} BlockManager\n * @property {Number} currentBlockIndex - Index of current working block\n * @property {Proxy} _blocks - Proxy for Blocks instance {@link Blocks}\n */\nexport default class BlockManager extends Module {\n\n /**\n * returns last Block\n * @return {Block}\n */\n public get lastBlock(): Block {\n return this._blocks[this._blocks.length - 1];\n }\n\n /**\n * Get current Block instance\n *\n * @return {Block}\n */\n public get currentBlock(): Block {\n return this._blocks[this.currentBlockIndex];\n }\n\n /**\n * Returns next Block instance\n * @return {Block|null}\n */\n public get nextBlock(): Block {\n const isLastBlock = this.currentBlockIndex === (this._blocks.length - 1);\n\n if (isLastBlock) {\n return null;\n }\n\n return this._blocks[this.currentBlockIndex + 1];\n }\n\n /**\n * Return first Block with inputs after current Block\n *\n * @returns {Block | undefined}\n */\n public get nextContentfulBlock(): Block {\n const nextBlocks = this.blocks.slice(this.currentBlockIndex + 1);\n\n return nextBlocks.find((block) => !!block.inputs.length);\n }\n\n /**\n * Return first Block with inputs before current Block\n *\n * @returns {Block | undefined}\n */\n public get previousContentfulBlock(): Block {\n const previousBlocks = this.blocks.slice(0, this.currentBlockIndex).reverse();\n\n return previousBlocks.find((block) => !!block.inputs.length);\n }\n\n /**\n * Returns previous Block instance\n * @return {Block|null}\n */\n public get previousBlock(): Block {\n const isFirstBlock = this.currentBlockIndex === 0;\n\n if (isFirstBlock) {\n return null;\n }\n\n return this._blocks[this.currentBlockIndex - 1];\n }\n\n /**\n * Get array of Block instances\n *\n * @returns {Block[]} {@link Blocks#array}\n */\n public get blocks(): Block[] {\n return this._blocks.array;\n }\n\n /**\n * Index of current working block\n *\n * @type {number}\n */\n public currentBlockIndex: number = -1;\n\n /**\n * Proxy for Blocks instance {@link Blocks}\n *\n * @type {Proxy}\n * @private\n */\n private _blocks: Blocks = null;\n\n /**\n * Should be called after Editor.UI preparation\n * Define this._blocks property\n *\n * @returns {Promise}\n */\n public async prepare() {\n const blocks = new Blocks(this.Editor.UI.nodes.redactor);\n\n /**\n * We need to use Proxy to overload set/get [] operator.\n * So we can use array-like syntax to access blocks\n *\n * @example\n * this._blocks[0] = new Block(...);\n *\n * block = this._blocks[0];\n *\n * @todo proxy the enumerate method\n *\n * @type {Proxy}\n * @private\n */\n this._blocks = new Proxy(blocks, {\n set: Blocks.set,\n get: Blocks.get,\n });\n }\n\n /**\n * Creates Block instance by tool name\n *\n * @param {String} toolName - tools passed in editor config {@link EditorConfig#tools}\n * @param {Object} data - constructor params\n * @param {Object} settings - block settings\n *\n * @return {Block}\n */\n public composeBlock(toolName: string, data: BlockToolData, settings?: ToolConfig): Block {\n const toolInstance = this.Editor.Tools.construct(toolName, data) as BlockTool;\n const toolClass = this.Editor.Tools.available[toolName] as BlockToolConstructable;\n const block = new Block(toolName, toolInstance, toolClass, settings, this.Editor.API.methods);\n\n this.bindEvents(block);\n\n return block;\n }\n\n /**\n * Insert new block into _blocks\n *\n * @param {String} toolName — plugin name, by default method inserts initial block type\n * @param {Object} data — plugin data\n * @param {Object} settings - default settings\n *\n * @return {Block}\n */\n public insert(\n toolName: string = this.config.initialBlock,\n data: BlockToolData = {},\n settings: ToolConfig = {},\n ): Block {\n // Increment index before construct,\n // because developers can use API/Blocks/getCurrentInputIndex on the render() method\n const newIndex = ++this.currentBlockIndex;\n const block = this.composeBlock(toolName, data, settings);\n\n this._blocks[newIndex] = block;\n return block;\n }\n\n /**\n * Always inserts at the end\n * @return {Block}\n */\n public insertAtEnd(): Block {\n /**\n * Define new value for current block index\n */\n this.currentBlockIndex = this.blocks.length - 1;\n\n /**\n * Insert initial typed block\n */\n return this.insert();\n }\n\n /**\n * Merge two blocks\n * @param {Block} targetBlock - previous block will be append to this block\n * @param {Block} blockToMerge - block that will be merged with target block\n *\n * @return {Promise} - the sequence that can be continued\n */\n public async mergeBlocks(targetBlock: Block, blockToMerge: Block): Promiseadaddad
<-- passed node for example \n * |\n * | right first-level siblings\n * |\n *
adaddad
<-- passed node for example
- * |
- * | right first-level siblings
- * |
- *
adaddad
<-- passed node for example
+ * |
+ * | right first-level siblings
+ * |
+ *