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,SAASic,EAAW5T,eACjC,GACF,CAtDA/O,EAAQmwB,uBAAyBA,EACjCnwB,EAAQqwB,yBAA2BA,EAuDnC,IAAI/iB,EAA8B,CAAC,CAEjCyiB,MAAO,QACPphB,IAAK,SAAa9K,GAChBssB,EAAuBtsB,EAAQ,KACjC,GACC,CAEDksB,MAAO,UACPphB,IAAK,SAAa9K,GAChBssB,EAAuBtsB,EAAQ,KACjC,GACC,CAEDksB,MAAO,cACPphB,IAAK,SAAa9K,EAAQ8rB,GACxB,IAAIa,EAAUb,EAAQ,GAClBc,EAAa,IAAMD,EAAQ3uB,OAC/BwuB,EAAyBxsB,EAAQ4sB,EACnC,IAEFzwB,EAAQsN,4BAA8BA,C","sources":["webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/cards/image.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/edit-history.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/edit-state.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/editor.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/event-manager.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/key-commands.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/mutation-handler.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/post.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/post/post-inserter.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/selection-change-observer.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/selection-manager.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/text-input-handler.js","webpack://dicom-frontend/./node_modules/mobiledoc-kit/dist/commonjs/mobiledoc-kit/editor/text-input-handlers.js"],"sourcesContent":["'use strict';\n\nvar _utilsPlaceholderImageSrc = require('../utils/placeholder-image-src');\n\nexports['default'] = {\n name: 'image',\n type: 'dom',\n\n render: function render(_ref) {\n var env = _ref.env;\n var options = _ref.options;\n var payload = _ref.payload;\n\n var img = document.createElement('img');\n img.src = payload.src || _utilsPlaceholderImageSrc['default'];\n return img;\n }\n};","'use strict';\n\nvar _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _parsersMobiledoc = require('../parsers/mobiledoc');\n\nvar _utilsFixedQueue = require('../utils/fixed-queue');\n\nfunction findLeafSectionAtIndex(post, index) {\n var section = undefined;\n post.walkAllLeafSections(function (_section, _index) {\n if (index === _index) {\n section = _section;\n }\n });\n return section;\n}\n\nvar Snapshot = (function () {\n function Snapshot(editor) {\n _classCallCheck(this, Snapshot);\n\n this.mobiledoc = editor.serialize();\n this.editor = editor;\n\n this.snapshotRange();\n }\n\n _createClass(Snapshot, [{\n key: 'snapshotRange',\n value: function snapshotRange() {\n var _editor = this.editor;\n var range = _editor.range;\n var cursor = _editor.cursor;\n\n if (cursor.hasCursor() && !range.isBlank) {\n var head = range.head;\n var tail = range.tail;\n\n this.range = {\n head: [head.leafSectionIndex, head.offset],\n tail: [tail.leafSectionIndex, tail.offset]\n };\n }\n }\n }, {\n key: 'getRange',\n value: function getRange(post) {\n if (this.range) {\n var _range = this.range;\n var head = _range.head;\n var tail = _range.tail;\n var _head = head;\n\n var _head2 = _slicedToArray(_head, 2);\n\n var headLeafSectionIndex = _head2[0];\n var headOffset = _head2[1];\n var _tail = tail;\n\n var _tail2 = _slicedToArray(_tail, 2);\n\n var tailLeafSectionIndex = _tail2[0];\n var tailOffset = _tail2[1];\n\n var headSection = findLeafSectionAtIndex(post, headLeafSectionIndex);\n var tailSection = findLeafSectionAtIndex(post, tailLeafSectionIndex);\n\n head = headSection.toPosition(headOffset);\n tail = tailSection.toPosition(tailOffset);\n\n return head.toRange(tail);\n }\n }\n }]);\n\n return Snapshot;\n})();\n\nexports.Snapshot = Snapshot;\n\nvar EditHistory = (function () {\n function EditHistory(editor, queueLength) {\n _classCallCheck(this, EditHistory);\n\n this.editor = editor;\n this._undoStack = new _utilsFixedQueue['default'](queueLength);\n this._redoStack = new _utilsFixedQueue['default'](queueLength);\n\n this._pendingSnapshot = null;\n }\n\n _createClass(EditHistory, [{\n key: 'snapshot',\n value: function snapshot() {\n // update the current snapshot with the range read from DOM\n if (this._pendingSnapshot) {\n this._pendingSnapshot.snapshotRange();\n }\n }\n }, {\n key: 'storeSnapshot',\n value: function storeSnapshot() {\n // store pending snapshot\n if (this._pendingSnapshot) {\n this._undoStack.push(this._pendingSnapshot);\n this._redoStack.clear();\n }\n\n // take new pending snapshot to store next time `storeSnapshot` is called\n this._pendingSnapshot = new Snapshot(this.editor);\n }\n }, {\n key: 'stepBackward',\n value: function stepBackward(postEditor) {\n // Throw away the pending snapshot\n this._pendingSnapshot = null;\n\n var snapshot = this._undoStack.pop();\n if (snapshot) {\n this._redoStack.push(new Snapshot(this.editor));\n this._restoreFromSnapshot(snapshot, postEditor);\n }\n }\n }, {\n key: 'stepForward',\n value: function stepForward(postEditor) {\n var snapshot = this._redoStack.pop();\n if (snapshot) {\n this._undoStack.push(new Snapshot(this.editor));\n this._restoreFromSnapshot(snapshot, postEditor);\n }\n postEditor.cancelSnapshot();\n }\n }, {\n key: '_restoreFromSnapshot',\n value: function _restoreFromSnapshot(snapshot, postEditor) {\n var mobiledoc = snapshot.mobiledoc;\n var editor = this.editor;\n var builder = editor.builder;\n var post = editor.post;\n\n var restoredPost = _parsersMobiledoc['default'].parse(builder, mobiledoc);\n\n postEditor.removeAllSections();\n postEditor.migrateSectionsFromPost(restoredPost);\n\n // resurrect snapshotted range if it exists\n var newRange = snapshot.getRange(post);\n if (newRange) {\n postEditor.setRange(newRange);\n }\n }\n }]);\n\n return EditHistory;\n})();\n\nexports['default'] = EditHistory;","'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _utilsArrayUtils = require('../utils/array-utils');\n\nvar _utilsCursorRange = require('../utils/cursor/range');\n\n/**\n * Used by {@link Editor} to manage its current state (cursor, active markups\n * and active sections).\n * @private\n */\n\nvar EditState = (function () {\n function EditState(editor) {\n _classCallCheck(this, EditState);\n\n this.editor = editor;\n\n var defaultState = {\n range: _utilsCursorRange['default'].blankRange(),\n activeMarkups: [],\n activeSections: [],\n activeSectionTagNames: []\n };\n\n this.prevState = this.state = defaultState;\n }\n\n _createClass(EditState, [{\n key: 'updateRange',\n value: function updateRange(newRange) {\n this.prevState = this.state;\n this.state = this._readState(newRange);\n }\n }, {\n key: 'destroy',\n value: function destroy() {\n this.editor = null;\n this.prevState = this.state = null;\n }\n\n /**\n * @return {Boolean}\n */\n }, {\n key: 'rangeDidChange',\n value: function rangeDidChange() {\n var range = this.state.range;\n var prevRange = this.prevState.range;\n\n return !prevRange.isEqual(range);\n }\n\n /**\n * @return {Boolean} Whether the input mode (active markups or active section tag names)\n * has changed.\n */\n }, {\n key: 'inputModeDidChange',\n value: function inputModeDidChange() {\n var state = this.state;\n var prevState = this.prevState;\n\n return !(0, _utilsArrayUtils.isArrayEqual)(state.activeMarkups, prevState.activeMarkups) || !(0, _utilsArrayUtils.isArrayEqual)(state.activeSectionTagNames, prevState.activeSectionTagNames);\n }\n\n /**\n * @return {Range}\n */\n }, {\n key: 'toggleMarkupState',\n\n /**\n * Update the editor's markup state. This is used when, e.g.,\n * a user types meta+B when the editor has a cursor but no selected text;\n * in this case the editor needs to track that it has an active \"b\" markup\n * and apply it to the next text the user types.\n */\n value: function toggleMarkupState(markup) {\n if ((0, _utilsArrayUtils.contains)(this.activeMarkups, markup)) {\n this._removeActiveMarkup(markup);\n } else {\n this._addActiveMarkup(markup);\n }\n }\n }, {\n key: '_readState',\n value: function _readState(range) {\n var state = {\n range: range,\n activeMarkups: this._readActiveMarkups(range),\n activeSections: this._readActiveSections(range)\n };\n // Section objects are 'live', so to check that they changed, we\n // need to map their tagNames now (and compare to mapped tagNames later).\n // In addition, to catch changes from ul -> ol, we keep track of the\n // un-nested tag names (otherwise we'd only see li -> li change)\n state.activeSectionTagNames = state.activeSections.map(function (s) {\n return s.isNested ? s.parent.tagName : s.tagName;\n });\n return state;\n }\n }, {\n key: '_readActiveSections',\n value: function _readActiveSections(range) {\n var head = range.head;\n var tail = range.tail;\n var post = this.editor.post;\n\n if (range.isBlank) {\n return [];\n } else {\n return post.sections.readRange(head.section, tail.section);\n }\n }\n }, {\n key: '_readActiveMarkups',\n value: function _readActiveMarkups(range) {\n var post = this.editor.post;\n\n return post.markupsInRange(range);\n }\n }, {\n key: '_removeActiveMarkup',\n value: function _removeActiveMarkup(markup) {\n var index = this.state.activeMarkups.indexOf(markup);\n this.state.activeMarkups.splice(index, 1);\n }\n }, {\n key: '_addActiveMarkup',\n value: function _addActiveMarkup(markup) {\n this.state.activeMarkups.push(markup);\n }\n }, {\n key: 'range',\n get: function get() {\n return this.state.range;\n }\n\n /**\n * @return {Section[]}\n */\n }, {\n key: 'activeSections',\n get: function get() {\n return this.state.activeSections;\n }\n\n /**\n * @return {Markup[]}\n */\n }, {\n key: 'activeMarkups',\n get: function get() {\n return this.state.activeMarkups;\n }\n }]);\n\n return EditState;\n})();\n\nexports['default'] = EditState;","'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _viewsTooltip = require('../views/tooltip');\n\nvar _post = require('./post');\n\nvar _cardsImage = require('../cards/image');\n\nvar _utilsKey = require('../utils/key');\n\nvar _parsersMobiledoc = require('../parsers/mobiledoc');\n\nvar _parsersHtml = require('../parsers/html');\n\nvar _parsersDom = require('../parsers/dom');\n\nvar _renderersEditorDom = require('../renderers/editor-dom');\n\nvar _modelsRenderTree = require('../models/render-tree');\n\nvar _renderersMobiledoc = require('../renderers/mobiledoc');\n\nvar _utilsMerge = require('../utils/merge');\n\nvar _utilsDomUtils = require('../utils/dom-utils');\n\nvar _utilsArrayUtils = require('../utils/array-utils');\n\nvar _utilsElementUtils = require('../utils/element-utils');\n\nvar _utilsCursor = require('../utils/cursor');\n\nvar _utilsCursorRange = require('../utils/cursor/range');\n\nvar _utilsCursorPosition = require('../utils/cursor/position');\n\nvar _modelsPostNodeBuilder = require('../models/post-node-builder');\n\nvar _textInputHandlers = require('./text-input-handlers');\n\nvar _keyCommands = require('./key-commands');\n\nvar _modelsCard = require('../models/card');\n\nvar _utilsAssert = require('../utils/assert');\n\nvar _editorMutationHandler = require('../editor/mutation-handler');\n\nvar _editorEditHistory = require('../editor/edit-history');\n\nvar _editorEventManager = require('../editor/event-manager');\n\nvar _editorEditState = require('../editor/edit-state');\n\nvar _mobiledocHtmlRenderer = require('mobiledoc-html-renderer');\n\nvar _mobiledocTextRenderer = require('mobiledoc-text-renderer');\n\nvar _modelsLifecycleCallbacks = require('../models/lifecycle-callbacks');\n\nvar _utilsLogManager = require('../utils/log-manager');\n\nvar _utilsToRange = require('../utils/to-range');\n\nvar _utilsMobiledocError = require('../utils/mobiledoc-error');\n\n// This export may later be deprecated, but re-export it from the renderer here\n// for consumers that may depend on it.\nObject.defineProperty(exports, 'EDITOR_ELEMENT_CLASS_NAME', {\n enumerable: true,\n get: function get() {\n return _renderersEditorDom.EDITOR_ELEMENT_CLASS_NAME;\n }\n});\n\nvar defaults = {\n placeholder: 'Write here...',\n spellcheck: true,\n autofocus: true,\n undoDepth: 5,\n cards: [],\n atoms: [],\n cardOptions: {},\n unknownCardHandler: function unknownCardHandler(_ref) {\n var env = _ref.env;\n\n throw new _utilsMobiledocError['default']('Unknown card encountered: ' + env.name);\n },\n unknownAtomHandler: function unknownAtomHandler(_ref2) {\n var env = _ref2.env;\n\n throw new _utilsMobiledocError['default']('Unknown atom encountered: ' + env.name);\n },\n mobiledoc: null,\n html: null\n};\n\nvar CALLBACK_QUEUES = {\n DID_UPDATE: 'didUpdate',\n WILL_RENDER: 'willRender',\n DID_RENDER: 'didRender',\n WILL_DELETE: 'willDelete',\n DID_DELETE: 'didDelete',\n CURSOR_DID_CHANGE: 'cursorDidChange',\n DID_REPARSE: 'didReparse',\n POST_DID_CHANGE: 'postDidChange',\n INPUT_MODE_DID_CHANGE: 'inputModeDidChange'\n};\n\n/**\n * The Editor is a core component of mobiledoc-kit. After instantiating\n * an editor, use {@link Editor#render} to display the editor on the web page.\n *\n * An editor uses a {@link Post} internally to represent the displayed document.\n * The post can be serialized as mobiledoc using {@link Editor#serialize}. Mobiledoc\n * is the transportable \"over-the-wire\" format (JSON) that is suited for persisting\n * and sharing between editors and renderers (for display, e.g.), whereas the Post\n * model is better suited for programmatic editing.\n *\n * The editor will call registered callbacks for certain state changes. These are:\n * * {@link Editor#cursorDidChange} -- The cursor position or selection changed.\n * * {@link Editor#postDidChange} -- The contents of the post changed due to user input or\n * programmatic editing. This hook can be used with {@link Editor#serialize}\n * to auto-save a post as it is being edited.\n * * {@link Editor#inputModeDidChange} -- The active section(s) or markup(s) at the current cursor\n * position or selection have changed. This hook can be used with\n * {@link Editor#activeMarkups} and {@link Editor#activeSections} to implement\n * a custom toolbar.\n * * {@link Editor#onTextInput} -- Register callbacks when the user enters text\n * that matches a given string or regex.\n */\n\nvar Editor = (function () {\n /**\n * @param {Object} [options]\n * @param {Object} [options.mobiledoc] The mobiledoc to load into the editor.\n * Supersedes `options.html`.\n * @param {String|DOM} [options.html] The html (as a string or DOM fragment)\n * to parse and load into the editor.\n * Will be ignored if `options.mobiledoc` is also passed.\n * @param {Array} [options.parserPlugins=[]]\n * @param {Array} [options.cards=[]] The cards that the editor may render.\n * @param {Array} [options.atoms=[]] The atoms that the editor may render.\n * @param {Function} [options.unknownCardHandler] Invoked by the editor's renderer\n * whenever it encounters an unknown card.\n * @param {Function} [options.unknownAtomHandler] Invoked by the editor's renderer\n * whenever it encounters an unknown atom.\n * @param {String} [options.placeholder] Default text to show before user starts typing.\n * @param {Boolean} [options.spellcheck=true] Whether to enable spellcheck\n * @param {Boolean} [options.autofocus=true] Whether to focus the editor when it is first rendered.\n * @param {number} [options.undoDepth=5] How many undo levels will be available.\n * Set to 0 to disable undo/redo functionality.\n * @return {Editor}\n * @public\n */\n\n function Editor() {\n var _this = this;\n\n var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n\n _classCallCheck(this, Editor);\n\n (0, _utilsAssert['default'])('editor create accepts an options object. For legacy usage passing an element for the first argument, consider the `html` option for loading DOM or HTML posts. For other cases call `editor.render(domNode)` after editor creation', options && !options.nodeType);\n this._views = [];\n this.isEditable = null;\n this._parserPlugins = options.parserPlugins || [];\n\n // FIXME: This should merge onto this.options\n (0, _utilsMerge.mergeWithOptions)(this, defaults, options);\n this.cards.push(_cardsImage['default']);\n\n _keyCommands.DEFAULT_KEY_COMMANDS.forEach(function (kc) {\n return _this.registerKeyCommand(kc);\n });\n\n this._logManager = new _utilsLogManager['default']();\n this._parser = new _parsersDom['default'](this.builder);\n var cards = this.cards;\n var atoms = this.atoms;\n var unknownCardHandler = this.unknownCardHandler;\n var unknownAtomHandler = this.unknownAtomHandler;\n var cardOptions = this.cardOptions;\n\n this._renderer = new _renderersEditorDom['default'](this, cards, atoms, unknownCardHandler, unknownAtomHandler, cardOptions);\n\n this.post = this.loadPost();\n this._renderTree = new _modelsRenderTree['default'](this.post);\n\n this._editHistory = new _editorEditHistory['default'](this, this.undoDepth);\n this._eventManager = new _editorEventManager['default'](this);\n this._mutationHandler = new _editorMutationHandler['default'](this);\n this._editState = new _editorEditState['default'](this);\n this._callbacks = new _modelsLifecycleCallbacks['default']((0, _utilsArrayUtils.values)(CALLBACK_QUEUES));\n\n _textInputHandlers.DEFAULT_TEXT_INPUT_HANDLERS.forEach(function (handler) {\n return _this.onTextInput(handler);\n });\n\n this.hasRendered = false;\n }\n\n /**\n * Turns on verbose logging for the editor.\n * @param {Array} [logTypes=[]] If present, only the given log types will be logged.\n * @public\n */\n\n _createClass(Editor, [{\n key: 'enableLogging',\n value: function enableLogging() {\n var logTypes = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];\n\n if (logTypes.length === 0) {\n this._logManager.enableAll();\n } else {\n this._logManager.enableTypes(logTypes);\n }\n }\n\n /**\n * Disable all logging\n * @public\n */\n }, {\n key: 'disableLogging',\n value: function disableLogging() {\n this._logManager.disable();\n }\n\n /**\n * @private\n */\n }, {\n key: 'loggerFor',\n value: function loggerFor(type) {\n return this._logManager['for'](type);\n }\n\n /**\n * The editor's instance of a post node builder.\n * @type {PostNodeBuilder}\n */\n }, {\n key: 'loadPost',\n value: function loadPost() {\n var mobiledoc = this.mobiledoc;\n var html = this.html;\n\n if (mobiledoc) {\n return _parsersMobiledoc['default'].parse(this.builder, mobiledoc);\n } else if (html) {\n if (typeof html === 'string') {\n var options = { plugins: this._parserPlugins };\n return new _parsersHtml['default'](this.builder, options).parse(this.html);\n } else {\n var dom = html;\n return this._parser.parse(dom);\n }\n } else {\n return this.builder.createPost();\n }\n }\n }, {\n key: 'rerender',\n value: function rerender() {\n var _this2 = this;\n\n var postRenderNode = this.post.renderNode;\n\n // if we haven't rendered this post's renderNode before, mark it dirty\n if (!postRenderNode.element) {\n (0, _utilsAssert['default'])('Must call `render` before `rerender` can be called', this.hasRendered);\n postRenderNode.element = this.element;\n postRenderNode.markDirty();\n }\n\n this.runCallbacks(CALLBACK_QUEUES.WILL_RENDER);\n this._mutationHandler.suspendObservation(function () {\n _this2._renderer.render(_this2._renderTree);\n });\n this.runCallbacks(CALLBACK_QUEUES.DID_RENDER);\n }\n\n /**\n * @param {Element} element The DOM element to render into.\n * Its contents will be replaced by the editor's rendered post.\n * @public\n */\n }, {\n key: 'render',\n value: function render(element) {\n (0, _utilsAssert['default'])('Cannot render an editor twice. Use `rerender` to update the ' + 'rendering of an existing editor instance.', !this.hasRendered);\n\n element.spellcheck = this.spellcheck;\n\n (0, _utilsDomUtils.clearChildNodes)(element);\n\n this.element = element;\n\n if (this.isEditable === null) {\n this.enableEditing();\n }\n\n this._addTooltip();\n\n // A call to `run` will trigger the didUpdatePostCallbacks hooks with a\n // postEditor.\n this.run(function () {});\n\n // Only set `hasRendered` to true after calling `run` to ensure that\n // no cursorDidChange or other callbacks get fired before the editor is\n // done rendering\n this.hasRendered = true;\n this.rerender();\n\n this._mutationHandler.init();\n this._eventManager.init();\n\n if (this.autofocus) {\n this.selectRange(this.post.headPosition());\n }\n }\n }, {\n key: '_addTooltip',\n value: function _addTooltip() {\n this.addView(new _viewsTooltip['default']({\n rootElement: this.element,\n showForTag: 'a'\n }));\n }\n }, {\n key: 'registerKeyCommand',\n\n /**\n * @param {Object} keyCommand The key command to register. It must specify a\n * modifier key (meta, ctrl, etc), a string representing the ascii key, and\n * a `run` method that will be passed the editor instance when the key command\n * is invoked\n * @public\n */\n value: function registerKeyCommand(rawKeyCommand) {\n var keyCommand = (0, _keyCommands.buildKeyCommand)(rawKeyCommand);\n (0, _utilsAssert['default'])('Key Command is not valid', (0, _keyCommands.validateKeyCommand)(keyCommand));\n this.keyCommands.unshift(keyCommand);\n }\n\n /**\n * Convenience for {@link PostEditor#deleteAtPosition}. Deletes and puts the\n * cursor in the new position.\n * @public\n */\n }, {\n key: 'deleteAtPosition',\n value: function deleteAtPosition(position, direction, _ref3) {\n var unit = _ref3.unit;\n\n this.run(function (postEditor) {\n var nextPosition = postEditor.deleteAtPosition(position, direction, { unit: unit });\n postEditor.setRange(nextPosition);\n });\n }\n\n /**\n * Convenience for {@link PostEditor#deleteRange}. Deletes and puts the\n * cursor in the new position.\n * @param {Range} range\n * @public\n */\n }, {\n key: 'deleteRange',\n value: function deleteRange(range) {\n this.run(function (postEditor) {\n var nextPosition = postEditor.deleteRange(range);\n postEditor.setRange(nextPosition);\n });\n }\n\n /**\n * @private\n */\n }, {\n key: 'performDelete',\n value: function performDelete() {\n var _ref4 = arguments.length <= 0 || arguments[0] === undefined ? { direction: _utilsKey.DIRECTION.BACKWARD, unit: 'char' } : arguments[0];\n\n var direction = _ref4.direction;\n var unit = _ref4.unit;\n var range = this.range;\n\n this.runCallbacks(CALLBACK_QUEUES.WILL_DELETE, [range, direction, unit]);\n if (range.isCollapsed) {\n this.deleteAtPosition(range.head, direction, { unit: unit });\n } else {\n this.deleteRange(range);\n }\n this.runCallbacks(CALLBACK_QUEUES.DID_DELETE, [range, direction, unit]);\n }\n }, {\n key: 'handleNewline',\n value: function handleNewline(event) {\n if (!this.hasCursor()) {\n return;\n }\n\n event.preventDefault();\n\n var range = this.range;\n\n this.run(function (postEditor) {\n var cursorSection = undefined;\n if (!range.isCollapsed) {\n var nextPosition = postEditor.deleteRange(range);\n cursorSection = nextPosition.section;\n if (cursorSection && cursorSection.isBlank) {\n postEditor.setRange(cursorSection.headPosition());\n return;\n }\n }\n cursorSection = postEditor.splitSection(range.head)[1];\n postEditor.setRange(cursorSection.headPosition());\n });\n }\n }, {\n key: 'showPrompt',\n value: function showPrompt(message, defaultValue, callback) {\n callback(window.prompt(message, defaultValue));\n }\n\n /**\n * Notify the editor that the post did change, and run associated\n * callbacks.\n * @private\n */\n }, {\n key: '_postDidChange',\n value: function _postDidChange() {\n this.runCallbacks(CALLBACK_QUEUES.POST_DID_CHANGE);\n }\n\n /**\n * Selects the given range or position. If given a collapsed range or a position, this positions the cursor\n * at the range's position. Otherwise a selection is created in the editor\n * surface encompassing the range.\n * @param {Range|Position} range\n */\n }, {\n key: 'selectRange',\n value: function selectRange(range) {\n range = (0, _utilsToRange['default'])(range);\n\n this.cursor.selectRange(range);\n this.range = range;\n }\n }, {\n key: '_readRangeFromDOM',\n value: function _readRangeFromDOM() {\n if (!this.isEditable) {\n return;\n }\n this.range = this.cursor.offsets;\n }\n }, {\n key: 'setPlaceholder',\n value: function setPlaceholder(placeholder) {\n (0, _utilsElementUtils.setData)(this.element, 'placeholder', placeholder);\n }\n }, {\n key: '_reparsePost',\n value: function _reparsePost() {\n var post = this._parser.parse(this.element);\n this.run(function (postEditor) {\n postEditor.removeAllSections();\n postEditor.migrateSectionsFromPost(post);\n postEditor.setRange(_utilsCursorRange['default'].blankRange());\n });\n\n this.runCallbacks(CALLBACK_QUEUES.DID_REPARSE);\n this._postDidChange();\n }\n }, {\n key: '_reparseSections',\n value: function _reparseSections() {\n var _this3 = this;\n\n var sections = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];\n\n var currentRange = undefined;\n sections.forEach(function (section) {\n _this3._parser.reparseSection(section, _this3._renderTree);\n });\n this._removeDetachedSections();\n\n if (this._renderTree.isDirty) {\n currentRange = this.range;\n }\n\n // force the current snapshot's range to remain the same rather than\n // rereading it from DOM after the new character is applied and the browser\n // updates the cursor position\n var range = this._editHistory._pendingSnapshot.range;\n this.run(function () {\n _this3._editHistory._pendingSnapshot.range = range;\n });\n this.rerender();\n if (currentRange) {\n this.selectRange(currentRange);\n }\n\n this.runCallbacks(CALLBACK_QUEUES.DID_REPARSE);\n this._postDidChange();\n }\n\n // FIXME this should be able to be removed now -- if any sections are detached,\n // it's due to a bug in the code.\n }, {\n key: '_removeDetachedSections',\n value: function _removeDetachedSections() {\n (0, _utilsArrayUtils.forEach)((0, _utilsArrayUtils.filter)(this.post.sections, function (s) {\n return !s.renderNode.isAttached();\n }), function (s) {\n return s.renderNode.scheduleForRemoval();\n });\n }\n\n /**\n * The sections from the cursor's selection start to the selection end\n * @type {Section[]}\n */\n }, {\n key: 'detectMarkupInRange',\n value: function detectMarkupInRange(range, markupTagName) {\n var markups = this.post.markupsInRange(range);\n return (0, _utilsArrayUtils.detect)(markups, function (markup) {\n return markup.hasTag(markupTagName);\n });\n }\n\n /**\n * @type {Markup[]}\n * @public\n */\n }, {\n key: 'hasActiveMarkup',\n\n /**\n * @param {Markup|String} markup A markup instance, or a string (e.g. \"b\")\n * @return {boolean}\n */\n value: function hasActiveMarkup(markup) {\n var matchesFn = undefined;\n if (typeof markup === 'string') {\n (function () {\n var tagName = (0, _utilsDomUtils.normalizeTagName)(markup);\n matchesFn = function (m) {\n return m.tagName === tagName;\n };\n })();\n } else {\n matchesFn = function (m) {\n return m === markup;\n };\n }\n\n return !!(0, _utilsArrayUtils.detect)(this.activeMarkups, matchesFn);\n }\n\n /**\n * @param {String} version The mobiledoc version to serialize to.\n * @return {Mobiledoc} Serialized mobiledoc\n * @public\n */\n }, {\n key: 'serialize',\n value: function serialize() {\n var version = arguments.length <= 0 || arguments[0] === undefined ? _renderersMobiledoc.MOBILEDOC_VERSION : arguments[0];\n\n return this.serializePost(this.post, 'mobiledoc', { version: version });\n }\n\n /**\n * Serialize the editor's post to the requested format.\n * Note that only mobiledoc format is lossless. If cards or atoms are present\n * in the post, the html and text formats will omit them in output because\n * the editor does not have access to the html and text versions of the\n * cards/atoms.\n * @param {string} format The format to serialize ('mobiledoc', 'text', 'html')\n * @return {Object|String} The editor's post, serialized to {format}\n * @public\n */\n }, {\n key: 'serializeTo',\n value: function serializeTo(format) {\n var post = this.post;\n return this.serializePost(post, format);\n }\n\n /**\n * @param {Post}\n * @param {String} format Same as {serializeTo}\n * @param {Object} [options]\n * @param {String} [options.version=MOBILEDOC_VERSION] version to serialize to\n * @return {Object|String}\n * @private\n */\n }, {\n key: 'serializePost',\n value: function serializePost(post, format) {\n var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];\n\n var validFormats = ['mobiledoc', 'html', 'text'];\n (0, _utilsAssert['default'])('Unrecognized serialization format ' + format, (0, _utilsArrayUtils.contains)(validFormats, format));\n\n if (format === 'mobiledoc') {\n var version = options.version || _renderersMobiledoc.MOBILEDOC_VERSION;\n return _renderersMobiledoc['default'].render(post, version);\n } else {\n var rendered = undefined;\n var mobiledoc = this.serializePost(post, 'mobiledoc');\n var unknownCardHandler = function unknownCardHandler() {};\n var unknownAtomHandler = function unknownAtomHandler() {};\n var rendererOptions = { unknownCardHandler: unknownCardHandler, unknownAtomHandler: unknownAtomHandler };\n\n switch (format) {\n case 'html':\n rendered = new _mobiledocHtmlRenderer['default'](rendererOptions).render(mobiledoc);\n return rendered.result;\n case 'text':\n rendered = new _mobiledocTextRenderer['default'](rendererOptions).render(mobiledoc);\n return rendered.result;\n }\n }\n }\n }, {\n key: 'addView',\n value: function addView(view) {\n this._views.push(view);\n }\n }, {\n key: 'removeAllViews',\n value: function removeAllViews() {\n this._views.forEach(function (v) {\n return v.destroy();\n });\n this._views = [];\n }\n\n /**\n * Whether the editor has a cursor (or a selected range).\n * It is possible for the editor to be focused but not have a selection.\n * In this case, key events will fire but the editor will not be able to\n * determine a cursor position, so they will be ignored.\n * @return {boolean}\n * @public\n */\n }, {\n key: 'hasCursor',\n value: function hasCursor() {\n return this.cursor.hasCursor();\n }\n\n /**\n * Tears down the editor's attached event listeners and views.\n * @public\n */\n }, {\n key: 'destroy',\n value: function destroy() {\n this.isDestroyed = true;\n if (this._hasSelection()) {\n this.cursor.clearSelection();\n }\n if (this._hasFocus()) {\n this.element.blur(); // FIXME This doesn't blur the element on IE11\n }\n this._mutationHandler.destroy();\n this._eventManager.destroy();\n this.removeAllViews();\n this._renderer.destroy();\n this._editState.destroy();\n }\n\n /**\n * Keep the user from directly editing the post using the keyboard and mouse.\n * Modification via the programmatic API is still permitted.\n * @see Editor#enableEditing\n * @public\n */\n }, {\n key: 'disableEditing',\n value: function disableEditing() {\n if (this.isEditable === false) {\n return;\n }\n\n this.isEditable = false;\n if (this.hasRendered) {\n this.element.setAttribute('contentEditable', false);\n this.setPlaceholder('');\n this.selectRange(_utilsCursorRange['default'].blankRange());\n }\n }\n\n /**\n * Allow the user to directly interact with editing a post via keyboard and mouse input.\n * Editor instances are editable by default. Use this method to re-enable\n * editing after disabling it.\n * @see Editor#disableEditing\n * @public\n */\n }, {\n key: 'enableEditing',\n value: function enableEditing() {\n this.isEditable = true;\n if (this.element) {\n this.element.setAttribute('contentEditable', true);\n this.setPlaceholder(this.placeholder);\n }\n }\n\n /**\n * Change a cardSection into edit mode\n * If called before the card has been rendered, it will be marked so that\n * it is rendered in edit mode when it gets rendered.\n * @param {CardSection} cardSection\n * @public\n */\n }, {\n key: 'editCard',\n value: function editCard(cardSection) {\n this._setCardMode(cardSection, _modelsCard.CARD_MODES.EDIT);\n }\n\n /**\n * Change a cardSection into display mode\n * If called before the card has been rendered, it will be marked so that\n * it is rendered in display mode when it gets rendered.\n * @param {CardSection} cardSection\n * @return undefined\n * @public\n */\n }, {\n key: 'displayCard',\n value: function displayCard(cardSection) {\n this._setCardMode(cardSection, _modelsCard.CARD_MODES.DISPLAY);\n }\n\n /**\n * Run a new post editing session. Yields a block with a new {@link PostEditor}\n * instance. This instance can be used to interact with the post abstract.\n * Rendering will be deferred until after the callback is completed.\n *\n * Usage:\n * ```\n * let markerRange = this.range;\n * editor.run((postEditor) => {\n * postEditor.deleteRange(markerRange);\n * // editing surface not updated yet\n * postEditor.schedule(() => {\n * console.log('logs during rerender flush');\n * });\n * // logging not yet flushed\n * });\n * // editing surface now updated.\n * // logging now flushed\n * ```\n *\n * @param {Function} callback Called with an instance of\n * {@link PostEditor} as its argument.\n * @return {Mixed} The return value of `callback`.\n * @public\n */\n }, {\n key: 'run',\n value: function run(callback) {\n var postEditor = new _post['default'](this);\n postEditor.begin();\n this._editHistory.snapshot();\n var result = callback(postEditor);\n this.runCallbacks(CALLBACK_QUEUES.DID_UPDATE, [postEditor]);\n postEditor.complete();\n this._readRangeFromDOM();\n\n if (postEditor._shouldCancelSnapshot) {\n this._editHistory._pendingSnapshot = null;\n }\n this._editHistory.storeSnapshot();\n\n return result;\n }\n\n /**\n * @param {Function} callback Called with `postEditor` as its argument.\n * @public\n */\n }, {\n key: 'didUpdatePost',\n value: function didUpdatePost(callback) {\n this.addCallback(CALLBACK_QUEUES.DID_UPDATE, callback);\n }\n\n /**\n * @param {Function} callback Called when the post has changed, either via\n * user input or programmatically. Use with {@link Editor#serialize} to\n * retrieve the post in portable mobiledoc format.\n */\n }, {\n key: 'postDidChange',\n value: function postDidChange(callback) {\n this.addCallback(CALLBACK_QUEUES.POST_DID_CHANGE, callback);\n }\n\n /**\n * Register a handler that will be invoked by the editor after the user enters\n * matching text.\n * @param {Object} inputHandler\n * @param {String} [inputHandler.text] Required if `match` is not provided\n * @param {RegExp} [inputHandler.match] Required if `text` is not provided\n * @param {Function} inputHandler.run This callback is invoked with the {@link Editor}\n * instance and an array of matches. If `text` was provided,\n * the matches array will equal [`text`], and if a `match`\n * regex was provided the matches array will be the result of\n * `match.exec` on the matching text. The callback is called\n * after the matching text has been inserted.\n * @public\n */\n }, {\n key: 'onTextInput',\n value: function onTextInput(inputHandler) {\n this._eventManager.registerInputHandler(inputHandler);\n }\n\n /**\n * @param {Function} callback Called when the editor's state (active markups or\n * active sections) has changed, either via user input or programmatically\n */\n }, {\n key: 'inputModeDidChange',\n value: function inputModeDidChange(callback) {\n this.addCallback(CALLBACK_QUEUES.INPUT_MODE_DID_CHANGE, callback);\n }\n\n /**\n * @param {Function} callback This callback will be called before the editor\n * is rendered.\n * @public\n */\n }, {\n key: 'willRender',\n value: function willRender(callback) {\n this.addCallback(CALLBACK_QUEUES.WILL_RENDER, callback);\n }\n\n /**\n * @param {Function} callback This callback will be called after the editor\n * is rendered.\n * @public\n */\n }, {\n key: 'didRender',\n value: function didRender(callback) {\n this.addCallback(CALLBACK_QUEUES.DID_RENDER, callback);\n }\n\n /**\n * @param {Function} callback This callback will be called before deleting.\n * @public\n */\n }, {\n key: 'willDelete',\n value: function willDelete(callback) {\n this.addCallback(CALLBACK_QUEUES.WILL_DELETE, callback);\n }\n\n /**\n * @param {Function} callback This callback will be called after deleting.\n * @public\n */\n }, {\n key: 'didDelete',\n value: function didDelete(callback) {\n this.addCallback(CALLBACK_QUEUES.DID_DELETE, callback);\n }\n\n /**\n * @param {Function} callback This callback will be called every time the cursor\n * position (or selection) changes.\n * @public\n */\n }, {\n key: 'cursorDidChange',\n value: function cursorDidChange(callback) {\n this.addCallback(CALLBACK_QUEUES.CURSOR_DID_CHANGE, callback);\n }\n }, {\n key: '_rangeDidChange',\n value: function _rangeDidChange() {\n if (this.hasRendered) {\n this.runCallbacks(CALLBACK_QUEUES.CURSOR_DID_CHANGE);\n }\n }\n }, {\n key: '_inputModeDidChange',\n value: function _inputModeDidChange() {\n this.runCallbacks(CALLBACK_QUEUES.INPUT_MODE_DID_CHANGE);\n }\n }, {\n key: '_insertEmptyMarkupSectionAtCursor',\n value: function _insertEmptyMarkupSectionAtCursor() {\n var _this4 = this;\n\n this.run(function (postEditor) {\n var section = postEditor.builder.createMarkupSection('p');\n postEditor.insertSectionBefore(_this4.post.sections, section);\n postEditor.setRange(section.toRange());\n });\n }\n\n /**\n * Toggles the given markup at the editor's current {@link Range}.\n * If the range is collapsed this changes the editor's state so that the\n * next characters typed will be affected. If there is text selected\n * (aka a non-collapsed range), the selections' markup will be toggled.\n * If the editor is not focused and has no active range, nothing happens.\n * @param {String} markup E.g. \"b\", \"em\", \"a\"\n * @public\n * @see PostEditor#toggleMarkup\n */\n }, {\n key: 'toggleMarkup',\n value: function toggleMarkup(markup) {\n markup = this.builder.createMarkup(markup);\n var range = this.range;\n\n if (range.isCollapsed) {\n this._editState.toggleMarkupState(markup);\n this._inputModeDidChange();\n\n // when clicking a button to toggle markup, the button can end up being focused,\n // so ensure the editor is focused\n this._ensureFocus();\n } else {\n this.run(function (postEditor) {\n return postEditor.toggleMarkup(markup, range);\n });\n }\n }\n\n // If the editor has a selection but is not focused, focus it\n }, {\n key: '_ensureFocus',\n value: function _ensureFocus() {\n if (this._hasSelection() && !this._hasFocus()) {\n this.focus();\n }\n }\n }, {\n key: 'focus',\n value: function focus() {\n this.element.focus();\n }\n\n /**\n * Whether there is a selection inside the editor's element.\n * It's possible to have a selection but not have focus.\n * @see #_hasFocus\n * @return {Boolean}\n */\n }, {\n key: '_hasSelection',\n value: function _hasSelection() {\n var cursor = this.cursor;\n\n return this.hasRendered && (cursor._hasCollapsedSelection() || cursor._hasSelection());\n }\n\n /**\n * Whether the editor's element is focused\n * It's possible to be focused but have no selection\n * @see #_hasSelection\n * @return {Boolean}\n */\n }, {\n key: '_hasFocus',\n value: function _hasFocus() {\n return document.activeElement === this.element;\n }\n\n /**\n * Toggles the tagName for the current active section(s). This will skip\n * non-markerable sections. E.g. if the editor's range includes a \"P\" MarkupSection\n * and a CardSection, only the MarkupSection will be toggled.\n * @param {String} tagName The new tagname to change to.\n * @public\n * @see PostEditor#toggleSection\n */\n }, {\n key: 'toggleSection',\n value: function toggleSection(tagName) {\n var _this5 = this;\n\n this.run(function (postEditor) {\n return postEditor.toggleSection(tagName, _this5.range);\n });\n }\n\n /**\n * Finds and runs the first matching key command for the event\n *\n * If multiple commands are bound to a key combination, the\n * first matching one is run.\n *\n * If a command returns `false` then the next matching command\n * is run instead.\n *\n * @param {Event} event The keyboard event triggered by the user\n * @return {Boolean} true when a command was successfully run\n * @private\n */\n }, {\n key: 'handleKeyCommand',\n value: function handleKeyCommand(event) {\n var keyCommands = (0, _keyCommands.findKeyCommands)(this.keyCommands, event);\n for (var i = 0; i < keyCommands.length; i++) {\n var keyCommand = keyCommands[i];\n if (keyCommand.run(this) !== false) {\n event.preventDefault();\n return true;\n }\n }\n return false;\n }\n\n /**\n * Inserts the text at the current cursor position. If the editor has\n * no current cursor position, nothing will be inserted. If the editor's\n * range is not collapsed, it will be deleted before insertion.\n *\n * @param {String} text\n * @public\n */\n }, {\n key: 'insertText',\n value: function insertText(text) {\n if (!this.hasCursor()) {\n return;\n }\n if (this.post.isBlank) {\n this._insertEmptyMarkupSectionAtCursor();\n }\n var activeMarkups = this.activeMarkups;\n var range = this.range;\n var position = this.range.head;\n\n this.run(function (postEditor) {\n if (!range.isCollapsed) {\n position = postEditor.deleteRange(range);\n }\n\n postEditor.insertTextWithMarkup(position, text, activeMarkups);\n });\n }\n\n /**\n * Inserts an atom at the current cursor position. If the editor has\n * no current cursor position, nothing will be inserted. If the editor's\n * range is not collapsed, it will be deleted before insertion.\n * @param {String} atomName\n * @param {String} [atomText='']\n * @param {Object} [atomPayload={}]\n * @return {Atom} The inserted atom.\n * @public\n */\n }, {\n key: 'insertAtom',\n value: function insertAtom(atomName) {\n var atomText = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];\n var atomPayload = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];\n\n if (!this.hasCursor()) {\n return;\n }\n if (this.post.isBlank) {\n this._insertEmptyMarkupSectionAtCursor();\n }\n\n var atom = undefined;\n var range = this.range;\n\n this.run(function (postEditor) {\n var position = range.head;\n\n atom = postEditor.builder.createAtom(atomName, atomText, atomPayload);\n if (!range.isCollapsed) {\n position = postEditor.deleteRange(range);\n }\n\n postEditor.insertMarkers(position, [atom]);\n });\n return atom;\n }\n\n /**\n * Inserts a card at the section after the current cursor position. If the editor has\n * no current cursor position, nothing will be inserted. If the editor's\n * range is not collapsed, it will be deleted before insertion. If the cursor is in\n * a blank section, it will be replaced with a card section.\n * The editor's cursor will be placed at the end of the inserted card.\n * @param {String} cardName\n * @param {Object} [cardPayload={}]\n * @param {Boolean} [inEditMode=false] Whether the card should be inserted in edit mode.\n * @return {Card} The inserted Card section.\n * @public\n */\n }, {\n key: 'insertCard',\n value: function insertCard(cardName) {\n var _this6 = this;\n\n var cardPayload = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n var inEditMode = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];\n\n if (!this.hasCursor()) {\n return;\n }\n if (this.post.isBlank) {\n this._insertEmptyMarkupSectionAtCursor();\n }\n\n var card = undefined;\n var range = this.range;\n\n this.run(function (postEditor) {\n var position = range.tail;\n card = postEditor.builder.createCardSection(cardName, cardPayload);\n if (inEditMode) {\n _this6.editCard(card);\n }\n\n if (!range.isCollapsed) {\n position = postEditor.deleteRange(range);\n }\n\n var section = position.section;\n if (section.isNested) {\n section = section.parent;\n }\n\n if (section.isBlank) {\n postEditor.replaceSection(section, card);\n } else {\n var collection = _this6.post.sections;\n postEditor.insertSectionBefore(collection, card, section.next);\n }\n\n // It is important to explicitly set the range to the end of the card.\n // Otherwise it is possible to create an inconsistent state in the\n // browser. For instance, if the user clicked a button that\n // called `editor.insertCard`, the editor surface may retain\n // the selection but lose focus, and the next keystroke by the user\n // will cause an unexpected DOM mutation (which can wipe out the\n // card).\n // See: https://github.com/bustlelabs/mobiledoc-kit/issues/286\n postEditor.setRange(card.tailPosition());\n });\n return card;\n }\n\n /**\n * @param {integer} x x-position in viewport\n * @param {integer} y y-position in viewport\n * @return {Position|null}\n */\n }, {\n key: 'positionAtPoint',\n value: function positionAtPoint(x, y) {\n return _utilsCursorPosition['default'].atPoint(x, y, this);\n }\n\n /**\n * @private\n */\n }, {\n key: '_setCardMode',\n value: function _setCardMode(cardSection, mode) {\n var renderNode = cardSection.renderNode;\n if (renderNode && renderNode.isRendered) {\n var cardNode = renderNode.cardNode;\n cardNode[mode]();\n } else {\n cardSection.setInitialMode(mode);\n }\n }\n }, {\n key: 'triggerEvent',\n value: function triggerEvent(context, eventName, event) {\n this._eventManager._trigger(context, eventName, event);\n }\n }, {\n key: 'addCallback',\n value: function addCallback() {\n var _callbacks;\n\n (_callbacks = this._callbacks).addCallback.apply(_callbacks, arguments);\n }\n }, {\n key: 'addCallbackOnce',\n value: function addCallbackOnce() {\n var _callbacks2;\n\n (_callbacks2 = this._callbacks).addCallbackOnce.apply(_callbacks2, arguments);\n }\n }, {\n key: 'runCallbacks',\n value: function runCallbacks() {\n var _callbacks3;\n\n if (this.isDestroyed) {\n // TODO warn that callback attempted after editor was destroyed\n return;\n }\n (_callbacks3 = this._callbacks).runCallbacks.apply(_callbacks3, arguments);\n }\n }, {\n key: 'builder',\n get: function get() {\n if (!this._builder) {\n this._builder = new _modelsPostNodeBuilder['default']();\n }\n return this._builder;\n }\n }, {\n key: 'keyCommands',\n get: function get() {\n if (!this._keyCommands) {\n this._keyCommands = [];\n }\n return this._keyCommands;\n }\n }, {\n key: 'cursor',\n get: function get() {\n return new _utilsCursor['default'](this);\n }\n\n /**\n * Return the current range for the editor (may be cached).\n * @return {Range}\n */\n }, {\n key: 'range',\n get: function get() {\n return this._editState.range;\n },\n set: function set(newRange) {\n this._editState.updateRange(newRange);\n\n if (this._editState.rangeDidChange()) {\n this._rangeDidChange();\n }\n\n if (this._editState.inputModeDidChange()) {\n this._inputModeDidChange();\n }\n }\n }, {\n key: 'activeSections',\n get: function get() {\n return this._editState.activeSections;\n }\n }, {\n key: 'activeSection',\n get: function get() {\n var activeSections = this.activeSections;\n\n return activeSections[activeSections.length - 1];\n }\n }, {\n key: 'activeMarkups',\n get: function get() {\n return this._editState.activeMarkups;\n }\n }]);\n\n return Editor;\n})();\n\nexports['default'] = Editor;","'use strict';\n\nvar _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _utilsAssert = require('../utils/assert');\n\nvar _utilsParseUtils = require('../utils/parse-utils');\n\nvar _utilsArrayUtils = require('../utils/array-utils');\n\nvar _utilsKey = require('../utils/key');\n\nvar _utilsCharacters = require('../utils/characters');\n\nvar _editorTextInputHandler = require('../editor/text-input-handler');\n\nvar _editorSelectionManager = require('../editor/selection-manager');\n\nvar _utilsBrowser = require('../utils/browser');\n\nvar ELEMENT_EVENT_TYPES = ['keydown', 'keyup', 'cut', 'copy', 'paste', 'keypress', 'drop'];\n\nvar EventManager = (function () {\n function EventManager(editor) {\n _classCallCheck(this, EventManager);\n\n this.editor = editor;\n this.logger = editor.loggerFor('event-manager');\n this._textInputHandler = new _editorTextInputHandler['default'](editor);\n this._listeners = [];\n this.modifierKeys = {\n shift: false,\n alt: false,\n ctrl: false\n };\n\n this._selectionManager = new _editorSelectionManager['default'](this.editor, this.selectionDidChange.bind(this));\n }\n\n _createClass(EventManager, [{\n key: 'init',\n value: function init() {\n var _this = this;\n\n var element = this.editor.element;\n\n (0, _utilsAssert['default'])('Cannot init EventManager without element', !!element);\n\n ELEMENT_EVENT_TYPES.forEach(function (type) {\n _this._addListener(element, type);\n });\n\n this._selectionManager.start();\n }\n }, {\n key: 'registerInputHandler',\n value: function registerInputHandler(inputHandler) {\n this._textInputHandler.register(inputHandler);\n }\n }, {\n key: '_addListener',\n value: function _addListener(context, type) {\n var _this2 = this;\n\n (0, _utilsAssert['default'])('Missing listener for ' + type, !!this[type]);\n\n var listener = function listener(event) {\n return _this2._handleEvent(type, event);\n };\n context.addEventListener(type, listener);\n this._listeners.push([context, type, listener]);\n }\n }, {\n key: '_removeListeners',\n value: function _removeListeners() {\n this._listeners.forEach(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 3);\n\n var context = _ref2[0];\n var type = _ref2[1];\n var listener = _ref2[2];\n\n context.removeEventListener(type, listener);\n });\n this._listeners = [];\n }\n\n // This is primarily useful for programmatically simulating events on the\n // editor from the tests.\n }, {\n key: '_trigger',\n value: function _trigger(context, type, event) {\n (0, _utilsArrayUtils.forEach)((0, _utilsArrayUtils.filter)(this._listeners, function (_ref3) {\n var _ref32 = _slicedToArray(_ref3, 2);\n\n var _context = _ref32[0];\n var _type = _ref32[1];\n\n return _context === context && _type === type;\n }), function (_ref4) {\n var _ref42 = _slicedToArray(_ref4, 3);\n\n var context = _ref42[0];\n var type = _ref42[1];\n var listener = _ref42[2];\n\n listener.call(context, event);\n });\n }\n }, {\n key: 'destroy',\n value: function destroy() {\n this._textInputHandler.destroy();\n this._selectionManager.destroy();\n this._removeListeners();\n }\n }, {\n key: '_handleEvent',\n value: function _handleEvent(type, event) {\n var element = event.target;\n\n if (!this.isElementAddressable(element)) {\n // abort handling this event\n return true;\n }\n\n this[type](event);\n }\n }, {\n key: 'isElementAddressable',\n value: function isElementAddressable(element) {\n return this.editor.cursor.isAddressable(element);\n }\n }, {\n key: 'selectionDidChange',\n value: function selectionDidChange(selection /*, prevSelection */) {\n var shouldNotify = true;\n var anchorNode = selection.anchorNode;\n\n if (!this.isElementAddressable(anchorNode)) {\n if (!this.editor.range.isBlank) {\n // Selection changed from something addressable to something\n // not-addressable -- e.g., blur event, user clicked outside editor,\n // etc\n shouldNotify = true;\n } else {\n // selection changes wholly outside the editor should not trigger\n // change notifications\n shouldNotify = false;\n }\n }\n\n if (shouldNotify) {\n this.editor._readRangeFromDOM();\n }\n }\n }, {\n key: 'keypress',\n value: function keypress(event) {\n var editor = this.editor;\n var _textInputHandler = this._textInputHandler;\n\n if (!editor.hasCursor()) {\n return;\n }\n\n var key = _utilsKey['default'].fromEvent(event);\n if (!key.isPrintable()) {\n return;\n } else {\n event.preventDefault();\n }\n\n _textInputHandler.handle(key.toString());\n }\n }, {\n key: 'keydown',\n value: function keydown(event) {\n var editor = this.editor;\n\n if (!editor.hasCursor()) {\n return;\n }\n if (!editor.isEditable) {\n return;\n }\n\n var key = _utilsKey['default'].fromEvent(event);\n this._updateModifiersFromKey(key, { isDown: true });\n\n if (editor.handleKeyCommand(event)) {\n return;\n }\n\n if (editor.post.isBlank) {\n editor._insertEmptyMarkupSectionAtCursor();\n }\n\n var range = editor.range;\n\n switch (true) {\n // FIXME This should be restricted to only card/atom boundaries\n case key.isHorizontalArrowWithoutModifiersOtherThanShift():\n var newRange = undefined;\n if (key.isShift()) {\n newRange = range.extend(key.direction * 1);\n } else {\n newRange = range.move(key.direction);\n }\n\n editor.selectRange(newRange);\n event.preventDefault();\n break;\n case key.isDelete():\n var direction = key.direction;\n\n var unit = 'char';\n if (this.modifierKeys.alt && _utilsBrowser['default'].isMac()) {\n unit = 'word';\n } else if (this.modifierKeys.ctrl && _utilsBrowser['default'].isWin()) {\n unit = 'word';\n }\n editor.performDelete({ direction: direction, unit: unit });\n event.preventDefault();\n break;\n case key.isEnter():\n editor.handleNewline(event);\n break;\n case key.isTab():\n event.preventDefault();\n editor.insertText(_utilsCharacters.TAB);\n break;\n }\n }\n }, {\n key: 'keyup',\n value: function keyup(event) {\n var editor = this.editor;\n\n if (!editor.hasCursor()) {\n return;\n }\n var key = _utilsKey['default'].fromEvent(event);\n this._updateModifiersFromKey(key, { isDown: false });\n }\n }, {\n key: 'cut',\n value: function cut(event) {\n event.preventDefault();\n\n this.copy(event);\n this.editor.performDelete();\n }\n }, {\n key: 'copy',\n value: function copy(event) {\n event.preventDefault();\n\n var editor = this.editor;\n var _editor = this.editor;\n var range = _editor.range;\n var post = _editor.post;\n\n post = post.trimTo(range);\n\n var data = {\n html: editor.serializePost(post, 'html'),\n text: editor.serializePost(post, 'text'),\n mobiledoc: editor.serializePost(post, 'mobiledoc')\n };\n\n (0, _utilsParseUtils.setClipboardData)(event, data, window);\n }\n }, {\n key: 'paste',\n value: function paste(event) {\n event.preventDefault();\n\n var editor = this.editor;\n\n var range = editor.range;\n\n if (!range.isCollapsed) {\n editor.performDelete();\n }\n var position = editor.range.head;\n var targetFormat = this.modifierKeys.shift ? 'text' : 'html';\n var pastedPost = (0, _utilsParseUtils.parsePostFromPaste)(event, editor, { targetFormat: targetFormat });\n\n editor.run(function (postEditor) {\n var nextPosition = postEditor.insertPost(position, pastedPost);\n postEditor.setRange(nextPosition);\n });\n }\n }, {\n key: 'drop',\n value: function drop(event) {\n event.preventDefault();\n\n var x = event.clientX;\n var y = event.clientY;\n var editor = this.editor;\n\n var position = editor.positionAtPoint(x, y);\n if (!position) {\n this.logger.log('Could not find drop position');\n return;\n }\n\n var post = (0, _utilsParseUtils.parsePostFromDrop)(event, editor, { logger: this.logger });\n if (!post) {\n this.logger.log('Could not determine post from drop event');\n return;\n }\n\n editor.run(function (postEditor) {\n var nextPosition = postEditor.insertPost(position, post);\n postEditor.setRange(nextPosition);\n });\n }\n }, {\n key: '_updateModifiersFromKey',\n value: function _updateModifiersFromKey(key, _ref5) {\n var isDown = _ref5.isDown;\n\n if (key.isShiftKey()) {\n this.modifierKeys.shift = isDown;\n } else if (key.isAltKey()) {\n this.modifierKeys.alt = isDown;\n } else if (key.isCtrlKey()) {\n this.modifierKeys.ctrl = isDown;\n }\n }\n }]);\n\n return EventManager;\n})();\n\nexports['default'] = EventManager;","'use strict';\n\nexports.buildKeyCommand = buildKeyCommand;\nexports.validateKeyCommand = validateKeyCommand;\nexports.findKeyCommands = findKeyCommands;\n\nfunction _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }\n\nvar _utilsKey = require('../utils/key');\n\nvar _utilsArrayUtils = require('../utils/array-utils');\n\nvar _utilsAssert = require('../utils/assert');\n\nvar _utilsBrowser = require('../utils/browser');\n\nfunction selectAll(editor) {\n var post = editor.post;\n\n editor.selectRange(post.toRange());\n}\n\nfunction gotoStartOfLine(editor) {\n var range = editor.range;\n var section = range.tail.section;\n\n editor.run(function (postEditor) {\n postEditor.setRange(section.headPosition());\n });\n}\n\nfunction gotoEndOfLine(editor) {\n var range = editor.range;\n var section = range.tail.section;\n\n editor.run(function (postEditor) {\n postEditor.setRange(section.tailPosition());\n });\n}\n\nfunction deleteToEndOfSection(editor) {\n var range = editor.range;\n\n if (range.isCollapsed) {\n var _range = range;\n var head = _range.head;\n var section = _range.head.section;\n\n range = head.toRange(section.tailPosition());\n }\n editor.run(function (postEditor) {\n var nextPosition = postEditor.deleteRange(range);\n postEditor.setRange(nextPosition);\n });\n}\n\nfunction toggleLink(editor) {\n if (editor.range.isCollapsed) {\n return;\n }\n\n var selectedText = editor.cursor.selectedText();\n var defaultUrl = '';\n if (selectedText.indexOf('http') !== -1) {\n defaultUrl = selectedText;\n }\n\n var range = editor.range;\n\n var hasLink = editor.detectMarkupInRange(range, 'a');\n\n if (hasLink) {\n editor.run(function (postEditor) {\n return postEditor.toggleMarkup('a');\n });\n } else {\n editor.showPrompt('Enter a URL', defaultUrl, function (url) {\n if (!url) {\n return;\n }\n\n editor.run(function (postEditor) {\n var markup = postEditor.builder.createMarkup('a', { href: url });\n postEditor.toggleMarkup(markup);\n });\n });\n }\n}\n\nvar DEFAULT_KEY_COMMANDS = [{\n str: 'META+B',\n run: function run(editor) {\n editor.toggleMarkup('strong');\n }\n}, {\n str: 'CTRL+B',\n run: function run(editor) {\n editor.toggleMarkup('strong');\n }\n}, {\n str: 'META+I',\n run: function run(editor) {\n editor.toggleMarkup('em');\n }\n}, {\n str: 'CTRL+I',\n run: function run(editor) {\n editor.toggleMarkup('em');\n }\n}, {\n str: 'CTRL+K',\n run: function run(editor) {\n if (_utilsBrowser['default'].isMac()) {\n return deleteToEndOfSection(editor);\n } else if (_utilsBrowser['default'].isWin()) {\n return toggleLink(editor);\n }\n }\n}, {\n str: 'CTRL+A',\n run: function run(editor) {\n if (_utilsBrowser['default'].isMac()) {\n gotoStartOfLine(editor);\n } else {\n selectAll(editor);\n }\n }\n}, {\n str: 'META+A',\n run: function run(editor) {\n if (_utilsBrowser['default'].isMac()) {\n selectAll(editor);\n }\n }\n}, {\n str: 'CTRL+E',\n run: function run(editor) {\n if (_utilsBrowser['default'].isMac()) {\n gotoEndOfLine(editor);\n }\n }\n}, {\n str: 'META+K',\n run: function run(editor) {\n return toggleLink(editor);\n }\n\n}, {\n str: 'META+Z',\n run: function run(editor) {\n editor.run(function (postEditor) {\n postEditor.undoLastChange();\n });\n }\n}, {\n str: 'META+SHIFT+Z',\n run: function run(editor) {\n editor.run(function (postEditor) {\n postEditor.redoLastChange();\n });\n }\n}, {\n str: 'CTRL+Z',\n run: function run(editor) {\n if (_utilsBrowser['default'].isMac()) {\n return false;\n }\n editor.run(function (postEditor) {\n return postEditor.undoLastChange();\n });\n }\n}, {\n str: 'CTRL+SHIFT+Z',\n run: function run(editor) {\n if (_utilsBrowser['default'].isMac()) {\n return false;\n }\n editor.run(function (postEditor) {\n return postEditor.redoLastChange();\n });\n }\n}];\n\nexports.DEFAULT_KEY_COMMANDS = DEFAULT_KEY_COMMANDS;\nfunction modifierNamesToMask(modiferNames) {\n var defaultVal = 0;\n return (0, _utilsArrayUtils.reduce)(modiferNames, function (sum, name) {\n var modifier = _utilsKey.MODIFIERS[name.toUpperCase()];\n (0, _utilsAssert['default'])('No modifier named \"' + name + '\" found', !!modifier);\n return sum + modifier;\n }, defaultVal);\n}\n\nfunction characterToCode(character) {\n var upperCharacter = character.toUpperCase();\n var special = _utilsKey.SPECIAL_KEYS[upperCharacter];\n if (special) {\n return special;\n } else {\n (0, _utilsAssert['default'])('Only 1 character can be used in a key command str (got \"' + character + '\")', character.length === 1);\n return upperCharacter.charCodeAt(0);\n }\n}\n\nfunction buildKeyCommand(keyCommand) {\n var str = keyCommand.str;\n\n if (!str) {\n return keyCommand;\n }\n (0, _utilsAssert['default'])('[deprecation] Key commands no longer use the `modifier` property', !keyCommand.modifier);\n\n var _str$split$reverse = str.split('+').reverse();\n\n var _str$split$reverse2 = _toArray(_str$split$reverse);\n\n var character = _str$split$reverse2[0];\n\n var modifierNames = _str$split$reverse2.slice(1);\n\n keyCommand.modifierMask = modifierNamesToMask(modifierNames);\n keyCommand.code = characterToCode(character);\n\n return keyCommand;\n}\n\nfunction validateKeyCommand(keyCommand) {\n return !!keyCommand.code && !!keyCommand.run;\n}\n\nfunction findKeyCommands(keyCommands, keyEvent) {\n var key = _utilsKey['default'].fromEvent(keyEvent);\n\n return (0, _utilsArrayUtils.filter)(keyCommands, function (_ref) {\n var modifierMask = _ref.modifierMask;\n var code = _ref.code;\n\n return key.keyCode === code && key.modifierMask === modifierMask;\n });\n}","'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _utilsSet = require('../utils/set');\n\nvar _utilsArrayUtils = require('../utils/array-utils');\n\nvar _utilsAssert = require('../utils/assert');\n\nvar _utilsDomUtils = require('../utils/dom-utils');\n\nvar MUTATION = {\n NODES_CHANGED: 'childList',\n CHARACTER_DATA: 'characterData'\n};\n\nvar MutationHandler = (function () {\n function MutationHandler(editor) {\n var _this = this;\n\n _classCallCheck(this, MutationHandler);\n\n this.editor = editor;\n this.logger = editor.loggerFor('mutation-handler');\n this.renderTree = null;\n this._isObserving = false;\n\n this._observer = new MutationObserver(function (mutations) {\n _this._handleMutations(mutations);\n });\n }\n\n _createClass(MutationHandler, [{\n key: 'init',\n value: function init() {\n this.startObserving();\n }\n }, {\n key: 'destroy',\n value: function destroy() {\n this.stopObserving();\n this._observer = null;\n }\n }, {\n key: 'suspendObservation',\n value: function suspendObservation(callback) {\n this.stopObserving();\n callback();\n this.startObserving();\n }\n }, {\n key: 'stopObserving',\n value: function stopObserving() {\n if (this._isObserving) {\n this._isObserving = false;\n this._observer.disconnect();\n }\n }\n }, {\n key: 'startObserving',\n value: function startObserving() {\n if (!this._isObserving) {\n var editor = this.editor;\n\n (0, _utilsAssert['default'])('Cannot observe un-rendered editor', editor.hasRendered);\n\n this._isObserving = true;\n this.renderTree = editor._renderTree;\n\n this._observer.observe(editor.element, {\n characterData: true,\n childList: true,\n subtree: true\n });\n }\n }\n }, {\n key: 'reparsePost',\n value: function reparsePost() {\n this.editor._reparsePost();\n }\n }, {\n key: 'reparseSections',\n value: function reparseSections(sections) {\n this.editor._reparseSections(sections);\n }\n\n /**\n * for each mutation:\n * * find the target nodes:\n * * if nodes changed, target nodes are:\n * * added nodes\n * * the target from which removed nodes were removed\n * * if character data changed\n * * target node is the mutation event's target (text node)\n * * filter out nodes that are no longer attached (parentNode is null)\n * * for each remaining node:\n * * find its section, add to sections-to-reparse\n * * if no section, reparse all (and break)\n */\n }, {\n key: '_handleMutations',\n value: function _handleMutations(mutations) {\n var reparsePost = false;\n var sections = new _utilsSet['default']();\n\n for (var i = 0; i < mutations.length; i++) {\n if (reparsePost) {\n break;\n }\n\n var nodes = this._findTargetNodes(mutations[i]);\n\n for (var j = 0; j < nodes.length; j++) {\n var node = nodes[j];\n var renderNode = this._findRenderNodeFromNode(node);\n if (renderNode) {\n if (renderNode.reparsesMutationOfChildNode(node)) {\n var section = this._findSectionFromRenderNode(renderNode);\n if (section) {\n sections.add(section);\n } else {\n reparsePost = true;\n }\n }\n } else {\n reparsePost = true;\n break;\n }\n }\n }\n\n if (reparsePost) {\n this.logger.log('reparsePost (' + mutations.length + ' mutations)');\n this.reparsePost();\n } else if (sections.length) {\n this.logger.log('reparse ' + sections.length + ' sections (' + mutations.length + ' mutations)');\n this.reparseSections(sections.toArray());\n }\n }\n }, {\n key: '_findTargetNodes',\n value: function _findTargetNodes(mutation) {\n var nodes = [];\n\n switch (mutation.type) {\n case MUTATION.CHARACTER_DATA:\n nodes.push(mutation.target);\n break;\n case MUTATION.NODES_CHANGED:\n (0, _utilsArrayUtils.forEach)(mutation.addedNodes, function (n) {\n return nodes.push(n);\n });\n if (mutation.removedNodes.length) {\n nodes.push(mutation.target);\n }\n break;\n }\n\n var element = this.editor.element;\n var attachedNodes = (0, _utilsArrayUtils.filter)(nodes, function (node) {\n return (0, _utilsDomUtils.containsNode)(element, node);\n });\n return attachedNodes;\n }\n }, {\n key: '_findSectionRenderNodeFromNode',\n value: function _findSectionRenderNodeFromNode(node) {\n return this.renderTree.findRenderNodeFromElement(node, function (rn) {\n return rn.postNode.isSection;\n });\n }\n }, {\n key: '_findRenderNodeFromNode',\n value: function _findRenderNodeFromNode(node) {\n return this.renderTree.findRenderNodeFromElement(node);\n }\n }, {\n key: '_findSectionFromRenderNode',\n value: function _findSectionFromRenderNode(renderNode) {\n var sectionRenderNode = this._findSectionRenderNodeFromNode(renderNode.element);\n return sectionRenderNode && sectionRenderNode.postNode;\n }\n }]);\n\n return MutationHandler;\n})();\n\nexports['default'] = MutationHandler;","'use strict';\n\nvar _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _utilsCursorPosition = require('../utils/cursor/position');\n\nvar _utilsCursorRange = require('../utils/cursor/range');\n\nvar _utilsArrayUtils = require('../utils/array-utils');\n\nvar _utilsKey = require('../utils/key');\n\nvar _modelsLifecycleCallbacks = require('../models/lifecycle-callbacks');\n\nvar _utilsAssert = require('../utils/assert');\n\nvar _utilsDomUtils = require('../utils/dom-utils');\n\nvar _postPostInserter = require('./post/post-inserter');\n\nvar _utilsDeprecate = require('../utils/deprecate');\n\nvar _utilsToRange = require('../utils/to-range');\n\nvar FORWARD = _utilsKey.DIRECTION.FORWARD;\nvar BACKWARD = _utilsKey.DIRECTION.BACKWARD;\n\nfunction isListSectionTagName(tagName) {\n return tagName === 'ul' || tagName === 'ol';\n}\n\nvar CALLBACK_QUEUES = {\n BEFORE_COMPLETE: 'beforeComplete',\n COMPLETE: 'complete',\n AFTER_COMPLETE: 'afterComplete'\n};\n\n/**\n * The PostEditor is used to modify a post. It should not be instantiated directly.\n * Instead, a new instance of a PostEditor is created by the editor and passed\n * as the argument to the callback in {@link Editor#run}.\n *\n * Usage:\n * ```\n * editor.run((postEditor) => {\n * // postEditor is an instance of PostEditor that can operate on the\n * // editor's post\n * });\n * ```\n */\n\nvar PostEditor = (function () {\n /**\n * @private\n */\n\n function PostEditor(editor) {\n var _this = this;\n\n _classCallCheck(this, PostEditor);\n\n this.editor = editor;\n this.builder = this.editor.builder;\n this._callbacks = new _modelsLifecycleCallbacks['default']((0, _utilsArrayUtils.values)(CALLBACK_QUEUES));\n\n this._didComplete = false;\n\n this._renderRange = function () {\n return _this.editor.selectRange(_this._range);\n };\n this._postDidChange = function () {\n return _this.editor._postDidChange();\n };\n this._rerender = function () {\n return _this.editor.rerender();\n };\n }\n\n _createClass(PostEditor, [{\n key: 'addCallback',\n value: function addCallback() {\n var _callbacks;\n\n (_callbacks = this._callbacks).addCallback.apply(_callbacks, arguments);\n }\n }, {\n key: 'addCallbackOnce',\n value: function addCallbackOnce() {\n var _callbacks2;\n\n (_callbacks2 = this._callbacks).addCallbackOnce.apply(_callbacks2, arguments);\n }\n }, {\n key: 'runCallbacks',\n value: function runCallbacks() {\n var _callbacks3;\n\n (_callbacks3 = this._callbacks).runCallbacks.apply(_callbacks3, arguments);\n }\n }, {\n key: 'begin',\n value: function begin() {\n // cache the editor's range\n this._range = this.editor.range;\n }\n\n /**\n * Schedules to select the given range on the editor after the postEditor\n * has completed its work. This also updates the postEditor's active range\n * (so that multiple calls to range-changing methods on the postEditor will\n * update the correct range).\n *\n * Usage:\n * let range = editor.range;\n * editor.run(postEditor => {\n * let nextPosition = postEditor.deleteRange(range);\n *\n * // Will position the editor's cursor at `nextPosition` after\n * // the postEditor finishes work and the editor rerenders.\n * postEditor.setRange(nextPosition);\n * });\n * @param {Range|Position} range\n * @public\n */\n }, {\n key: 'setRange',\n value: function setRange(range) {\n range = (0, _utilsToRange['default'])(range);\n\n // TODO validate that the range is valid\n // (does not contain marked-for-removal head or tail sections?)\n this._range = range;\n this.scheduleAfterRender(this._renderRange, true);\n }\n\n /**\n * Delete a range from the post\n *\n * Usage:\n * ```\n * let { range } = editor;\n * editor.run((postEditor) => {\n * let nextPosition = postEditor.deleteRange(range);\n * postEditor.setRange(nextPosition);\n * });\n * ```\n * @param {Range} range Cursor Range object with head and tail Positions\n * @return {Position} The position where the cursor would go after deletion\n * @public\n */\n }, {\n key: 'deleteRange',\n value: function deleteRange(range) {\n (0, _utilsAssert['default'])(\"Must pass MobiledocKit Range to `deleteRange`\", range instanceof _utilsCursorRange['default']);\n\n var head = range.head;\n var headSection = range.head.section;\n var tail = range.tail;\n var tailSection = range.tail.section;\n var post = this.editor.post;\n\n if (headSection === tailSection) {\n return this.cutSection(headSection, head, tail);\n }\n\n var nextSection = headSection.nextLeafSection();\n\n var nextPos = this.cutSection(headSection, head, headSection.tailPosition());\n // cutSection can replace the section, so re-read headSection here\n headSection = nextPos.section;\n\n // Remove sections in the middle of the range\n while (nextSection !== tailSection) {\n var tmp = nextSection;\n nextSection = nextSection.nextLeafSection();\n this.removeSection(tmp);\n }\n\n var tailPos = this.cutSection(tailSection, tailSection.headPosition(), tail);\n // cutSection can replace the section, so re-read tailSection here\n tailSection = tailPos.section;\n\n if (tailSection.isBlank) {\n this.removeSection(tailSection);\n } else {\n // If head and tail sections are markerable, join them\n // Note: They may not be the same section type. E.g. this may join\n // a tail section that was a list item onto a markup section, or vice versa.\n // (This is the desired behavior.)\n if (headSection.isMarkerable && tailSection.isMarkerable) {\n headSection.join(tailSection);\n this._markDirty(headSection);\n this.removeSection(tailSection);\n } else if (headSection.isBlank) {\n this.removeSection(headSection);\n nextPos = tailPos;\n }\n }\n\n if (post.isBlank) {\n post.sections.append(this.builder.createMarkupSection('p'));\n nextPos = post.headPosition();\n }\n\n return nextPos;\n }\n\n /**\n * Note: This method may replace `section` with a different section.\n *\n * \"Cut\" out the part of the section inside `headOffset` and `tailOffset`.\n * If section is markerable this splits markers that straddle the head or tail (if necessary),\n * and removes markers that are wholly inside the offsets.\n * If section is a card, this may replace it with a blank markup section if the\n * positions contain the entire card.\n *\n * @param {Section} section\n * @param {Position} head\n * @param {Position} tail\n * @return {Position}\n * @private\n */\n }, {\n key: 'cutSection',\n value: function cutSection(section, head, tail) {\n var _this2 = this;\n\n (0, _utilsAssert['default'])('Must pass head position and tail position to `cutSection`', head instanceof _utilsCursorPosition['default'] && tail instanceof _utilsCursorPosition['default']);\n (0, _utilsAssert['default'])('Must pass positions within same section to `cutSection`', head.section === tail.section);\n\n if (section.isBlank || head.isEqual(tail)) {\n return head;\n }\n if (section.isCardSection) {\n if (head.isHead() && tail.isTail()) {\n var newSection = this.builder.createMarkupSection();\n this.replaceSection(section, newSection);\n return newSection.headPosition();\n } else {\n return tail;\n }\n }\n\n var range = head.toRange(tail);\n this.splitMarkers(range).forEach(function (m) {\n return _this2.removeMarker(m);\n });\n\n return head;\n }\n }, {\n key: '_coalesceMarkers',\n value: function _coalesceMarkers(section) {\n if (section.isMarkerable) {\n this._removeBlankMarkers(section);\n this._joinSimilarMarkers(section);\n }\n }\n }, {\n key: '_removeBlankMarkers',\n value: function _removeBlankMarkers(section) {\n var _this3 = this;\n\n (0, _utilsArrayUtils.forEach)((0, _utilsArrayUtils.filter)(section.markers, function (m) {\n return m.isBlank;\n }), function (m) {\n return _this3.removeMarker(m);\n });\n }\n\n // joins markers that have identical markups\n }, {\n key: '_joinSimilarMarkers',\n value: function _joinSimilarMarkers(section) {\n var marker = section.markers.head;\n var nextMarker = undefined;\n while (marker && marker.next) {\n nextMarker = marker.next;\n\n if (marker.canJoin(nextMarker)) {\n nextMarker.value = marker.value + nextMarker.value;\n this._markDirty(nextMarker);\n this.removeMarker(marker);\n }\n\n marker = nextMarker;\n }\n }\n }, {\n key: 'removeMarker',\n value: function removeMarker(marker) {\n this._scheduleForRemoval(marker);\n if (marker.section) {\n this._markDirty(marker.section);\n marker.section.markers.remove(marker);\n }\n }\n }, {\n key: '_scheduleForRemoval',\n value: function _scheduleForRemoval(postNode) {\n var _this4 = this;\n\n if (postNode.renderNode) {\n postNode.renderNode.scheduleForRemoval();\n\n this.scheduleRerender();\n this.scheduleDidUpdate();\n }\n var removedAdjacentToList = postNode.prev && postNode.prev.isListSection || postNode.next && postNode.next.isListSection;\n if (removedAdjacentToList) {\n this.addCallback(CALLBACK_QUEUES.BEFORE_COMPLETE, function () {\n return _this4._joinContiguousListSections();\n });\n }\n }\n }, {\n key: '_joinContiguousListSections',\n value: function _joinContiguousListSections() {\n var _this5 = this;\n\n var post = this.editor.post;\n\n var range = this._range;\n var prev = undefined;\n var groups = [];\n var currentGroup = undefined;\n\n // FIXME do we need to force a re-render of the range if changed sections\n // are contained within the range?\n var updatedHead = null;\n (0, _utilsArrayUtils.forEach)(post.sections, function (section) {\n if (prev && prev.isListSection && section.isListSection && prev.tagName === section.tagName) {\n\n currentGroup = currentGroup || [prev];\n currentGroup.push(section);\n } else {\n if (currentGroup) {\n groups.push(currentGroup);\n }\n currentGroup = null;\n }\n prev = section;\n });\n\n if (currentGroup) {\n groups.push(currentGroup);\n }\n\n (0, _utilsArrayUtils.forEach)(groups, function (group) {\n var list = group[0];\n (0, _utilsArrayUtils.forEach)(group, function (listSection) {\n if (listSection === list) {\n return;\n }\n\n var currentHead = range.head;\n var prevPosition = undefined;\n\n // FIXME is there a currentHead if there is no range?\n // is the current head a list item in the section\n if (!range.isBlank && currentHead.section.isListItem && currentHead.section.parent === listSection) {\n prevPosition = list.tailPosition();\n }\n _this5._joinListSections(list, listSection);\n if (prevPosition) {\n updatedHead = prevPosition.move(FORWARD);\n }\n });\n });\n\n if (updatedHead) {\n this.setRange(updatedHead);\n }\n }\n }, {\n key: '_joinListSections',\n value: function _joinListSections(baseList, nextList) {\n baseList.join(nextList);\n this._markDirty(baseList);\n this.removeSection(nextList);\n }\n }, {\n key: '_markDirty',\n value: function _markDirty(postNode) {\n var _this6 = this;\n\n if (postNode.renderNode) {\n postNode.renderNode.markDirty();\n\n this.scheduleRerender();\n this.scheduleDidUpdate();\n }\n if (postNode.section) {\n this._markDirty(postNode.section);\n }\n if (postNode.isMarkerable) {\n this.addCallback(CALLBACK_QUEUES.BEFORE_COMPLETE, function () {\n return _this6._coalesceMarkers(postNode);\n });\n }\n }\n\n /**\n * @param {Position} position object with {section, offset} the marker and offset to delete from\n * @param {Number} direction The direction to delete in (default is BACKWARD)\n * @return {Position} for positioning the cursor\n * @public\n * @deprecated after v0.10.3\n */\n }, {\n key: 'deleteFrom',\n value: function deleteFrom(position) {\n var direction = arguments.length <= 1 || arguments[1] === undefined ? _utilsKey.DIRECTION.BACKWARD : arguments[1];\n\n (0, _utilsDeprecate['default'])(\"`postEditor#deleteFrom is deprecated. Use `deleteAtPosition(position, direction=BACKWARD, {unit}={unit: 'char'})` instead\");\n return this.deleteAtPosition(position, direction, { unit: 'char' });\n }\n\n /**\n * Delete 1 `unit` (can be 'char' or 'word') in the given `direction` at the given\n * `position`. In almost all cases this will be equivalent to deleting the range formed\n * by expanding the position 1 unit in the given direction. The exception is when deleting\n * backward from the beginning of a list item, which reverts the list item into a markup section\n * instead of joining it with its previous list item (if any).\n *\n * Usage:\n *\n * let position = section.tailPosition();\n * // Section has text of \"Howdy!\"\n * editor.run((postEditor) => {\n * postEditor.deleteAtPosition(position);\n * });\n * // section has text of \"Howdy\"\n *\n * @param {Position} position The position to delete at\n * @param {Direction} [direction=DIRECTION.BACKWARD] direction The direction to delete in\n * @param {Object} [options]\n * @param {String} [options.unit=\"char\"] The unit of deletion (\"word\" or \"char\")\n * @return {Position}\n */\n }, {\n key: 'deleteAtPosition',\n value: function deleteAtPosition(position) {\n var direction = arguments.length <= 1 || arguments[1] === undefined ? _utilsKey.DIRECTION.BACKWARD : arguments[1];\n\n var _ref = arguments.length <= 2 || arguments[2] === undefined ? { unit: 'char' } : arguments[2];\n\n var unit = _ref.unit;\n\n if (direction === _utilsKey.DIRECTION.BACKWARD) {\n return this._deleteAtPositionBackward(position, unit);\n } else {\n return this._deleteAtPositionForward(position, unit);\n }\n }\n }, {\n key: '_deleteAtPositionBackward',\n value: function _deleteAtPositionBackward(position, unit) {\n if (position.isHead() && position.section.isListItem) {\n this.toggleSection('p', position);\n return this._range.head;\n } else {\n var prevPosition = unit === 'word' ? position.moveWord(BACKWARD) : position.move(BACKWARD);\n var range = prevPosition.toRange(position);\n return this.deleteRange(range);\n }\n }\n }, {\n key: '_deleteAtPositionForward',\n value: function _deleteAtPositionForward(position, unit) {\n var nextPosition = unit === 'word' ? position.moveWord(FORWARD) : position.move(FORWARD);\n var range = position.toRange(nextPosition);\n return this.deleteRange(range);\n }\n\n /**\n * Split markers at two positions, once at the head, and if necessary once\n * at the tail.\n *\n * Usage:\n * ```\n * let range = editor.range;\n * editor.run((postEditor) => {\n * postEditor.splitMarkers(range);\n * });\n * ```\n * The return value will be marker object completely inside the offsets\n * provided. Markers outside of the split may also have been modified.\n *\n * @param {Range} markerRange\n * @return {Array} of markers that are inside the split\n * @private\n */\n }, {\n key: 'splitMarkers',\n value: function splitMarkers(range) {\n var post = this.editor.post;\n var head = range.head;\n var tail = range.tail;\n\n this.splitSectionMarkerAtOffset(head.section, head.offset);\n this.splitSectionMarkerAtOffset(tail.section, tail.offset);\n\n return post.markersContainedByRange(range);\n }\n }, {\n key: 'splitSectionMarkerAtOffset',\n value: function splitSectionMarkerAtOffset(section, offset) {\n var _this7 = this;\n\n var edit = section.splitMarkerAtOffset(offset);\n edit.removed.forEach(function (m) {\n return _this7.removeMarker(m);\n });\n }\n\n /**\n * Split the section at the position.\n *\n * Usage:\n * ```\n * let position = editor.cursor.offsets.head;\n * editor.run((postEditor) => {\n * postEditor.splitSection(position);\n * });\n * // Will result in the creation of two new sections\n * // replacing the old one at the cursor position\n * ```\n * The return value will be the two new sections. One or both of these\n * sections can be blank (contain only a blank marker), for example if the\n * headMarkerOffset is 0.\n *\n * @param {Position} position\n * @return {Array} new sections, one for the first half and one for the second (either one can be null)\n * @public\n */\n }, {\n key: 'splitSection',\n value: function splitSection(position) {\n var _this8 = this;\n\n var section = position.section;\n\n if (section.isCardSection) {\n return this._splitCardSection(section, position);\n } else if (section.isListItem) {\n var isLastAndBlank = section.isBlank && !section.next;\n if (isLastAndBlank) {\n // if is last, replace the item with a blank markup section\n var _parent = section.parent;\n var collection = this.editor.post.sections;\n var blank = this.builder.createMarkupSection();\n this.removeSection(section);\n this.insertSectionBefore(collection, blank, _parent.next);\n\n return [null, blank];\n } else {\n var _splitListItem2 = this._splitListItem(section, position);\n\n var _splitListItem22 = _slicedToArray(_splitListItem2, 2);\n\n var pre = _splitListItem22[0];\n var post = _splitListItem22[1];\n\n return [pre, post];\n }\n } else {\n var splitSections = section.splitAtPosition(position);\n splitSections.forEach(function (s) {\n return _this8._coalesceMarkers(s);\n });\n this._replaceSection(section, splitSections);\n\n return splitSections;\n }\n }\n\n /**\n * @param {Section} cardSection\n * @param {Position} position to split at\n * @return {Section[]} 2-item array of pre and post-split sections\n * @private\n */\n }, {\n key: '_splitCardSection',\n value: function _splitCardSection(cardSection, position) {\n var offset = position.offset;\n\n (0, _utilsAssert['default'])('Cards section must be split at offset 0 or 1', offset === 0 || offset === 1);\n\n var newSection = this.builder.createMarkupSection();\n var nextSection = undefined;\n var surroundingSections = undefined;\n\n if (offset === 0) {\n nextSection = cardSection;\n surroundingSections = [newSection, cardSection];\n } else {\n nextSection = cardSection.next;\n surroundingSections = [cardSection, newSection];\n }\n\n var collection = this.editor.post.sections;\n this.insertSectionBefore(collection, newSection, nextSection);\n\n return surroundingSections;\n }\n\n /**\n * @param {Section} section\n * @param {Section} newSection\n * @return null\n * @public\n */\n }, {\n key: 'replaceSection',\n value: function replaceSection(section, newSection) {\n if (!section) {\n // FIXME should a falsy section be a valid argument?\n this.insertSectionBefore(this.editor.post.sections, newSection, null);\n } else {\n this._replaceSection(section, [newSection]);\n }\n }\n }, {\n key: 'moveSectionBefore',\n value: function moveSectionBefore(collection, renderedSection, beforeSection) {\n var newSection = renderedSection.clone();\n this.removeSection(renderedSection);\n this.insertSectionBefore(collection, newSection, beforeSection);\n return newSection;\n }\n\n /**\n * @param {Section} section A section that is already in DOM\n * @public\n */\n }, {\n key: 'moveSectionUp',\n value: function moveSectionUp(renderedSection) {\n var isFirst = !renderedSection.prev;\n if (isFirst) {\n return renderedSection;\n }\n\n var collection = renderedSection.parent.sections;\n var beforeSection = renderedSection.prev;\n return this.moveSectionBefore(collection, renderedSection, beforeSection);\n }\n\n /**\n * @param {Section} section A section that is already in DOM\n * @public\n */\n }, {\n key: 'moveSectionDown',\n value: function moveSectionDown(renderedSection) {\n var isLast = !renderedSection.next;\n if (isLast) {\n return renderedSection;\n }\n\n var beforeSection = renderedSection.next.next;\n var collection = renderedSection.parent.sections;\n return this.moveSectionBefore(collection, renderedSection, beforeSection);\n }\n\n /**\n * Insert an array of markers at the given position. If the position is in\n * a non-markerable section (like a card section), this method throws an error.\n *\n * @param {Position} position\n * @param {Marker[]} markers\n * @return {Position} The position that represents the end of the inserted markers.\n * @public\n */\n }, {\n key: 'insertMarkers',\n value: function insertMarkers(position, markers) {\n var _this9 = this;\n\n var section = position.section;\n var offset = position.offset;\n\n (0, _utilsAssert['default'])('Cannot insert markers at non-markerable position', section.isMarkerable);\n\n var edit = section.splitMarkerAtOffset(offset);\n edit.removed.forEach(function (marker) {\n return _this9._scheduleForRemoval(marker);\n });\n\n var prevMarker = section.markerBeforeOffset(offset);\n markers.forEach(function (marker) {\n section.markers.insertAfter(marker, prevMarker);\n offset += marker.length;\n prevMarker = marker;\n });\n\n this._coalesceMarkers(section);\n this._markDirty(section);\n\n var nextPosition = section.toPosition(offset);\n this.setRange(nextPosition);\n return nextPosition;\n }\n\n /**\n * Inserts text with the given markups, ignoring the existing markups at\n * the position, if any.\n *\n * @param {Position} position\n * @param {String} text\n * @param {Markup[]} markups\n * @return {Position} position at the end of the inserted text\n */\n }, {\n key: 'insertTextWithMarkup',\n value: function insertTextWithMarkup(position, text) {\n var markups = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];\n var section = position.section;\n\n if (!section.isMarkerable) {\n return;\n }\n var marker = this.builder.createMarker(text, markups);\n return this.insertMarkers(position, [marker]);\n }\n\n /**\n * Insert the text at the given position\n * Inherits the markups already at that position, if any.\n *\n * @param {Position} position\n * @param {String} text\n * @return {Position} position at the end of the inserted text.\n */\n }, {\n key: 'insertText',\n value: function insertText(position, text) {\n var section = position.section;\n\n if (!section.isMarkerable) {\n return;\n }\n var markups = position.marker && position.marker.markups;\n markups = markups || [];\n return this.insertTextWithMarkup(position, text, markups);\n }\n }, {\n key: '_replaceSection',\n value: function _replaceSection(section, newSections) {\n var _this10 = this;\n\n var nextSection = section.next;\n var collection = section.parent.sections;\n\n var nextNewSection = newSections[0];\n if (nextNewSection.isMarkupSection && section.isListItem) {\n // put the new section after the ListSection (section.parent)\n // instead of after the ListItem\n collection = section.parent.parent.sections;\n nextSection = section.parent.next;\n }\n\n newSections.forEach(function (s) {\n return _this10.insertSectionBefore(collection, s, nextSection);\n });\n this.removeSection(section);\n }\n\n /**\n * Given a markerRange (for example `editor.range`) mark all markers\n * inside it as a given markup. The markup must be provided as a post\n * abstract node.\n *\n * Usage:\n *\n * let range = editor.range;\n * let strongMarkup = editor.builder.createMarkup('strong');\n * editor.run((postEditor) => {\n * postEditor.addMarkupToRange(range, strongMarkup);\n * });\n * // Will result some markers possibly being split, and the markup\n * // being applied to all markers between the split.\n *\n * @param {Range} range\n * @param {Markup} markup A markup post abstract node\n * @public\n */\n }, {\n key: 'addMarkupToRange',\n value: function addMarkupToRange(range, markup) {\n var _this11 = this;\n\n if (range.isCollapsed) {\n return;\n }\n\n var markers = this.splitMarkers(range);\n if (markers.length) {\n (function () {\n // We insert the new markup at a consistent index across the range.\n // If we just push on the end of the list, it can end up in different positions\n // of the markup stack. This results in unnecessary closing and re-opening of\n // the markup each time it changes position.\n // If we just push it at the beginning of the list, this causes unnecessary closing\n // and re-opening of surrounding tags.\n // So, we look for any tags open across the whole range, and push into the stack\n // at the end of those.\n // Prompted by https://github.com/bustlelabs/mobiledoc-kit/issues/360\n\n var markupsOpenAcrossRange = (0, _utilsArrayUtils.reduce)(markers, function (soFar, marker) {\n return (0, _utilsArrayUtils.commonItems)(soFar, marker.markups);\n }, markers[0].markups);\n var indexToInsert = markupsOpenAcrossRange.length;\n\n markers.forEach(function (marker) {\n marker.addMarkupAtIndex(markup, indexToInsert);\n _this11._markDirty(marker);\n });\n })();\n }\n }\n\n /**\n * Given a markerRange (for example `editor.range`) remove the given\n * markup from all contained markers.\n *\n * Usage:\n * ```\n * let { range } = editor;\n * let markup = markerRange.headMarker.markups[0];\n * editor.run(postEditor => {\n * postEditor.removeMarkupFromRange(range, markup);\n * });\n * // Will result in some markers possibly being split, and the markup\n * // being removed from all markers between the split.\n * ```\n * @param {Range} range Object with offsets\n * @param {Markup|Function} markupOrCallback A markup post abstract node or\n * a function that returns true when passed a markup that should be removed\n * @private\n */\n }, {\n key: 'removeMarkupFromRange',\n value: function removeMarkupFromRange(range, markupOrMarkupCallback) {\n var _this12 = this;\n\n if (range.isCollapsed) {\n return;\n }\n\n this.splitMarkers(range).forEach(function (marker) {\n marker.removeMarkup(markupOrMarkupCallback);\n _this12._markDirty(marker);\n });\n }\n\n /**\n * Toggle the given markup in the given range (or at the position given). If the range/position\n * has the markup, the markup will be removed. If nothing in the range/position\n * has the markup, the markup will be added to everything in the range/position.\n *\n * Usage:\n * ```\n * // Remove any 'strong' markup if it exists in the selection, otherwise\n * // make it all 'strong'\n * editor.run(postEditor => postEditor.toggleMarkup('strong'));\n *\n * // add/remove a link to 'bustle.com' to the selection\n * editor.run(postEditor => {\n * const linkMarkup = postEditor.builder.createMarkup('a', {href: 'http://bustle.com'});\n * postEditor.toggleMarkup(linkMarkup);\n * });\n * ```\n * @param {Markup|String} markupOrString Either a markup object created using\n * the builder (useful when adding a markup with attributes, like an 'a' markup),\n * or, if a string, the tag name of the markup (e.g. 'strong', 'em') to toggle.\n * @param {Range|Position} range in which to toggle. Defaults to current editor range.\n * @public\n */\n }, {\n key: 'toggleMarkup',\n value: function toggleMarkup(markupOrMarkupString) {\n var range = arguments.length <= 1 || arguments[1] === undefined ? this._range : arguments[1];\n\n range = (0, _utilsToRange['default'])(range);\n var markup = typeof markupOrMarkupString === 'string' ? this.builder.createMarkup(markupOrMarkupString) : markupOrMarkupString;\n\n var hasMarkup = this.editor.detectMarkupInRange(range, markup.tagName);\n // FIXME: This implies only a single markup in a range. This may not be\n // true for links (which are not the same object instance like multiple\n // strong tags would be).\n if (hasMarkup) {\n this.removeMarkupFromRange(range, hasMarkup);\n } else {\n this.addMarkupToRange(range, markup);\n }\n\n this.setRange(range);\n }\n\n /**\n * Toggles the tagName of the active section or sections in the given range/position.\n * If every section has the tag name, they will all be reset to default sections.\n * Otherwise, every section will be changed to the requested type\n *\n * @param {String} sectionTagName A valid markup section or\n * list section tag name (e.g. 'blockquote', 'h2', 'ul')\n * @param {Range|Position} range The range over which to toggle.\n * Defaults to the current editor range.\n * @public\n */\n }, {\n key: 'toggleSection',\n value: function toggleSection(sectionTagName) {\n var _this13 = this;\n\n var range = arguments.length <= 1 || arguments[1] === undefined ? this._range : arguments[1];\n\n range = (0, _utilsToRange['default'])(range);\n\n sectionTagName = (0, _utilsDomUtils.normalizeTagName)(sectionTagName);\n var post = this.editor.post;\n\n var nextRange = range;\n\n var everySectionHasTagName = true;\n post.walkMarkerableSections(range, function (section) {\n if (!_this13._isSameSectionType(section, sectionTagName)) {\n everySectionHasTagName = false;\n }\n });\n\n var tagName = everySectionHasTagName ? 'p' : sectionTagName;\n var firstChanged = undefined;\n post.walkMarkerableSections(range, function (section) {\n var changedSection = _this13.changeSectionTagName(section, tagName);\n firstChanged = firstChanged || changedSection;\n });\n\n if (firstChanged) {\n nextRange = firstChanged.headPosition().toRange();\n }\n this.setRange(nextRange);\n }\n }, {\n key: '_isSameSectionType',\n value: function _isSameSectionType(section, sectionTagName) {\n return section.isListItem ? section.parent.tagName === sectionTagName : section.tagName === sectionTagName;\n }\n\n /**\n * @param {Markerable} section\n * @private\n */\n }, {\n key: 'changeSectionTagName',\n value: function changeSectionTagName(section, newTagName) {\n (0, _utilsAssert['default'])('Cannot pass non-markerable section to `changeSectionTagName`', section.isMarkerable);\n\n if (isListSectionTagName(newTagName)) {\n return this._changeSectionToListItem(section, newTagName);\n } else if (section.isListItem) {\n return this._changeSectionFromListItem(section, newTagName);\n } else {\n section.tagName = newTagName;\n this._markDirty(section);\n return section;\n }\n }\n\n /**\n * Splits the item at the position given.\n * If the position is at the start or end of the item, the pre- or post-item\n * will contain a single empty (\"\") marker.\n * @param {ListItem} item\n * @param {Position} position\n * @return {Array} the pre-item and post-item on either side of the split\n * @private\n */\n }, {\n key: '_splitListItem',\n value: function _splitListItem(item, position) {\n var section = position.section;\n var offset = position.offset;\n\n (0, _utilsAssert['default'])('Cannot split list item at position that does not include item', item === section);\n\n item.splitMarkerAtOffset(offset);\n var prevMarker = item.markerBeforeOffset(offset);\n var preItem = this.builder.createListItem(),\n postItem = this.builder.createListItem();\n\n var currentItem = preItem;\n item.markers.forEach(function (marker) {\n currentItem.markers.append(marker.clone());\n if (marker === prevMarker) {\n currentItem = postItem;\n }\n });\n this._replaceSection(item, [preItem, postItem]);\n return [preItem, postItem];\n }\n\n /**\n * Splits the list at the position given.\n * @return {Array} pre-split list and post-split list, either of which could\n * be blank (0-item list) if the position is at the start or end of the list.\n *\n * Note: Contiguous list sections will be joined in the before_complete queue\n * of the postEditor.\n *\n * @private\n */\n }, {\n key: '_splitListAtPosition',\n value: function _splitListAtPosition(list, position) {\n (0, _utilsAssert['default'])('Cannot split list at position not in list', position.section.parent === list);\n\n var positionIsMiddle = !position.isHead() && !position.isTail();\n if (positionIsMiddle) {\n var item = position.section;\n\n var _splitListItem3 = // jshint ignore:line\n this._splitListItem(item, position);\n\n var _splitListItem32 = _slicedToArray(_splitListItem3, 2);\n\n var pre = _splitListItem32[0];\n var post = _splitListItem32[1];\n\n position = pre.tailPosition();\n }\n\n var preList = this.builder.createListSection(list.tagName);\n var postList = this.builder.createListSection(list.tagName);\n\n var preItem = position.section;\n var currentList = preList;\n list.items.forEach(function (item) {\n // If this item matches the start item and the position is at its start,\n // it should be appended to the postList instead of the preList\n if (item === preItem && position.isEqual(item.headPosition())) {\n currentList = postList;\n }\n currentList.items.append(item.clone());\n // If we just appended the preItem, append the remaining items to the postList\n if (item === preItem) {\n currentList = postList;\n }\n });\n\n this._replaceSection(list, [preList, postList]);\n return [preList, postList];\n }\n\n /**\n * @return Array of [prev, mid, next] lists. `prev` and `next` can\n * be blank, depending on the position of `item`. `mid` will always\n * be a 1-item list containing `item`. `prev` and `next` will be\n * removed in the before_complete queue if they are blank\n * (and still attached).\n *\n * @private\n */\n }, {\n key: '_splitListAtItem',\n value: function _splitListAtItem(list, item) {\n var _this14 = this;\n\n var next = list;\n var prev = this.builder.createListSection(next.tagName);\n var mid = this.builder.createListSection(next.tagName);\n\n var addToPrev = true;\n // must turn the LinkedList into an array so that we can remove items\n // as we iterate through it\n var items = next.items.toArray();\n items.forEach(function (i) {\n var listToAppend = undefined;\n if (i === item) {\n addToPrev = false;\n listToAppend = mid;\n } else if (addToPrev) {\n listToAppend = prev;\n } else {\n return; // break after iterating prev and mid parts of the list\n }\n listToAppend.join(i);\n _this14.removeSection(i);\n });\n var found = !addToPrev;\n (0, _utilsAssert['default'])('Cannot split list at item that is not present in the list', found);\n\n var collection = this.editor.post.sections;\n this.insertSectionBefore(collection, mid, next);\n this.insertSectionBefore(collection, prev, mid);\n\n // Remove possibly blank prev/next lists\n this.addCallback(CALLBACK_QUEUES.BEFORE_COMPLETE, function () {\n [prev, next].forEach(function (_list) {\n var isAttached = !!_list.parent;\n if (_list.isBlank && isAttached) {\n _this14.removeSection(_list);\n }\n });\n });\n\n return [prev, mid, next];\n }\n }, {\n key: '_changeSectionFromListItem',\n value: function _changeSectionFromListItem(section, newTagName) {\n (0, _utilsAssert['default'])('Must pass list item to `_changeSectionFromListItem`', section.isListItem);\n\n var listSection = section.parent;\n var markupSection = this.builder.createMarkupSection(newTagName);\n markupSection.join(section);\n\n var _splitListAtItem2 = this._splitListAtItem(listSection, section);\n\n var _splitListAtItem22 = _slicedToArray(_splitListAtItem2, 3);\n\n var prev = _splitListAtItem22[0];\n var mid = _splitListAtItem22[1];\n var next = _splitListAtItem22[2];\n // jshint ignore:line\n this.replaceSection(mid, markupSection);\n return markupSection;\n }\n }, {\n key: '_changeSectionToListItem',\n value: function _changeSectionToListItem(section, newTagName) {\n var isAlreadyCorrectListItem = section.isListItem && section.parent.tagName === newTagName;\n\n if (isAlreadyCorrectListItem) {\n return section;\n }\n\n var listSection = this.builder.createListSection(newTagName);\n listSection.join(section);\n\n var sectionToReplace = undefined;\n if (section.isListItem) {\n var _splitListAtItem3 = this._splitListAtItem(section.parent, section);\n\n var _splitListAtItem32 = _slicedToArray(_splitListAtItem3, 3);\n\n var prev = _splitListAtItem32[0];\n var mid = _splitListAtItem32[1];\n var next = _splitListAtItem32[2];\n // jshint ignore:line\n sectionToReplace = mid;\n } else {\n sectionToReplace = section;\n }\n this.replaceSection(sectionToReplace, listSection);\n return listSection;\n }\n\n /**\n * Insert a given section before another one, updating the post abstract\n * and the rendered UI.\n *\n * Usage:\n * ```\n * let markerRange = editor.range;\n * let sectionWithCursor = markerRange.headMarker.section;\n * let section = editor.builder.createCardSection('my-image');\n * let collection = sectionWithCursor.parent.sections;\n * editor.run((postEditor) => {\n * postEditor.insertSectionBefore(collection, section, sectionWithCursor);\n * });\n * ```\n * @param {LinkedList} collection The list of sections to insert into\n * @param {Object} section The new section\n * @param {Object} beforeSection Optional The section \"before\" is relative to,\n * if falsy the new section will be appended to the collection\n * @public\n */\n }, {\n key: 'insertSectionBefore',\n value: function insertSectionBefore(collection, section, beforeSection) {\n collection.insertBefore(section, beforeSection);\n this._markDirty(section.parent);\n }\n\n /**\n * Insert the given section after the current active section, or, if no\n * section is active, at the end of the document.\n * @param {Section} section\n * @public\n */\n }, {\n key: 'insertSection',\n value: function insertSection(section) {\n var activeSection = this.editor.activeSection;\n var nextSection = activeSection && activeSection.next;\n\n var collection = this.editor.post.sections;\n this.insertSectionBefore(collection, section, nextSection);\n }\n\n /**\n * Insert the given section at the end of the document.\n * @param {Section} section\n * @public\n */\n }, {\n key: 'insertSectionAtEnd',\n value: function insertSectionAtEnd(section) {\n this.insertSectionBefore(this.editor.post.sections, section, null);\n }\n\n /**\n * Insert the `post` at the given position in the editor's post.\n * @param {Position} position\n * @param {Post} post\n * @private\n */\n }, {\n key: 'insertPost',\n value: function insertPost(position, newPost) {\n var post = this.editor.post;\n var inserter = new _postPostInserter['default'](this, post);\n var nextPosition = inserter.insert(position, newPost);\n return nextPosition;\n }\n\n /**\n * Remove a given section from the post abstract and the rendered UI.\n *\n * Usage:\n * ```\n * let { range } = editor;\n * let sectionWithCursor = range.head.section;\n * editor.run((postEditor) => {\n * postEditor.removeSection(sectionWithCursor);\n * });\n * ```\n * @param {Object} section The section to remove\n * @public\n */\n }, {\n key: 'removeSection',\n value: function removeSection(section) {\n var parent = section.parent;\n this._scheduleForRemoval(section);\n parent.sections.remove(section);\n\n if (parent.isListSection) {\n this._scheduleListRemovalIfEmpty(parent);\n }\n }\n }, {\n key: 'removeAllSections',\n value: function removeAllSections() {\n var _this15 = this;\n\n this.editor.post.sections.toArray().forEach(function (section) {\n _this15.removeSection(section);\n });\n }\n }, {\n key: 'migrateSectionsFromPost',\n value: function migrateSectionsFromPost(post) {\n var _this16 = this;\n\n post.sections.toArray().forEach(function (section) {\n post.sections.remove(section);\n _this16.insertSectionBefore(_this16.editor.post.sections, section, null);\n });\n }\n }, {\n key: '_scheduleListRemovalIfEmpty',\n value: function _scheduleListRemovalIfEmpty(listSection) {\n var _this17 = this;\n\n this.addCallback(CALLBACK_QUEUES.BEFORE_COMPLETE, function () {\n // if the list is attached and blank after we do other rendering stuff,\n // remove it\n var isAttached = !!listSection.parent;\n if (isAttached && listSection.isBlank) {\n _this17.removeSection(listSection);\n }\n });\n }\n\n /**\n * A method for adding work the deferred queue\n *\n * @param {Function} callback to run during completion\n * @param {Boolean} [once=false] Whether to only schedule the callback once.\n * @public\n */\n }, {\n key: 'schedule',\n value: function schedule(callback) {\n var once = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];\n\n (0, _utilsAssert['default'])('Work can only be scheduled before a post edit has completed', !this._didComplete);\n if (once) {\n this.addCallbackOnce(CALLBACK_QUEUES.COMPLETE, callback);\n } else {\n this.addCallback(CALLBACK_QUEUES.COMPLETE, callback);\n }\n }\n\n /**\n * A method for adding work the deferred queue. The callback will only\n * be added to the queue once, even if `scheduleOnce` is called multiple times.\n * The function cannot be an anonymous function.\n *\n * @param {Function} callback to run during completion\n * @public\n */\n }, {\n key: 'scheduleOnce',\n value: function scheduleOnce(callback) {\n this.schedule(callback, true);\n }\n\n /**\n * Add a rerender job to the queue\n *\n * @public\n */\n }, {\n key: 'scheduleRerender',\n value: function scheduleRerender() {\n this.scheduleOnce(this._rerender);\n }\n\n /**\n * Schedule a notification that the post has been changed.\n * The notification will result in the editor firing its `postDidChange`\n * hook after the postEditor completes its work (at the end of {@link Editor#run}).\n *\n * @public\n */\n }, {\n key: 'scheduleDidUpdate',\n value: function scheduleDidUpdate() {\n this.scheduleOnce(this._postDidChange);\n }\n }, {\n key: 'scheduleAfterRender',\n value: function scheduleAfterRender(callback) {\n var once = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];\n\n if (once) {\n this.addCallbackOnce(CALLBACK_QUEUES.AFTER_COMPLETE, callback);\n } else {\n this.addCallback(CALLBACK_QUEUES.AFTER_COMPLETE, callback);\n }\n }\n\n /**\n * Flush any work on the queue. {@link Editor#run} calls this method; it\n * should not be called directly.\n *\n * @private\n */\n }, {\n key: 'complete',\n value: function complete() {\n (0, _utilsAssert['default'])('Post editing can only be completed once', !this._didComplete);\n\n this.runCallbacks(CALLBACK_QUEUES.BEFORE_COMPLETE);\n this._didComplete = true;\n this.runCallbacks(CALLBACK_QUEUES.COMPLETE);\n this.runCallbacks(CALLBACK_QUEUES.AFTER_COMPLETE);\n }\n }, {\n key: 'undoLastChange',\n value: function undoLastChange() {\n this.editor._editHistory.stepBackward(this);\n }\n }, {\n key: 'redoLastChange',\n value: function redoLastChange() {\n this.editor._editHistory.stepForward(this);\n }\n }, {\n key: 'cancelSnapshot',\n value: function cancelSnapshot() {\n this._shouldCancelSnapshot = true;\n }\n }]);\n\n return PostEditor;\n})();\n\nexports['default'] = PostEditor;","'use strict';\n\nvar _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _utilsAssert = require('../../utils/assert');\n\nvar _modelsTypes = require('../../models/types');\n\nvar MARKERABLE = 'markerable',\n NESTED_MARKERABLE = 'nested_markerable',\n NON_MARKERABLE = 'non_markerable';\n\nvar Visitor = (function () {\n function Visitor(inserter, cursorPosition) {\n _classCallCheck(this, Visitor);\n\n var postEditor = inserter.postEditor;\n var post = inserter.post;\n\n this.postEditor = postEditor;\n this._post = post;\n this.cursorPosition = cursorPosition;\n this.builder = this.postEditor.builder;\n\n this._hasInsertedFirstLeafSection = false;\n }\n\n _createClass(Visitor, [{\n key: 'visit',\n value: function visit(node) {\n var method = node.type;\n (0, _utilsAssert['default'])('Cannot visit node of type ' + node.type, !!this[method]);\n this[method](node);\n }\n }, {\n key: '_canMergeSection',\n value: function _canMergeSection(section) {\n if (this._hasInsertedFirstLeafSection) {\n return false;\n } else {\n return this._isMarkerable && section.isMarkerable;\n }\n }\n }, {\n key: _modelsTypes.POST_TYPE,\n value: function value(node) {\n var _this = this;\n\n if (this.cursorSection.isBlank && !this._isNested) {\n // replace blank section with entire post\n var newSections = node.sections.map(function (s) {\n return s.clone();\n });\n this._replaceSection(this.cursorSection, newSections);\n } else {\n node.sections.forEach(function (section) {\n return _this.visit(section);\n });\n }\n }\n }, {\n key: _modelsTypes.MARKUP_SECTION_TYPE,\n value: function value(node) {\n this[MARKERABLE](node);\n }\n }, {\n key: _modelsTypes.LIST_SECTION_TYPE,\n value: function value(node) {\n var _this2 = this;\n\n var hasNext = !!node.next;\n node.items.forEach(function (item) {\n return _this2.visit(item);\n });\n\n if (this._isNested && hasNext) {\n this._breakNestedAtCursor();\n }\n }\n }, {\n key: _modelsTypes.LIST_ITEM_TYPE,\n value: function value(node) {\n this[NESTED_MARKERABLE](node);\n }\n }, {\n key: _modelsTypes.CARD_TYPE,\n value: function value(node) {\n this[NON_MARKERABLE](node);\n }\n }, {\n key: _modelsTypes.IMAGE_SECTION_TYPE,\n value: function value(node) {\n this[NON_MARKERABLE](node);\n }\n }, {\n key: NON_MARKERABLE,\n value: function value(section) {\n if (this._isNested) {\n this._breakNestedAtCursor();\n } else if (!this.cursorSection.isBlank) {\n this._breakAtCursor();\n }\n\n this._insertLeafSection(section);\n }\n }, {\n key: MARKERABLE,\n value: function value(section) {\n if (this._canMergeSection(section)) {\n this._mergeSection(section);\n } else if (this._isNested && this._isMarkerable) {\n // If we are attaching a markerable section to a list item,\n // insert a linebreak then merge the section onto the resulting blank list item\n this._breakAtCursor();\n\n // Advance the cursor to the head of the blank list item\n var nextPosition = this.cursorSection.next.headPosition();\n this.cursorPosition = nextPosition;\n\n // Merge this section onto the list item\n this._mergeSection(section);\n } else {\n this._breakAtCursor();\n this._insertLeafSection(section);\n }\n }\n }, {\n key: NESTED_MARKERABLE,\n value: function value(section) {\n if (this._canMergeSection(section)) {\n this._mergeSection(section);\n return;\n }\n\n section = this._isNested ? section : this._wrapNestedSection(section);\n this._breakAtCursor();\n this._insertLeafSection(section);\n }\n\n // break out of a nested cursor position\n }, {\n key: '_breakNestedAtCursor',\n value: function _breakNestedAtCursor() {\n (0, _utilsAssert['default'])('Cannot call _breakNestedAtCursor if not nested', this._isNested);\n\n var parent = this.cursorSection.parent;\n var cursorAtEndOfList = this.cursorPosition.isEqual(parent.tailPosition());\n\n if (cursorAtEndOfList) {\n var blank = this.builder.createMarkupSection();\n this._insertSectionAfter(blank, parent);\n } else {\n var _breakListAtCursor2 = this._breakListAtCursor();\n\n var _breakListAtCursor22 = _slicedToArray(_breakListAtCursor2, 3);\n\n var pre = _breakListAtCursor22[0];\n var blank = _breakListAtCursor22[1];\n var post = _breakListAtCursor22[2];\n // jshint ignore:line\n this.cursorPosition = blank.tailPosition();\n }\n }\n }, {\n key: '_breakListAtCursor',\n value: function _breakListAtCursor() {\n (0, _utilsAssert['default'])('Cannot _splitParentSection if cursor position is not nested', this._isNested);\n\n var list = this.cursorSection.parent,\n position = this.cursorPosition,\n blank = this.builder.createMarkupSection();\n\n var _postEditor$_splitListAtPosition = this.postEditor._splitListAtPosition(list, position);\n\n var _postEditor$_splitListAtPosition2 = _slicedToArray(_postEditor$_splitListAtPosition, 2);\n\n var pre = _postEditor$_splitListAtPosition2[0];\n var post = _postEditor$_splitListAtPosition2[1];\n\n var collection = this._post.sections,\n reference = post;\n this.postEditor.insertSectionBefore(collection, blank, reference);\n return [pre, blank, post];\n }\n }, {\n key: '_wrapNestedSection',\n value: function _wrapNestedSection(section) {\n var tagName = section.parent.tagName;\n var parent = this.builder.createListSection(tagName);\n parent.items.append(section.clone());\n return parent;\n }\n }, {\n key: '_mergeSection',\n value: function _mergeSection(section) {\n (0, _utilsAssert['default'])('Can only merge markerable sections', this._isMarkerable && section.isMarkerable);\n this._hasInsertedFirstLeafSection = true;\n\n var markers = section.markers.map(function (m) {\n return m.clone();\n });\n var position = this.postEditor.insertMarkers(this.cursorPosition, markers);\n\n this.cursorPosition = position;\n }\n\n // Can be called to add a line break when in a nested section or a parent\n // section.\n }, {\n key: '_breakAtCursor',\n value: function _breakAtCursor() {\n if (this.cursorSection.isBlank) {\n return;\n } else if (this._isMarkerable) {\n this._breakMarkerableAtCursor();\n } else {\n this._breakNonMarkerableAtCursor();\n }\n }\n\n // Inserts a blank section before/after the cursor,\n // depending on cursor position.\n }, {\n key: '_breakNonMarkerableAtCursor',\n value: function _breakNonMarkerableAtCursor() {\n var collection = this._post.sections,\n blank = this.builder.createMarkupSection(),\n reference = this.cursorPosition.isHead() ? this.cursorSection : this.cursorSection.next;\n this.postEditor.insertSectionBefore(collection, blank, reference);\n this.cursorPosition = blank.tailPosition();\n }\n }, {\n key: '_breakMarkerableAtCursor',\n value: function _breakMarkerableAtCursor() {\n var _postEditor$splitSection = // jshint ignore:line\n this.postEditor.splitSection(this.cursorPosition);\n\n var _postEditor$splitSection2 = _slicedToArray(_postEditor$splitSection, 2);\n\n var pre = _postEditor$splitSection2[0];\n var post = _postEditor$splitSection2[1];\n\n this.cursorPosition = pre.tailPosition();\n }\n }, {\n key: '_replaceSection',\n value: function _replaceSection(section, newSections) {\n var _this3 = this;\n\n (0, _utilsAssert['default'])('Cannot replace section that does not have parent.sections', section.parent && section.parent.sections);\n (0, _utilsAssert['default'])('Must pass enumerable to _replaceSection', !!newSections.forEach);\n\n var collection = section.parent.sections;\n var reference = section.next;\n this.postEditor.removeSection(section);\n newSections.forEach(function (section) {\n _this3.postEditor.insertSectionBefore(collection, section, reference);\n });\n var lastSection = newSections[newSections.length - 1];\n\n this.cursorPosition = lastSection.tailPosition();\n }\n }, {\n key: '_insertSectionBefore',\n value: function _insertSectionBefore(section, reference) {\n var collection = this.cursorSection.parent.sections;\n this.postEditor.insertSectionBefore(collection, section, reference);\n\n this.cursorPosition = section.tailPosition();\n }\n\n // Insert a section after the parent section.\n // E.g., add a markup section after a list section\n }, {\n key: '_insertSectionAfter',\n value: function _insertSectionAfter(section, parent) {\n (0, _utilsAssert['default'])('Cannot _insertSectionAfter nested section', !parent.isNested);\n var reference = parent.next;\n var collection = this._post.sections;\n this.postEditor.insertSectionBefore(collection, section, reference);\n this.cursorPosition = section.tailPosition();\n }\n }, {\n key: '_insertLeafSection',\n value: function _insertLeafSection(section) {\n (0, _utilsAssert['default'])('Can only _insertLeafSection when cursor is at end of section', this.cursorPosition.isTail());\n\n this._hasInsertedFirstLeafSection = true;\n section = section.clone();\n\n if (this.cursorSection.isBlank) {\n (0, _utilsAssert['default'])('Cannot insert leaf non-markerable section when cursor is nested', !(section.isMarkerable && this._isNested));\n this._replaceSection(this.cursorSection, [section]);\n } else if (this.cursorSection.next && this.cursorSection.next.isBlank) {\n this._replaceSection(this.cursorSection.next, [section]);\n } else {\n var reference = this.cursorSection.next;\n this._insertSectionBefore(section, reference);\n }\n }\n }, {\n key: 'cursorPosition',\n get: function get() {\n return this._cursorPosition;\n },\n set: function set(position) {\n this._cursorPosition = position;\n this.postEditor.setRange(position);\n }\n }, {\n key: '_isMarkerable',\n get: function get() {\n return this.cursorSection.isMarkerable;\n }\n }, {\n key: 'cursorSection',\n get: function get() {\n return this.cursorPosition.section;\n }\n }, {\n key: 'cursorOffset',\n get: function get() {\n return this.cursorPosition.offset;\n }\n }, {\n key: '_isNested',\n get: function get() {\n return this.cursorSection.isNested;\n }\n }]);\n\n return Visitor;\n})();\n\nvar Inserter = (function () {\n function Inserter(postEditor, post) {\n _classCallCheck(this, Inserter);\n\n this.postEditor = postEditor;\n this.post = post;\n }\n\n _createClass(Inserter, [{\n key: 'insert',\n value: function insert(cursorPosition, newPost) {\n var visitor = new Visitor(this, cursorPosition);\n visitor.visit(newPost);\n return visitor.cursorPosition;\n }\n }]);\n\n return Inserter;\n})();\n\nexports['default'] = Inserter;","\"use strict\";\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar instance = undefined;\n\nvar SelectionChangeObserver = (function () {\n function SelectionChangeObserver() {\n _classCallCheck(this, SelectionChangeObserver);\n\n this.started = false;\n this.listeners = [];\n this.selection = {};\n }\n\n _createClass(SelectionChangeObserver, [{\n key: \"addListener\",\n value: function addListener(listener) {\n if (this.listeners.indexOf(listener) === -1) {\n this.listeners.push(listener);\n this.start();\n }\n }\n }, {\n key: \"removeListener\",\n value: function removeListener(listener) {\n var index = this.listeners.indexOf(listener);\n if (index !== -1) {\n this.listeners.splice(index, 1);\n if (this.listeners.length === 0) {\n this.stop();\n }\n }\n }\n }, {\n key: \"start\",\n value: function start() {\n if (this.started) {\n return;\n }\n this.started = true;\n\n this.poll();\n }\n }, {\n key: \"stop\",\n value: function stop() {\n this.started = false;\n this.selection = {};\n }\n }, {\n key: \"notifyListeners\",\n value: function notifyListeners() /* newSelection, prevSelection */{\n var _arguments = arguments;\n\n this.listeners.forEach(function (listener) {\n listener.selectionDidChange.apply(listener, _arguments);\n });\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.stop();\n this.listeners = [];\n }\n }, {\n key: \"getSelection\",\n value: function getSelection() {\n var selection = window.getSelection();\n var anchorNode = selection.anchorNode;\n var focusNode = selection.focusNode;\n var anchorOffset = selection.anchorOffset;\n var focusOffset = selection.focusOffset;\n\n return { anchorNode: anchorNode, focusNode: focusNode, anchorOffset: anchorOffset, focusOffset: focusOffset };\n }\n }, {\n key: \"poll\",\n value: function poll() {\n var _this = this;\n\n if (this.started) {\n this.update();\n this.runNext(function () {\n return _this.poll();\n });\n }\n }\n }, {\n key: \"runNext\",\n value: function runNext(fn) {\n window.requestAnimationFrame(fn);\n }\n }, {\n key: \"update\",\n value: function update() {\n var prevSelection = this.selection;\n var curSelection = this.getSelection();\n if (!this.selectionIsEqual(prevSelection, curSelection)) {\n this.selection = curSelection;\n this.notifyListeners(curSelection, prevSelection);\n }\n }\n }, {\n key: \"selectionIsEqual\",\n value: function selectionIsEqual(s1, s2) {\n return s1.anchorNode === s2.anchorNode && s1.anchorOffset === s2.anchorOffset && s1.focusNode === s2.focusNode && s1.focusOffset === s2.focusOffset;\n }\n }], [{\n key: \"getInstance\",\n value: function getInstance() {\n if (!instance) {\n instance = new SelectionChangeObserver();\n }\n return instance;\n }\n }, {\n key: \"addListener\",\n value: function addListener(listener) {\n SelectionChangeObserver.getInstance().addListener(listener);\n }\n }, {\n key: \"removeListener\",\n value: function removeListener(listener) {\n SelectionChangeObserver.getInstance().removeListener(listener);\n }\n }]);\n\n return SelectionChangeObserver;\n})();\n\nexports[\"default\"] = SelectionChangeObserver;","'use strict';\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _editorSelectionChangeObserver = require('../editor/selection-change-observer');\n\nvar SelectionManager = (function () {\n function SelectionManager(editor, callback) {\n _classCallCheck(this, SelectionManager);\n\n this.editor = editor;\n this.callback = callback;\n this.started = false;\n }\n\n _createClass(SelectionManager, [{\n key: 'start',\n value: function start() {\n if (this.started) {\n return;\n }\n\n _editorSelectionChangeObserver['default'].addListener(this);\n this.started = true;\n }\n }, {\n key: 'stop',\n value: function stop() {\n this.started = false;\n _editorSelectionChangeObserver['default'].removeListener(this);\n }\n }, {\n key: 'destroy',\n value: function destroy() {\n this.stop();\n }\n }, {\n key: 'selectionDidChange',\n value: function selectionDidChange() {\n if (this.started) {\n this.callback.apply(this, arguments);\n }\n }\n }]);\n\n return SelectionManager;\n})();\n\nexports['default'] = SelectionManager;","'use strict';\n\nvar _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();\n\nvar _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\nvar _utilsStringUtils = require('../utils/string-utils');\n\nvar _utilsAssert = require('../utils/assert');\n\nvar TextInputHandler = (function () {\n function TextInputHandler(editor) {\n _classCallCheck(this, TextInputHandler);\n\n this.editor = editor;\n this._handlers = [];\n }\n\n _createClass(TextInputHandler, [{\n key: 'register',\n value: function register(handler) {\n (0, _utilsAssert['default'])('Input Handler is not valid', this._validateHandler(handler));\n this._handlers.push(handler);\n }\n }, {\n key: 'handle',\n value: function handle(string) {\n var editor = this.editor;\n\n editor.insertText(string);\n\n var matchedHandler = this._findHandler();\n if (matchedHandler) {\n var _matchedHandler = _slicedToArray(matchedHandler, 2);\n\n var handler = _matchedHandler[0];\n var matches = _matchedHandler[1];\n\n handler.run(editor, matches);\n }\n }\n }, {\n key: '_findHandler',\n value: function _findHandler() {\n var _editor$range = this.editor.range;\n var head = _editor$range.head;\n var section = _editor$range.head.section;\n\n var preText = section.textUntil(head);\n\n for (var i = 0; i < this._handlers.length; i++) {\n var handler = this._handlers[i];\n var text = handler.text;\n var match = handler.match;\n\n if (text && (0, _utilsStringUtils.endsWith)(preText, text)) {\n return [handler, [text]];\n } else if (match && match.test(preText)) {\n return [handler, match.exec(preText)];\n }\n }\n }\n }, {\n key: '_validateHandler',\n value: function _validateHandler(handler) {\n return !!handler.run && ( // has `run`\n !!handler.text || !!handler.match) && // and `text` or `match`\n !(!!handler.text && !!handler.match); // not both `text` and `match`\n }\n }, {\n key: 'destroy',\n value: function destroy() {\n this._handlers = [];\n }\n }]);\n\n return TextInputHandler;\n})();\n\nexports['default'] = TextInputHandler;","/**\n * Convert section at the editor's cursor position into a list.\n * Does nothing if the cursor position is not at the start of the section,\n * or if the section is already a list item.\n *\n * @param {Editor} editor\n * @param {String} listTagName (\"ul\" or \"ol\")\n * @public\n */\n'use strict';\n\nexports.replaceWithListSection = replaceWithListSection;\nexports.replaceWithHeaderSection = replaceWithHeaderSection;\n\nfunction replaceWithListSection(editor, listTagName) {\n var _editor$range = editor.range;\n var head = _editor$range.head;\n var section = _editor$range.head.section;\n\n // Skip if cursor is not at end of section\n if (!head.isTail()) {\n return;\n }\n\n if (section.isListItem) {\n return;\n }\n\n editor.run(function (postEditor) {\n var builder = postEditor.builder;\n\n var item = builder.createListItem();\n var listSection = builder.createListSection(listTagName, [item]);\n\n postEditor.replaceSection(section, listSection);\n postEditor.setRange(listSection.headPosition());\n });\n}\n\n/**\n * Convert section at the editor's cursor position into a header section.\n * Does nothing if the cursor position is not at the start of the section.\n *\n * @param {Editor} editor\n * @param {String} headingTagName (\"h1\",\"h2\",\"h3\")\n * @public\n */\n\nfunction replaceWithHeaderSection(editor, headingTagName) {\n var _editor$range2 = editor.range;\n var head = _editor$range2.head;\n var section = _editor$range2.head.section;\n\n // Skip if cursor is not at end of section\n if (!head.isTail()) {\n return;\n }\n\n editor.run(function (postEditor) {\n var builder = postEditor.builder;\n\n var newSection = builder.createMarkupSection(headingTagName);\n postEditor.replaceSection(section, newSection);\n postEditor.setRange(newSection.headPosition());\n });\n}\n\nvar DEFAULT_TEXT_INPUT_HANDLERS = [{\n // \"* \" -> ul\n match: /^\\* $/,\n run: function run(editor) {\n replaceWithListSection(editor, 'ul');\n }\n}, {\n // \"1\" -> ol, \"1.\" -> ol\n match: /^1\\.? $/,\n run: function run(editor) {\n replaceWithListSection(editor, 'ol');\n }\n}, {\n // \"# \" -> h1, \"## \" -> h2, \"### \" -> h3\n match: /^(#{1,3}) $/,\n run: function run(editor, matches) {\n var capture = matches[1];\n var headingTag = 'h' + capture.length;\n replaceWithHeaderSection(editor, headingTag);\n }\n}];\nexports.DEFAULT_TEXT_INPUT_HANDLERS = DEFAULT_TEXT_INPUT_HANDLERS;"],"names":["_utilsPlaceholderImageSrc","exports","name","type","render","_ref","env","options","payload","img","document","createElement","src","_slicedToArray","sliceIterator","arr","i","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","push","value","length","err","Array","isArray","Object","TypeError","_createClass","defineProperties","target","props","descriptor","enumerable","configurable","writable","defineProperty","key","Constructor","protoProps","staticProps","prototype","_classCallCheck","instance","_parsersMobiledoc","_utilsFixedQueue","findLeafSectionAtIndex","post","index","section","walkAllLeafSections","_section","_index","Snapshot","editor","this","mobiledoc","serialize","snapshotRange","_editor","range","cursor","hasCursor","isBlank","head","tail","leafSectionIndex","offset","_range","_head","_head2","headLeafSectionIndex","headOffset","_tail","_tail2","tailLeafSectionIndex","tailOffset","headSection","tailSection","toPosition","toRange","EditHistory","queueLength","_undoStack","_redoStack","_pendingSnapshot","clear","postEditor","snapshot","pop","_restoreFromSnapshot","cancelSnapshot","builder","restoredPost","parse","removeAllSections","migrateSectionsFromPost","newRange","getRange","setRange","_utilsArrayUtils","_utilsCursorRange","EditState","defaultState","blankRange","activeMarkups","activeSections","activeSectionTagNames","prevState","state","_readState","prevRange","isEqual","isArrayEqual","markup","contains","_removeActiveMarkup","_addActiveMarkup","_readActiveMarkups","_readActiveSections","map","s","isNested","parent","tagName","sections","readRange","markupsInRange","indexOf","splice","get","_viewsTooltip","_post","_cardsImage","_utilsKey","_parsersHtml","_parsersDom","_renderersEditorDom","_modelsRenderTree","_renderersMobiledoc","_utilsMerge","_utilsDomUtils","_utilsElementUtils","_utilsCursor","_utilsCursorPosition","_modelsPostNodeBuilder","_textInputHandlers","_keyCommands","_modelsCard","_utilsAssert","_editorMutationHandler","_editorEditHistory","_editorEventManager","_editorEditState","_mobiledocHtmlRenderer","_mobiledocTextRenderer","_modelsLifecycleCallbacks","_utilsLogManager","_utilsToRange","_utilsMobiledocError","EDITOR_ELEMENT_CLASS_NAME","defaults","placeholder","spellcheck","autofocus","undoDepth","cards","atoms","cardOptions","unknownCardHandler","unknownAtomHandler","_ref2","html","CALLBACK_QUEUES","DID_UPDATE","WILL_RENDER","DID_RENDER","WILL_DELETE","DID_DELETE","CURSOR_DID_CHANGE","DID_REPARSE","POST_DID_CHANGE","INPUT_MODE_DID_CHANGE","Editor","_this","arguments","nodeType","_views","isEditable","_parserPlugins","parserPlugins","mergeWithOptions","DEFAULT_KEY_COMMANDS","forEach","kc","registerKeyCommand","_logManager","_parser","_renderer","loadPost","_renderTree","_editHistory","_eventManager","_mutationHandler","_editState","_callbacks","values","DEFAULT_TEXT_INPUT_HANDLERS","handler","onTextInput","hasRendered","logTypes","enableAll","enableTypes","disable","plugins","dom","createPost","_this2","postRenderNode","renderNode","element","markDirty","runCallbacks","suspendObservation","clearChildNodes","enableEditing","_addTooltip","run","rerender","init","selectRange","headPosition","addView","rootElement","showForTag","rawKeyCommand","keyCommand","buildKeyCommand","validateKeyCommand","keyCommands","unshift","position","direction","_ref3","unit","nextPosition","deleteAtPosition","deleteRange","_ref4","DIRECTION","BACKWARD","isCollapsed","event","preventDefault","cursorSection","splitSection","message","defaultValue","callback","window","prompt","offsets","setData","_postDidChange","_this3","currentRange","reparseSection","_removeDetachedSections","isDirty","filter","isAttached","scheduleForRemoval","markupTagName","markups","detect","hasTag","matchesFn","normalizeTagName","m","version","MOBILEDOC_VERSION","serializePost","format","validFormats","rendered","rendererOptions","result","view","v","destroy","isDestroyed","_hasSelection","clearSelection","_hasFocus","blur","removeAllViews","setAttribute","setPlaceholder","cardSection","_setCardMode","CARD_MODES","EDIT","DISPLAY","begin","complete","_readRangeFromDOM","_shouldCancelSnapshot","storeSnapshot","addCallback","inputHandler","registerInputHandler","_this4","createMarkupSection","insertSectionBefore","createMarkup","toggleMarkupState","_inputModeDidChange","_ensureFocus","toggleMarkup","focus","_hasCollapsedSelection","activeElement","_this5","toggleSection","findKeyCommands","text","_insertEmptyMarkupSectionAtCursor","insertTextWithMarkup","atomName","atomText","atomPayload","atom","createAtom","insertMarkers","cardName","_this6","cardPayload","inEditMode","card","createCardSection","editCard","replaceSection","collection","tailPosition","x","y","atPoint","mode","isRendered","cardNode","setInitialMode","context","eventName","_trigger","apply","_callbacks2","addCallbackOnce","_callbacks3","_builder","set","updateRange","rangeDidChange","_rangeDidChange","inputModeDidChange","_utilsParseUtils","_utilsCharacters","_editorTextInputHandler","_editorSelectionManager","_utilsBrowser","ELEMENT_EVENT_TYPES","EventManager","logger","loggerFor","_textInputHandler","_listeners","modifierKeys","shift","alt","ctrl","_selectionManager","selectionDidChange","bind","_addListener","start","register","listener","_handleEvent","addEventListener","removeEventListener","_ref32","_context","_type","_ref42","call","_removeListeners","isElementAddressable","isAddressable","selection","shouldNotify","anchorNode","fromEvent","isPrintable","handle","toString","_updateModifiersFromKey","isDown","handleKeyCommand","isHorizontalArrowWithoutModifiersOtherThanShift","isShift","extend","move","isDelete","isMac","isWin","performDelete","isEnter","handleNewline","isTab","insertText","TAB","copy","trimTo","data","setClipboardData","targetFormat","pastedPost","parsePostFromPaste","insertPost","clientX","clientY","positionAtPoint","parsePostFromDrop","log","_ref5","isShiftKey","isAltKey","isCtrlKey","_toArray","from","selectAll","gotoStartOfLine","gotoEndOfLine","deleteToEndOfSection","toggleLink","selectedText","defaultUrl","hasLink","detectMarkupInRange","showPrompt","url","href","str","undoLastChange","redoLastChange","modifierNamesToMask","modiferNames","defaultVal","reduce","sum","modifier","MODIFIERS","toUpperCase","characterToCode","character","upperCharacter","special","SPECIAL_KEYS","charCodeAt","_str$split$reverse","split","reverse","_str$split$reverse2","modifierNames","slice","modifierMask","code","keyEvent","keyCode","_utilsSet","MUTATION","NODES_CHANGED","CHARACTER_DATA","MutationHandler","renderTree","_isObserving","_observer","MutationObserver","mutations","_handleMutations","startObserving","stopObserving","disconnect","observe","characterData","childList","subtree","_reparsePost","_reparseSections","reparsePost","nodes","_findTargetNodes","j","node","_findRenderNodeFromNode","reparsesMutationOfChildNode","_findSectionFromRenderNode","add","reparseSections","toArray","mutation","addedNodes","n","removedNodes","attachedNodes","containsNode","findRenderNodeFromElement","rn","postNode","isSection","sectionRenderNode","_findSectionRenderNodeFromNode","_postPostInserter","_utilsDeprecate","FORWARD","isListSectionTagName","BEFORE_COMPLETE","COMPLETE","AFTER_COMPLETE","PostEditor","_didComplete","_renderRange","_rerender","scheduleAfterRender","cutSection","nextSection","nextLeafSection","nextPos","tmp","removeSection","tailPos","isMarkerable","join","_markDirty","append","isCardSection","isHead","isTail","newSection","splitMarkers","removeMarker","_removeBlankMarkers","_joinSimilarMarkers","markers","marker","nextMarker","canJoin","_scheduleForRemoval","remove","scheduleRerender","scheduleDidUpdate","removedAdjacentToList","prev","isListSection","_joinContiguousListSections","groups","currentGroup","updatedHead","group","list","listSection","currentHead","prevPosition","isListItem","_joinListSections","baseList","nextList","_coalesceMarkers","_deleteAtPositionBackward","_deleteAtPositionForward","moveWord","splitSectionMarkerAtOffset","markersContainedByRange","_this7","edit","splitMarkerAtOffset","removed","_this8","_splitCardSection","isLastAndBlank","_parent","blank","_splitListItem2","_splitListItem","_splitListItem22","pre","splitSections","splitAtPosition","_replaceSection","surroundingSections","renderedSection","beforeSection","clone","isFirst","moveSectionBefore","isLast","_this9","prevMarker","markerBeforeOffset","insertAfter","createMarker","newSections","_this10","nextNewSection","isMarkupSection","_this11","markupsOpenAcrossRange","soFar","commonItems","indexToInsert","addMarkupAtIndex","markupOrMarkupCallback","_this12","removeMarkup","markupOrMarkupString","hasMarkup","removeMarkupFromRange","addMarkupToRange","sectionTagName","_this13","nextRange","everySectionHasTagName","walkMarkerableSections","_isSameSectionType","firstChanged","changedSection","changeSectionTagName","newTagName","_changeSectionToListItem","_changeSectionFromListItem","item","preItem","createListItem","postItem","currentItem","positionIsMiddle","_splitListItem3","_splitListItem32","preList","createListSection","postList","currentList","items","_this14","mid","addToPrev","listToAppend","found","_list","markupSection","_splitListAtItem2","_splitListAtItem","_splitListAtItem22","isAlreadyCorrectListItem","sectionToReplace","_splitListAtItem3","_splitListAtItem32","insertBefore","activeSection","newPost","inserter","insert","_scheduleListRemovalIfEmpty","_this15","_this16","_this17","once","schedule","scheduleOnce","stepBackward","stepForward","_modelsTypes","MARKERABLE","NESTED_MARKERABLE","NON_MARKERABLE","Visitor","cursorPosition","_hasInsertedFirstLeafSection","method","_isMarkerable","POST_TYPE","_isNested","visit","MARKUP_SECTION_TYPE","LIST_SECTION_TYPE","hasNext","_breakNestedAtCursor","LIST_ITEM_TYPE","CARD_TYPE","IMAGE_SECTION_TYPE","_breakAtCursor","_insertLeafSection","_canMergeSection","_mergeSection","_wrapNestedSection","cursorAtEndOfList","_insertSectionAfter","_breakListAtCursor2","_breakListAtCursor","_breakListAtCursor22","_postEditor$_splitListAtPosition","_splitListAtPosition","_postEditor$_splitListAtPosition2","reference","_breakMarkerableAtCursor","_breakNonMarkerableAtCursor","_postEditor$splitSection","_postEditor$splitSection2","lastSection","_insertSectionBefore","_cursorPosition","Inserter","visitor","SelectionChangeObserver","started","listeners","stop","poll","_arguments","getSelection","focusNode","anchorOffset","focusOffset","update","runNext","fn","requestAnimationFrame","prevSelection","curSelection","selectionIsEqual","notifyListeners","s1","s2","getInstance","addListener","removeListener","_editorSelectionChangeObserver","SelectionManager","_utilsStringUtils","TextInputHandler","_handlers","_validateHandler","string","matchedHandler","_findHandler","_matchedHandler","matches","_editor$range","preText","textUntil","match","endsWith","test","exec","replaceWithListSection","listTagName","replaceWithHeaderSection","headingTagName","_editor$range2","capture","headingTag"],"sourceRoot":""}