) → this\n// Insert the given content at the given position.\nTransform.prototype.insert = function(pos, content) {\n return this.replaceWith(pos, pos, content)\n};\n\n\n\nfunction fitLeftInner($from, depth, placed, placedBelow) {\n var content = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, openEnd = 0, placedHere = placed[depth];\n if ($from.depth > depth) {\n var inner = fitLeftInner($from, depth + 1, placed, placedBelow || placedHere);\n openEnd = inner.openEnd + 1;\n content = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from($from.node(depth + 1).copy(inner.content));\n }\n\n if (placedHere) {\n content = content.append(placedHere.content);\n openEnd = placedHere.openEnd;\n }\n if (placedBelow) {\n content = content.append($from.node(depth).contentMatchAt($from.indexAfter(depth)).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true));\n openEnd = 0;\n }\n\n return {content: content, openEnd: openEnd}\n}\n\nfunction fitLeft($from, placed) {\n var ref = fitLeftInner($from, 0, placed, false);\n var content = ref.content;\n var openEnd = ref.openEnd;\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](content, $from.depth, openEnd || 0)\n}\n\nfunction fitRightJoin(content, parent, $from, $to, depth, openStart, openEnd) {\n var match, count = content.childCount, matchCount = count - (openEnd > 0 ? 1 : 0);\n var parentNode = openStart < 0 ? parent : $from.node(depth);\n if (openStart < 0)\n { match = parentNode.contentMatchAt(matchCount); }\n else if (count == 1 && openEnd > 0)\n { match = parentNode.contentMatchAt(openStart ? $from.index(depth) : $from.indexAfter(depth)); }\n else\n { match = parentNode.contentMatchAt($from.indexAfter(depth))\n .matchFragment(content, count > 0 && openStart ? 1 : 0, matchCount); }\n\n var toNode = $to.node(depth);\n if (openEnd > 0 && depth < $to.depth) {\n var after = toNode.content.cutByIndex($to.indexAfter(depth)).addToStart(content.lastChild);\n var joinable$1 = match.fillBefore(after, true);\n // Can't insert content if there's a single node stretched across this gap\n if (joinable$1 && joinable$1.size && openStart > 0 && count == 1) { joinable$1 = null; }\n\n if (joinable$1) {\n var inner = fitRightJoin(content.lastChild.content, content.lastChild, $from, $to,\n depth + 1, count == 1 ? openStart - 1 : -1, openEnd - 1);\n if (inner) {\n var last = content.lastChild.copy(inner);\n if (joinable$1.size)\n { return content.cutByIndex(0, count - 1).append(joinable$1).addToEnd(last) }\n else\n { return content.replaceChild(count - 1, last) }\n }\n }\n }\n if (openEnd > 0)\n { match = match.matchType((count == 1 && openStart > 0 ? $from.node(depth + 1) : content.lastChild).type); }\n\n // If we're here, the next level can't be joined, so we see what\n // happens if we leave it open.\n var toIndex = $to.index(depth);\n if (toIndex == toNode.childCount && !toNode.type.compatibleContent(parent.type)) { return null }\n var joinable = match.fillBefore(toNode.content, true, toIndex);\n for (var i = toIndex; joinable && i < toNode.content.childCount; i++)\n { if (!parentNode.type.allowsMarks(toNode.content.child(i).marks)) { joinable = null; } }\n if (!joinable) { return null }\n\n if (openEnd > 0) {\n var closed = fitRightClosed(content.lastChild, openEnd - 1, $from, depth + 1,\n count == 1 ? openStart - 1 : -1);\n content = content.replaceChild(count - 1, closed);\n }\n content = content.append(joinable);\n if ($to.depth > depth)\n { content = content.addToEnd(fitRightSeparate($to, depth + 1)); }\n return content\n}\n\nfunction fitRightClosed(node, openEnd, $from, depth, openStart) {\n var match, content = node.content, count = content.childCount;\n if (openStart >= 0)\n { match = $from.node(depth).contentMatchAt($from.indexAfter(depth))\n .matchFragment(content, openStart > 0 ? 1 : 0, count); }\n else\n { match = node.contentMatchAt(count); }\n\n if (openEnd > 0) {\n var closed = fitRightClosed(content.lastChild, openEnd - 1, $from, depth + 1,\n count == 1 ? openStart - 1 : -1);\n content = content.replaceChild(count - 1, closed);\n }\n\n return node.copy(content.append(match.fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true)))\n}\n\nfunction fitRightSeparate($to, depth) {\n var node = $to.node(depth);\n var fill = node.contentMatchAt(0).fillBefore(node.content, true, $to.index(depth));\n if ($to.depth > depth) { fill = fill.addToEnd(fitRightSeparate($to, depth + 1)); }\n return node.copy(fill)\n}\n\nfunction normalizeSlice(content, openStart, openEnd) {\n while (openStart > 0 && openEnd > 0 && content.childCount == 1) {\n content = content.firstChild.content;\n openStart--;\n openEnd--;\n }\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](content, openStart, openEnd)\n}\n\n// : (ResolvedPos, ResolvedPos, number, Slice) → Slice\nfunction fitRight($from, $to, slice) {\n var fitted = fitRightJoin(slice.content, $from.node(0), $from, $to, 0, slice.openStart, slice.openEnd);\n if (!fitted) { return null }\n return normalizeSlice(fitted, slice.openStart, $to.depth)\n}\n\nfunction fitsTrivially($from, $to, slice) {\n return !slice.openStart && !slice.openEnd && $from.start() == $to.start() &&\n $from.parent.canReplace($from.index(), $to.index(), slice.content)\n}\n\nfunction canMoveText($from, $to, slice) {\n if (!$to.parent.isTextblock) { return false }\n\n var parent = slice.openEnd ? nodeRight(slice.content, slice.openEnd)\n : $from.node($from.depth - (slice.openStart - slice.openEnd));\n if (!parent.isTextblock) { return false }\n for (var i = $to.index(); i < $to.parent.childCount; i++)\n { if (!parent.type.allowsMarks($to.parent.child(i).marks)) { return false } }\n var match;\n if (slice.openEnd) {\n match = parent.contentMatchAt(parent.childCount);\n } else {\n match = parent.contentMatchAt(parent.childCount);\n if (slice.size) { match = match.matchFragment(slice.content, slice.openStart ? 1 : 0); }\n }\n match = match.matchFragment($to.parent.content, $to.index());\n return match && match.validEnd\n}\n\nfunction nodeRight(content, depth) {\n for (var i = 1; i < depth; i++) { content = content.lastChild.content; }\n return content.lastChild\n}\n\n// Algorithm for 'placing' the elements of a slice into a gap:\n//\n// We consider the content of each node that is open to the left to be\n// independently placeable. I.e. in , when the\n// paragraph on the left is open, \"foo\" can be placed (somewhere on\n// the left side of the replacement gap) independently from p(\"bar\").\n//\n// So placeSlice splits up a slice into a number of sub-slices,\n// along with information on where they can be placed on the given\n// left-side edge. It works by walking the open side of the slice,\n// from the inside out, and trying to find a landing spot for each\n// element, by simultaneously scanning over the gap side. When no\n// place is found for an open node's content, it is left in that node.\n\n// : (ResolvedPos, Slice) → [{content: Fragment, openEnd: number, depth: number}]\nfunction placeSlice($from, slice) {\n var frontier = new Frontier($from);\n for (var pass = 1; slice.size && pass <= 3; pass++) {\n var value = frontier.placeSlice(slice.content, slice.openStart, slice.openEnd, pass);\n if (pass == 3 && value != slice && value.size) { pass = 0; } // Restart if the 3rd pass made progress but left content\n slice = value;\n }\n while (frontier.open.length) { frontier.closeNode(); }\n return frontier.placed\n}\n\n// Helper class that models the open side of the insert position,\n// keeping track of the content match and already inserted content\n// at each depth.\nvar Frontier = function Frontier($pos) {\n // : [{parent: Node, match: ContentMatch, content: Fragment, wrapper: bool, openEnd: number, depth: number}]\n this.open = [];\n for (var d = 0; d <= $pos.depth; d++) {\n var parent = $pos.node(d), match = parent.contentMatchAt($pos.indexAfter(d));\n this.open.push({parent: parent, match: match, content: prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, wrapper: false, openEnd: 0, depth: d});\n }\n this.placed = [];\n};\n\n// : (Fragment, number, number, number, ?Node) → Slice\n// Tries to place the content of the given slice, and returns a\n// slice containing unplaced content.\n//\n// pass 1: try to fit directly\n// pass 2: allow wrapper nodes to be introduced\n// pass 3: allow unwrapping of nodes that aren't open\nFrontier.prototype.placeSlice = function placeSlice (fragment, openStart, openEnd, pass, parent) {\n if (openStart > 0) {\n var first = fragment.firstChild;\n var inner = this.placeSlice(first.content, Math.max(0, openStart - 1),\n openEnd && fragment.childCount == 1 ? openEnd - 1 : 0,\n pass, first);\n if (inner.content != first.content) {\n if (inner.content.size) {\n fragment = fragment.replaceChild(0, first.copy(inner.content));\n openStart = inner.openStart + 1;\n } else {\n if (fragment.childCount == 1) { openEnd = 0; }\n fragment = fragment.cutByIndex(1);\n openStart = 0;\n }\n }\n }\n var result = this.placeContent(fragment, openStart, openEnd, pass, parent);\n if (pass > 2 && result.size && openStart == 0) {\n var child = result.content.firstChild, single = result.content.childCount == 1;\n this.placeContent(child.content, 0, openEnd && single ? openEnd - 1 : 0, pass, child);\n result = single ? prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty : new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](result.content.cutByIndex(1), 0, openEnd);\n }\n return result\n};\n\nFrontier.prototype.placeContent = function placeContent (fragment, openStart, openEnd, pass, parent) {\n var i = 0;\n // Go over the fragment's children\n for (; i < fragment.childCount; i++) {\n var child = fragment.child(i), placed = false, last = i == fragment.childCount - 1;\n // Try each open node in turn, starting from the innermost\n for (var d = this.open.length - 1; d >= 0; d--) {\n var open = this.open[d], wrap = (void 0);\n\n // If pass > 1, it is allowed to wrap the node to help find a\n // fit, so if findWrapping returns something, we add open\n // nodes to the frontier for that wrapping.\n if (pass > 1 && (wrap = open.match.findWrapping(child.type)) &&\n !(parent && wrap.length && wrap[wrap.length - 1] == parent.type)) {\n while (this.open.length - 1 > d) { this.closeNode(); }\n for (var w = 0; w < wrap.length; w++) {\n open.match = open.match.matchType(wrap[w]);\n d++;\n open = {parent: wrap[w].create(),\n match: wrap[w].contentMatch,\n content: prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, wrapper: true, openEnd: 0, depth: d + w};\n this.open.push(open);\n }\n }\n\n // See if the child fits here\n var match = open.match.matchType(child.type);\n if (!match) {\n var fill = open.match.fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(child));\n if (fill) {\n for (var j = 0; j < fill.childCount; j++) {\n var ch = fill.child(j);\n this.addNode(open, ch, 0);\n match = open.match.matchFragment(ch);\n }\n } else if (parent && open.match.matchType(parent.type)) {\n // Don't continue looking further up if the parent node\n // would fit here.\n break\n } else {\n continue\n }\n }\n\n // Close open nodes above this one, since we're starting to\n // add to this.\n while (this.open.length - 1 > d) { this.closeNode(); }\n // Strip marks from the child or close its start when necessary\n child = child.mark(open.parent.type.allowedMarks(child.marks));\n if (openStart) {\n child = closeNodeStart(child, openStart, last ? openEnd : 0);\n openStart = 0;\n }\n // Add the child to this open node and adjust its metadata\n this.addNode(open, child, last ? openEnd : 0);\n open.match = match;\n if (last) { openEnd = 0; }\n placed = true;\n break\n }\n // As soon as we've failed to place a node we stop looking at\n // later nodes\n if (!placed) { break }\n }\n // Close the current open node if it's not the the root and we\n // either placed up to the end of the node or the the current\n // slice depth's node type matches the open node's type\n if (this.open.length > 1 &&\n (i > 0 && i == fragment.childCount ||\n parent && this.open[this.open.length - 1].parent.type == parent.type))\n { this.closeNode(); }\n\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](fragment.cutByIndex(i), openStart, openEnd)\n};\n\nFrontier.prototype.addNode = function addNode (open, node, openEnd) {\n open.content = closeFragmentEnd(open.content, open.openEnd).addToEnd(node);\n open.openEnd = openEnd;\n};\n\nFrontier.prototype.closeNode = function closeNode () {\n var open = this.open.pop();\n if (open.content.size == 0) ; else if (open.wrapper) {\n this.addNode(this.open[this.open.length - 1], open.parent.copy(open.content), open.openEnd + 1);\n } else {\n this.placed[open.depth] = {depth: open.depth, content: open.content, openEnd: open.openEnd};\n }\n};\n\nfunction closeNodeStart(node, openStart, openEnd) {\n var content = node.content;\n if (openStart > 1) {\n var first = closeNodeStart(node.firstChild, openStart - 1, node.childCount == 1 ? openEnd - 1 : 0);\n content = node.content.replaceChild(0, first);\n }\n var fill = node.type.contentMatch.fillBefore(content, openEnd == 0);\n return node.copy(fill.append(content))\n}\n\nfunction closeNodeEnd(node, depth) {\n var content = node.content;\n if (depth > 1) {\n var last = closeNodeEnd(node.lastChild, depth - 1);\n content = node.content.replaceChild(node.childCount - 1, last);\n }\n var fill = node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true);\n return node.copy(content.append(fill))\n}\n\nfunction closeFragmentEnd(fragment, depth) {\n return depth ? fragment.replaceChild(fragment.childCount - 1, closeNodeEnd(fragment.lastChild, depth)) : fragment\n}\n\n// :: (number, number, Slice) → this\n// Replace a range of the document with a given slice, using `from`,\n// `to`, and the slice's [`openStart`](#model.Slice.openStart) property\n// as hints, rather than fixed start and end points. This method may\n// grow the replaced area or close open nodes in the slice in order to\n// get a fit that is more in line with WYSIWYG expectations, by\n// dropping fully covered parent nodes of the replaced region when\n// they are marked [non-defining](#model.NodeSpec.defining), or\n// including an open parent node from the slice that _is_ marked as\n// [defining](#model.NodeSpec.defining).\n//\n// This is the method, for example, to handle paste. The similar\n// [`replace`](#transform.Transform.replace) method is a more\n// primitive tool which will _not_ move the start and end of its given\n// range, and is useful in situations where you need more precise\n// control over what happens.\nTransform.prototype.replaceRange = function(from, to, slice) {\n if (!slice.size) { return this.deleteRange(from, to) }\n\n var $from = this.doc.resolve(from), $to = this.doc.resolve(to);\n if (fitsTrivially($from, $to, slice))\n { return this.step(new ReplaceStep(from, to, slice)) }\n\n var targetDepths = coveredDepths($from, this.doc.resolve(to));\n // Can't replace the whole document, so remove 0 if it's present\n if (targetDepths[targetDepths.length - 1] == 0) { targetDepths.pop(); }\n // Negative numbers represent not expansion over the whole node at\n // that depth, but replacing from $from.before(-D) to $to.pos.\n var preferredTarget = -($from.depth + 1);\n targetDepths.unshift(preferredTarget);\n // This loop picks a preferred target depth, if one of the covering\n // depths is not outside of a defining node, and adds negative\n // depths for any depth that has $from at its start and does not\n // cross a defining node.\n for (var d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {\n var spec = $from.node(d).type.spec;\n if (spec.defining || spec.isolating) { break }\n if (targetDepths.indexOf(d) > -1) { preferredTarget = d; }\n else if ($from.before(d) == pos) { targetDepths.splice(1, 0, -d); }\n }\n // Try to fit each possible depth of the slice into each possible\n // target depth, starting with the preferred depths.\n var preferredTargetIndex = targetDepths.indexOf(preferredTarget);\n\n var leftNodes = [], preferredDepth = slice.openStart;\n for (var content = slice.content, i = 0;; i++) {\n var node = content.firstChild;\n leftNodes.push(node);\n if (i == slice.openStart) { break }\n content = node.content;\n }\n // Back up if the node directly above openStart, or the node above\n // that separated only by a non-defining textblock node, is defining.\n if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining &&\n $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 1].type)\n { preferredDepth -= 1; }\n else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining &&\n $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 2].type)\n { preferredDepth -= 2; }\n\n for (var j = slice.openStart; j >= 0; j--) {\n var openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);\n var insert = leftNodes[openDepth];\n if (!insert) { continue }\n for (var i$1 = 0; i$1 < targetDepths.length; i$1++) {\n // Loop over possible expansion levels, starting with the\n // preferred one\n var targetDepth = targetDepths[(i$1 + preferredTargetIndex) % targetDepths.length], expand = true;\n if (targetDepth < 0) { expand = false; targetDepth = -targetDepth; }\n var parent = $from.node(targetDepth - 1), index = $from.index(targetDepth - 1);\n if (parent.canReplaceWith(index, index, insert.type, insert.marks))\n { return this.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to,\n new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](closeFragment(slice.content, 0, slice.openStart, openDepth),\n openDepth, slice.openEnd)) }\n }\n }\n\n var startSteps = this.steps.length;\n for (var i$2 = targetDepths.length - 1; i$2 >= 0; i$2--) {\n this.replace(from, to, slice);\n if (this.steps.length > startSteps) { break }\n var depth = targetDepths[i$2];\n if (i$2 < 0) { continue }\n from = $from.before(depth); to = $to.after(depth);\n }\n return this\n};\n\nfunction closeFragment(fragment, depth, oldOpen, newOpen, parent) {\n if (depth < oldOpen) {\n var first = fragment.firstChild;\n fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));\n }\n if (depth > newOpen) {\n var match = parent.contentMatchAt(0);\n var start = match.fillBefore(fragment).append(fragment);\n fragment = start.append(match.matchFragment(start).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true));\n }\n return fragment\n}\n\n// :: (number, number, Node) → this\n// Replace the given range with a node, but use `from` and `to` as\n// hints, rather than precise positions. When from and to are the same\n// and are at the start or end of a parent node in which the given\n// node doesn't fit, this method may _move_ them out towards a parent\n// that does allow the given node to be placed. When the given range\n// completely covers a parent node, this method may completely replace\n// that parent node.\nTransform.prototype.replaceRangeWith = function(from, to, node) {\n if (!node.isInline && from == to && this.doc.resolve(from).parent.content.size) {\n var point = insertPoint(this.doc, from, node.type);\n if (point != null) { from = to = point; }\n }\n return this.replaceRange(from, to, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(node), 0, 0))\n};\n\n// :: (number, number) → this\n// Delete the given range, expanding it to cover fully covered\n// parent nodes until a valid replace is found.\nTransform.prototype.deleteRange = function(from, to) {\n var $from = this.doc.resolve(from), $to = this.doc.resolve(to);\n var covered = coveredDepths($from, $to);\n for (var i = 0; i < covered.length; i++) {\n var depth = covered[i], last = i == covered.length - 1;\n if ((last && depth == 0) || $from.node(depth).type.contentMatch.validEnd)\n { return this.delete($from.start(depth), $to.end(depth)) }\n if (depth > 0 && (last || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1))))\n { return this.delete($from.before(depth), $to.after(depth)) }\n }\n for (var d = 1; d <= $from.depth && d <= $to.depth; d++) {\n if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d)\n { return this.delete($from.before(d), to) }\n }\n return this.delete(from, to)\n};\n\n// : (ResolvedPos, ResolvedPos) → [number]\n// Returns an array of all depths for which $from - $to spans the\n// whole content of the nodes at that depth.\nfunction coveredDepths($from, $to) {\n var result = [], minDepth = Math.min($from.depth, $to.depth);\n for (var d = minDepth; d >= 0; d--) {\n var start = $from.start(d);\n if (start < $from.pos - ($from.depth - d) ||\n $to.end(d) > $to.pos + ($to.depth - d) ||\n $from.node(d).type.spec.isolating ||\n $to.node(d).type.spec.isolating) { break }\n if (start == $to.start(d)) { result.push(d); }\n }\n return result\n}\n\n\n//# sourceMappingURL=index.es.js.map\n\n\n//# sourceURL=webpack:///./node_modules/prosemirror-transform/dist/index.es.js?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"AddMarkStep\", function() { return AddMarkStep; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"MapResult\", function() { return MapResult; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Mapping\", function() { return Mapping; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"RemoveMarkStep\", function() { return RemoveMarkStep; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ReplaceAroundStep\", function() { return ReplaceAroundStep; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ReplaceStep\", function() { return ReplaceStep; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Step\", function() { return Step; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"StepMap\", function() { return StepMap; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"StepResult\", function() { return StepResult; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Transform\", function() { return Transform; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TransformError\", function() { return TransformError; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"canJoin\", function() { return canJoin; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"canSplit\", function() { return canSplit; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dropPoint\", function() { return dropPoint; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"findWrapping\", function() { return findWrapping; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"insertPoint\", function() { return insertPoint; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"joinPoint\", function() { return joinPoint; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"liftTarget\", function() { return liftTarget; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"replaceStep\", function() { return replaceStep; });\n/* harmony import */ var prosemirror_model__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prosemirror-model */ \"./node_modules/prosemirror-model/dist/index.es.js\");\n // Mappable:: interface\n// There are several things that positions can be mapped through.\n// Such objects conform to this interface.\n//\n// map:: (pos: number, assoc: ?number) → number\n// Map a position through this object. When given, `assoc` (should\n// be -1 or 1, defaults to 1) determines with which side the\n// position is associated, which determines in which direction to\n// move when a chunk of content is inserted at the mapped position.\n//\n// mapResult:: (pos: number, assoc: ?number) → MapResult\n// Map a position, and return an object containing additional\n// information about the mapping. The result's `deleted` field tells\n// you whether the position was deleted (completely enclosed in a\n// replaced range) during the mapping. When content on only one side\n// is deleted, the position itself is only considered deleted when\n// `assoc` points in the direction of the deleted content.\n// Recovery values encode a range index and an offset. They are\n// represented as numbers, because tons of them will be created when\n// mapping, for example, a large number of decorations. The number's\n// lower 16 bits provide the index, the remaining bits the offset.\n//\n// Note: We intentionally don't use bit shift operators to en- and\n// decode these, since those clip to 32 bits, which we might in rare\n// cases want to overflow. A 64-bit float can represent 48-bit\n// integers precisely.\n\nvar lower16 = 0xffff;\nvar factor16 = Math.pow(2, 16);\n\nfunction makeRecover(index, offset) {\n return index + offset * factor16;\n}\n\nfunction recoverIndex(value) {\n return value & lower16;\n}\n\nfunction recoverOffset(value) {\n return (value - (value & lower16)) / factor16;\n} // ::- An object representing a mapped position with extra\n// information.\n\n\nvar MapResult = function MapResult(pos, deleted, recover) {\n if (deleted === void 0) deleted = false;\n if (recover === void 0) recover = null; // :: number The mapped version of the position.\n\n this.pos = pos; // :: bool Tells you whether the position was deleted, that is,\n // whether the step removed its surroundings from the document.\n\n this.deleted = deleted;\n this.recover = recover;\n}; // :: class extends Mappable\n// A map describing the deletions and insertions made by a step, which\n// can be used to find the correspondence between positions in the\n// pre-step version of a document and the same position in the\n// post-step version.\n\n\nvar StepMap = function StepMap(ranges, inverted) {\n if (inverted === void 0) inverted = false;\n this.ranges = ranges;\n this.inverted = inverted;\n};\n\nStepMap.prototype.recover = function recover(value) {\n var diff = 0,\n index = recoverIndex(value);\n\n if (!this.inverted) {\n for (var i = 0; i < index; i++) {\n diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];\n }\n }\n\n return this.ranges[index * 3] + diff + recoverOffset(value);\n}; // : (number, ?number) → MapResult\n\n\nStepMap.prototype.mapResult = function mapResult(pos, assoc) {\n if (assoc === void 0) assoc = 1;\n return this._map(pos, assoc, false);\n}; // : (number, ?number) → number\n\n\nStepMap.prototype.map = function map(pos, assoc) {\n if (assoc === void 0) assoc = 1;\n return this._map(pos, assoc, true);\n};\n\nStepMap.prototype._map = function _map(pos, assoc, simple) {\n var diff = 0,\n oldIndex = this.inverted ? 2 : 1,\n newIndex = this.inverted ? 1 : 2;\n\n for (var i = 0; i < this.ranges.length; i += 3) {\n var start = this.ranges[i] - (this.inverted ? diff : 0);\n\n if (start > pos) {\n break;\n }\n\n var oldSize = this.ranges[i + oldIndex],\n newSize = this.ranges[i + newIndex],\n end = start + oldSize;\n\n if (pos <= end) {\n var side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;\n var result = start + diff + (side < 0 ? 0 : newSize);\n\n if (simple) {\n return result;\n }\n\n var recover = makeRecover(i / 3, pos - start);\n return new MapResult(result, assoc < 0 ? pos != start : pos != end, recover);\n }\n\n diff += newSize - oldSize;\n }\n\n return simple ? pos + diff : new MapResult(pos + diff);\n};\n\nStepMap.prototype.touches = function touches(pos, recover) {\n var diff = 0,\n index = recoverIndex(recover);\n var oldIndex = this.inverted ? 2 : 1,\n newIndex = this.inverted ? 1 : 2;\n\n for (var i = 0; i < this.ranges.length; i += 3) {\n var start = this.ranges[i] - (this.inverted ? diff : 0);\n\n if (start > pos) {\n break;\n }\n\n var oldSize = this.ranges[i + oldIndex],\n end = start + oldSize;\n\n if (pos <= end && i == index * 3) {\n return true;\n }\n\n diff += this.ranges[i + newIndex] - oldSize;\n }\n\n return false;\n}; // :: ((oldStart: number, oldEnd: number, newStart: number, newEnd: number))\n// Calls the given function on each of the changed ranges included in\n// this map.\n\n\nStepMap.prototype.forEach = function forEach(f) {\n var oldIndex = this.inverted ? 2 : 1,\n newIndex = this.inverted ? 1 : 2;\n\n for (var i = 0, diff = 0; i < this.ranges.length; i += 3) {\n var start = this.ranges[i],\n oldStart = start - (this.inverted ? diff : 0),\n newStart = start + (this.inverted ? 0 : diff);\n var oldSize = this.ranges[i + oldIndex],\n newSize = this.ranges[i + newIndex];\n f(oldStart, oldStart + oldSize, newStart, newStart + newSize);\n diff += newSize - oldSize;\n }\n}; // :: () → StepMap\n// Create an inverted version of this map. The result can be used to\n// map positions in the post-step document to the pre-step document.\n\n\nStepMap.prototype.invert = function invert() {\n return new StepMap(this.ranges, !this.inverted);\n};\n\nStepMap.prototype.toString = function toString() {\n return (this.inverted ? \"-\" : \"\") + JSON.stringify(this.ranges);\n}; // :: (n: number) → StepMap\n// Create a map that moves all positions by offset `n` (which may be\n// negative). This can be useful when applying steps meant for a\n// sub-document to a larger document, or vice-versa.\n\n\nStepMap.offset = function offset(n) {\n return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);\n};\n\nStepMap.empty = new StepMap([]); // :: class extends Mappable\n// A mapping represents a pipeline of zero or more [step\n// maps](#transform.StepMap). It has special provisions for losslessly\n// handling mapping positions through a series of steps in which some\n// steps are inverted versions of earlier steps. (This comes up when\n// ‘[rebasing](/docs/guide/#transform.rebasing)’ steps for\n// collaboration or history management.)\n\nvar Mapping = function Mapping(maps, mirror, from, to) {\n // :: [StepMap]\n // The step maps in this mapping.\n this.maps = maps || []; // :: number\n // The starting position in the `maps` array, used when `map` or\n // `mapResult` is called.\n\n this.from = from || 0; // :: number\n // The end position in the `maps` array.\n\n this.to = to == null ? this.maps.length : to;\n this.mirror = mirror;\n}; // :: (?number, ?number) → Mapping\n// Create a mapping that maps only through a part of this one.\n\n\nMapping.prototype.slice = function slice(from, to) {\n if (from === void 0) from = 0;\n if (to === void 0) to = this.maps.length;\n return new Mapping(this.maps, this.mirror, from, to);\n};\n\nMapping.prototype.copy = function copy() {\n return new Mapping(this.maps.slice(), this.mirror && this.mirror.slice(), this.from, this.to);\n}; // :: (StepMap, ?number)\n// Add a step map to the end of this mapping. If `mirrors` is\n// given, it should be the index of the step map that is the mirror\n// image of this one.\n\n\nMapping.prototype.appendMap = function appendMap(map, mirrors) {\n this.to = this.maps.push(map);\n\n if (mirrors != null) {\n this.setMirror(this.maps.length - 1, mirrors);\n }\n}; // :: (Mapping)\n// Add all the step maps in a given mapping to this one (preserving\n// mirroring information).\n\n\nMapping.prototype.appendMapping = function appendMapping(mapping) {\n for (var i = 0, startSize = this.maps.length; i < mapping.maps.length; i++) {\n var mirr = mapping.getMirror(i);\n this.appendMap(mapping.maps[i], mirr != null && mirr < i ? startSize + mirr : null);\n }\n}; // :: (number) → ?number\n// Finds the offset of the step map that mirrors the map at the\n// given offset, in this mapping (as per the second argument to\n// `appendMap`).\n\n\nMapping.prototype.getMirror = function getMirror(n) {\n if (this.mirror) {\n for (var i = 0; i < this.mirror.length; i++) {\n if (this.mirror[i] == n) {\n return this.mirror[i + (i % 2 ? -1 : 1)];\n }\n }\n }\n};\n\nMapping.prototype.setMirror = function setMirror(n, m) {\n if (!this.mirror) {\n this.mirror = [];\n }\n\n this.mirror.push(n, m);\n}; // :: (Mapping)\n// Append the inverse of the given mapping to this one.\n\n\nMapping.prototype.appendMappingInverted = function appendMappingInverted(mapping) {\n for (var i = mapping.maps.length - 1, totalSize = this.maps.length + mapping.maps.length; i >= 0; i--) {\n var mirr = mapping.getMirror(i);\n this.appendMap(mapping.maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : null);\n }\n}; // :: () → Mapping\n// Create an inverted version of this mapping.\n\n\nMapping.prototype.invert = function invert() {\n var inverse = new Mapping();\n inverse.appendMappingInverted(this);\n return inverse;\n}; // : (number, ?number) → number\n// Map a position through this mapping.\n\n\nMapping.prototype.map = function map(pos, assoc) {\n if (assoc === void 0) assoc = 1;\n\n if (this.mirror) {\n return this._map(pos, assoc, true);\n }\n\n for (var i = this.from; i < this.to; i++) {\n pos = this.maps[i].map(pos, assoc);\n }\n\n return pos;\n}; // : (number, ?number) → MapResult\n// Map a position through this mapping, returning a mapping\n// result.\n\n\nMapping.prototype.mapResult = function mapResult(pos, assoc) {\n if (assoc === void 0) assoc = 1;\n return this._map(pos, assoc, false);\n};\n\nMapping.prototype._map = function _map(pos, assoc, simple) {\n var deleted = false,\n recoverables = null;\n\n for (var i = this.from; i < this.to; i++) {\n var map = this.maps[i],\n rec = recoverables && recoverables[i];\n\n if (rec != null && map.touches(pos, rec)) {\n pos = map.recover(rec);\n continue;\n }\n\n var result = map.mapResult(pos, assoc);\n\n if (result.recover != null) {\n var corr = this.getMirror(i);\n\n if (corr != null && corr > i && corr < this.to) {\n if (result.deleted) {\n i = corr;\n pos = this.maps[corr].recover(result.recover);\n continue;\n } else {\n (recoverables || (recoverables = Object.create(null)))[corr] = result.recover;\n }\n }\n }\n\n if (result.deleted) {\n deleted = true;\n }\n\n pos = result.pos;\n }\n\n return simple ? pos : new MapResult(pos, deleted);\n};\n\nfunction TransformError(message) {\n var err = Error.call(this, message);\n err.__proto__ = TransformError.prototype;\n return err;\n}\n\nTransformError.prototype = Object.create(Error.prototype);\nTransformError.prototype.constructor = TransformError;\nTransformError.prototype.name = \"TransformError\"; // ::- Abstraction to build up and track an array of\n// [steps](#transform.Step) representing a document transformation.\n//\n// Most transforming methods return the `Transform` object itself, so\n// that they can be chained.\n\nvar Transform = function Transform(doc) {\n // :: Node\n // The current document (the result of applying the steps in the\n // transform).\n this.doc = doc; // :: [Step]\n // The steps in this transform.\n\n this.steps = []; // :: [Node]\n // The documents before each of the steps.\n\n this.docs = []; // :: Mapping\n // A mapping with the maps for each of the steps in this transform.\n\n this.mapping = new Mapping();\n};\n\nvar prototypeAccessors = {\n before: {\n configurable: true\n },\n docChanged: {\n configurable: true\n }\n}; // :: Node The starting document.\n\nprototypeAccessors.before.get = function () {\n return this.docs.length ? this.docs[0] : this.doc;\n}; // :: (step: Step) → this\n// Apply a new step in this transform, saving the result. Throws an\n// error when the step fails.\n\n\nTransform.prototype.step = function step(object) {\n var result = this.maybeStep(object);\n\n if (result.failed) {\n throw new TransformError(result.failed);\n }\n\n return this;\n}; // :: (Step) → StepResult\n// Try to apply a step in this transformation, ignoring it if it\n// fails. Returns the step result.\n\n\nTransform.prototype.maybeStep = function maybeStep(step) {\n var result = step.apply(this.doc);\n\n if (!result.failed) {\n this.addStep(step, result.doc);\n }\n\n return result;\n}; // :: bool\n// True when the document has been changed (when there are any\n// steps).\n\n\nprototypeAccessors.docChanged.get = function () {\n return this.steps.length > 0;\n};\n\nTransform.prototype.addStep = function addStep(step, doc) {\n this.docs.push(this.doc);\n this.steps.push(step);\n this.mapping.appendMap(step.getMap());\n this.doc = doc;\n};\n\nObject.defineProperties(Transform.prototype, prototypeAccessors);\n\nfunction mustOverride() {\n throw new Error(\"Override me\");\n}\n\nvar stepsByID = Object.create(null); // ::- A step object represents an atomic change. It generally applies\n// only to the document it was created for, since the positions\n// stored in it will only make sense for that document.\n//\n// New steps are defined by creating classes that extend `Step`,\n// overriding the `apply`, `invert`, `map`, `getMap` and `fromJSON`\n// methods, and registering your class with a unique\n// JSON-serialization identifier using\n// [`Step.jsonID`](#transform.Step^jsonID).\n\nvar Step = function Step() {};\n\nStep.prototype.apply = function apply(_doc) {\n return mustOverride();\n}; // :: () → StepMap\n// Get the step map that represents the changes made by this step,\n// and which can be used to transform between positions in the old\n// and the new document.\n\n\nStep.prototype.getMap = function getMap() {\n return StepMap.empty;\n}; // :: (doc: Node) → Step\n// Create an inverted version of this step. Needs the document as it\n// was before the step as argument.\n\n\nStep.prototype.invert = function invert(_doc) {\n return mustOverride();\n}; // :: (mapping: Mappable) → ?Step\n// Map this step through a mappable thing, returning either a\n// version of that step with its positions adjusted, or `null` if\n// the step was entirely deleted by the mapping.\n\n\nStep.prototype.map = function map(_mapping) {\n return mustOverride();\n}; // :: (other: Step) → ?Step\n// Try to merge this step with another one, to be applied directly\n// after it. Returns the merged step when possible, null if the\n// steps can't be merged.\n\n\nStep.prototype.merge = function merge(_other) {\n return null;\n}; // :: () → Object\n// Create a JSON-serializeable representation of this step. When\n// defining this for a custom subclass, make sure the result object\n// includes the step type's [JSON id](#transform.Step^jsonID) under\n// the `stepType` property.\n\n\nStep.prototype.toJSON = function toJSON() {\n return mustOverride();\n}; // :: (Schema, Object) → Step\n// Deserialize a step from its JSON representation. Will call\n// through to the step class' own implementation of this method.\n\n\nStep.fromJSON = function fromJSON(schema, json) {\n if (!json || !json.stepType) {\n throw new RangeError(\"Invalid input for Step.fromJSON\");\n }\n\n var type = stepsByID[json.stepType];\n\n if (!type) {\n throw new RangeError(\"No step type \" + json.stepType + \" defined\");\n }\n\n return type.fromJSON(schema, json);\n}; // :: (string, constructor)\n// To be able to serialize steps to JSON, each step needs a string\n// ID to attach to its JSON representation. Use this method to\n// register an ID for your step classes. Try to pick something\n// that's unlikely to clash with steps from other modules.\n\n\nStep.jsonID = function jsonID(id, stepClass) {\n if (id in stepsByID) {\n throw new RangeError(\"Duplicate use of step JSON ID \" + id);\n }\n\n stepsByID[id] = stepClass;\n stepClass.prototype.jsonID = id;\n return stepClass;\n}; // ::- The result of [applying](#transform.Step.apply) a step. Contains either a\n// new document or a failure value.\n\n\nvar StepResult = function StepResult(doc, failed) {\n // :: ?Node The transformed document.\n this.doc = doc; // :: ?string Text providing information about a failed step.\n\n this.failed = failed;\n}; // :: (Node) → StepResult\n// Create a successful step result.\n\n\nStepResult.ok = function ok(doc) {\n return new StepResult(doc, null);\n}; // :: (string) → StepResult\n// Create a failed step result.\n\n\nStepResult.fail = function fail(message) {\n return new StepResult(null, message);\n}; // :: (Node, number, number, Slice) → StepResult\n// Call [`Node.replace`](#model.Node.replace) with the given\n// arguments. Create a successful result if it succeeds, and a\n// failed one if it throws a `ReplaceError`.\n\n\nStepResult.fromReplace = function fromReplace(doc, from, to, slice) {\n try {\n return StepResult.ok(doc.replace(from, to, slice));\n } catch (e) {\n if (e instanceof prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"ReplaceError\"]) {\n return StepResult.fail(e.message);\n }\n\n throw e;\n }\n}; // ::- Replace a part of the document with a slice of new content.\n\n\nvar ReplaceStep = /*@__PURE__*/function (Step) {\n function ReplaceStep(from, to, slice, structure) {\n Step.call(this);\n this.from = from;\n this.to = to;\n this.slice = slice;\n this.structure = !!structure;\n }\n\n if (Step) ReplaceStep.__proto__ = Step;\n ReplaceStep.prototype = Object.create(Step && Step.prototype);\n ReplaceStep.prototype.constructor = ReplaceStep;\n\n ReplaceStep.prototype.apply = function apply(doc) {\n if (this.structure && contentBetween(doc, this.from, this.to)) {\n return StepResult.fail(\"Structure replace would overwrite content\");\n }\n\n return StepResult.fromReplace(doc, this.from, this.to, this.slice);\n };\n\n ReplaceStep.prototype.getMap = function getMap() {\n return new StepMap([this.from, this.to - this.from, this.slice.size]);\n };\n\n ReplaceStep.prototype.invert = function invert(doc) {\n return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));\n };\n\n ReplaceStep.prototype.map = function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n\n if (from.deleted && to.deleted) {\n return null;\n }\n\n return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);\n };\n\n ReplaceStep.prototype.merge = function merge(other) {\n if (!(other instanceof ReplaceStep) || other.structure != this.structure) {\n return null;\n }\n\n if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {\n var slice = this.slice.size + other.slice.size == 0 ? prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty : new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);\n return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);\n } else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {\n var slice$1 = this.slice.size + other.slice.size == 0 ? prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty : new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);\n return new ReplaceStep(other.from, this.to, slice$1, this.structure);\n } else {\n return null;\n }\n };\n\n ReplaceStep.prototype.toJSON = function toJSON() {\n var json = {\n stepType: \"replace\",\n from: this.from,\n to: this.to\n };\n\n if (this.slice.size) {\n json.slice = this.slice.toJSON();\n }\n\n if (this.structure) {\n json.structure = true;\n }\n\n return json;\n };\n\n ReplaceStep.fromJSON = function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\") {\n throw new RangeError(\"Invalid input for ReplaceStep.fromJSON\");\n }\n\n return new ReplaceStep(json.from, json.to, prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].fromJSON(schema, json.slice), !!json.structure);\n };\n\n return ReplaceStep;\n}(Step);\n\nStep.jsonID(\"replace\", ReplaceStep); // ::- Replace a part of the document with a slice of content, but\n// preserve a range of the replaced content by moving it into the\n// slice.\n\nvar ReplaceAroundStep = /*@__PURE__*/function (Step) {\n function ReplaceAroundStep(from, to, gapFrom, gapTo, slice, insert, structure) {\n Step.call(this);\n this.from = from;\n this.to = to;\n this.gapFrom = gapFrom;\n this.gapTo = gapTo;\n this.slice = slice;\n this.insert = insert;\n this.structure = !!structure;\n }\n\n if (Step) ReplaceAroundStep.__proto__ = Step;\n ReplaceAroundStep.prototype = Object.create(Step && Step.prototype);\n ReplaceAroundStep.prototype.constructor = ReplaceAroundStep;\n\n ReplaceAroundStep.prototype.apply = function apply(doc) {\n if (this.structure && (contentBetween(doc, this.from, this.gapFrom) || contentBetween(doc, this.gapTo, this.to))) {\n return StepResult.fail(\"Structure gap-replace would overwrite content\");\n }\n\n var gap = doc.slice(this.gapFrom, this.gapTo);\n\n if (gap.openStart || gap.openEnd) {\n return StepResult.fail(\"Gap is not a flat range\");\n }\n\n var inserted = this.slice.insertAt(this.insert, gap.content);\n\n if (!inserted) {\n return StepResult.fail(\"Content does not fit in gap\");\n }\n\n return StepResult.fromReplace(doc, this.from, this.to, inserted);\n };\n\n ReplaceAroundStep.prototype.getMap = function getMap() {\n return new StepMap([this.from, this.gapFrom - this.from, this.insert, this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);\n };\n\n ReplaceAroundStep.prototype.invert = function invert(doc) {\n var gap = this.gapTo - this.gapFrom;\n return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);\n };\n\n ReplaceAroundStep.prototype.map = function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n var gapFrom = mapping.map(this.gapFrom, -1),\n gapTo = mapping.map(this.gapTo, 1);\n\n if (from.deleted && to.deleted || gapFrom < from.pos || gapTo > to.pos) {\n return null;\n }\n\n return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);\n };\n\n ReplaceAroundStep.prototype.toJSON = function toJSON() {\n var json = {\n stepType: \"replaceAround\",\n from: this.from,\n to: this.to,\n gapFrom: this.gapFrom,\n gapTo: this.gapTo,\n insert: this.insert\n };\n\n if (this.slice.size) {\n json.slice = this.slice.toJSON();\n }\n\n if (this.structure) {\n json.structure = true;\n }\n\n return json;\n };\n\n ReplaceAroundStep.fromJSON = function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\" || typeof json.gapFrom != \"number\" || typeof json.gapTo != \"number\" || typeof json.insert != \"number\") {\n throw new RangeError(\"Invalid input for ReplaceAroundStep.fromJSON\");\n }\n\n return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].fromJSON(schema, json.slice), json.insert, !!json.structure);\n };\n\n return ReplaceAroundStep;\n}(Step);\n\nStep.jsonID(\"replaceAround\", ReplaceAroundStep);\n\nfunction contentBetween(doc, from, to) {\n var $from = doc.resolve(from),\n dist = to - from,\n depth = $from.depth;\n\n while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {\n depth--;\n dist--;\n }\n\n if (dist > 0) {\n var next = $from.node(depth).maybeChild($from.indexAfter(depth));\n\n while (dist > 0) {\n if (!next || next.isLeaf) {\n return true;\n }\n\n next = next.firstChild;\n dist--;\n }\n }\n\n return false;\n}\n\nfunction canCut(node, start, end) {\n return (start == 0 || node.canReplace(start, node.childCount)) && (end == node.childCount || node.canReplace(0, end));\n} // :: (NodeRange) → ?number\n// Try to find a target depth to which the content in the given range\n// can be lifted. Will not go across\n// [isolating](#model.NodeSpec.isolating) parent nodes.\n\n\nfunction liftTarget(range) {\n var parent = range.parent;\n var content = parent.content.cutByIndex(range.startIndex, range.endIndex);\n\n for (var depth = range.depth;; --depth) {\n var node = range.$from.node(depth);\n var index = range.$from.index(depth),\n endIndex = range.$to.indexAfter(depth);\n\n if (depth < range.depth && node.canReplace(index, endIndex, content)) {\n return depth;\n }\n\n if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex)) {\n break;\n }\n }\n} // :: (NodeRange, number) → this\n// Split the content in the given range off from its parent, if there\n// is sibling content before or after it, and move it up the tree to\n// the depth specified by `target`. You'll probably want to use\n// [`liftTarget`](#transform.liftTarget) to compute `target`, to make\n// sure the lift is valid.\n\n\nTransform.prototype.lift = function (range, target) {\n var $from = range.$from;\n var $to = range.$to;\n var depth = range.depth;\n var gapStart = $from.before(depth + 1),\n gapEnd = $to.after(depth + 1);\n var start = gapStart,\n end = gapEnd;\n var before = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty,\n openStart = 0;\n\n for (var d = depth, splitting = false; d > target; d--) {\n if (splitting || $from.index(d) > 0) {\n splitting = true;\n before = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from($from.node(d).copy(before));\n openStart++;\n } else {\n start--;\n }\n }\n\n var after = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty,\n openEnd = 0;\n\n for (var d$1 = depth, splitting$1 = false; d$1 > target; d$1--) {\n if (splitting$1 || $to.after(d$1 + 1) < $to.end(d$1)) {\n splitting$1 = true;\n after = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from($to.node(d$1).copy(after));\n openEnd++;\n } else {\n end++;\n }\n }\n\n return this.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](before.append(after), openStart, openEnd), before.size - openStart, true));\n}; // :: (NodeRange, NodeType, ?Object, ?NodeRange) → ?[{type: NodeType, attrs: ?Object}]\n// Try to find a valid way to wrap the content in the given range in a\n// node of the given type. May introduce extra nodes around and inside\n// the wrapper node, if necessary. Returns null if no valid wrapping\n// could be found. When `innerRange` is given, that range's content is\n// used as the content to fit into the wrapping, instead of the\n// content of `range`.\n\n\nfunction findWrapping(range, nodeType, attrs, innerRange) {\n if (innerRange === void 0) innerRange = range;\n var around = findWrappingOutside(range, nodeType);\n var inner = around && findWrappingInside(innerRange, nodeType);\n\n if (!inner) {\n return null;\n }\n\n return around.map(withAttrs).concat({\n type: nodeType,\n attrs: attrs\n }).concat(inner.map(withAttrs));\n}\n\nfunction withAttrs(type) {\n return {\n type: type,\n attrs: null\n };\n}\n\nfunction findWrappingOutside(range, type) {\n var parent = range.parent;\n var startIndex = range.startIndex;\n var endIndex = range.endIndex;\n var around = parent.contentMatchAt(startIndex).findWrapping(type);\n\n if (!around) {\n return null;\n }\n\n var outer = around.length ? around[0] : type;\n return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;\n}\n\nfunction findWrappingInside(range, type) {\n var parent = range.parent;\n var startIndex = range.startIndex;\n var endIndex = range.endIndex;\n var inner = parent.child(startIndex);\n var inside = type.contentMatch.findWrapping(inner.type);\n\n if (!inside) {\n return null;\n }\n\n var lastType = inside.length ? inside[inside.length - 1] : type;\n var innerMatch = lastType.contentMatch;\n\n for (var i = startIndex; innerMatch && i < endIndex; i++) {\n innerMatch = innerMatch.matchType(parent.child(i).type);\n }\n\n if (!innerMatch || !innerMatch.validEnd) {\n return null;\n }\n\n return inside;\n} // :: (NodeRange, [{type: NodeType, attrs: ?Object}]) → this\n// Wrap the given [range](#model.NodeRange) in the given set of wrappers.\n// The wrappers are assumed to be valid in this position, and should\n// probably be computed with [`findWrapping`](#transform.findWrapping).\n\n\nTransform.prototype.wrap = function (range, wrappers) {\n var content = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty;\n\n for (var i = wrappers.length - 1; i >= 0; i--) {\n content = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(wrappers[i].type.create(wrappers[i].attrs, content));\n }\n\n var start = range.start,\n end = range.end;\n return this.step(new ReplaceAroundStep(start, end, start, end, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](content, 0, 0), wrappers.length, true));\n}; // :: (number, ?number, NodeType, ?Object) → this\n// Set the type of all textblocks (partly) between `from` and `to` to\n// the given node type with the given attributes.\n\n\nTransform.prototype.setBlockType = function (from, to, type, attrs) {\n var this$1 = this;\n if (to === void 0) to = from;\n\n if (!type.isTextblock) {\n throw new RangeError(\"Type given to setBlockType should be a textblock\");\n }\n\n var mapFrom = this.steps.length;\n this.doc.nodesBetween(from, to, function (node, pos) {\n if (node.isTextblock && !node.hasMarkup(type, attrs) && canChangeType(this$1.doc, this$1.mapping.slice(mapFrom).map(pos), type)) {\n // Ensure all markup that isn't allowed in the new node type is cleared\n this$1.clearIncompatible(this$1.mapping.slice(mapFrom).map(pos, 1), type);\n var mapping = this$1.mapping.slice(mapFrom);\n var startM = mapping.map(pos, 1),\n endM = mapping.map(pos + node.nodeSize, 1);\n this$1.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(type.create(attrs, null, node.marks)), 0, 0), 1, true));\n return false;\n }\n });\n return this;\n};\n\nfunction canChangeType(doc, pos, type) {\n var $pos = doc.resolve(pos),\n index = $pos.index();\n return $pos.parent.canReplaceWith(index, index + 1, type);\n} // :: (number, ?NodeType, ?Object, ?[Mark]) → this\n// Change the type, attributes, and/or marks of the node at `pos`.\n// When `type` isn't given, the existing node type is preserved,\n\n\nTransform.prototype.setNodeMarkup = function (pos, type, attrs, marks) {\n var node = this.doc.nodeAt(pos);\n\n if (!node) {\n throw new RangeError(\"No node at given position\");\n }\n\n if (!type) {\n type = node.type;\n }\n\n var newNode = type.create(attrs, null, marks || node.marks);\n\n if (node.isLeaf) {\n return this.replaceWith(pos, pos + node.nodeSize, newNode);\n }\n\n if (!type.validContent(node.content)) {\n throw new RangeError(\"Invalid content for node type \" + type.name);\n }\n\n return this.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(newNode), 0, 0), 1, true));\n}; // :: (Node, number, number, ?[?{type: NodeType, attrs: ?Object}]) → bool\n// Check whether splitting at the given position is allowed.\n\n\nfunction canSplit(doc, pos, depth, typesAfter) {\n if (depth === void 0) depth = 1;\n var $pos = doc.resolve(pos),\n base = $pos.depth - depth;\n var innerType = typesAfter && typesAfter[typesAfter.length - 1] || $pos.parent;\n\n if (base < 0 || $pos.parent.type.spec.isolating || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount))) {\n return false;\n }\n\n for (var d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {\n var node = $pos.node(d),\n index$1 = $pos.index(d);\n\n if (node.type.spec.isolating) {\n return false;\n }\n\n var rest = node.content.cutByIndex(index$1, node.childCount);\n var after = typesAfter && typesAfter[i] || node;\n\n if (after != node) {\n rest = rest.replaceChild(0, after.type.create(after.attrs));\n }\n\n if (!node.canReplace(index$1 + 1, node.childCount) || !after.type.validContent(rest)) {\n return false;\n }\n }\n\n var index = $pos.indexAfter(base);\n var baseType = typesAfter && typesAfter[0];\n return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);\n} // :: (number, ?number, ?[?{type: NodeType, attrs: ?Object}]) → this\n// Split the node at the given position, and optionally, if `depth` is\n// greater than one, any number of nodes above that. By default, the\n// parts split off will inherit the node type of the original node.\n// This can be changed by passing an array of types and attributes to\n// use after the split.\n\n\nTransform.prototype.split = function (pos, depth, typesAfter) {\n if (depth === void 0) depth = 1;\n var $pos = this.doc.resolve(pos),\n before = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty,\n after = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty;\n\n for (var d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {\n before = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from($pos.node(d).copy(before));\n var typeAfter = typesAfter && typesAfter[i];\n after = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));\n }\n\n return this.step(new ReplaceStep(pos, pos, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](before.append(after), depth, depth), true));\n}; // :: (Node, number) → bool\n// Test whether the blocks before and after a given position can be\n// joined.\n\n\nfunction canJoin(doc, pos) {\n var $pos = doc.resolve(pos),\n index = $pos.index();\n return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index, index + 1);\n}\n\nfunction joinable(a, b) {\n return a && b && !a.isLeaf && a.canAppend(b);\n} // :: (Node, number, ?number) → ?number\n// Find an ancestor of the given position that can be joined to the\n// block before (or after if `dir` is positive). Returns the joinable\n// point, if any.\n\n\nfunction joinPoint(doc, pos, dir) {\n if (dir === void 0) dir = -1;\n var $pos = doc.resolve(pos);\n\n for (var d = $pos.depth;; d--) {\n var before = void 0,\n after = void 0,\n index = $pos.index(d);\n\n if (d == $pos.depth) {\n before = $pos.nodeBefore;\n after = $pos.nodeAfter;\n } else if (dir > 0) {\n before = $pos.node(d + 1);\n index++;\n after = $pos.node(d).maybeChild(index);\n } else {\n before = $pos.node(d).maybeChild(index - 1);\n after = $pos.node(d + 1);\n }\n\n if (before && !before.isTextblock && joinable(before, after) && $pos.node(d).canReplace(index, index + 1)) {\n return pos;\n }\n\n if (d == 0) {\n break;\n }\n\n pos = dir < 0 ? $pos.before(d) : $pos.after(d);\n }\n} // :: (number, ?number) → this\n// Join the blocks around the given position. If depth is 2, their\n// last and first siblings are also joined, and so on.\n\n\nTransform.prototype.join = function (pos, depth) {\n if (depth === void 0) depth = 1;\n var step = new ReplaceStep(pos - depth, pos + depth, prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty, true);\n return this.step(step);\n}; // :: (Node, number, NodeType) → ?number\n// Try to find a point where a node of the given type can be inserted\n// near `pos`, by searching up the node hierarchy when `pos` itself\n// isn't a valid place but is at the start or end of a node. Return\n// null if no position was found.\n\n\nfunction insertPoint(doc, pos, nodeType) {\n var $pos = doc.resolve(pos);\n\n if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType)) {\n return pos;\n }\n\n if ($pos.parentOffset == 0) {\n for (var d = $pos.depth - 1; d >= 0; d--) {\n var index = $pos.index(d);\n\n if ($pos.node(d).canReplaceWith(index, index, nodeType)) {\n return $pos.before(d + 1);\n }\n\n if (index > 0) {\n return null;\n }\n }\n }\n\n if ($pos.parentOffset == $pos.parent.content.size) {\n for (var d$1 = $pos.depth - 1; d$1 >= 0; d$1--) {\n var index$1 = $pos.indexAfter(d$1);\n\n if ($pos.node(d$1).canReplaceWith(index$1, index$1, nodeType)) {\n return $pos.after(d$1 + 1);\n }\n\n if (index$1 < $pos.node(d$1).childCount) {\n return null;\n }\n }\n }\n} // :: (Node, number, Slice) → ?number\n// Finds a position at or around the given position where the given\n// slice can be inserted. Will look at parent nodes' nearest boundary\n// and try there, even if the original position wasn't directly at the\n// start or end of that node. Returns null when no position was found.\n\n\nfunction dropPoint(doc, pos, slice) {\n var $pos = doc.resolve(pos);\n\n if (!slice.content.size) {\n return pos;\n }\n\n var content = slice.content;\n\n for (var i = 0; i < slice.openStart; i++) {\n content = content.firstChild.content;\n }\n\n for (var pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {\n for (var d = $pos.depth; d >= 0; d--) {\n var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;\n var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);\n\n if (pass == 1 ? $pos.node(d).canReplace(insertPos, insertPos, content) : $pos.node(d).contentMatchAt(insertPos).findWrapping(content.firstChild.type)) {\n return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);\n }\n }\n }\n\n return null;\n}\n\nfunction mapFragment(fragment, f, parent) {\n var mapped = [];\n\n for (var i = 0; i < fragment.childCount; i++) {\n var child = fragment.child(i);\n\n if (child.content.size) {\n child = child.copy(mapFragment(child.content, f, child));\n }\n\n if (child.isInline) {\n child = f(child, parent, i);\n }\n\n mapped.push(child);\n }\n\n return prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].fromArray(mapped);\n} // ::- Add a mark to all inline content between two positions.\n\n\nvar AddMarkStep = /*@__PURE__*/function (Step) {\n function AddMarkStep(from, to, mark) {\n Step.call(this);\n this.from = from;\n this.to = to;\n this.mark = mark;\n }\n\n if (Step) AddMarkStep.__proto__ = Step;\n AddMarkStep.prototype = Object.create(Step && Step.prototype);\n AddMarkStep.prototype.constructor = AddMarkStep;\n\n AddMarkStep.prototype.apply = function apply(doc) {\n var this$1 = this;\n var oldSlice = doc.slice(this.from, this.to),\n $from = doc.resolve(this.from);\n var parent = $from.node($from.sharedDepth(this.to));\n var slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](mapFragment(oldSlice.content, function (node, parent) {\n if (!parent.type.allowsMarkType(this$1.mark.type)) {\n return node;\n }\n\n return node.mark(this$1.mark.addToSet(node.marks));\n }, parent), oldSlice.openStart, oldSlice.openEnd);\n return StepResult.fromReplace(doc, this.from, this.to, slice);\n };\n\n AddMarkStep.prototype.invert = function invert() {\n return new RemoveMarkStep(this.from, this.to, this.mark);\n };\n\n AddMarkStep.prototype.map = function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n\n if (from.deleted && to.deleted || from.pos >= to.pos) {\n return null;\n }\n\n return new AddMarkStep(from.pos, to.pos, this.mark);\n };\n\n AddMarkStep.prototype.merge = function merge(other) {\n if (other instanceof AddMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) {\n return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);\n }\n };\n\n AddMarkStep.prototype.toJSON = function toJSON() {\n return {\n stepType: \"addMark\",\n mark: this.mark.toJSON(),\n from: this.from,\n to: this.to\n };\n };\n\n AddMarkStep.fromJSON = function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\") {\n throw new RangeError(\"Invalid input for AddMarkStep.fromJSON\");\n }\n\n return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));\n };\n\n return AddMarkStep;\n}(Step);\n\nStep.jsonID(\"addMark\", AddMarkStep); // ::- Remove a mark from all inline content between two positions.\n\nvar RemoveMarkStep = /*@__PURE__*/function (Step) {\n function RemoveMarkStep(from, to, mark) {\n Step.call(this);\n this.from = from;\n this.to = to;\n this.mark = mark;\n }\n\n if (Step) RemoveMarkStep.__proto__ = Step;\n RemoveMarkStep.prototype = Object.create(Step && Step.prototype);\n RemoveMarkStep.prototype.constructor = RemoveMarkStep;\n\n RemoveMarkStep.prototype.apply = function apply(doc) {\n var this$1 = this;\n var oldSlice = doc.slice(this.from, this.to);\n var slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](mapFragment(oldSlice.content, function (node) {\n return node.mark(this$1.mark.removeFromSet(node.marks));\n }), oldSlice.openStart, oldSlice.openEnd);\n return StepResult.fromReplace(doc, this.from, this.to, slice);\n };\n\n RemoveMarkStep.prototype.invert = function invert() {\n return new AddMarkStep(this.from, this.to, this.mark);\n };\n\n RemoveMarkStep.prototype.map = function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n\n if (from.deleted && to.deleted || from.pos >= to.pos) {\n return null;\n }\n\n return new RemoveMarkStep(from.pos, to.pos, this.mark);\n };\n\n RemoveMarkStep.prototype.merge = function merge(other) {\n if (other instanceof RemoveMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) {\n return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);\n }\n };\n\n RemoveMarkStep.prototype.toJSON = function toJSON() {\n return {\n stepType: \"removeMark\",\n mark: this.mark.toJSON(),\n from: this.from,\n to: this.to\n };\n };\n\n RemoveMarkStep.fromJSON = function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\") {\n throw new RangeError(\"Invalid input for RemoveMarkStep.fromJSON\");\n }\n\n return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));\n };\n\n return RemoveMarkStep;\n}(Step);\n\nStep.jsonID(\"removeMark\", RemoveMarkStep); // :: (number, number, Mark) → this\n// Add the given mark to the inline content between `from` and `to`.\n\nTransform.prototype.addMark = function (from, to, mark) {\n var this$1 = this;\n var removed = [],\n added = [],\n removing = null,\n adding = null;\n this.doc.nodesBetween(from, to, function (node, pos, parent) {\n if (!node.isInline) {\n return;\n }\n\n var marks = node.marks;\n\n if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {\n var start = Math.max(pos, from),\n end = Math.min(pos + node.nodeSize, to);\n var newSet = mark.addToSet(marks);\n\n for (var i = 0; i < marks.length; i++) {\n if (!marks[i].isInSet(newSet)) {\n if (removing && removing.to == start && removing.mark.eq(marks[i])) {\n removing.to = end;\n } else {\n removed.push(removing = new RemoveMarkStep(start, end, marks[i]));\n }\n }\n }\n\n if (adding && adding.to == start) {\n adding.to = end;\n } else {\n added.push(adding = new AddMarkStep(start, end, mark));\n }\n }\n });\n removed.forEach(function (s) {\n return this$1.step(s);\n });\n added.forEach(function (s) {\n return this$1.step(s);\n });\n return this;\n}; // :: (number, number, ?union) → this\n// Remove marks from inline nodes between `from` and `to`. When `mark`\n// is a single mark, remove precisely that mark. When it is a mark type,\n// remove all marks of that type. When it is null, remove all marks of\n// any type.\n\n\nTransform.prototype.removeMark = function (from, to, mark) {\n var this$1 = this;\n if (mark === void 0) mark = null;\n var matched = [],\n step = 0;\n this.doc.nodesBetween(from, to, function (node, pos) {\n if (!node.isInline) {\n return;\n }\n\n step++;\n var toRemove = null;\n\n if (mark instanceof prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"MarkType\"]) {\n var found = mark.isInSet(node.marks);\n\n if (found) {\n toRemove = [found];\n }\n } else if (mark) {\n if (mark.isInSet(node.marks)) {\n toRemove = [mark];\n }\n } else {\n toRemove = node.marks;\n }\n\n if (toRemove && toRemove.length) {\n var end = Math.min(pos + node.nodeSize, to);\n\n for (var i = 0; i < toRemove.length; i++) {\n var style = toRemove[i],\n found$1 = void 0;\n\n for (var j = 0; j < matched.length; j++) {\n var m = matched[j];\n\n if (m.step == step - 1 && style.eq(matched[j].style)) {\n found$1 = m;\n }\n }\n\n if (found$1) {\n found$1.to = end;\n found$1.step = step;\n } else {\n matched.push({\n style: style,\n from: Math.max(pos, from),\n to: end,\n step: step\n });\n }\n }\n }\n });\n matched.forEach(function (m) {\n return this$1.step(new RemoveMarkStep(m.from, m.to, m.style));\n });\n return this;\n}; // :: (number, NodeType, ?ContentMatch) → this\n// Removes all marks and nodes from the content of the node at `pos`\n// that don't match the given new parent node type. Accepts an\n// optional starting [content match](#model.ContentMatch) as third\n// argument.\n\n\nTransform.prototype.clearIncompatible = function (pos, parentType, match) {\n if (match === void 0) match = parentType.contentMatch;\n var node = this.doc.nodeAt(pos);\n var delSteps = [],\n cur = pos + 1;\n\n for (var i = 0; i < node.childCount; i++) {\n var child = node.child(i),\n end = cur + child.nodeSize;\n var allowed = match.matchType(child.type, child.attrs);\n\n if (!allowed) {\n delSteps.push(new ReplaceStep(cur, end, prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty));\n } else {\n match = allowed;\n\n for (var j = 0; j < child.marks.length; j++) {\n if (!parentType.allowsMarkType(child.marks[j].type)) {\n this.step(new RemoveMarkStep(cur, end, child.marks[j]));\n }\n }\n }\n\n cur = end;\n }\n\n if (!match.validEnd) {\n var fill = match.fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true);\n this.replace(cur, cur, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](fill, 0, 0));\n }\n\n for (var i$1 = delSteps.length - 1; i$1 >= 0; i$1--) {\n this.step(delSteps[i$1]);\n }\n\n return this;\n}; // :: (Node, number, ?number, ?Slice) → ?Step\n// ‘Fit’ a slice into a given position in the document, producing a\n// [step](#transform.Step) that inserts it. Will return null if\n// there's no meaningful way to insert the slice here, or inserting it\n// would be a no-op (an empty slice over an empty range).\n\n\nfunction replaceStep(doc, from, to, slice) {\n if (to === void 0) to = from;\n if (slice === void 0) slice = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty;\n\n if (from == to && !slice.size) {\n return null;\n }\n\n var $from = doc.resolve(from),\n $to = doc.resolve(to); // Optimization -- avoid work if it's obvious that it's not needed.\n\n if (fitsTrivially($from, $to, slice)) {\n return new ReplaceStep(from, to, slice);\n }\n\n var placed = placeSlice($from, slice);\n var fittedLeft = fitLeft($from, placed);\n var fitted = fitRight($from, $to, fittedLeft);\n\n if (!fitted) {\n return null;\n }\n\n if (fittedLeft.size != fitted.size && canMoveText($from, $to, fittedLeft)) {\n var d = $to.depth,\n after = $to.after(d);\n\n while (d > 1 && after == $to.end(--d)) {\n ++after;\n }\n\n var fittedAfter = fitRight($from, doc.resolve(after), fittedLeft);\n\n if (fittedAfter) {\n return new ReplaceAroundStep(from, after, to, $to.end(), fittedAfter, fittedLeft.size);\n }\n }\n\n return fitted.size || from != to ? new ReplaceStep(from, to, fitted) : null;\n} // :: (number, ?number, ?Slice) → this\n// Replace the part of the document between `from` and `to` with the\n// given `slice`.\n\n\nTransform.prototype.replace = function (from, to, slice) {\n if (to === void 0) to = from;\n if (slice === void 0) slice = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty;\n var step = replaceStep(this.doc, from, to, slice);\n\n if (step) {\n this.step(step);\n }\n\n return this;\n}; // :: (number, number, union) → this\n// Replace the given range with the given content, which may be a\n// fragment, node, or array of nodes.\n\n\nTransform.prototype.replaceWith = function (from, to, content) {\n return this.replace(from, to, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(content), 0, 0));\n}; // :: (number, number) → this\n// Delete the content between the given positions.\n\n\nTransform.prototype[\"delete\"] = function (from, to) {\n return this.replace(from, to, prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"].empty);\n}; // :: (number, union) → this\n// Insert the given content at the given position.\n\n\nTransform.prototype.insert = function (pos, content) {\n return this.replaceWith(pos, pos, content);\n};\n\nfunction fitLeftInner($from, depth, placed, placedBelow) {\n var content = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty,\n openEnd = 0,\n placedHere = placed[depth];\n\n if ($from.depth > depth) {\n var inner = fitLeftInner($from, depth + 1, placed, placedBelow || placedHere);\n openEnd = inner.openEnd + 1;\n content = prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from($from.node(depth + 1).copy(inner.content));\n }\n\n if (placedHere) {\n content = content.append(placedHere.content);\n openEnd = placedHere.openEnd;\n }\n\n if (placedBelow) {\n content = content.append($from.node(depth).contentMatchAt($from.indexAfter(depth)).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true));\n openEnd = 0;\n }\n\n return {\n content: content,\n openEnd: openEnd\n };\n}\n\nfunction fitLeft($from, placed) {\n var ref = fitLeftInner($from, 0, placed, false);\n var content = ref.content;\n var openEnd = ref.openEnd;\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](content, $from.depth, openEnd || 0);\n}\n\nfunction fitRightJoin(content, parent, $from, $to, depth, openStart, openEnd) {\n var match,\n count = content.childCount,\n matchCount = count - (openEnd > 0 ? 1 : 0);\n var parentNode = openStart < 0 ? parent : $from.node(depth);\n\n if (openStart < 0) {\n match = parentNode.contentMatchAt(matchCount);\n } else if (count == 1 && openEnd > 0) {\n match = parentNode.contentMatchAt(openStart ? $from.index(depth) : $from.indexAfter(depth));\n } else {\n match = parentNode.contentMatchAt($from.indexAfter(depth)).matchFragment(content, count > 0 && openStart ? 1 : 0, matchCount);\n }\n\n var toNode = $to.node(depth);\n\n if (openEnd > 0 && depth < $to.depth) {\n var after = toNode.content.cutByIndex($to.indexAfter(depth)).addToStart(content.lastChild);\n var joinable$1 = match.fillBefore(after, true); // Can't insert content if there's a single node stretched across this gap\n\n if (joinable$1 && joinable$1.size && openStart > 0 && count == 1) {\n joinable$1 = null;\n }\n\n if (joinable$1) {\n var inner = fitRightJoin(content.lastChild.content, content.lastChild, $from, $to, depth + 1, count == 1 ? openStart - 1 : -1, openEnd - 1);\n\n if (inner) {\n var last = content.lastChild.copy(inner);\n\n if (joinable$1.size) {\n return content.cutByIndex(0, count - 1).append(joinable$1).addToEnd(last);\n } else {\n return content.replaceChild(count - 1, last);\n }\n }\n }\n }\n\n if (openEnd > 0) {\n match = match.matchType((count == 1 && openStart > 0 ? $from.node(depth + 1) : content.lastChild).type);\n } // If we're here, the next level can't be joined, so we see what\n // happens if we leave it open.\n\n\n var toIndex = $to.index(depth);\n\n if (toIndex == toNode.childCount && !toNode.type.compatibleContent(parent.type)) {\n return null;\n }\n\n var joinable = match.fillBefore(toNode.content, true, toIndex);\n\n for (var i = toIndex; joinable && i < toNode.content.childCount; i++) {\n if (!parentNode.type.allowsMarks(toNode.content.child(i).marks)) {\n joinable = null;\n }\n }\n\n if (!joinable) {\n return null;\n }\n\n if (openEnd > 0) {\n var closed = fitRightClosed(content.lastChild, openEnd - 1, $from, depth + 1, count == 1 ? openStart - 1 : -1);\n content = content.replaceChild(count - 1, closed);\n }\n\n content = content.append(joinable);\n\n if ($to.depth > depth) {\n content = content.addToEnd(fitRightSeparate($to, depth + 1));\n }\n\n return content;\n}\n\nfunction fitRightClosed(node, openEnd, $from, depth, openStart) {\n var match,\n content = node.content,\n count = content.childCount;\n\n if (openStart >= 0) {\n match = $from.node(depth).contentMatchAt($from.indexAfter(depth)).matchFragment(content, openStart > 0 ? 1 : 0, count);\n } else {\n match = node.contentMatchAt(count);\n }\n\n if (openEnd > 0) {\n var closed = fitRightClosed(content.lastChild, openEnd - 1, $from, depth + 1, count == 1 ? openStart - 1 : -1);\n content = content.replaceChild(count - 1, closed);\n }\n\n return node.copy(content.append(match.fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true)));\n}\n\nfunction fitRightSeparate($to, depth) {\n var node = $to.node(depth);\n var fill = node.contentMatchAt(0).fillBefore(node.content, true, $to.index(depth));\n\n if ($to.depth > depth) {\n fill = fill.addToEnd(fitRightSeparate($to, depth + 1));\n }\n\n return node.copy(fill);\n}\n\nfunction normalizeSlice(content, openStart, openEnd) {\n while (openStart > 0 && openEnd > 0 && content.childCount == 1) {\n content = content.firstChild.content;\n openStart--;\n openEnd--;\n }\n\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](content, openStart, openEnd);\n} // : (ResolvedPos, ResolvedPos, number, Slice) → Slice\n\n\nfunction fitRight($from, $to, slice) {\n var fitted = fitRightJoin(slice.content, $from.node(0), $from, $to, 0, slice.openStart, slice.openEnd);\n\n if (!fitted) {\n return null;\n }\n\n return normalizeSlice(fitted, slice.openStart, $to.depth);\n}\n\nfunction fitsTrivially($from, $to, slice) {\n return !slice.openStart && !slice.openEnd && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice.content);\n}\n\nfunction canMoveText($from, $to, slice) {\n if (!$to.parent.isTextblock) {\n return false;\n }\n\n var parent = slice.openEnd ? nodeRight(slice.content, slice.openEnd) : $from.node($from.depth - (slice.openStart - slice.openEnd));\n\n if (!parent.isTextblock) {\n return false;\n }\n\n for (var i = $to.index(); i < $to.parent.childCount; i++) {\n if (!parent.type.allowsMarks($to.parent.child(i).marks)) {\n return false;\n }\n }\n\n var match;\n\n if (slice.openEnd) {\n match = parent.contentMatchAt(parent.childCount);\n } else {\n match = parent.contentMatchAt(parent.childCount);\n\n if (slice.size) {\n match = match.matchFragment(slice.content, slice.openStart ? 1 : 0);\n }\n }\n\n match = match.matchFragment($to.parent.content, $to.index());\n return match && match.validEnd;\n}\n\nfunction nodeRight(content, depth) {\n for (var i = 1; i < depth; i++) {\n content = content.lastChild.content;\n }\n\n return content.lastChild;\n} // Algorithm for 'placing' the elements of a slice into a gap:\n//\n// We consider the content of each node that is open to the left to be\n// independently placeable. I.e. in , when the\n// paragraph on the left is open, \"foo\" can be placed (somewhere on\n// the left side of the replacement gap) independently from p(\"bar\").\n//\n// So placeSlice splits up a slice into a number of sub-slices,\n// along with information on where they can be placed on the given\n// left-side edge. It works by walking the open side of the slice,\n// from the inside out, and trying to find a landing spot for each\n// element, by simultaneously scanning over the gap side. When no\n// place is found for an open node's content, it is left in that node.\n// : (ResolvedPos, Slice) → [{content: Fragment, openEnd: number, depth: number}]\n\n\nfunction placeSlice($from, slice) {\n var frontier = new Frontier($from);\n\n for (var pass = 1; slice.size && pass <= 3; pass++) {\n var value = frontier.placeSlice(slice.content, slice.openStart, slice.openEnd, pass);\n\n if (pass == 3 && value != slice && value.size) {\n pass = 0;\n } // Restart if the 3rd pass made progress but left content\n\n\n slice = value;\n }\n\n while (frontier.open.length) {\n frontier.closeNode();\n }\n\n return frontier.placed;\n} // Helper class that models the open side of the insert position,\n// keeping track of the content match and already inserted content\n// at each depth.\n\n\nvar Frontier = function Frontier($pos) {\n // : [{parent: Node, match: ContentMatch, content: Fragment, wrapper: bool, openEnd: number, depth: number}]\n this.open = [];\n\n for (var d = 0; d <= $pos.depth; d++) {\n var parent = $pos.node(d),\n match = parent.contentMatchAt($pos.indexAfter(d));\n this.open.push({\n parent: parent,\n match: match,\n content: prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty,\n wrapper: false,\n openEnd: 0,\n depth: d\n });\n }\n\n this.placed = [];\n}; // : (Fragment, number, number, number, ?Node) → Slice\n// Tries to place the content of the given slice, and returns a\n// slice containing unplaced content.\n//\n// pass 1: try to fit directly\n// pass 2: allow wrapper nodes to be introduced\n// pass 3: allow unwrapping of nodes that aren't open\n\n\nFrontier.prototype.placeSlice = function placeSlice(fragment, openStart, openEnd, pass, parent) {\n if (openStart > 0) {\n var first = fragment.firstChild;\n var inner = this.placeSlice(first.content, Math.max(0, openStart - 1), openEnd && fragment.childCount == 1 ? openEnd - 1 : 0, pass, first);\n\n if (inner.content != first.content) {\n if (inner.content.size) {\n fragment = fragment.replaceChild(0, first.copy(inner.content));\n openStart = inner.openStart + 1;\n } else {\n if (fragment.childCount == 1) {\n openEnd = 0;\n }\n\n fragment = fragment.cutByIndex(1);\n openStart = 0;\n }\n }\n }\n\n var result = this.placeContent(fragment, openStart, openEnd, pass, parent);\n\n if (pass > 2 && result.size && openStart == 0) {\n var child = result.content.firstChild,\n single = result.content.childCount == 1;\n this.placeContent(child.content, 0, openEnd && single ? openEnd - 1 : 0, pass, child);\n result = single ? prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty : new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](result.content.cutByIndex(1), 0, openEnd);\n }\n\n return result;\n};\n\nFrontier.prototype.placeContent = function placeContent(fragment, openStart, openEnd, pass, parent) {\n var i = 0; // Go over the fragment's children\n\n for (; i < fragment.childCount; i++) {\n var child = fragment.child(i),\n placed = false,\n last = i == fragment.childCount - 1; // Try each open node in turn, starting from the innermost\n\n for (var d = this.open.length - 1; d >= 0; d--) {\n var open = this.open[d],\n wrap = void 0; // If pass > 1, it is allowed to wrap the node to help find a\n // fit, so if findWrapping returns something, we add open\n // nodes to the frontier for that wrapping.\n\n if (pass > 1 && (wrap = open.match.findWrapping(child.type)) && !(parent && wrap.length && wrap[wrap.length - 1] == parent.type)) {\n while (this.open.length - 1 > d) {\n this.closeNode();\n }\n\n for (var w = 0; w < wrap.length; w++) {\n open.match = open.match.matchType(wrap[w]);\n d++;\n open = {\n parent: wrap[w].create(),\n match: wrap[w].contentMatch,\n content: prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty,\n wrapper: true,\n openEnd: 0,\n depth: d + w\n };\n this.open.push(open);\n }\n } // See if the child fits here\n\n\n var match = open.match.matchType(child.type);\n\n if (!match) {\n var fill = open.match.fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(child));\n\n if (fill) {\n for (var j = 0; j < fill.childCount; j++) {\n var ch = fill.child(j);\n this.addNode(open, ch, 0);\n match = open.match.matchFragment(ch);\n }\n } else if (parent && open.match.matchType(parent.type)) {\n // Don't continue looking further up if the parent node\n // would fit here.\n break;\n } else {\n continue;\n }\n } // Close open nodes above this one, since we're starting to\n // add to this.\n\n\n while (this.open.length - 1 > d) {\n this.closeNode();\n } // Strip marks from the child or close its start when necessary\n\n\n child = child.mark(open.parent.type.allowedMarks(child.marks));\n\n if (openStart) {\n child = closeNodeStart(child, openStart, last ? openEnd : 0);\n openStart = 0;\n } // Add the child to this open node and adjust its metadata\n\n\n this.addNode(open, child, last ? openEnd : 0);\n open.match = match;\n\n if (last) {\n openEnd = 0;\n }\n\n placed = true;\n break;\n } // As soon as we've failed to place a node we stop looking at\n // later nodes\n\n\n if (!placed) {\n break;\n }\n } // Close the current open node if it's not the the root and we\n // either placed up to the end of the node or the the current\n // slice depth's node type matches the open node's type\n\n\n if (this.open.length > 1 && (i > 0 && i == fragment.childCount || parent && this.open[this.open.length - 1].parent.type == parent.type)) {\n this.closeNode();\n }\n\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](fragment.cutByIndex(i), openStart, openEnd);\n};\n\nFrontier.prototype.addNode = function addNode(open, node, openEnd) {\n open.content = closeFragmentEnd(open.content, open.openEnd).addToEnd(node);\n open.openEnd = openEnd;\n};\n\nFrontier.prototype.closeNode = function closeNode() {\n var open = this.open.pop();\n if (open.content.size == 0) ;else if (open.wrapper) {\n this.addNode(this.open[this.open.length - 1], open.parent.copy(open.content), open.openEnd + 1);\n } else {\n this.placed[open.depth] = {\n depth: open.depth,\n content: open.content,\n openEnd: open.openEnd\n };\n }\n};\n\nfunction closeNodeStart(node, openStart, openEnd) {\n var content = node.content;\n\n if (openStart > 1) {\n var first = closeNodeStart(node.firstChild, openStart - 1, node.childCount == 1 ? openEnd - 1 : 0);\n content = node.content.replaceChild(0, first);\n }\n\n var fill = node.type.contentMatch.fillBefore(content, openEnd == 0);\n return node.copy(fill.append(content));\n}\n\nfunction closeNodeEnd(node, depth) {\n var content = node.content;\n\n if (depth > 1) {\n var last = closeNodeEnd(node.lastChild, depth - 1);\n content = node.content.replaceChild(node.childCount - 1, last);\n }\n\n var fill = node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true);\n return node.copy(content.append(fill));\n}\n\nfunction closeFragmentEnd(fragment, depth) {\n return depth ? fragment.replaceChild(fragment.childCount - 1, closeNodeEnd(fragment.lastChild, depth)) : fragment;\n} // :: (number, number, Slice) → this\n// Replace a range of the document with a given slice, using `from`,\n// `to`, and the slice's [`openStart`](#model.Slice.openStart) property\n// as hints, rather than fixed start and end points. This method may\n// grow the replaced area or close open nodes in the slice in order to\n// get a fit that is more in line with WYSIWYG expectations, by\n// dropping fully covered parent nodes of the replaced region when\n// they are marked [non-defining](#model.NodeSpec.defining), or\n// including an open parent node from the slice that _is_ marked as\n// [defining](#model.NodeSpec.defining).\n//\n// This is the method, for example, to handle paste. The similar\n// [`replace`](#transform.Transform.replace) method is a more\n// primitive tool which will _not_ move the start and end of its given\n// range, and is useful in situations where you need more precise\n// control over what happens.\n\n\nTransform.prototype.replaceRange = function (from, to, slice) {\n if (!slice.size) {\n return this.deleteRange(from, to);\n }\n\n var $from = this.doc.resolve(from),\n $to = this.doc.resolve(to);\n\n if (fitsTrivially($from, $to, slice)) {\n return this.step(new ReplaceStep(from, to, slice));\n }\n\n var targetDepths = coveredDepths($from, this.doc.resolve(to)); // Can't replace the whole document, so remove 0 if it's present\n\n if (targetDepths[targetDepths.length - 1] == 0) {\n targetDepths.pop();\n } // Negative numbers represent not expansion over the whole node at\n // that depth, but replacing from $from.before(-D) to $to.pos.\n\n\n var preferredTarget = -($from.depth + 1);\n targetDepths.unshift(preferredTarget); // This loop picks a preferred target depth, if one of the covering\n // depths is not outside of a defining node, and adds negative\n // depths for any depth that has $from at its start and does not\n // cross a defining node.\n\n for (var d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {\n var spec = $from.node(d).type.spec;\n\n if (spec.defining || spec.isolating) {\n break;\n }\n\n if (targetDepths.indexOf(d) > -1) {\n preferredTarget = d;\n } else if ($from.before(d) == pos) {\n targetDepths.splice(1, 0, -d);\n }\n } // Try to fit each possible depth of the slice into each possible\n // target depth, starting with the preferred depths.\n\n\n var preferredTargetIndex = targetDepths.indexOf(preferredTarget);\n var leftNodes = [],\n preferredDepth = slice.openStart;\n\n for (var content = slice.content, i = 0;; i++) {\n var node = content.firstChild;\n leftNodes.push(node);\n\n if (i == slice.openStart) {\n break;\n }\n\n content = node.content;\n } // Back up if the node directly above openStart, or the node above\n // that separated only by a non-defining textblock node, is defining.\n\n\n if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining && $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 1].type) {\n preferredDepth -= 1;\n } else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining && $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 2].type) {\n preferredDepth -= 2;\n }\n\n for (var j = slice.openStart; j >= 0; j--) {\n var openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);\n var insert = leftNodes[openDepth];\n\n if (!insert) {\n continue;\n }\n\n for (var i$1 = 0; i$1 < targetDepths.length; i$1++) {\n // Loop over possible expansion levels, starting with the\n // preferred one\n var targetDepth = targetDepths[(i$1 + preferredTargetIndex) % targetDepths.length],\n expand = true;\n\n if (targetDepth < 0) {\n expand = false;\n targetDepth = -targetDepth;\n }\n\n var parent = $from.node(targetDepth - 1),\n index = $from.index(targetDepth - 1);\n\n if (parent.canReplaceWith(index, index, insert.type, insert.marks)) {\n return this.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd));\n }\n }\n }\n\n var startSteps = this.steps.length;\n\n for (var i$2 = targetDepths.length - 1; i$2 >= 0; i$2--) {\n this.replace(from, to, slice);\n\n if (this.steps.length > startSteps) {\n break;\n }\n\n var depth = targetDepths[i$2];\n\n if (i$2 < 0) {\n continue;\n }\n\n from = $from.before(depth);\n to = $to.after(depth);\n }\n\n return this;\n};\n\nfunction closeFragment(fragment, depth, oldOpen, newOpen, parent) {\n if (depth < oldOpen) {\n var first = fragment.firstChild;\n fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));\n }\n\n if (depth > newOpen) {\n var match = parent.contentMatchAt(0);\n var start = match.fillBefore(fragment).append(fragment);\n fragment = start.append(match.matchFragment(start).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].empty, true));\n }\n\n return fragment;\n} // :: (number, number, Node) → this\n// Replace the given range with a node, but use `from` and `to` as\n// hints, rather than precise positions. When from and to are the same\n// and are at the start or end of a parent node in which the given\n// node doesn't fit, this method may _move_ them out towards a parent\n// that does allow the given node to be placed. When the given range\n// completely covers a parent node, this method may completely replace\n// that parent node.\n\n\nTransform.prototype.replaceRangeWith = function (from, to, node) {\n if (!node.isInline && from == to && this.doc.resolve(from).parent.content.size) {\n var point = insertPoint(this.doc, from, node.type);\n\n if (point != null) {\n from = to = point;\n }\n }\n\n return this.replaceRange(from, to, new prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_0__[\"Fragment\"].from(node), 0, 0));\n}; // :: (number, number) → this\n// Delete the given range, expanding it to cover fully covered\n// parent nodes until a valid replace is found.\n\n\nTransform.prototype.deleteRange = function (from, to) {\n var $from = this.doc.resolve(from),\n $to = this.doc.resolve(to);\n var covered = coveredDepths($from, $to);\n\n for (var i = 0; i < covered.length; i++) {\n var depth = covered[i],\n last = i == covered.length - 1;\n\n if (last && depth == 0 || $from.node(depth).type.contentMatch.validEnd) {\n return this[\"delete\"]($from.start(depth), $to.end(depth));\n }\n\n if (depth > 0 && (last || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1)))) {\n return this[\"delete\"]($from.before(depth), $to.after(depth));\n }\n }\n\n for (var d = 1; d <= $from.depth && d <= $to.depth; d++) {\n if (from - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d) {\n return this[\"delete\"]($from.before(d), to);\n }\n }\n\n return this[\"delete\"](from, to);\n}; // : (ResolvedPos, ResolvedPos) → [number]\n// Returns an array of all depths for which $from - $to spans the\n// whole content of the nodes at that depth.\n\n\nfunction coveredDepths($from, $to) {\n var result = [],\n minDepth = Math.min($from.depth, $to.depth);\n\n for (var d = minDepth; d >= 0; d--) {\n var start = $from.start(d);\n\n if (start < $from.pos - ($from.depth - d) || $to.end(d) > $to.pos + ($to.depth - d) || $from.node(d).type.spec.isolating || $to.node(d).type.spec.isolating) {\n break;\n }\n\n if (start == $to.start(d)) {\n result.push(d);\n }\n }\n\n return result;\n}\n\n\n\n//# sourceURL=webpack:///./node_modules/prosemirror-transform/dist/index.es.js?");
/***/ }),
/***/ "./node_modules/prosemirror-view/dist/index.es.js":
/*!********************************************************!*\
!*** ./node_modules/prosemirror-view/dist/index.es.js ***!
\********************************************************/
/*! exports provided: Decoration, DecorationSet, EditorView, __endComposition, __parseFromClipboard, __serializeForClipboard */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Decoration\", function() { return Decoration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"DecorationSet\", function() { return DecorationSet; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"EditorView\", function() { return EditorView; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__endComposition\", function() { return endComposition; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__parseFromClipboard\", function() { return parseFromClipboard; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__serializeForClipboard\", function() { return serializeForClipboard; });\n/* harmony import */ var prosemirror_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prosemirror-state */ \"./node_modules/prosemirror-state/dist/index.es.js\");\n/* harmony import */ var prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prosemirror-model */ \"./node_modules/prosemirror-model/dist/index.es.js\");\n/* harmony import */ var prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prosemirror-transform */ \"./node_modules/prosemirror-transform/dist/index.es.js\");\n\n\n\n\nvar result = {};\n\nif (typeof navigator != \"undefined\" && typeof document != \"undefined\") {\n var ie_edge = /Edge\\/(\\d+)/.exec(navigator.userAgent);\n var ie_upto10 = /MSIE \\d/.test(navigator.userAgent);\n var ie_11up = /Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);\n\n result.mac = /Mac/.test(navigator.platform);\n var ie = result.ie = !!(ie_upto10 || ie_11up || ie_edge);\n result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null;\n result.gecko = !ie && /gecko\\/(\\d+)/i.test(navigator.userAgent);\n result.gecko_version = result.gecko && +(/Firefox\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1];\n var chrome = !ie && /Chrome\\/(\\d+)/.exec(navigator.userAgent);\n result.chrome = !!chrome;\n result.chrome_version = chrome && +chrome[1];\n result.ios = !ie && /AppleWebKit/.test(navigator.userAgent) && /Mobile\\/\\w+/.test(navigator.userAgent);\n result.android = /Android \\d/.test(navigator.userAgent);\n result.webkit = !ie && 'WebkitAppearance' in document.documentElement.style;\n result.safari = /Apple Computer/.test(navigator.vendor);\n result.webkit_version = result.webkit && +(/\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1];\n}\n\nvar domIndex = function(node) {\n for (var index = 0;; index++) {\n node = node.previousSibling;\n if (!node) { return index }\n }\n};\n\nvar parentNode = function(node) {\n var parent = node.parentNode;\n return parent && parent.nodeType == 11 ? parent.host : parent\n};\n\nvar textRange = function(node, from, to) {\n var range = document.createRange();\n range.setEnd(node, to == null ? node.nodeValue.length : to);\n range.setStart(node, from || 0);\n return range\n};\n\n// Scans forward and backward through DOM positions equivalent to the\n// given one to see if the two are in the same place (i.e. after a\n// text node vs at the end of that text node)\nvar isEquivalentPosition = function(node, off, targetNode, targetOff) {\n return targetNode && (scanFor(node, off, targetNode, targetOff, -1) ||\n scanFor(node, off, targetNode, targetOff, 1))\n};\n\nvar atomElements = /^(img|br|input|textarea|hr)$/i;\n\nfunction scanFor(node, off, targetNode, targetOff, dir) {\n for (;;) {\n if (node == targetNode && off == targetOff) { return true }\n if (off == (dir < 0 ? 0 : nodeSize(node))) {\n var parent = node.parentNode;\n if (parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == \"false\")\n { return false }\n off = domIndex(node) + (dir < 0 ? 0 : 1);\n node = parent;\n } else if (node.nodeType == 1) {\n node = node.childNodes[off + (dir < 0 ? -1 : 0)];\n if (node.contentEditable == \"false\") { return false }\n off = dir < 0 ? nodeSize(node) : 0;\n } else {\n return false\n }\n }\n}\n\nfunction nodeSize(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length\n}\n\nfunction isOnEdge(node, offset, parent) {\n for (var atStart = offset == 0, atEnd = offset == nodeSize(node); atStart || atEnd;) {\n if (node == parent) { return true }\n var index = domIndex(node);\n node = node.parentNode;\n if (!node) { return false }\n atStart = atStart && index == 0;\n atEnd = atEnd && index == nodeSize(node);\n }\n}\n\nfunction hasBlockDesc(dom) {\n var desc;\n for (var cur = dom; cur; cur = cur.parentNode) { if (desc = cur.pmViewDesc) { break } }\n return desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom)\n}\n\n// Work around Chrome issue https://bugs.chromium.org/p/chromium/issues/detail?id=447523\n// (isCollapsed inappropriately returns true in shadow dom)\nvar selectionCollapsed = function(domSel) {\n var collapsed = domSel.isCollapsed;\n if (collapsed && result.chrome && domSel.rangeCount && !domSel.getRangeAt(0).collapsed)\n { collapsed = false; }\n return collapsed\n};\n\nfunction keyEvent(keyCode, key) {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"keydown\", true, true);\n event.keyCode = keyCode;\n event.key = event.code = key;\n return event\n}\n\nfunction windowRect(win) {\n return {left: 0, right: win.innerWidth,\n top: 0, bottom: win.innerHeight}\n}\n\nfunction getSide(value, side) {\n return typeof value == \"number\" ? value : value[side]\n}\n\nfunction scrollRectIntoView(view, rect, startDOM) {\n var scrollThreshold = view.someProp(\"scrollThreshold\") || 0, scrollMargin = view.someProp(\"scrollMargin\") || 5;\n var doc = view.dom.ownerDocument, win = doc.defaultView;\n for (var parent = startDOM || view.dom;; parent = parentNode(parent)) {\n if (!parent) { break }\n if (parent.nodeType != 1) { continue }\n var atTop = parent == doc.body || parent.nodeType != 1;\n var bounding = atTop ? windowRect(win) : parent.getBoundingClientRect();\n var moveX = 0, moveY = 0;\n if (rect.top < bounding.top + getSide(scrollThreshold, \"top\"))\n { moveY = -(bounding.top - rect.top + getSide(scrollMargin, \"top\")); }\n else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, \"bottom\"))\n { moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, \"bottom\"); }\n if (rect.left < bounding.left + getSide(scrollThreshold, \"left\"))\n { moveX = -(bounding.left - rect.left + getSide(scrollMargin, \"left\")); }\n else if (rect.right > bounding.right - getSide(scrollThreshold, \"right\"))\n { moveX = rect.right - bounding.right + getSide(scrollMargin, \"right\"); }\n if (moveX || moveY) {\n if (atTop) {\n win.scrollBy(moveX, moveY);\n } else {\n if (moveY) { parent.scrollTop += moveY; }\n if (moveX) { parent.scrollLeft += moveX; }\n rect = {left: rect.left - moveX, top: rect.top - moveY, right: rect.right - moveX, bottom: rect.bottom - moveY};\n }\n }\n if (atTop) { break }\n }\n}\n\n// Store the scroll position of the editor's parent nodes, along with\n// the top position of an element near the top of the editor, which\n// will be used to make sure the visible viewport remains stable even\n// when the size of the content above changes.\nfunction storeScrollPos(view) {\n var rect = view.dom.getBoundingClientRect(), startY = Math.max(0, rect.top);\n var refDOM, refTop;\n for (var x = (rect.left + rect.right) / 2, y = startY + 1;\n y < Math.min(innerHeight, rect.bottom); y += 5) {\n var dom = view.root.elementFromPoint(x, y);\n if (dom == view.dom || !view.dom.contains(dom)) { continue }\n var localRect = dom.getBoundingClientRect();\n if (localRect.top >= startY - 20) {\n refDOM = dom;\n refTop = localRect.top;\n break\n }\n }\n return {refDOM: refDOM, refTop: refTop, stack: scrollStack(view.dom)}\n}\n\nfunction scrollStack(dom) {\n var stack = [], doc = dom.ownerDocument;\n for (; dom; dom = parentNode(dom)) {\n stack.push({dom: dom, top: dom.scrollTop, left: dom.scrollLeft});\n if (dom == doc) { break }\n }\n return stack\n}\n\n// Reset the scroll position of the editor's parent nodes to that what\n// it was before, when storeScrollPos was called.\nfunction resetScrollPos(ref) {\n var refDOM = ref.refDOM;\n var refTop = ref.refTop;\n var stack = ref.stack;\n\n var newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0;\n restoreScrollStack(stack, newRefTop == 0 ? 0 : newRefTop - refTop);\n}\n\nfunction restoreScrollStack(stack, dTop) {\n for (var i = 0; i < stack.length; i++) {\n var ref = stack[i];\n var dom = ref.dom;\n var top = ref.top;\n var left = ref.left;\n if (dom.scrollTop != top + dTop) { dom.scrollTop = top + dTop; }\n if (dom.scrollLeft != left) { dom.scrollLeft = left; }\n }\n}\n\nvar preventScrollSupported = null;\n// Feature-detects support for .focus({preventScroll: true}), and uses\n// a fallback kludge when not supported.\nfunction focusPreventScroll(dom) {\n if (dom.setActive) { return dom.setActive() } // in IE\n if (preventScrollSupported) { return dom.focus(preventScrollSupported) }\n\n var stored = scrollStack(dom);\n dom.focus(preventScrollSupported == null ? {\n get preventScroll() {\n preventScrollSupported = {preventScroll: true};\n return true\n }\n } : undefined);\n if (!preventScrollSupported) {\n preventScrollSupported = false;\n restoreScrollStack(stored, 0);\n }\n}\n\nfunction findOffsetInNode(node, coords) {\n var closest, dxClosest = 2e8, coordsClosest, offset = 0;\n var rowBot = coords.top, rowTop = coords.top;\n for (var child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {\n var rects = (void 0);\n if (child.nodeType == 1) { rects = child.getClientRects(); }\n else if (child.nodeType == 3) { rects = textRange(child).getClientRects(); }\n else { continue }\n\n for (var i = 0; i < rects.length; i++) {\n var rect = rects[i];\n if (rect.top <= rowBot && rect.bottom >= rowTop) {\n rowBot = Math.max(rect.bottom, rowBot);\n rowTop = Math.min(rect.top, rowTop);\n var dx = rect.left > coords.left ? rect.left - coords.left\n : rect.right < coords.left ? coords.left - rect.right : 0;\n if (dx < dxClosest) {\n closest = child;\n dxClosest = dx;\n coordsClosest = dx && closest.nodeType == 3 ? {left: rect.right < coords.left ? rect.right : rect.left, top: coords.top} : coords;\n if (child.nodeType == 1 && dx)\n { offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0); }\n continue\n }\n }\n if (!closest && (coords.left >= rect.right && coords.top >= rect.top ||\n coords.left >= rect.left && coords.top >= rect.bottom))\n { offset = childIndex + 1; }\n }\n }\n if (closest && closest.nodeType == 3) { return findOffsetInText(closest, coordsClosest) }\n if (!closest || (dxClosest && closest.nodeType == 1)) { return {node: node, offset: offset} }\n return findOffsetInNode(closest, coordsClosest)\n}\n\nfunction findOffsetInText(node, coords) {\n var len = node.nodeValue.length;\n var range = document.createRange();\n for (var i = 0; i < len; i++) {\n range.setEnd(node, i + 1);\n range.setStart(node, i);\n var rect = singleRect(range, 1);\n if (rect.top == rect.bottom) { continue }\n if (inRect(coords, rect))\n { return {node: node, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0)} }\n }\n return {node: node, offset: 0}\n}\n\nfunction inRect(coords, rect) {\n return coords.left >= rect.left - 1 && coords.left <= rect.right + 1&&\n coords.top >= rect.top - 1 && coords.top <= rect.bottom + 1\n}\n\nfunction targetKludge(dom, coords) {\n var parent = dom.parentNode;\n if (parent && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left)\n { return parent }\n return dom\n}\n\nfunction posFromElement(view, elt, coords) {\n var ref = findOffsetInNode(elt, coords);\n var node = ref.node;\n var offset = ref.offset;\n var bias = -1;\n if (node.nodeType == 1 && !node.firstChild) {\n var rect = node.getBoundingClientRect();\n bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;\n }\n return view.docView.posFromDOM(node, offset, bias)\n}\n\nfunction posFromCaret(view, node, offset, coords) {\n // Browser (in caretPosition/RangeFromPoint) will agressively\n // normalize towards nearby inline nodes. Since we are interested in\n // positions between block nodes too, we first walk up the hierarchy\n // of nodes to see if there are block nodes that the coordinates\n // fall outside of. If so, we take the position before/after that\n // block. If not, we call `posFromDOM` on the raw node/offset.\n var outside = -1;\n for (var cur = node;;) {\n if (cur == view.dom) { break }\n var desc = view.docView.nearestDesc(cur, true);\n if (!desc) { return null }\n if (desc.node.isBlock && desc.parent) {\n var rect = desc.dom.getBoundingClientRect();\n if (rect.left > coords.left || rect.top > coords.top) { outside = desc.posBefore; }\n else if (rect.right < coords.left || rect.bottom < coords.top) { outside = desc.posAfter; }\n else { break }\n }\n cur = desc.dom.parentNode;\n }\n return outside > -1 ? outside : view.docView.posFromDOM(node, offset)\n}\n\nfunction elementFromPoint(element, coords, box) {\n var len = element.childNodes.length;\n if (len && box.top < box.bottom) {\n for (var startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {\n var child = element.childNodes[i];\n if (child.nodeType == 1) {\n var rects = child.getClientRects();\n for (var j = 0; j < rects.length; j++) {\n var rect = rects[j];\n if (inRect(coords, rect)) { return elementFromPoint(child, coords, rect) }\n }\n }\n if ((i = (i + 1) % len) == startI) { break }\n }\n }\n return element\n}\n\n// Given an x,y position on the editor, get the position in the document.\nfunction posAtCoords(view, coords) {\n var assign, assign$1;\n\n var root = view.root, node, offset;\n if (root.caretPositionFromPoint) {\n try { // Firefox throws for this call in hard-to-predict circumstances (#994)\n var pos$1 = root.caretPositionFromPoint(coords.left, coords.top);\n if (pos$1) { ((assign = pos$1, node = assign.offsetNode, offset = assign.offset)); }\n } catch (_) {}\n }\n if (!node && root.caretRangeFromPoint) {\n var range = root.caretRangeFromPoint(coords.left, coords.top);\n if (range) { ((assign$1 = range, node = assign$1.startContainer, offset = assign$1.startOffset)); }\n }\n\n var elt = root.elementFromPoint(coords.left, coords.top + 1), pos;\n if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {\n var box = view.dom.getBoundingClientRect();\n if (!inRect(coords, box)) { return null }\n elt = elementFromPoint(view.dom, coords, box);\n if (!elt) { return null }\n }\n elt = targetKludge(elt, coords);\n if (node) {\n if (result.gecko && node.nodeType == 1) {\n // Firefox will sometimes return offsets into nodes, which\n // have no actual children, from caretPositionFromPoint (#953)\n offset = Math.min(offset, node.childNodes.length);\n // It'll also move the returned position before image nodes,\n // even if those are behind it.\n if (offset < node.childNodes.length) {\n var next = node.childNodes[offset], box$1;\n if (next.nodeName == \"IMG\" && (box$1 = next.getBoundingClientRect()).right <= coords.left &&\n box$1.bottom > coords.top)\n { offset++; }\n }\n }\n // Suspiciously specific kludge to work around caret*FromPoint\n // never returning a position at the end of the document\n if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 &&\n coords.top > node.lastChild.getBoundingClientRect().bottom)\n { pos = view.state.doc.content.size; }\n // Ignore positions directly after a BR, since caret*FromPoint\n // 'round up' positions that would be more accurately placed\n // before the BR node.\n else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != \"BR\")\n { pos = posFromCaret(view, node, offset, coords); }\n }\n if (pos == null) { pos = posFromElement(view, elt, coords); }\n\n var desc = view.docView.nearestDesc(elt, true);\n return {pos: pos, inside: desc ? desc.posAtStart - desc.border : -1}\n}\n\nfunction singleRect(object, bias) {\n var rects = object.getClientRects();\n return !rects.length ? object.getBoundingClientRect() : rects[bias < 0 ? 0 : rects.length - 1]\n}\n\n// : (EditorView, number) → {left: number, top: number, right: number, bottom: number}\n// Given a position in the document model, get a bounding box of the\n// character at that position, relative to the window.\nfunction coordsAtPos(view, pos) {\n var ref = view.docView.domFromPos(pos);\n var node = ref.node;\n var offset = ref.offset;\n\n // These browsers support querying empty text ranges\n if (node.nodeType == 3 && (result.chrome || result.gecko)) {\n var rect = singleRect(textRange(node, offset, offset), 0);\n // Firefox returns bad results (the position before the space)\n // when querying a position directly after line-broken\n // whitespace. Detect this situation and and kludge around it\n if (result.gecko && offset && /\\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {\n var rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1);\n if (Math.abs(rectBefore.left - rect.left) < 1 && rectBefore.top == rect.top) {\n var rectAfter = singleRect(textRange(node, offset, offset + 1), -1);\n return flattenV(rectAfter, rectAfter.left < rectBefore.left)\n }\n }\n return rect\n }\n\n if (node.nodeType == 1 && !view.state.doc.resolve(pos).parent.inlineContent) {\n // Return a horizontal line in block context\n var top = true, rect$1;\n if (offset < node.childNodes.length) {\n var after = node.childNodes[offset];\n if (after.nodeType == 1) { rect$1 = after.getBoundingClientRect(); }\n }\n if (!rect$1 && offset) {\n var before = node.childNodes[offset - 1];\n if (before.nodeType == 1) { rect$1 = before.getBoundingClientRect(); top = false; }\n }\n return flattenH(rect$1 || node.getBoundingClientRect(), top)\n }\n\n // Not Firefox/Chrome, or not in a text node, so we have to use\n // actual element/character rectangles to get a solution (this part\n // is not very bidi-safe)\n //\n // Try the left side first, fall back to the right one if that\n // doesn't work.\n for (var dir = -1; dir < 2; dir += 2) {\n if (dir < 0 && offset) {\n var prev = (void 0), target = node.nodeType == 3 ? textRange(node, offset - 1, offset)\n : (prev = node.childNodes[offset - 1]).nodeType == 3 ? textRange(prev)\n : prev.nodeType == 1 && prev.nodeName != \"BR\" ? prev : null; // BR nodes tend to only return the rectangle before them\n if (target) {\n var rect$2 = singleRect(target, 1);\n if (rect$2.top < rect$2.bottom) { return flattenV(rect$2, false) }\n }\n } else if (dir > 0 && offset < nodeSize(node)) {\n var next = (void 0), target$1 = node.nodeType == 3 ? textRange(node, offset, offset + 1)\n : (next = node.childNodes[offset]).nodeType == 3 ? textRange(next)\n : next.nodeType == 1 ? next : null;\n if (target$1) {\n var rect$3 = singleRect(target$1, -1);\n if (rect$3.top < rect$3.bottom) { return flattenV(rect$3, true) }\n }\n }\n }\n // All else failed, just try to get a rectangle for the target node\n return flattenV(singleRect(node.nodeType == 3 ? textRange(node) : node, 0), false)\n}\n\nfunction flattenV(rect, left) {\n if (rect.width == 0) { return rect }\n var x = left ? rect.left : rect.right;\n return {top: rect.top, bottom: rect.bottom, left: x, right: x}\n}\n\nfunction flattenH(rect, top) {\n if (rect.height == 0) { return rect }\n var y = top ? rect.top : rect.bottom;\n return {top: y, bottom: y, left: rect.left, right: rect.right}\n}\n\nfunction withFlushedState(view, state, f) {\n var viewState = view.state, active = view.root.activeElement;\n if (viewState != state) { view.updateState(state); }\n if (active != view.dom) { view.focus(); }\n try {\n return f()\n } finally {\n if (viewState != state) { view.updateState(viewState); }\n if (active != view.dom) { active.focus(); }\n }\n}\n\n// : (EditorView, number, number)\n// Whether vertical position motion in a given direction\n// from a position would leave a text block.\nfunction endOfTextblockVertical(view, state, dir) {\n var sel = state.selection;\n var $pos = dir == \"up\" ? sel.$anchor.min(sel.$head) : sel.$anchor.max(sel.$head);\n return withFlushedState(view, state, function () {\n var ref = view.docView.domFromPos($pos.pos);\n var dom = ref.node;\n for (;;) {\n var nearest = view.docView.nearestDesc(dom, true);\n if (!nearest) { break }\n if (nearest.node.isBlock) { dom = nearest.dom; break }\n dom = nearest.dom.parentNode;\n }\n var coords = coordsAtPos(view, $pos.pos);\n for (var child = dom.firstChild; child; child = child.nextSibling) {\n var boxes = (void 0);\n if (child.nodeType == 1) { boxes = child.getClientRects(); }\n else if (child.nodeType == 3) { boxes = textRange(child, 0, child.nodeValue.length).getClientRects(); }\n else { continue }\n for (var i = 0; i < boxes.length; i++) {\n var box = boxes[i];\n if (box.bottom > box.top && (dir == \"up\" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1))\n { return false }\n }\n }\n return true\n })\n}\n\nvar maybeRTL = /[\\u0590-\\u08ac]/;\n\nfunction endOfTextblockHorizontal(view, state, dir) {\n var ref = state.selection;\n var $head = ref.$head;\n if (!$head.parent.isTextblock) { return false }\n var offset = $head.parentOffset, atStart = !offset, atEnd = offset == $head.parent.content.size;\n var sel = getSelection();\n // If the textblock is all LTR, or the browser doesn't support\n // Selection.modify (Edge), fall back to a primitive approach\n if (!maybeRTL.test($head.parent.textContent) || !sel.modify)\n { return dir == \"left\" || dir == \"backward\" ? atStart : atEnd }\n\n return withFlushedState(view, state, function () {\n // This is a huge hack, but appears to be the best we can\n // currently do: use `Selection.modify` to move the selection by\n // one character, and see if that moves the cursor out of the\n // textblock (or doesn't move it at all, when at the start/end of\n // the document).\n var oldRange = sel.getRangeAt(0), oldNode = sel.focusNode, oldOff = sel.focusOffset;\n var oldBidiLevel = sel.caretBidiLevel; // Only for Firefox\n sel.modify(\"move\", dir, \"character\");\n var parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;\n var result = !parentDOM.contains(sel.focusNode.nodeType == 1 ? sel.focusNode : sel.focusNode.parentNode) ||\n (oldNode == sel.focusNode && oldOff == sel.focusOffset);\n // Restore the previous selection\n sel.removeAllRanges();\n sel.addRange(oldRange);\n if (oldBidiLevel != null) { sel.caretBidiLevel = oldBidiLevel; }\n return result\n })\n}\n\nvar cachedState = null, cachedDir = null, cachedResult = false;\nfunction endOfTextblock(view, state, dir) {\n if (cachedState == state && cachedDir == dir) { return cachedResult }\n cachedState = state; cachedDir = dir;\n return cachedResult = dir == \"up\" || dir == \"down\"\n ? endOfTextblockVertical(view, state, dir)\n : endOfTextblockHorizontal(view, state, dir)\n}\n\n// NodeView:: interface\n//\n// By default, document nodes are rendered using the result of the\n// [`toDOM`](#model.NodeSpec.toDOM) method of their spec, and managed\n// entirely by the editor. For some use cases, such as embedded\n// node-specific editing interfaces, you want more control over\n// the behavior of a node's in-editor representation, and need to\n// [define](#view.EditorProps.nodeViews) a custom node view.\n//\n// Objects returned as node views must conform to this interface.\n//\n// dom:: ?dom.Node\n// The outer DOM node that represents the document node. When not\n// given, the default strategy is used to create a DOM node.\n//\n// contentDOM:: ?dom.Node\n// The DOM node that should hold the node's content. Only meaningful\n// if the node view also defines a `dom` property and if its node\n// type is not a leaf node type. When this is present, ProseMirror\n// will take care of rendering the node's children into it. When it\n// is not present, the node view itself is responsible for rendering\n// (or deciding not to render) its child nodes.\n//\n// update:: ?(node: Node, decorations: [Decoration]) → bool\n// When given, this will be called when the view is updating itself.\n// It will be given a node (possibly of a different type), and an\n// array of active decorations (which are automatically drawn, and\n// the node view may ignore if it isn't interested in them), and\n// should return true if it was able to update to that node, and\n// false otherwise. If the node view has a `contentDOM` property (or\n// no `dom` property), updating its child nodes will be handled by\n// ProseMirror.\n//\n// selectNode:: ?()\n// Can be used to override the way the node's selected status (as a\n// node selection) is displayed.\n//\n// deselectNode:: ?()\n// When defining a `selectNode` method, you should also provide a\n// `deselectNode` method to remove the effect again.\n//\n// setSelection:: ?(anchor: number, head: number, root: dom.Document)\n// This will be called to handle setting the selection inside the\n// node. The `anchor` and `head` positions are relative to the start\n// of the node. By default, a DOM selection will be created between\n// the DOM positions corresponding to those positions, but if you\n// override it you can do something else.\n//\n// stopEvent:: ?(event: dom.Event) → bool\n// Can be used to prevent the editor view from trying to handle some\n// or all DOM events that bubble up from the node view. Events for\n// which this returns true are not handled by the editor.\n//\n// ignoreMutation:: ?(dom.MutationRecord) → bool\n// Called when a DOM\n// [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)\n// or a selection change happens within the view. When the change is\n// a selection change, the record will have a `type` property of\n// `\"selection\"` (which doesn't occur for native mutation records).\n// Return false if the editor should re-read the selection or\n// re-parse the range around the mutation, true if it can safely be\n// ignored.\n//\n// destroy:: ?()\n// Called when the node view is removed from the editor or the whole\n// editor is destroyed.\n\n// View descriptions are data structures that describe the DOM that is\n// used to represent the editor's content. They are used for:\n//\n// - Incremental redrawing when the document changes\n//\n// - Figuring out what part of the document a given DOM position\n// corresponds to\n//\n// - Wiring in custom implementations of the editing interface for a\n// given node\n//\n// They form a doubly-linked mutable tree, starting at `view.docView`.\n\nvar NOT_DIRTY = 0, CHILD_DIRTY = 1, CONTENT_DIRTY = 2, NODE_DIRTY = 3;\n\n// Superclass for the various kinds of descriptions. Defines their\n// basic structure and shared methods.\nvar ViewDesc = function ViewDesc(parent, children, dom, contentDOM) {\n this.parent = parent;\n this.children = children;\n this.dom = dom;\n // An expando property on the DOM node provides a link back to its\n // description.\n dom.pmViewDesc = this;\n // This is the node that holds the child views. It may be null for\n // descs that don't have children.\n this.contentDOM = contentDOM;\n this.dirty = NOT_DIRTY;\n};\n\nvar prototypeAccessors = { beforePosition: { configurable: true },size: { configurable: true },border: { configurable: true },posBefore: { configurable: true },posAtStart: { configurable: true },posAfter: { configurable: true },posAtEnd: { configurable: true },contentLost: { configurable: true } };\n\n// Used to check whether a given description corresponds to a\n// widget/mark/node.\nViewDesc.prototype.matchesWidget = function matchesWidget () { return false };\nViewDesc.prototype.matchesMark = function matchesMark () { return false };\nViewDesc.prototype.matchesNode = function matchesNode () { return false };\nViewDesc.prototype.matchesHack = function matchesHack () { return false };\n\nprototypeAccessors.beforePosition.get = function () { return false };\n\n// : () → ?ParseRule\n// When parsing in-editor content (in domchange.js), we allow\n// descriptions to determine the parse rules that should be used to\n// parse them.\nViewDesc.prototype.parseRule = function parseRule () { return null };\n\n// : (dom.Event) → bool\n// Used by the editor's event handler to ignore events that come\n// from certain descs.\nViewDesc.prototype.stopEvent = function stopEvent () { return false };\n\n// The size of the content represented by this desc.\nprototypeAccessors.size.get = function () {\n var size = 0;\n for (var i = 0; i < this.children.length; i++) { size += this.children[i].size; }\n return size\n};\n\n// For block nodes, this represents the space taken up by their\n// start/end tokens.\nprototypeAccessors.border.get = function () { return 0 };\n\nViewDesc.prototype.destroy = function destroy () {\n this.parent = null;\n if (this.dom.pmViewDesc == this) { this.dom.pmViewDesc = null; }\n for (var i = 0; i < this.children.length; i++)\n { this.children[i].destroy(); }\n};\n\nViewDesc.prototype.posBeforeChild = function posBeforeChild (child) {\n for (var i = 0, pos = this.posAtStart; i < this.children.length; i++) {\n var cur = this.children[i];\n if (cur == child) { return pos }\n pos += cur.size;\n }\n};\n\nprototypeAccessors.posBefore.get = function () {\n return this.parent.posBeforeChild(this)\n};\n\nprototypeAccessors.posAtStart.get = function () {\n return this.parent ? this.parent.posBeforeChild(this) + this.border : 0\n};\n\nprototypeAccessors.posAfter.get = function () {\n return this.posBefore + this.size\n};\n\nprototypeAccessors.posAtEnd.get = function () {\n return this.posAtStart + this.size - 2 * this.border\n};\n\n// : (dom.Node, number, ?number) → number\nViewDesc.prototype.localPosFromDOM = function localPosFromDOM (dom, offset, bias) {\n // If the DOM position is in the content, use the child desc after\n // it to figure out a position.\n if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) {\n if (bias < 0) {\n var domBefore, desc;\n if (dom == this.contentDOM) {\n domBefore = dom.childNodes[offset - 1];\n } else {\n while (dom.parentNode != this.contentDOM) { dom = dom.parentNode; }\n domBefore = dom.previousSibling;\n }\n while (domBefore && !((desc = domBefore.pmViewDesc) && desc.parent == this)) { domBefore = domBefore.previousSibling; }\n return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart\n } else {\n var domAfter, desc$1;\n if (dom == this.contentDOM) {\n domAfter = dom.childNodes[offset];\n } else {\n while (dom.parentNode != this.contentDOM) { dom = dom.parentNode; }\n domAfter = dom.nextSibling;\n }\n while (domAfter && !((desc$1 = domAfter.pmViewDesc) && desc$1.parent == this)) { domAfter = domAfter.nextSibling; }\n return domAfter ? this.posBeforeChild(desc$1) : this.posAtEnd\n }\n }\n // Otherwise, use various heuristics, falling back on the bias\n // parameter, to determine whether to return the position at the\n // start or at the end of this view desc.\n var atEnd;\n if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {\n atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;\n } else if (this.dom.firstChild) {\n if (offset == 0) { for (var search = dom;; search = search.parentNode) {\n if (search == this.dom) { atEnd = false; break }\n if (search.parentNode.firstChild != search) { break }\n } }\n if (atEnd == null && offset == dom.childNodes.length) { for (var search$1 = dom;; search$1 = search$1.parentNode) {\n if (search$1 == this.dom) { atEnd = true; break }\n if (search$1.parentNode.lastChild != search$1) { break }\n } }\n }\n return (atEnd == null ? bias > 0 : atEnd) ? this.posAtEnd : this.posAtStart\n};\n\n// Scan up the dom finding the first desc that is a descendant of\n// this one.\nViewDesc.prototype.nearestDesc = function nearestDesc (dom, onlyNodes) {\n for (var first = true, cur = dom; cur; cur = cur.parentNode) {\n var desc = this.getDesc(cur);\n if (desc && (!onlyNodes || desc.node)) {\n // If dom is outside of this desc's nodeDOM, don't count it.\n if (first && desc.nodeDOM && !(desc.nodeDOM.nodeType == 1 ? desc.nodeDOM.contains(dom) : desc.nodeDOM == dom)) { first = false; }\n else { return desc }\n }\n }\n};\n\nViewDesc.prototype.getDesc = function getDesc (dom) {\n var desc = dom.pmViewDesc;\n for (var cur = desc; cur; cur = cur.parent) { if (cur == this) { return desc } }\n};\n\nViewDesc.prototype.posFromDOM = function posFromDOM (dom, offset, bias) {\n for (var scan = dom;; scan = scan.parentNode) {\n var desc = this.getDesc(scan);\n if (desc) { return desc.localPosFromDOM(dom, offset, bias) }\n }\n};\n\n// : (number) → ?NodeViewDesc\n// Find the desc for the node after the given pos, if any. (When a\n// parent node overrode rendering, there might not be one.)\nViewDesc.prototype.descAt = function descAt (pos) {\n for (var i = 0, offset = 0; i < this.children.length; i++) {\n var child = this.children[i], end = offset + child.size;\n if (offset == pos && end != offset) {\n while (!child.border && child.children.length) { child = child.children[0]; }\n return child\n }\n if (pos < end) { return child.descAt(pos - offset - child.border) }\n offset = end;\n }\n};\n\n// : (number) → {node: dom.Node, offset: number}\nViewDesc.prototype.domFromPos = function domFromPos (pos) {\n if (!this.contentDOM) { return {node: this.dom, offset: 0} }\n for (var offset = 0, i = 0;; i++) {\n if (offset == pos) {\n while (i < this.children.length && (this.children[i].beforePosition || this.children[i].dom.parentNode != this.contentDOM)) { i++; }\n return {node: this.contentDOM,\n offset: i == this.children.length ? this.contentDOM.childNodes.length : domIndex(this.children[i].dom)}\n }\n if (i == this.children.length) { throw new Error(\"Invalid position \" + pos) }\n var child = this.children[i], end = offset + child.size;\n if (pos < end) { return child.domFromPos(pos - offset - child.border) }\n offset = end;\n }\n};\n\n// Used to find a DOM range in a single parent for a given changed\n// range.\nViewDesc.prototype.parseRange = function parseRange (from, to, base) {\n if ( base === void 0 ) base = 0;\n\n if (this.children.length == 0)\n { return {node: this.contentDOM, from: from, to: to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length} }\n\n var fromOffset = -1, toOffset = -1;\n for (var offset = base, i = 0;; i++) {\n var child = this.children[i], end = offset + child.size;\n if (fromOffset == -1 && from <= end) {\n var childBase = offset + child.border;\n // FIXME maybe descend mark views to parse a narrower range?\n if (from >= childBase && to <= end - child.border && child.node &&\n child.contentDOM && this.contentDOM.contains(child.contentDOM))\n { return child.parseRange(from, to, childBase) }\n\n from = offset;\n for (var j = i; j > 0; j--) {\n var prev = this.children[j - 1];\n if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) {\n fromOffset = domIndex(prev.dom) + 1;\n break\n }\n from -= prev.size;\n }\n if (fromOffset == -1) { fromOffset = 0; }\n }\n if (fromOffset > -1 && to <= end) {\n to = end;\n for (var j$1 = i + 1; j$1 < this.children.length; j$1++) {\n var next = this.children[j$1];\n if (next.size && next.dom.parentNode == this.contentDOM && !next.emptyChildAt(-1)) {\n toOffset = domIndex(next.dom);\n break\n }\n to += next.size;\n }\n if (toOffset == -1) { toOffset = this.contentDOM.childNodes.length; }\n break\n }\n offset = end;\n }\n return {node: this.contentDOM, from: from, to: to, fromOffset: fromOffset, toOffset: toOffset}\n};\n\nViewDesc.prototype.emptyChildAt = function emptyChildAt (side) {\n if (this.border || !this.contentDOM || !this.children.length) { return false }\n var child = this.children[side < 0 ? 0 : this.children.length - 1];\n return child.size == 0 || child.emptyChildAt(side)\n};\n\n// : (number) → dom.Node\nViewDesc.prototype.domAfterPos = function domAfterPos (pos) {\n var ref = this.domFromPos(pos);\n var node = ref.node;\n var offset = ref.offset;\n if (node.nodeType != 1 || offset == node.childNodes.length)\n { throw new RangeError(\"No node after pos \" + pos) }\n return node.childNodes[offset]\n};\n\n// : (number, number, dom.Document)\n// View descs are responsible for setting any selection that falls\n// entirely inside of them, so that custom implementations can do\n// custom things with the selection. Note that this falls apart when\n// a selection starts in such a node and ends in another, in which\n// case we just use whatever domFromPos produces as a best effort.\nViewDesc.prototype.setSelection = function setSelection (anchor, head, root, force) {\n // If the selection falls entirely in a child, give it to that child\n var from = Math.min(anchor, head), to = Math.max(anchor, head);\n for (var i = 0, offset = 0; i < this.children.length; i++) {\n var child = this.children[i], end = offset + child.size;\n if (from > offset && to < end)\n { return child.setSelection(anchor - offset - child.border, head - offset - child.border, root, force) }\n offset = end;\n }\n\n var anchorDOM = this.domFromPos(anchor), headDOM = this.domFromPos(head);\n var domSel = root.getSelection(), range = document.createRange();\n if (!force &&\n isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) &&\n isEquivalentPosition(headDOM.node, headDOM.offset, domSel.focusNode, domSel.focusOffset))\n { return }\n\n // Selection.extend can be used to create an 'inverted' selection\n // (one where the focus is before the anchor), but not all\n // browsers support it yet.\n if (domSel.extend) {\n range.setEnd(anchorDOM.node, anchorDOM.offset);\n range.collapse(false);\n } else {\n if (anchor > head) { var tmp = anchorDOM; anchorDOM = headDOM; headDOM = tmp; }\n range.setEnd(headDOM.node, headDOM.offset);\n range.setStart(anchorDOM.node, anchorDOM.offset);\n }\n domSel.removeAllRanges();\n domSel.addRange(range);\n if (domSel.extend)\n { domSel.extend(headDOM.node, headDOM.offset); }\n};\n\n// : (dom.MutationRecord) → bool\nViewDesc.prototype.ignoreMutation = function ignoreMutation (mutation) {\n return !this.contentDOM && mutation.type != \"selection\"\n};\n\nprototypeAccessors.contentLost.get = function () {\n return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM)\n};\n\n// Remove a subtree of the element tree that has been touched\n// by a DOM change, so that the next update will redraw it.\nViewDesc.prototype.markDirty = function markDirty (from, to) {\n for (var offset = 0, i = 0; i < this.children.length; i++) {\n var child = this.children[i], end = offset + child.size;\n if (offset == end ? from <= end && to >= offset : from < end && to > offset) {\n var startInside = offset + child.border, endInside = end - child.border;\n if (from >= startInside && to <= endInside) {\n this.dirty = from == offset || to == end ? CONTENT_DIRTY : CHILD_DIRTY;\n if (from == startInside && to == endInside &&\n (child.contentLost || child.dom.parentNode != this.contentDOM)) { child.dirty = NODE_DIRTY; }\n else { child.markDirty(from - startInside, to - startInside); }\n return\n } else {\n child.dirty = NODE_DIRTY;\n }\n }\n offset = end;\n }\n this.dirty = CONTENT_DIRTY;\n};\n\nViewDesc.prototype.markParentsDirty = function markParentsDirty () {\n for (var node = this.parent; node; node = node.parent) {\n var dirty = CONTENT_DIRTY ;\n if (node.dirty < dirty) { node.dirty = dirty; }\n }\n};\n\nObject.defineProperties( ViewDesc.prototype, prototypeAccessors );\n\n// Reused array to avoid allocating fresh arrays for things that will\n// stay empty anyway.\nvar nothing = [];\n\n// A widget desc represents a widget decoration, which is a DOM node\n// drawn between the document nodes.\nvar WidgetViewDesc = /*@__PURE__*/(function (ViewDesc) {\n function WidgetViewDesc(parent, widget, view, pos) {\n var self, dom = widget.type.toDOM;\n if (typeof dom == \"function\") { dom = dom(view, function () {\n if (!self) { return pos }\n if (self.parent) { return self.parent.posBeforeChild(self) }\n }); }\n if (!widget.type.spec.raw) {\n if (dom.nodeType != 1) {\n var wrap = document.createElement(\"span\");\n wrap.appendChild(dom);\n dom = wrap;\n }\n dom.contentEditable = false;\n dom.classList.add(\"ProseMirror-widget\");\n }\n ViewDesc.call(this, parent, nothing, dom, null);\n this.widget = widget;\n self = this;\n }\n\n if ( ViewDesc ) WidgetViewDesc.__proto__ = ViewDesc;\n WidgetViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );\n WidgetViewDesc.prototype.constructor = WidgetViewDesc;\n\n var prototypeAccessors$1 = { beforePosition: { configurable: true } };\n\n prototypeAccessors$1.beforePosition.get = function () {\n return this.widget.type.side < 0\n };\n\n WidgetViewDesc.prototype.matchesWidget = function matchesWidget (widget) {\n return this.dirty == NOT_DIRTY && widget.type.eq(this.widget.type)\n };\n\n WidgetViewDesc.prototype.parseRule = function parseRule () { return {ignore: true} };\n\n WidgetViewDesc.prototype.stopEvent = function stopEvent (event) {\n var stop = this.widget.spec.stopEvent;\n return stop ? stop(event) : false\n };\n\n WidgetViewDesc.prototype.ignoreMutation = function ignoreMutation (mutation) {\n return mutation.type != \"selection\" || this.widget.spec.ignoreSelection\n };\n\n Object.defineProperties( WidgetViewDesc.prototype, prototypeAccessors$1 );\n\n return WidgetViewDesc;\n}(ViewDesc));\n\nvar CompositionViewDesc = /*@__PURE__*/(function (ViewDesc) {\n function CompositionViewDesc(parent, dom, textDOM, text) {\n ViewDesc.call(this, parent, nothing, dom, null);\n this.textDOM = textDOM;\n this.text = text;\n }\n\n if ( ViewDesc ) CompositionViewDesc.__proto__ = ViewDesc;\n CompositionViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );\n CompositionViewDesc.prototype.constructor = CompositionViewDesc;\n\n var prototypeAccessors$2 = { size: { configurable: true } };\n\n prototypeAccessors$2.size.get = function () { return this.text.length };\n\n CompositionViewDesc.prototype.localPosFromDOM = function localPosFromDOM (dom, offset) {\n if (dom != this.textDOM) { return this.posAtStart + (offset ? this.size : 0) }\n return this.posAtStart + offset\n };\n\n CompositionViewDesc.prototype.domFromPos = function domFromPos (pos) {\n return {node: this.textDOM, offset: pos}\n };\n\n CompositionViewDesc.prototype.ignoreMutation = function ignoreMutation (mut) {\n return mut.type === 'characterData' && mut.target.nodeValue == mut.oldValue\n };\n\n Object.defineProperties( CompositionViewDesc.prototype, prototypeAccessors$2 );\n\n return CompositionViewDesc;\n}(ViewDesc));\n\n// A mark desc represents a mark. May have multiple children,\n// depending on how the mark is split. Note that marks are drawn using\n// a fixed nesting order, for simplicity and predictability, so in\n// some cases they will be split more often than would appear\n// necessary.\nvar MarkViewDesc = /*@__PURE__*/(function (ViewDesc) {\n function MarkViewDesc(parent, mark, dom, contentDOM) {\n ViewDesc.call(this, parent, [], dom, contentDOM);\n this.mark = mark;\n }\n\n if ( ViewDesc ) MarkViewDesc.__proto__ = ViewDesc;\n MarkViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );\n MarkViewDesc.prototype.constructor = MarkViewDesc;\n\n MarkViewDesc.create = function create (parent, mark, inline, view) {\n var custom = view.nodeViews[mark.type.name];\n var spec = custom && custom(mark, view, inline);\n if (!spec || !spec.dom)\n { spec = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMSerializer\"].renderSpec(document, mark.type.spec.toDOM(mark, inline)); }\n return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom)\n };\n\n MarkViewDesc.prototype.parseRule = function parseRule () { return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM} };\n\n MarkViewDesc.prototype.matchesMark = function matchesMark (mark) { return this.dirty != NODE_DIRTY && this.mark.eq(mark) };\n\n MarkViewDesc.prototype.markDirty = function markDirty (from, to) {\n ViewDesc.prototype.markDirty.call(this, from, to);\n // Move dirty info to nearest node view\n if (this.dirty != NOT_DIRTY) {\n var parent = this.parent;\n while (!parent.node) { parent = parent.parent; }\n if (parent.dirty < this.dirty) { parent.dirty = this.dirty; }\n this.dirty = NOT_DIRTY;\n }\n };\n\n MarkViewDesc.prototype.slice = function slice (from, to, view) {\n var copy = MarkViewDesc.create(this.parent, this.mark, true, view);\n var nodes = this.children, size = this.size;\n if (to < size) { nodes = replaceNodes(nodes, to, size, view); }\n if (from > 0) { nodes = replaceNodes(nodes, 0, from, view); }\n for (var i = 0; i < nodes.length; i++) { nodes[i].parent = copy; }\n copy.children = nodes;\n return copy\n };\n\n return MarkViewDesc;\n}(ViewDesc));\n\n// Node view descs are the main, most common type of view desc, and\n// correspond to an actual node in the document. Unlike mark descs,\n// they populate their child array themselves.\nvar NodeViewDesc = /*@__PURE__*/(function (ViewDesc) {\n function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos) {\n ViewDesc.call(this, parent, node.isLeaf ? nothing : [], dom, contentDOM);\n this.nodeDOM = nodeDOM;\n this.node = node;\n this.outerDeco = outerDeco;\n this.innerDeco = innerDeco;\n if (contentDOM) { this.updateChildren(view, pos); }\n }\n\n if ( ViewDesc ) NodeViewDesc.__proto__ = ViewDesc;\n NodeViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );\n NodeViewDesc.prototype.constructor = NodeViewDesc;\n\n var prototypeAccessors$3 = { size: { configurable: true },border: { configurable: true } };\n\n // By default, a node is rendered using the `toDOM` method from the\n // node type spec. But client code can use the `nodeViews` spec to\n // supply a custom node view, which can influence various aspects of\n // the way the node works.\n //\n // (Using subclassing for this was intentionally decided against,\n // since it'd require exposing a whole slew of finnicky\n // implementation details to the user code that they probably will\n // never need.)\n NodeViewDesc.create = function create (parent, node, outerDeco, innerDeco, view, pos) {\n var assign;\n\n var custom = view.nodeViews[node.type.name], descObj;\n var spec = custom && custom(node, view, function () {\n // (This is a function that allows the custom view to find its\n // own position)\n if (!descObj) { return pos }\n if (descObj.parent) { return descObj.parent.posBeforeChild(descObj) }\n }, outerDeco);\n\n var dom = spec && spec.dom, contentDOM = spec && spec.contentDOM;\n if (node.isText) {\n if (!dom) { dom = document.createTextNode(node.text); }\n else if (dom.nodeType != 3) { throw new RangeError(\"Text must be rendered as a DOM text node\") }\n } else if (!dom) {\n((assign = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMSerializer\"].renderSpec(document, node.type.spec.toDOM(node)), dom = assign.dom, contentDOM = assign.contentDOM));\n }\n if (!contentDOM && !node.isText && dom.nodeName != \"BR\") { // Chrome gets confused by \n if (!dom.hasAttribute(\"contenteditable\")) { dom.contentEditable = false; }\n if (node.type.spec.draggable) { dom.draggable = true; }\n }\n\n var nodeDOM = dom;\n dom = applyOuterDeco(dom, outerDeco, node);\n\n if (spec)\n { return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM,\n spec, view, pos + 1) }\n else if (node.isText)\n { return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view) }\n else\n { return new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos + 1) }\n };\n\n NodeViewDesc.prototype.parseRule = function parseRule () {\n var this$1 = this;\n\n // Experimental kludge to allow opt-in re-parsing of nodes\n if (this.node.type.spec.reparseInView) { return null }\n // FIXME the assumption that this can always return the current\n // attrs means that if the user somehow manages to change the\n // attrs in the dom, that won't be picked up. Not entirely sure\n // whether this is a problem\n var rule = {node: this.node.type.name, attrs: this.node.attrs};\n if (this.node.type.spec.code) { rule.preserveWhitespace = \"full\"; }\n if (this.contentDOM && !this.contentLost) { rule.contentElement = this.contentDOM; }\n else { rule.getContent = function () { return this$1.contentDOM ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].empty : this$1.node.content; }; }\n return rule\n };\n\n NodeViewDesc.prototype.matchesNode = function matchesNode (node, outerDeco, innerDeco) {\n return this.dirty == NOT_DIRTY && node.eq(this.node) &&\n sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco)\n };\n\n prototypeAccessors$3.size.get = function () { return this.node.nodeSize };\n\n prototypeAccessors$3.border.get = function () { return this.node.isLeaf ? 0 : 1 };\n\n // Syncs `this.children` to match `this.node.content` and the local\n // decorations, possibly introducing nesting for marks. Then, in a\n // separate step, syncs the DOM inside `this.contentDOM` to\n // `this.children`.\n NodeViewDesc.prototype.updateChildren = function updateChildren (view, pos) {\n var this$1 = this;\n\n var inline = this.node.inlineContent, off = pos;\n var composition = inline && view.composing && this.localCompositionNode(view, pos);\n var updater = new ViewTreeUpdater(this, composition && composition.node);\n iterDeco(this.node, this.innerDeco, function (widget, i, insideNode) {\n if (widget.spec.marks)\n { updater.syncToMarks(widget.spec.marks, inline, view); }\n else if (widget.type.side >= 0 && !insideNode)\n { updater.syncToMarks(i == this$1.node.childCount ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Mark\"].none : this$1.node.child(i).marks, inline, view); }\n // If the next node is a desc matching this widget, reuse it,\n // otherwise insert the widget as a new view desc.\n updater.placeWidget(widget, view, off);\n }, function (child, outerDeco, innerDeco, i) {\n // Make sure the wrapping mark descs match the node's marks.\n updater.syncToMarks(child.marks, inline, view);\n // Either find an existing desc that exactly matches this node,\n // and drop the descs before it.\n updater.findNodeMatch(child, outerDeco, innerDeco, i) ||\n // Or try updating the next desc to reflect this node.\n updater.updateNextNode(child, outerDeco, innerDeco, view, i) ||\n // Or just add it as a new desc.\n updater.addNode(child, outerDeco, innerDeco, view, off);\n off += child.nodeSize;\n });\n // Drop all remaining descs after the current position.\n updater.syncToMarks(nothing, inline, view);\n if (this.node.isTextblock) { updater.addTextblockHacks(); }\n updater.destroyRest();\n\n // Sync the DOM if anything changed\n if (updater.changed || this.dirty == CONTENT_DIRTY) {\n // May have to protect focused DOM from being changed if a composition is active\n if (composition) { this.protectLocalComposition(view, composition); }\n this.renderChildren();\n }\n };\n\n NodeViewDesc.prototype.renderChildren = function renderChildren () {\n renderDescs(this.contentDOM, this.children);\n if (result.ios) { iosHacks(this.dom); }\n };\n\n NodeViewDesc.prototype.localCompositionNode = function localCompositionNode (view, pos) {\n // Only do something if both the selection and a focused text node\n // are inside of this node, and the node isn't already part of a\n // view that's a child of this view\n var ref = view.state.selection;\n var from = ref.from;\n var to = ref.to;\n if (!(view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) || from < pos || to > pos + this.node.content.size) { return }\n var sel = view.root.getSelection();\n var textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);\n if (!textNode || !this.dom.contains(textNode.parentNode)) { return }\n\n // Find the text in the focused node in the node, stop if it's not\n // there (may have been modified through other means, in which\n // case it should overwritten)\n var text = textNode.nodeValue;\n var textPos = findTextInFragment(this.node.content, text, from - pos, to - pos);\n\n return textPos < 0 ? null : {node: textNode, pos: textPos, text: text}\n };\n\n NodeViewDesc.prototype.protectLocalComposition = function protectLocalComposition (view, ref) {\n var node = ref.node;\n var pos = ref.pos;\n var text = ref.text;\n\n // The node is already part of a local view desc, leave it there\n if (this.getDesc(node)) { return }\n\n // Create a composition view for the orphaned nodes\n var topNode = node;\n for (;; topNode = topNode.parentNode) {\n if (topNode.parentNode == this.contentDOM) { break }\n while (topNode.previousSibling) { topNode.parentNode.removeChild(topNode.previousSibling); }\n while (topNode.nextSibling) { topNode.parentNode.removeChild(topNode.nextSibling); }\n if (topNode.pmViewDesc) { topNode.pmViewDesc = null; }\n }\n var desc = new CompositionViewDesc(this, topNode, node, text);\n view.compositionNodes.push(desc);\n\n // Patch up this.children to contain the composition view\n this.children = replaceNodes(this.children, pos, pos + text.length, view, desc);\n };\n\n // : (Node, [Decoration], DecorationSet, EditorView) → bool\n // If this desc be updated to match the given node decoration,\n // do so and return true.\n NodeViewDesc.prototype.update = function update (node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY ||\n !node.sameMarkup(this.node)) { return false }\n this.updateInner(node, outerDeco, innerDeco, view);\n return true\n };\n\n NodeViewDesc.prototype.updateInner = function updateInner (node, outerDeco, innerDeco, view) {\n this.updateOuterDeco(outerDeco);\n this.node = node;\n this.innerDeco = innerDeco;\n if (this.contentDOM) { this.updateChildren(view, this.posAtStart); }\n this.dirty = NOT_DIRTY;\n };\n\n NodeViewDesc.prototype.updateOuterDeco = function updateOuterDeco (outerDeco) {\n if (sameOuterDeco(outerDeco, this.outerDeco)) { return }\n var needsWrap = this.nodeDOM.nodeType != 1;\n var oldDOM = this.dom;\n this.dom = patchOuterDeco(this.dom, this.nodeDOM,\n computeOuterDeco(this.outerDeco, this.node, needsWrap),\n computeOuterDeco(outerDeco, this.node, needsWrap));\n if (this.dom != oldDOM) {\n oldDOM.pmViewDesc = null;\n this.dom.pmViewDesc = this;\n }\n this.outerDeco = outerDeco;\n };\n\n // Mark this node as being the selected node.\n NodeViewDesc.prototype.selectNode = function selectNode () {\n this.nodeDOM.classList.add(\"ProseMirror-selectednode\");\n if (this.contentDOM || !this.node.type.spec.draggable) { this.dom.draggable = true; }\n };\n\n // Remove selected node marking from this node.\n NodeViewDesc.prototype.deselectNode = function deselectNode () {\n this.nodeDOM.classList.remove(\"ProseMirror-selectednode\");\n if (this.contentDOM || !this.node.type.spec.draggable) { this.dom.draggable = false; }\n };\n\n Object.defineProperties( NodeViewDesc.prototype, prototypeAccessors$3 );\n\n return NodeViewDesc;\n}(ViewDesc));\n\n// Create a view desc for the top-level document node, to be exported\n// and used by the view class.\nfunction docViewDesc(doc, outerDeco, innerDeco, dom, view) {\n applyOuterDeco(dom, outerDeco, doc);\n return new NodeViewDesc(null, doc, outerDeco, innerDeco, dom, dom, dom, view, 0)\n}\n\nvar TextViewDesc = /*@__PURE__*/(function (NodeViewDesc) {\n function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view) {\n NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM, view);\n }\n\n if ( NodeViewDesc ) TextViewDesc.__proto__ = NodeViewDesc;\n TextViewDesc.prototype = Object.create( NodeViewDesc && NodeViewDesc.prototype );\n TextViewDesc.prototype.constructor = TextViewDesc;\n\n TextViewDesc.prototype.parseRule = function parseRule () {\n return {skip: this.nodeDOM.parentNode || true}\n };\n\n TextViewDesc.prototype.update = function update (node, outerDeco) {\n if (this.dirty == NODE_DIRTY || (this.dirty != NOT_DIRTY && !this.inParent()) ||\n !node.sameMarkup(this.node)) { return false }\n this.updateOuterDeco(outerDeco);\n if ((this.dirty != NOT_DIRTY || node.text != this.node.text) && node.text != this.nodeDOM.nodeValue)\n { this.nodeDOM.nodeValue = node.text; }\n this.node = node;\n this.dirty = NOT_DIRTY;\n return true\n };\n\n TextViewDesc.prototype.inParent = function inParent () {\n var parentDOM = this.parent.contentDOM;\n for (var n = this.nodeDOM; n; n = n.parentNode) { if (n == parentDOM) { return true } }\n return false\n };\n\n TextViewDesc.prototype.domFromPos = function domFromPos (pos) {\n return {node: this.nodeDOM, offset: pos}\n };\n\n TextViewDesc.prototype.localPosFromDOM = function localPosFromDOM (dom, offset, bias) {\n if (dom == this.nodeDOM) { return this.posAtStart + Math.min(offset, this.node.text.length) }\n return NodeViewDesc.prototype.localPosFromDOM.call(this, dom, offset, bias)\n };\n\n TextViewDesc.prototype.ignoreMutation = function ignoreMutation (mutation) {\n return mutation.type != \"characterData\" && mutation.type != \"selection\"\n };\n\n TextViewDesc.prototype.slice = function slice (from, to, view) {\n var node = this.node.cut(from, to), dom = document.createTextNode(node.text);\n return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom, view)\n };\n\n return TextViewDesc;\n}(NodeViewDesc));\n\n// A dummy desc used to tag trailing BR or span nodes created to work\n// around contentEditable terribleness.\nvar BRHackViewDesc = /*@__PURE__*/(function (ViewDesc) {\n function BRHackViewDesc () {\n ViewDesc.apply(this, arguments);\n }\n\n if ( ViewDesc ) BRHackViewDesc.__proto__ = ViewDesc;\n BRHackViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );\n BRHackViewDesc.prototype.constructor = BRHackViewDesc;\n\n BRHackViewDesc.prototype.parseRule = function parseRule () { return {ignore: true} };\n BRHackViewDesc.prototype.matchesHack = function matchesHack () { return this.dirty == NOT_DIRTY };\n\n return BRHackViewDesc;\n}(ViewDesc));\n\n// A separate subclass is used for customized node views, so that the\n// extra checks only have to be made for nodes that are actually\n// customized.\nvar CustomNodeViewDesc = /*@__PURE__*/(function (NodeViewDesc) {\n function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos) {\n NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos);\n this.spec = spec;\n }\n\n if ( NodeViewDesc ) CustomNodeViewDesc.__proto__ = NodeViewDesc;\n CustomNodeViewDesc.prototype = Object.create( NodeViewDesc && NodeViewDesc.prototype );\n CustomNodeViewDesc.prototype.constructor = CustomNodeViewDesc;\n\n // A custom `update` method gets to decide whether the update goes\n // through. If it does, and there's a `contentDOM` node, our logic\n // updates the children.\n CustomNodeViewDesc.prototype.update = function update (node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY) { return false }\n if (this.spec.update) {\n var result = this.spec.update(node, outerDeco);\n if (result) { this.updateInner(node, outerDeco, innerDeco, view); }\n return result\n } else if (!this.contentDOM && !node.isLeaf) {\n return false\n } else {\n return NodeViewDesc.prototype.update.call(this, node, outerDeco, innerDeco, view)\n }\n };\n\n CustomNodeViewDesc.prototype.selectNode = function selectNode () {\n this.spec.selectNode ? this.spec.selectNode() : NodeViewDesc.prototype.selectNode.call(this);\n };\n\n CustomNodeViewDesc.prototype.deselectNode = function deselectNode () {\n this.spec.deselectNode ? this.spec.deselectNode() : NodeViewDesc.prototype.deselectNode.call(this);\n };\n\n CustomNodeViewDesc.prototype.setSelection = function setSelection (anchor, head, root, force) {\n this.spec.setSelection ? this.spec.setSelection(anchor, head, root)\n : NodeViewDesc.prototype.setSelection.call(this, anchor, head, root, force);\n };\n\n CustomNodeViewDesc.prototype.destroy = function destroy () {\n if (this.spec.destroy) { this.spec.destroy(); }\n NodeViewDesc.prototype.destroy.call(this);\n };\n\n CustomNodeViewDesc.prototype.stopEvent = function stopEvent (event) {\n return this.spec.stopEvent ? this.spec.stopEvent(event) : false\n };\n\n CustomNodeViewDesc.prototype.ignoreMutation = function ignoreMutation (mutation) {\n return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : NodeViewDesc.prototype.ignoreMutation.call(this, mutation)\n };\n\n return CustomNodeViewDesc;\n}(NodeViewDesc));\n\n// : (dom.Node, [ViewDesc])\n// Sync the content of the given DOM node with the nodes associated\n// with the given array of view descs, recursing into mark descs\n// because this should sync the subtree for a whole node at a time.\nfunction renderDescs(parentDOM, descs) {\n var dom = parentDOM.firstChild;\n for (var i = 0; i < descs.length; i++) {\n var desc = descs[i], childDOM = desc.dom;\n if (childDOM.parentNode == parentDOM) {\n while (childDOM != dom) { dom = rm(dom); }\n dom = dom.nextSibling;\n } else {\n parentDOM.insertBefore(childDOM, dom);\n }\n if (desc instanceof MarkViewDesc) {\n var pos = dom ? dom.previousSibling : parentDOM.lastChild;\n renderDescs(desc.contentDOM, desc.children);\n dom = pos ? pos.nextSibling : parentDOM.firstChild;\n }\n }\n while (dom) { dom = rm(dom); }\n}\n\nfunction OuterDecoLevel(nodeName) {\n if (nodeName) { this.nodeName = nodeName; }\n}\nOuterDecoLevel.prototype = Object.create(null);\n\nvar noDeco = [new OuterDecoLevel];\n\nfunction computeOuterDeco(outerDeco, node, needsWrap) {\n if (outerDeco.length == 0) { return noDeco }\n\n var top = needsWrap ? noDeco[0] : new OuterDecoLevel, result = [top];\n\n for (var i = 0; i < outerDeco.length; i++) {\n var attrs = outerDeco[i].type.attrs, cur = top;\n if (!attrs) { continue }\n if (attrs.nodeName)\n { result.push(cur = new OuterDecoLevel(attrs.nodeName)); }\n\n for (var name in attrs) {\n var val = attrs[name];\n if (val == null) { continue }\n if (needsWrap && result.length == 1)\n { result.push(cur = top = new OuterDecoLevel(node.isInline ? \"span\" : \"div\")); }\n if (name == \"class\") { cur.class = (cur.class ? cur.class + \" \" : \"\") + val; }\n else if (name == \"style\") { cur.style = (cur.style ? cur.style + \";\" : \"\") + val; }\n else if (name != \"nodeName\") { cur[name] = val; }\n }\n }\n\n return result\n}\n\nfunction patchOuterDeco(outerDOM, nodeDOM, prevComputed, curComputed) {\n // Shortcut for trivial case\n if (prevComputed == noDeco && curComputed == noDeco) { return nodeDOM }\n\n var curDOM = nodeDOM;\n for (var i = 0; i < curComputed.length; i++) {\n var deco = curComputed[i], prev = prevComputed[i];\n if (i) {\n var parent = (void 0);\n if (prev && prev.nodeName == deco.nodeName && curDOM != outerDOM &&\n (parent = curDOM.parentNode) && parent.tagName.toLowerCase() == deco.nodeName) {\n curDOM = parent;\n } else {\n parent = document.createElement(deco.nodeName);\n parent.appendChild(curDOM);\n prev = noDeco[0];\n curDOM = parent;\n }\n }\n patchAttributes(curDOM, prev || noDeco[0], deco);\n }\n return curDOM\n}\n\nfunction patchAttributes(dom, prev, cur) {\n for (var name in prev)\n { if (name != \"class\" && name != \"style\" && name != \"nodeName\" && !(name in cur))\n { dom.removeAttribute(name); } }\n for (var name$1 in cur)\n { if (name$1 != \"class\" && name$1 != \"style\" && name$1 != \"nodeName\" && cur[name$1] != prev[name$1])\n { dom.setAttribute(name$1, cur[name$1]); } }\n if (prev.class != cur.class) {\n var prevList = prev.class ? prev.class.split(\" \") : nothing;\n var curList = cur.class ? cur.class.split(\" \") : nothing;\n for (var i = 0; i < prevList.length; i++) { if (curList.indexOf(prevList[i]) == -1)\n { dom.classList.remove(prevList[i]); } }\n for (var i$1 = 0; i$1 < curList.length; i$1++) { if (prevList.indexOf(curList[i$1]) == -1)\n { dom.classList.add(curList[i$1]); } }\n }\n if (prev.style != cur.style) {\n if (prev.style) {\n var prop = /\\s*([\\w\\-\\xa1-\\uffff]+)\\s*:(?:\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|\\(.*?\\)|[^;])*/g, m;\n while (m = prop.exec(prev.style))\n { dom.style.removeProperty(m[1]); }\n }\n if (cur.style)\n { dom.style.cssText += cur.style; }\n }\n}\n\nfunction applyOuterDeco(dom, deco, node) {\n return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1))\n}\n\n// : ([Decoration], [Decoration]) → bool\nfunction sameOuterDeco(a, b) {\n if (a.length != b.length) { return false }\n for (var i = 0; i < a.length; i++) { if (!a[i].type.eq(b[i].type)) { return false } }\n return true\n}\n\n// Remove a DOM node and return its next sibling.\nfunction rm(dom) {\n var next = dom.nextSibling;\n dom.parentNode.removeChild(dom);\n return next\n}\n\n// Helper class for incrementally updating a tree of mark descs and\n// the widget and node descs inside of them.\nvar ViewTreeUpdater = function ViewTreeUpdater(top, lockedNode) {\n this.top = top;\n this.lock = lockedNode;\n // Index into `this.top`'s child array, represents the current\n // update position.\n this.index = 0;\n // When entering a mark, the current top and index are pushed\n // onto this.\n this.stack = [];\n // Tracks whether anything was changed\n this.changed = false;\n\n var pre = preMatch(top.node.content, top.children);\n this.preMatched = pre.nodes;\n this.preMatchOffset = pre.offset;\n};\n\nViewTreeUpdater.prototype.getPreMatch = function getPreMatch (index) {\n return index >= this.preMatchOffset ? this.preMatched[index - this.preMatchOffset] : null\n};\n\n// Destroy and remove the children between the given indices in\n// `this.top`.\nViewTreeUpdater.prototype.destroyBetween = function destroyBetween (start, end) {\n if (start == end) { return }\n for (var i = start; i < end; i++) { this.top.children[i].destroy(); }\n this.top.children.splice(start, end - start);\n this.changed = true;\n};\n\n// Destroy all remaining children in `this.top`.\nViewTreeUpdater.prototype.destroyRest = function destroyRest () {\n this.destroyBetween(this.index, this.top.children.length);\n};\n\n// : ([Mark], EditorView)\n// Sync the current stack of mark descs with the given array of\n// marks, reusing existing mark descs when possible.\nViewTreeUpdater.prototype.syncToMarks = function syncToMarks (marks, inline, view) {\n var keep = 0, depth = this.stack.length >> 1;\n var maxKeep = Math.min(depth, marks.length);\n while (keep < maxKeep &&\n (keep == depth - 1 ? this.top : this.stack[(keep + 1) << 1]).matchesMark(marks[keep]) && marks[keep].type.spec.spanning !== false)\n { keep++; }\n\n while (keep < depth) {\n this.destroyRest();\n this.top.dirty = NOT_DIRTY;\n this.index = this.stack.pop();\n this.top = this.stack.pop();\n depth--;\n }\n while (depth < marks.length) {\n this.stack.push(this.top, this.index + 1);\n var found = -1;\n for (var i = this.index; i < Math.min(this.index + 3, this.top.children.length); i++) {\n if (this.top.children[i].matchesMark(marks[depth])) { found = i; break }\n }\n if (found > -1) {\n if (found > this.index) {\n this.changed = true;\n this.destroyBetween(this.index, found);\n }\n this.top = this.top.children[this.index];\n } else {\n var markDesc = MarkViewDesc.create(this.top, marks[depth], inline, view);\n this.top.children.splice(this.index, 0, markDesc);\n this.top = markDesc;\n this.changed = true;\n }\n this.index = 0;\n depth++;\n }\n};\n\n// : (Node, [Decoration], DecorationSet) → bool\n// Try to find a node desc matching the given data. Skip over it and\n// return true when successful.\nViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch (node, outerDeco, innerDeco, index) {\n var found = -1, preMatch = index < 0 ? undefined : this.getPreMatch(index), children = this.top.children;\n if (preMatch && preMatch.matchesNode(node, outerDeco, innerDeco)) {\n found = children.indexOf(preMatch);\n } else {\n for (var i = this.index, e = Math.min(children.length, i + 5); i < e; i++) {\n var child = children[i];\n if (child.matchesNode(node, outerDeco, innerDeco) && this.preMatched.indexOf(child) < 0) {\n found = i;\n break\n }\n }\n }\n if (found < 0) { return false }\n this.destroyBetween(this.index, found);\n this.index++;\n return true\n};\n\n// : (Node, [Decoration], DecorationSet, EditorView, Fragment, number) → bool\n// Try to update the next node, if any, to the given data. Checks\n// pre-matches to avoid overwriting nodes that could still be used.\nViewTreeUpdater.prototype.updateNextNode = function updateNextNode (node, outerDeco, innerDeco, view, index) {\n if (this.index == this.top.children.length) { return false }\n var next = this.top.children[this.index];\n if (next instanceof NodeViewDesc) {\n var preMatch = this.preMatched.indexOf(next);\n if (preMatch > -1 && preMatch + this.preMatchOffset != index) { return false }\n var nextDOM = next.dom;\n\n // Can't update if nextDOM is or contains this.lock, except if\n // it's a text node whose content already matches the new text\n // and whose decorations match the new ones.\n var locked = this.lock && (nextDOM == this.lock || nextDOM.nodeType == 1 && nextDOM.contains(this.lock.parentNode)) &&\n !(node.isText && next.node && next.node.isText && next.nodeDOM.nodeValue == node.text &&\n next.dirty != NODE_DIRTY && sameOuterDeco(outerDeco, next.outerDeco));\n if (!locked && next.update(node, outerDeco, innerDeco, view)) {\n if (next.dom != nextDOM) { this.changed = true; }\n this.index++;\n return true\n }\n }\n return false\n};\n\n// : (Node, [Decoration], DecorationSet, EditorView)\n// Insert the node as a newly created node desc.\nViewTreeUpdater.prototype.addNode = function addNode (node, outerDeco, innerDeco, view, pos) {\n this.top.children.splice(this.index++, 0, NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view, pos));\n this.changed = true;\n};\n\nViewTreeUpdater.prototype.placeWidget = function placeWidget (widget, view, pos) {\n if (this.index < this.top.children.length && this.top.children[this.index].matchesWidget(widget)) {\n this.index++;\n } else {\n var desc = new WidgetViewDesc(this.top, widget, view, pos);\n this.top.children.splice(this.index++, 0, desc);\n this.changed = true;\n }\n};\n\n// Make sure a textblock looks and behaves correctly in\n// contentEditable.\nViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks () {\n var lastChild = this.top.children[this.index - 1];\n while (lastChild instanceof MarkViewDesc) { lastChild = lastChild.children[lastChild.children.length - 1]; }\n\n if (!lastChild || // Empty textblock\n !(lastChild instanceof TextViewDesc) ||\n /\\n$/.test(lastChild.node.text)) {\n if (this.index < this.top.children.length && this.top.children[this.index].matchesHack()) {\n this.index++;\n } else {\n var dom = document.createElement(\"br\");\n this.top.children.splice(this.index++, 0, new BRHackViewDesc(this.top, nothing, dom, null));\n this.changed = true;\n }\n }\n};\n\n// : (Fragment, [ViewDesc]) → [ViewDesc]\n// Iterate from the end of the fragment and array of descs to find\n// directly matching ones, in order to avoid overeagerly reusing\n// those for other nodes. Returns an array whose positions correspond\n// to node positions in the fragment, and whose elements are either\n// descs matched to the child at that index, or empty.\nfunction preMatch(frag, descs) {\n var result = [], end = frag.childCount;\n for (var i = descs.length - 1; end > 0 && i >= 0; i--) {\n var desc = descs[i], node = desc.node;\n if (!node) { continue }\n if (node != frag.child(end - 1)) { break }\n result.push(desc);\n --end;\n }\n return {nodes: result.reverse(), offset: end}\n}\n\nfunction compareSide(a, b) { return a.type.side - b.type.side }\n\n// : (ViewDesc, DecorationSet, (Decoration, number), (Node, [Decoration], DecorationSet, number))\n// This function abstracts iterating over the nodes and decorations in\n// a fragment. Calls `onNode` for each node, with its local and child\n// decorations. Splits text nodes when there is a decoration starting\n// or ending inside of them. Calls `onWidget` for each widget.\nfunction iterDeco(parent, deco, onWidget, onNode) {\n var locals = deco.locals(parent), offset = 0;\n // Simple, cheap variant for when there are no local decorations\n if (locals.length == 0) {\n for (var i = 0; i < parent.childCount; i++) {\n var child = parent.child(i);\n onNode(child, locals, deco.forChild(offset, child), i);\n offset += child.nodeSize;\n }\n return\n }\n\n var decoIndex = 0, active = [], restNode = null;\n for (var parentIndex = 0;;) {\n if (decoIndex < locals.length && locals[decoIndex].to == offset) {\n var widget = locals[decoIndex++], widgets = (void 0);\n while (decoIndex < locals.length && locals[decoIndex].to == offset)\n { (widgets || (widgets = [widget])).push(locals[decoIndex++]); }\n if (widgets) {\n widgets.sort(compareSide);\n for (var i$1 = 0; i$1 < widgets.length; i$1++) { onWidget(widgets[i$1], parentIndex, !!restNode); }\n } else {\n onWidget(widget, parentIndex, !!restNode);\n }\n }\n\n var child$1 = (void 0), index = (void 0);\n if (restNode) {\n index = -1;\n child$1 = restNode;\n restNode = null;\n } else if (parentIndex < parent.childCount) {\n index = parentIndex;\n child$1 = parent.child(parentIndex++);\n } else {\n break\n }\n\n for (var i$2 = 0; i$2 < active.length; i$2++) { if (active[i$2].to <= offset) { active.splice(i$2--, 1); } }\n while (decoIndex < locals.length && locals[decoIndex].from == offset) { active.push(locals[decoIndex++]); }\n\n var end = offset + child$1.nodeSize;\n if (child$1.isText) {\n var cutAt = end;\n if (decoIndex < locals.length && locals[decoIndex].from < cutAt) { cutAt = locals[decoIndex].from; }\n for (var i$3 = 0; i$3 < active.length; i$3++) { if (active[i$3].to < cutAt) { cutAt = active[i$3].to; } }\n if (cutAt < end) {\n restNode = child$1.cut(cutAt - offset);\n child$1 = child$1.cut(0, cutAt - offset);\n end = cutAt;\n index = -1;\n }\n }\n\n onNode(child$1, active.length ? active.slice() : nothing, deco.forChild(offset, child$1), index);\n offset = end;\n }\n}\n\n// List markers in Mobile Safari will mysteriously disappear\n// sometimes. This works around that.\nfunction iosHacks(dom) {\n if (dom.nodeName == \"UL\" || dom.nodeName == \"OL\") {\n var oldCSS = dom.style.cssText;\n dom.style.cssText = oldCSS + \"; list-style: square !important\";\n window.getComputedStyle(dom).listStyle;\n dom.style.cssText = oldCSS;\n }\n}\n\nfunction nearbyTextNode(node, offset) {\n for (;;) {\n if (node.nodeType == 3) { return node }\n if (node.nodeType == 1 && offset > 0) {\n if (node.childNodes.length > offset && node.childNodes[offset].nodeType == 3)\n { return node.childNodes[offset] }\n node = node.childNodes[offset - 1];\n offset = nodeSize(node);\n } else if (node.nodeType == 1 && offset < node.childNodes.length) {\n node = node.childNodes[offset];\n offset = 0;\n } else {\n return null\n }\n }\n}\n\n// Find a piece of text in an inline fragment, overlapping from-to\nfunction findTextInFragment(frag, text, from, to) {\n for (var i = 0, pos = 0; i < frag.childCount && pos <= to;) {\n var child = frag.child(i++), childStart = pos;\n pos += child.nodeSize;\n if (!child.isText) { continue }\n var str = child.text;\n while (i < frag.childCount) {\n var next = frag.child(i++);\n pos += next.nodeSize;\n if (!next.isText) { break }\n str += next.text;\n }\n if (pos >= from) {\n var found = str.lastIndexOf(text, to - childStart);\n if (found >= 0 && found + text.length + childStart >= from)\n { return childStart + found }\n }\n }\n return -1\n}\n\n// Replace range from-to in an array of view descs with replacement\n// (may be null to just delete). This goes very much against the grain\n// of the rest of this code, which tends to create nodes with the\n// right shape in one go, rather than messing with them after\n// creation, but is necessary in the composition hack.\nfunction replaceNodes(nodes, from, to, view, replacement) {\n var result = [];\n for (var i = 0, off = 0; i < nodes.length; i++) {\n var child = nodes[i], start = off, end = off += child.size;\n if (start >= to || end <= from) {\n result.push(child);\n } else {\n if (start < from) { result.push(child.slice(0, from - start, view)); }\n if (replacement) {\n result.push(replacement);\n replacement = null;\n }\n if (end > to) { result.push(child.slice(to - start, child.size, view)); }\n }\n }\n return result\n}\n\nfunction moveSelectionBlock(state, dir) {\n var ref = state.selection;\n var $anchor = ref.$anchor;\n var $head = ref.$head;\n var $side = dir > 0 ? $anchor.max($head) : $anchor.min($head);\n var $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;\n return $start && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].findFrom($start, dir)\n}\n\nfunction apply(view, sel) {\n view.dispatch(view.state.tr.setSelection(sel).scrollIntoView());\n return true\n}\n\nfunction selectHorizontally(view, dir, mods) {\n var sel = view.state.selection;\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) {\n if (!sel.empty || mods.indexOf(\"s\") > -1) {\n return false\n } else if (view.endOfTextblock(dir > 0 ? \"right\" : \"left\")) {\n var next = moveSelectionBlock(view.state, dir);\n if (next && (next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"])) { return apply(view, next) }\n return false\n } else {\n var $head = sel.$head, node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter, desc;\n if (!node || node.isText) { return false }\n var nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;\n if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) { return false }\n if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"](dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head))\n } else if (result.webkit) {\n // Chrome and Safari will introduce extra pointless cursor\n // positions around inline uneditable nodes, so we have to\n // take over and move the cursor past them (#937)\n return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"](view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)))\n } else {\n return false\n }\n }\n } else if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"] && sel.node.isInline) {\n return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"](dir > 0 ? sel.$to : sel.$from))\n } else {\n var next$1 = moveSelectionBlock(view.state, dir);\n if (next$1) { return apply(view, next$1) }\n return false\n }\n}\n\nfunction nodeLen(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length\n}\n\nfunction isIgnorable(dom) {\n var desc = dom.pmViewDesc;\n return desc && desc.size == 0 && (dom.nextSibling || dom.nodeName != \"BR\")\n}\n\n// Make sure the cursor isn't directly after one or more ignored\n// nodes, which will confuse the browser's cursor motion logic.\nfunction skipIgnoredNodesLeft(view) {\n var sel = view.root.getSelection();\n var node = sel.focusNode, offset = sel.focusOffset;\n if (!node) { return }\n var moveNode, moveOffset, force = false;\n // Gecko will do odd things when the selection is directly in front\n // of a non-editable node, so in that case, move it into the next\n // node if possible. Issue prosemirror/prosemirror#832.\n if (result.gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset])) { force = true; }\n for (;;) {\n if (offset > 0) {\n if (node.nodeType != 1) {\n break\n } else {\n var before = node.childNodes[offset - 1];\n if (isIgnorable(before)) {\n moveNode = node;\n moveOffset = --offset;\n } else if (before.nodeType == 3) {\n node = before;\n offset = node.nodeValue.length;\n } else { break }\n }\n } else if (isBlockNode(node)) {\n break\n } else {\n var prev = node.previousSibling;\n while (prev && isIgnorable(prev)) {\n moveNode = node.parentNode;\n moveOffset = domIndex(prev);\n prev = prev.previousSibling;\n }\n if (!prev) {\n node = node.parentNode;\n if (node == view.dom) { break }\n offset = 0;\n } else {\n node = prev;\n offset = nodeLen(node);\n }\n }\n }\n if (force) { setSelFocus(view, sel, node, offset); }\n else if (moveNode) { setSelFocus(view, sel, moveNode, moveOffset); }\n}\n\n// Make sure the cursor isn't directly before one or more ignored\n// nodes.\nfunction skipIgnoredNodesRight(view) {\n var sel = view.root.getSelection();\n var node = sel.focusNode, offset = sel.focusOffset;\n if (!node) { return }\n var len = nodeLen(node);\n var moveNode, moveOffset;\n for (;;) {\n if (offset < len) {\n if (node.nodeType != 1) { break }\n var after = node.childNodes[offset];\n if (isIgnorable(after)) {\n moveNode = node;\n moveOffset = ++offset;\n }\n else { break }\n } else if (isBlockNode(node)) {\n break\n } else {\n var next = node.nextSibling;\n while (next && isIgnorable(next)) {\n moveNode = next.parentNode;\n moveOffset = domIndex(next) + 1;\n next = next.nextSibling;\n }\n if (!next) {\n node = node.parentNode;\n if (node == view.dom) { break }\n offset = len = 0;\n } else {\n node = next;\n offset = 0;\n len = nodeLen(node);\n }\n }\n }\n if (moveNode) { setSelFocus(view, sel, moveNode, moveOffset); }\n}\n\nfunction isBlockNode(dom) {\n var desc = dom.pmViewDesc;\n return desc && desc.node && desc.node.isBlock\n}\n\nfunction setSelFocus(view, sel, node, offset) {\n if (selectionCollapsed(sel)) {\n var range = document.createRange();\n range.setEnd(node, offset);\n range.setStart(node, offset);\n sel.removeAllRanges();\n sel.addRange(range);\n } else if (sel.extend) {\n sel.extend(node, offset);\n }\n view.domObserver.setCurSelection();\n}\n\n// : (EditorState, number)\n// Check whether vertical selection motion would involve node\n// selections. If so, apply it (if not, the result is left to the\n// browser)\nfunction selectVertically(view, dir, mods) {\n var sel = view.state.selection;\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"] && !sel.empty || mods.indexOf(\"s\") > -1) { return false }\n var $from = sel.$from;\n var $to = sel.$to;\n\n if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? \"up\" : \"down\")) {\n var next = moveSelectionBlock(view.state, dir);\n if (next && (next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]))\n { return apply(view, next) }\n }\n if (!$from.parent.inlineContent) {\n var beyond = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].findFrom(dir < 0 ? $from : $to, dir);\n return beyond ? apply(view, beyond) : true\n }\n return false\n}\n\nfunction stopNativeHorizontalDelete(view, dir) {\n if (!(view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"])) { return true }\n var ref = view.state.selection;\n var $head = ref.$head;\n var $anchor = ref.$anchor;\n var empty = ref.empty;\n if (!$head.sameParent($anchor)) { return true }\n if (!empty) { return false }\n if (view.endOfTextblock(dir > 0 ? \"forward\" : \"backward\")) { return true }\n var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter);\n if (nextNode && !nextNode.isText) {\n var tr = view.state.tr;\n if (dir < 0) { tr.delete($head.pos - nextNode.nodeSize, $head.pos); }\n else { tr.delete($head.pos, $head.pos + nextNode.nodeSize); }\n view.dispatch(tr);\n return true\n }\n return false\n}\n\nfunction switchEditable(view, node, state) {\n view.domObserver.stop();\n node.contentEditable = state;\n view.domObserver.start();\n}\n\n// Issue #867 / https://bugs.chromium.org/p/chromium/issues/detail?id=903821\n// In which Chrome does really wrong things when the down arrow is\n// pressed when the cursor is directly at the start of a textblock and\n// has an uneditable node after it\nfunction chromeDownArrowBug(view) {\n if (!result.chrome || view.state.selection.$head.parentOffset > 0) { return }\n var ref = view.root.getSelection();\n var focusNode = ref.focusNode;\n var focusOffset = ref.focusOffset;\n if (focusNode && focusNode.nodeType == 1 && focusOffset == 0 &&\n focusNode.firstChild && focusNode.firstChild.contentEditable == \"false\") {\n var child = focusNode.firstChild;\n switchEditable(view, child, true);\n setTimeout(function () { return switchEditable(view, child, false); }, 20);\n }\n}\n\n// A backdrop key mapping used to make sure we always suppress keys\n// that have a dangerous default effect, even if the commands they are\n// bound to return false, and to make sure that cursor-motion keys\n// find a cursor (as opposed to a node selection) when pressed. For\n// cursor-motion keys, the code in the handlers also takes care of\n// block selections.\n\nfunction getMods(event) {\n var result = \"\";\n if (event.ctrlKey) { result += \"c\"; }\n if (event.metaKey) { result += \"m\"; }\n if (event.altKey) { result += \"a\"; }\n if (event.shiftKey) { result += \"s\"; }\n return result\n}\n\nfunction captureKeyDown(view, event) {\n var code = event.keyCode, mods = getMods(event);\n if (code == 8 || (result.mac && code == 72 && mods == \"c\")) { // Backspace, Ctrl-h on Mac\n return stopNativeHorizontalDelete(view, -1) || skipIgnoredNodesLeft(view)\n } else if (code == 46 || (result.mac && code == 68 && mods == \"c\")) { // Delete, Ctrl-d on Mac\n return stopNativeHorizontalDelete(view, 1) || skipIgnoredNodesRight(view)\n } else if ((code == 13 && !result.ios) || code == 27) { // Enter (let through on iOS, to avoid keyboard sync issues), Esc\n return true\n } else if (code == 37) { // Left arrow\n return selectHorizontally(view, -1, mods) || skipIgnoredNodesLeft(view)\n } else if (code == 39) { // Right arrow\n return selectHorizontally(view, 1, mods) || skipIgnoredNodesRight(view)\n } else if (code == 38) { // Up arrow\n return selectVertically(view, -1, mods) || skipIgnoredNodesLeft(view)\n } else if (code == 40) { // Down arrow\n return chromeDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodesRight(view)\n } else if (mods == (result.mac ? \"m\" : \"c\") &&\n (code == 66 || code == 73 || code == 89 || code == 90)) { // Mod-[biyz]\n return true\n }\n return false\n}\n\nfunction selectionFromDOM(view, origin) {\n var domSel = view.root.getSelection(), doc = view.state.doc;\n var nearestDesc = view.docView.nearestDesc(domSel.focusNode), inWidget = nearestDesc && nearestDesc.size == 0;\n var head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);\n var $head = doc.resolve(head), $anchor, selection;\n if (selectionCollapsed(domSel)) {\n $anchor = $head;\n while (nearestDesc && !nearestDesc.node) { nearestDesc = nearestDesc.parent; }\n if (nearestDesc && nearestDesc.node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(nearestDesc.node) && nearestDesc.parent\n && !(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {\n var pos = nearestDesc.posBefore;\n selection = new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"](head == pos ? $head : doc.resolve(pos));\n }\n } else {\n $anchor = doc.resolve(view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset));\n }\n\n if (!selection) {\n var bias = origin == \"pointer\" || (view.state.selection.head < $head.pos && !inWidget) ? 1 : -1;\n selection = selectionBetween(view, $anchor, $head, bias);\n }\n return selection\n}\n\nfunction selectionToDOM(view, force) {\n var sel = view.state.selection;\n syncNodeSelection(view, sel);\n\n if (view.editable ? !view.hasFocus() : !(hasSelection(view) && document.activeElement.contains(view.dom))) { return }\n\n view.domObserver.disconnectSelection();\n\n if (view.cursorWrapper) {\n selectCursorWrapper(view);\n } else {\n var anchor = sel.anchor;\n var head = sel.head;\n var resetEditableFrom, resetEditableTo;\n if (brokenSelectBetweenUneditable && !(sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"])) {\n if (!sel.$from.parent.inlineContent)\n { resetEditableFrom = temporarilyEditableNear(view, sel.from); }\n if (!sel.empty && !sel.$from.parent.inlineContent)\n { resetEditableTo = temporarilyEditableNear(view, sel.to); }\n }\n view.docView.setSelection(anchor, head, view.root, force);\n if (brokenSelectBetweenUneditable) {\n if (resetEditableFrom) { resetEditable(resetEditableFrom); }\n if (resetEditableTo) { resetEditable(resetEditableTo); }\n }\n if (sel.visible) {\n view.dom.classList.remove(\"ProseMirror-hideselection\");\n } else if (anchor != head) {\n view.dom.classList.add(\"ProseMirror-hideselection\");\n if (\"onselectionchange\" in document) { removeClassOnSelectionChange(view); }\n }\n }\n\n view.domObserver.setCurSelection();\n view.domObserver.connectSelection();\n}\n\n// Kludge to work around Webkit not allowing a selection to start/end\n// between non-editable block nodes. We briefly make something\n// editable, set the selection, then set it uneditable again.\n\nvar brokenSelectBetweenUneditable = result.safari || result.chrome && result.chrome_version < 63;\n\nfunction temporarilyEditableNear(view, pos) {\n var ref = view.docView.domFromPos(pos);\n var node = ref.node;\n var offset = ref.offset;\n var after = offset < node.childNodes.length ? node.childNodes[offset] : null;\n var before = offset ? node.childNodes[offset - 1] : null;\n if (result.safari && after && after.contentEditable == \"false\") { return setEditable(after) }\n if ((!after || after.contentEditable == \"false\") && (!before || before.contentEditable == \"false\")) {\n if (after) { return setEditable(after) }\n else if (before) { return setEditable(before) }\n }\n}\n\nfunction setEditable(element) {\n element.contentEditable = \"true\";\n if (result.safari && element.draggable) { element.draggable = false; element.wasDraggable = true; }\n return element\n}\n\nfunction resetEditable(element) {\n element.contentEditable = \"false\";\n if (element.wasDraggable) { element.draggable = true; element.wasDraggable = null; }\n}\n\nfunction removeClassOnSelectionChange(view) {\n var doc = view.dom.ownerDocument;\n doc.removeEventListener(\"selectionchange\", view.hideSelectionGuard);\n var domSel = view.root.getSelection();\n var node = domSel.anchorNode, offset = domSel.anchorOffset;\n doc.addEventListener(\"selectionchange\", view.hideSelectionGuard = function () {\n if (domSel.anchorNode != node || domSel.anchorOffset != offset) {\n doc.removeEventListener(\"selectionchange\", view.hideSelectionGuard);\n view.dom.classList.remove(\"ProseMirror-hideselection\");\n }\n });\n}\n\nfunction selectCursorWrapper(view) {\n var domSel = view.root.getSelection(), range = document.createRange();\n var node = view.cursorWrapper.dom, img = node.nodeName == \"IMG\";\n if (img) { range.setEnd(node.parentNode, domIndex(node) + 1); }\n else { range.setEnd(node, 0); }\n range.collapse(false);\n domSel.removeAllRanges();\n domSel.addRange(range);\n // Kludge to kill 'control selection' in IE11 when selecting an\n // invisible cursor wrapper, since that would result in those weird\n // resize handles and a selection that considers the absolutely\n // positioned wrapper, rather than the root editable node, the\n // focused element.\n if (!img && !view.state.selection.visible && result.ie && result.ie_version <= 11) {\n node.disabled = true;\n node.disabled = false;\n }\n}\n\nfunction syncNodeSelection(view, sel) {\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) {\n var desc = view.docView.descAt(sel.from);\n if (desc != view.lastSelectedViewDesc) {\n clearNodeSelection(view);\n if (desc) { desc.selectNode(); }\n view.lastSelectedViewDesc = desc;\n }\n } else {\n clearNodeSelection(view);\n }\n}\n\n// Clear all DOM statefulness of the last node selection.\nfunction clearNodeSelection(view) {\n if (view.lastSelectedViewDesc) {\n if (view.lastSelectedViewDesc.parent)\n { view.lastSelectedViewDesc.deselectNode(); }\n view.lastSelectedViewDesc = null;\n }\n}\n\nfunction selectionBetween(view, $anchor, $head, bias) {\n return view.someProp(\"createSelectionBetween\", function (f) { return f(view, $anchor, $head); })\n || prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"].between($anchor, $head, bias)\n}\n\nfunction hasFocusAndSelection(view) {\n if (view.editable && view.root.activeElement != view.dom) { return false }\n return hasSelection(view)\n}\n\nfunction hasSelection(view) {\n var sel = view.root.getSelection();\n if (!sel.anchorNode) { return false }\n try {\n // Firefox will raise 'permission denied' errors when accessing\n // properties of `sel.anchorNode` when it's in a generated CSS\n // element.\n return view.dom.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode) &&\n (view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode))\n } catch(_) {\n return false\n }\n}\n\nfunction anchorInRightPlace(view) {\n var anchorDOM = view.docView.domFromPos(view.state.selection.anchor);\n var domSel = view.root.getSelection();\n return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset)\n}\n\n// Note that all referencing and parsing is done with the\n// start-of-operation selection and document, since that's the one\n// that the DOM represents. If any changes came in in the meantime,\n// the modification is mapped over those before it is applied, in\n// readDOMChange.\n\nfunction parseBetween(view, from_, to_) {\n var ref = view.docView.parseRange(from_, to_);\n var parent = ref.node;\n var fromOffset = ref.fromOffset;\n var toOffset = ref.toOffset;\n var from = ref.from;\n var to = ref.to;\n\n var domSel = view.root.getSelection(), find = null, anchor = domSel.anchorNode;\n if (anchor && view.dom.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {\n find = [{node: anchor, offset: domSel.anchorOffset}];\n if (!selectionCollapsed(domSel))\n { find.push({node: domSel.focusNode, offset: domSel.focusOffset}); }\n }\n // Work around issue in Chrome where backspacing sometimes replaces\n // the deleted content with a random BR node (issues #799, #831)\n if (result.chrome && view.lastKeyCode === 8) {\n for (var off = toOffset; off > fromOffset; off--) {\n var node = parent.childNodes[off - 1], desc = node.pmViewDesc;\n if (node.nodeType == \"BR\" && !desc) { toOffset = off; break }\n if (!desc || desc.size) { break }\n }\n }\n var startDoc = view.state.doc;\n var parser = view.someProp(\"domParser\") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMParser\"].fromSchema(view.state.schema);\n var $from = startDoc.resolve(from);\n\n var sel = null, doc = parser.parse(parent, {\n topNode: $from.parent,\n topMatch: $from.parent.contentMatchAt($from.index()),\n topOpen: true,\n from: fromOffset,\n to: toOffset,\n preserveWhitespace: $from.parent.type.spec.code ? \"full\" : true,\n editableContent: true,\n findPositions: find,\n ruleFromNode: ruleFromNode,\n context: $from\n });\n if (find && find[0].pos != null) {\n var anchor$1 = find[0].pos, head = find[1] && find[1].pos;\n if (head == null) { head = anchor$1; }\n sel = {anchor: anchor$1 + from, head: head + from};\n }\n return {doc: doc, sel: sel, from: from, to: to}\n}\n\nfunction ruleFromNode(dom) {\n var desc = dom.pmViewDesc;\n if (desc) {\n return desc.parseRule()\n } else if (dom.nodeName == \"BR\" && dom.parentNode) {\n // Safari replaces the list item or table cell with a BR\n // directly in the list node (?!) if you delete the last\n // character in a list item or table cell (#708, #862)\n if (result.safari && /^(ul|ol)$/i.test(dom.parentNode.nodeName)) {\n var skip = document.createElement(\"div\");\n skip.appendChild(document.createElement(\"li\"));\n return {skip: skip}\n } else if (dom.parentNode.lastChild == dom || result.safari && /^(tr|table)$/i.test(dom.parentNode.nodeName)) {\n return {ignore: true}\n }\n } else if (dom.nodeName == \"IMG\" && dom.getAttribute(\"mark-placeholder\")) {\n return {ignore: true}\n }\n}\n\nfunction readDOMChange(view, from, to, typeOver, addedNodes) {\n if (from < 0) {\n var origin = view.lastSelectionTime > Date.now() - 50 ? view.lastSelectionOrigin : null;\n var newSel = selectionFromDOM(view, origin);\n if (!view.state.selection.eq(newSel)) {\n var tr$1 = view.state.tr.setSelection(newSel);\n if (origin == \"pointer\") { tr$1.setMeta(\"pointer\", true); }\n else if (origin == \"key\") { tr$1.scrollIntoView(); }\n view.dispatch(tr$1);\n }\n return\n }\n\n var $before = view.state.doc.resolve(from);\n var shared = $before.sharedDepth(to);\n from = $before.before(shared + 1);\n to = view.state.doc.resolve(to).after(shared + 1);\n\n var sel = view.state.selection;\n var parse = parseBetween(view, from, to);\n\n var doc = view.state.doc, compare = doc.slice(parse.from, parse.to);\n var preferredPos, preferredSide;\n // Prefer anchoring to end when Backspace is pressed\n if (view.lastKeyCode === 8 && Date.now() - 100 < view.lastKeyCodeTime) {\n preferredPos = view.state.selection.to;\n preferredSide = \"end\";\n } else {\n preferredPos = view.state.selection.from;\n preferredSide = \"start\";\n }\n view.lastKeyCode = null;\n\n var change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);\n if (!change) {\n if (typeOver && sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"] && !sel.empty && sel.$head.sameParent(sel.$anchor) &&\n !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {\n change = {start: sel.from, endA: sel.to, endB: sel.to};\n } else {\n if (parse.sel) {\n var sel$1 = resolveSelection(view, view.state.doc, parse.sel);\n if (sel$1 && !sel$1.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel$1)); }\n }\n return\n }\n }\n view.domChangeCount++;\n // Handle the case where overwriting a selection by typing matches\n // the start or end of the selected content, creating a change\n // that's smaller than what was actually overwritten.\n if (view.state.selection.from < view.state.selection.to &&\n change.start == change.endB &&\n view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) {\n if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2) {\n change.start = view.state.selection.from;\n } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2) {\n change.endB += (view.state.selection.to - change.endA);\n change.endA = view.state.selection.to;\n }\n }\n\n // IE11 will insert a non-breaking space _ahead_ of the space after\n // the cursor space when adding a space before another space. When\n // that happened, adjust the change to cover the space instead.\n if (result.ie && result.ie_version <= 11 && change.endB == change.start + 1 &&\n change.endA == change.start && change.start > parse.from &&\n parse.doc.textBetween(change.start - parse.from - 1, change.start - parse.from + 1) == \" \\u00a0\") {\n change.start--;\n change.endA--;\n change.endB--;\n }\n\n var $from = parse.doc.resolveNoCache(change.start - parse.from);\n var $to = parse.doc.resolveNoCache(change.endB - parse.from);\n var nextSel;\n // If this looks like the effect of pressing Enter (or was recorded\n // as being an iOS enter press), just dispatch an Enter key instead.\n if (((result.ios && view.lastIOSEnter > Date.now() - 100 &&\n (!$from.sameParent($to) || addedNodes.some(function (n) { return n.nodeName == \"DIV\"; }))) ||\n (!$from.sameParent($to) && $from.pos < parse.doc.content.size &&\n (nextSel = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].findFrom(parse.doc.resolve($from.pos + 1), 1, true)) &&\n nextSel.head == $to.pos)) &&\n view.someProp(\"handleKeyDown\", function (f) { return f(view, keyEvent(13, \"Enter\")); })) {\n view.lastIOSEnter = 0;\n return\n }\n // Same for backspace\n if (view.state.selection.anchor > change.start &&\n looksLikeJoin(doc, change.start, change.endA, $from, $to) &&\n view.someProp(\"handleKeyDown\", function (f) { return f(view, keyEvent(8, \"Backspace\")); })) {\n if (result.android && result.chrome) { view.domObserver.suppressSelectionUpdates(); } // #820\n return\n }\n\n var chFrom = change.start, chTo = change.endA;\n\n var tr, storedMarks, markChange, $from1;\n if ($from.sameParent($to) && $from.parent.inlineContent) {\n if ($from.pos == $to.pos) { // Deletion\n // IE11 sometimes weirdly moves the DOM selection around after\n // backspacing out the first element in a textblock\n if (result.ie && result.ie_version <= 11 && $from.parentOffset == 0) {\n view.domObserver.suppressSelectionUpdates();\n setTimeout(function () { return selectionToDOM(view); }, 20);\n }\n tr = view.state.tr.delete(chFrom, chTo);\n storedMarks = doc.resolve(change.start).marksAcross(doc.resolve(change.endA));\n } else if ( // Adding or removing a mark\n change.endA == change.endB && ($from1 = doc.resolve(change.start)) &&\n (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset),\n $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))\n ) {\n tr = view.state.tr;\n if (markChange.type == \"add\") { tr.addMark(chFrom, chTo, markChange.mark); }\n else { tr.removeMark(chFrom, chTo, markChange.mark); }\n } else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {\n // Both positions in the same text node -- simply insert text\n var text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);\n if (view.someProp(\"handleTextInput\", function (f) { return f(view, chFrom, chTo, text); })) { return }\n tr = view.state.tr.insertText(text, chFrom, chTo);\n }\n }\n\n if (!tr)\n { tr = view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from)); }\n if (parse.sel) {\n var sel$2 = resolveSelection(view, tr.doc, parse.sel);\n // Chrome Android will sometimes, during composition, report the\n // selection in the wrong place. If it looks like that is\n // happening, don't update the selection.\n // Edge just doesn't move the cursor forward when you start typing\n // in an empty block or between br nodes.\n if (sel$2 && !(result.chrome && result.android && view.composing && sel$2.empty && sel$2.head == chFrom ||\n result.ie && sel$2.empty && sel$2.head == chFrom))\n { tr.setSelection(sel$2); }\n }\n if (storedMarks) { tr.ensureMarks(storedMarks); }\n view.dispatch(tr.scrollIntoView());\n}\n\nfunction resolveSelection(view, doc, parsedSel) {\n if (Math.max(parsedSel.anchor, parsedSel.head) > doc.content.size) { return null }\n return selectionBetween(view, doc.resolve(parsedSel.anchor), doc.resolve(parsedSel.head))\n}\n\n// : (Fragment, Fragment) → ?{mark: Mark, type: string}\n// Given two same-length, non-empty fragments of inline content,\n// determine whether the first could be created from the second by\n// removing or adding a single mark type.\nfunction isMarkChange(cur, prev) {\n var curMarks = cur.firstChild.marks, prevMarks = prev.firstChild.marks;\n var added = curMarks, removed = prevMarks, type, mark, update;\n for (var i = 0; i < prevMarks.length; i++) { added = prevMarks[i].removeFromSet(added); }\n for (var i$1 = 0; i$1 < curMarks.length; i$1++) { removed = curMarks[i$1].removeFromSet(removed); }\n if (added.length == 1 && removed.length == 0) {\n mark = added[0];\n type = \"add\";\n update = function (node) { return node.mark(mark.addToSet(node.marks)); };\n } else if (added.length == 0 && removed.length == 1) {\n mark = removed[0];\n type = \"remove\";\n update = function (node) { return node.mark(mark.removeFromSet(node.marks)); };\n } else {\n return null\n }\n var updated = [];\n for (var i$2 = 0; i$2 < prev.childCount; i$2++) { updated.push(update(prev.child(i$2))); }\n if (prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(updated).eq(cur)) { return {mark: mark, type: type} }\n}\n\nfunction looksLikeJoin(old, start, end, $newStart, $newEnd) {\n if (!$newStart.parent.isTextblock ||\n // The content must have shrunk\n end - start <= $newEnd.pos - $newStart.pos ||\n // newEnd must point directly at or after the end of the block that newStart points into\n skipClosingAndOpening($newStart, true, false) < $newEnd.pos)\n { return false }\n\n var $start = old.resolve(start);\n // Start must be at the end of a block\n if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock)\n { return false }\n var $next = old.resolve(skipClosingAndOpening($start, true, true));\n // The next textblock must start before end and end near it\n if (!$next.parent.isTextblock || $next.pos > end ||\n skipClosingAndOpening($next, true, false) < end)\n { return false }\n\n // The fragments after the join point must match\n return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content)\n}\n\nfunction skipClosingAndOpening($pos, fromEnd, mayOpen) {\n var depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;\n while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {\n depth--;\n end++;\n fromEnd = false;\n }\n if (mayOpen) {\n var next = $pos.node(depth).maybeChild($pos.indexAfter(depth));\n while (next && !next.isLeaf) {\n next = next.firstChild;\n end++;\n }\n }\n return end\n}\n\nfunction findDiff(a, b, pos, preferredPos, preferredSide) {\n var start = a.findDiffStart(b, pos);\n if (start == null) { return null }\n var ref = a.findDiffEnd(b, pos + a.size, pos + b.size);\n var endA = ref.a;\n var endB = ref.b;\n if (preferredSide == \"end\") {\n var adjust = Math.max(0, start - Math.min(endA, endB));\n preferredPos -= endA + adjust - start;\n }\n if (endA < start && a.size < b.size) {\n var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0;\n start -= move;\n endB = start + (endB - endA);\n endA = start;\n } else if (endB < start) {\n var move$1 = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0;\n start -= move$1;\n endA = start + (endA - endB);\n endB = start;\n }\n return {start: start, endA: endA, endB: endB}\n}\n\nfunction serializeForClipboard(view, slice) {\n var context = [];\n var content = slice.content;\n var openStart = slice.openStart;\n var openEnd = slice.openEnd;\n while (openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild.childCount == 1) {\n openStart--;\n openEnd--;\n var node = content.firstChild;\n context.push(node.type.name, node.type.hasRequiredAttrs() ? node.attrs : null);\n content = node.content;\n }\n\n var serializer = view.someProp(\"clipboardSerializer\") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMSerializer\"].fromSchema(view.state.schema);\n var doc = detachedDoc(), wrap = doc.createElement(\"div\");\n wrap.appendChild(serializer.serializeFragment(content, {document: doc}));\n\n var firstChild = wrap.firstChild, needsWrap;\n while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {\n for (var i = needsWrap.length - 1; i >= 0; i--) {\n var wrapper = doc.createElement(needsWrap[i]);\n while (wrap.firstChild) { wrapper.appendChild(wrap.firstChild); }\n wrap.appendChild(wrapper);\n }\n firstChild = wrap.firstChild;\n }\n\n if (firstChild && firstChild.nodeType == 1)\n { firstChild.setAttribute(\"data-pm-slice\", (openStart + \" \" + openEnd + \" \" + (JSON.stringify(context)))); }\n\n var text = view.someProp(\"clipboardTextSerializer\", function (f) { return f(slice); }) ||\n slice.content.textBetween(0, slice.content.size, \"\\n\\n\");\n\n return {dom: wrap, text: text}\n}\n\n// : (EditorView, string, string, ?bool, ResolvedPos) → ?Slice\n// Read a slice of content from the clipboard (or drop data).\nfunction parseFromClipboard(view, text, html, plainText, $context) {\n var dom, inCode = $context.parent.type.spec.code, slice;\n if (!html && !text) { return null }\n var asText = text && (plainText || inCode || !html);\n if (asText) {\n view.someProp(\"transformPastedText\", function (f) { text = f(text); });\n if (inCode) { return new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(view.state.schema.text(text)), 0, 0) }\n var parsed = view.someProp(\"clipboardTextParser\", function (f) { return f(text, $context); });\n if (parsed) {\n slice = parsed;\n } else {\n dom = document.createElement(\"div\");\n text.trim().split(/(?:\\r\\n?|\\n)+/).forEach(function (block) {\n dom.appendChild(document.createElement(\"p\")).textContent = block;\n });\n }\n } else {\n view.someProp(\"transformPastedHTML\", function (f) { html = f(html); });\n dom = readHTML(html);\n }\n\n var contextNode = dom && dom.querySelector(\"[data-pm-slice]\");\n var sliceData = contextNode && /^(\\d+) (\\d+) (.*)/.exec(contextNode.getAttribute(\"data-pm-slice\"));\n if (!slice) {\n var parser = view.someProp(\"clipboardParser\") || view.someProp(\"domParser\") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMParser\"].fromSchema(view.state.schema);\n slice = parser.parseSlice(dom, {preserveWhitespace: !!(asText || sliceData), context: $context});\n }\n if (sliceData)\n { slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]); }\n else // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent\n { slice = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"].maxOpen(normalizeSiblings(slice.content, $context), false); }\n\n view.someProp(\"transformPasted\", function (f) { slice = f(slice); });\n return slice\n}\n\n// Takes a slice parsed with parseSlice, which means there hasn't been\n// any content-expression checking done on the top nodes, tries to\n// find a parent node in the current context that might fit the nodes,\n// and if successful, rebuilds the slice so that it fits into that parent.\n//\n// This addresses the problem that Transform.replace expects a\n// coherent slice, and will fail to place a set of siblings that don't\n// fit anywhere in the schema.\nfunction normalizeSiblings(fragment, $context) {\n if (fragment.childCount < 2) { return fragment }\n var loop = function ( d ) {\n var parent = $context.node(d);\n var match = parent.contentMatchAt($context.index(d));\n var lastWrap = (void 0), result = [];\n fragment.forEach(function (node) {\n if (!result) { return }\n var wrap = match.findWrapping(node.type), inLast;\n if (!wrap) { return result = null }\n if (inLast = result.length && lastWrap.length && addToSibling(wrap, lastWrap, node, result[result.length - 1], 0)) {\n result[result.length - 1] = inLast;\n } else {\n if (result.length) { result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length); }\n var wrapped = withWrappers(node, wrap);\n result.push(wrapped);\n match = match.matchType(wrapped.type, wrapped.attrs);\n lastWrap = wrap;\n }\n });\n if (result) { return { v: prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(result) } }\n };\n\n for (var d = $context.depth; d >= 0; d--) {\n var returned = loop( d );\n\n if ( returned ) return returned.v;\n }\n return fragment\n}\n\nfunction withWrappers(node, wrap, from) {\n if ( from === void 0 ) from = 0;\n\n for (var i = wrap.length - 1; i >= from; i--)\n { node = wrap[i].create(null, prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(node)); }\n return node\n}\n\n// Used to group adjacent nodes wrapped in similar parents by\n// normalizeSiblings into the same parent node\nfunction addToSibling(wrap, lastWrap, node, sibling, depth) {\n if (depth < wrap.length && depth < lastWrap.length && wrap[depth] == lastWrap[depth]) {\n var inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1);\n if (inner) { return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner)) }\n var match = sibling.contentMatchAt(sibling.childCount);\n if (match.matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1]))\n { return sibling.copy(sibling.content.append(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(withWrappers(node, wrap, depth + 1)))) }\n }\n}\n\nfunction closeRight(node, depth) {\n if (depth == 0) { return node }\n var fragment = node.content.replaceChild(node.childCount - 1, closeRight(node.lastChild, depth - 1));\n var fill = node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].empty, true);\n return node.copy(fragment.append(fill))\n}\n\nfunction closeRange(fragment, side, from, to, depth, openEnd) {\n var node = side < 0 ? fragment.firstChild : fragment.lastChild, inner = node.content;\n if (depth < to - 1) { inner = closeRange(inner, side, from, to, depth + 1, openEnd); }\n if (depth >= from)\n { inner = side < 0 ? node.contentMatchAt(0).fillBefore(inner, fragment.childCount > 1 || openEnd <= depth).append(inner)\n : inner.append(node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].empty, true)); }\n return fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node.copy(inner))\n}\n\nfunction closeSlice(slice, openStart, openEnd) {\n if (openStart < slice.openStart)\n { slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd); }\n if (openEnd < slice.openEnd)\n { slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](closeRange(slice.content, 1, openEnd, slice.openEnd, 0, 0), slice.openStart, openEnd); }\n return slice\n}\n\n// Trick from jQuery -- some elements must be wrapped in other\n// elements for innerHTML to work. I.e. if you do `div.innerHTML =\n// \"
.. \"` the table cells are ignored.\nvar wrapMap = {\n thead: [\"table\"],\n tbody: [\"table\"],\n tfoot: [\"table\"],\n caption: [\"table\"],\n colgroup: [\"table\"],\n col: [\"table\", \"colgroup\"],\n tr: [\"table\", \"tbody\"],\n td: [\"table\", \"tbody\", \"tr\"],\n th: [\"table\", \"tbody\", \"tr\"]\n};\n\nvar _detachedDoc = null;\nfunction detachedDoc() {\n return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument(\"title\"))\n}\n\nfunction readHTML(html) {\n var metas = /(\\s* ]*>)*/.exec(html);\n if (metas) { html = html.slice(metas[0].length); }\n var elt = detachedDoc().createElement(\"div\");\n var firstTag = /(?: ]*>)*<([a-z][^>\\s]+)/i.exec(html), wrap, depth = 0;\n if (wrap = firstTag && wrapMap[firstTag[1].toLowerCase()]) {\n html = wrap.map(function (n) { return \"<\" + n + \">\"; }).join(\"\") + html + wrap.map(function (n) { return \"\" + n + \">\"; }).reverse().join(\"\");\n depth = wrap.length;\n }\n elt.innerHTML = html;\n for (var i = 0; i < depth; i++) { elt = elt.firstChild; }\n return elt\n}\n\nfunction addContext(slice, context) {\n if (!slice.size) { return slice }\n var schema = slice.content.firstChild.type.schema, array;\n try { array = JSON.parse(context); }\n catch(e) { return slice }\n var content = slice.content;\n var openStart = slice.openStart;\n var openEnd = slice.openEnd;\n for (var i = array.length - 2; i >= 0; i -= 2) {\n var type = schema.nodes[array[i]];\n if (!type || type.hasRequiredAttrs()) { break }\n content = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(type.create(array[i + 1], content));\n openStart++; openEnd++;\n }\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](content, openStart, openEnd)\n}\n\nvar observeOptions = {\n childList: true,\n characterData: true,\n characterDataOldValue: true,\n attributes: true,\n attributeOldValue: true,\n subtree: true\n};\n// IE11 has very broken mutation observers, so we also listen to DOMCharacterDataModified\nvar useCharData = result.ie && result.ie_version <= 11;\n\nvar SelectionState = function SelectionState() {\n this.anchorNode = this.anchorOffset = this.focusNode = this.focusOffset = null;\n};\n\nSelectionState.prototype.set = function set (sel) {\n this.anchorNode = sel.anchorNode; this.anchorOffset = sel.anchorOffset;\n this.focusNode = sel.focusNode; this.focusOffset = sel.focusOffset;\n};\n\nSelectionState.prototype.eq = function eq (sel) {\n return sel.anchorNode == this.anchorNode && sel.anchorOffset == this.anchorOffset &&\n sel.focusNode == this.focusNode && sel.focusOffset == this.focusOffset\n};\n\nvar DOMObserver = function DOMObserver(view, handleDOMChange) {\n var this$1 = this;\n\n this.view = view;\n this.handleDOMChange = handleDOMChange;\n this.queue = [];\n this.flushingSoon = false;\n this.observer = window.MutationObserver &&\n new window.MutationObserver(function (mutations) {\n for (var i = 0; i < mutations.length; i++) { this$1.queue.push(mutations[i]); }\n // IE11 will sometimes (on backspacing out a single character\n // text node after a BR node) call the observer callback\n // before actually updating the DOM, which will cause\n // ProseMirror to miss the change (see #930)\n if (result.ie && result.ie_version <= 11 && mutations.some(\n function (m) { return m.type == \"childList\" && m.removedNodes.length ||\n m.type == \"characterData\" && m.oldValue.length > m.target.nodeValue.length; }))\n { this$1.flushSoon(); }\n else\n { this$1.flush(); }\n });\n this.currentSelection = new SelectionState;\n if (useCharData) {\n this.onCharData = function (e) {\n this$1.queue.push({target: e.target, type: \"characterData\", oldValue: e.prevValue});\n this$1.flushSoon();\n };\n }\n this.onSelectionChange = this.onSelectionChange.bind(this);\n this.suppressingSelectionUpdates = false;\n};\n\nDOMObserver.prototype.flushSoon = function flushSoon () {\n var this$1 = this;\n\n if (!this.flushingSoon) {\n this.flushingSoon = true;\n window.setTimeout(function () { this$1.flushingSoon = false; this$1.flush(); }, 20);\n }\n};\n\nDOMObserver.prototype.start = function start () {\n if (this.observer)\n { this.observer.observe(this.view.dom, observeOptions); }\n if (useCharData)\n { this.view.dom.addEventListener(\"DOMCharacterDataModified\", this.onCharData); }\n this.connectSelection();\n};\n\nDOMObserver.prototype.stop = function stop () {\n var this$1 = this;\n\n if (this.observer) {\n var take = this.observer.takeRecords();\n if (take.length) {\n for (var i = 0; i < take.length; i++) { this.queue.push(take[i]); }\n window.setTimeout(function () { return this$1.flush(); }, 20);\n }\n this.observer.disconnect();\n }\n if (useCharData) { this.view.dom.removeEventListener(\"DOMCharacterDataModified\", this.onCharData); }\n this.disconnectSelection();\n};\n\nDOMObserver.prototype.connectSelection = function connectSelection () {\n this.view.dom.ownerDocument.addEventListener(\"selectionchange\", this.onSelectionChange);\n};\n\nDOMObserver.prototype.disconnectSelection = function disconnectSelection () {\n this.view.dom.ownerDocument.removeEventListener(\"selectionchange\", this.onSelectionChange);\n};\n\nDOMObserver.prototype.suppressSelectionUpdates = function suppressSelectionUpdates () {\n var this$1 = this;\n\n this.suppressingSelectionUpdates = true;\n setTimeout(function () { return this$1.suppressingSelectionUpdates = false; }, 50);\n};\n\nDOMObserver.prototype.onSelectionChange = function onSelectionChange () {\n if (!hasFocusAndSelection(this.view)) { return }\n if (this.suppressingSelectionUpdates) { return selectionToDOM(this.view) }\n // Deletions on IE11 fire their events in the wrong order, giving\n // us a selection change event before the DOM changes are\n // reported.\n if (result.ie && result.ie_version <= 11 && !this.view.state.selection.empty) {\n var sel = this.view.root.getSelection();\n // Selection.isCollapsed isn't reliable on IE\n if (sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))\n { return this.flushSoon() }\n }\n this.flush();\n};\n\nDOMObserver.prototype.setCurSelection = function setCurSelection () {\n this.currentSelection.set(this.view.root.getSelection());\n};\n\nDOMObserver.prototype.ignoreSelectionChange = function ignoreSelectionChange (sel) {\n if (sel.rangeCount == 0) { return true }\n var container = sel.getRangeAt(0).commonAncestorContainer;\n var desc = this.view.docView.nearestDesc(container);\n if (desc && desc.ignoreMutation({type: \"selection\", target: container.nodeType == 3 ? container.parentNode : container})) {\n this.setCurSelection();\n return true\n }\n};\n\nDOMObserver.prototype.flush = function flush () {\n if (!this.view.docView || this.flushingSoon) { return }\n var mutations = this.observer ? this.observer.takeRecords() : [];\n if (this.queue.length) {\n mutations = this.queue.concat(mutations);\n this.queue.length = 0;\n }\n\n var sel = this.view.root.getSelection();\n var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel);\n\n var from = -1, to = -1, typeOver = false, added = [];\n if (this.view.editable) {\n for (var i = 0; i < mutations.length; i++) {\n var result$1 = this.registerMutation(mutations[i], added);\n if (result$1) {\n from = from < 0 ? result$1.from : Math.min(result$1.from, from);\n to = to < 0 ? result$1.to : Math.max(result$1.to, to);\n if (result$1.typeOver && !this.view.composing) { typeOver = true; }\n }\n }\n }\n\n if (result.gecko && added.length > 1) {\n var brs = added.filter(function (n) { return n.nodeName == \"BR\"; });\n if (brs.length == 2) {\n var a = brs[0];\n var b = brs[1];\n if (a.parentNode && a.parentNode.parentNode == b.parentNode) { b.remove(); }\n else { a.remove(); }\n }\n }\n\n if (from > -1 || newSel) {\n if (from > -1) {\n this.view.docView.markDirty(from, to);\n checkCSS(this.view);\n }\n this.handleDOMChange(from, to, typeOver, added);\n if (this.view.docView.dirty) { this.view.updateState(this.view.state); }\n else if (!this.currentSelection.eq(sel)) { selectionToDOM(this.view); }\n }\n};\n\nDOMObserver.prototype.registerMutation = function registerMutation (mut, added) {\n // Ignore mutations inside nodes that were already noted as inserted\n if (added.indexOf(mut.target) > -1) { return null }\n var desc = this.view.docView.nearestDesc(mut.target);\n if (mut.type == \"attributes\" &&\n (desc == this.view.docView || mut.attributeName == \"contenteditable\" ||\n // Firefox sometimes fires spurious events for null/empty styles\n (mut.attributeName == \"style\" && !mut.oldValue && !mut.target.getAttribute(\"style\"))))\n { return null }\n if (!desc || desc.ignoreMutation(mut)) { return null }\n\n if (mut.type == \"childList\") {\n var prev = mut.previousSibling, next = mut.nextSibling;\n if (result.ie && result.ie_version <= 11 && mut.addedNodes.length) {\n // IE11 gives us incorrect next/prev siblings for some\n // insertions, so if there are added nodes, recompute those\n for (var i = 0; i < mut.addedNodes.length; i++) {\n var ref = mut.addedNodes[i];\n var previousSibling = ref.previousSibling;\n var nextSibling = ref.nextSibling;\n if (!previousSibling || Array.prototype.indexOf.call(mut.addedNodes, previousSibling) < 0) { prev = previousSibling; }\n if (!nextSibling || Array.prototype.indexOf.call(mut.addedNodes, nextSibling) < 0) { next = nextSibling; }\n }\n }\n var fromOffset = prev && prev.parentNode == mut.target\n ? domIndex(prev) + 1 : 0;\n var from = desc.localPosFromDOM(mut.target, fromOffset, -1);\n var toOffset = next && next.parentNode == mut.target\n ? domIndex(next) : mut.target.childNodes.length;\n for (var i$1 = 0; i$1 < mut.addedNodes.length; i$1++) { added.push(mut.addedNodes[i$1]); }\n var to = desc.localPosFromDOM(mut.target, toOffset, 1);\n return {from: from, to: to}\n } else if (mut.type == \"attributes\") {\n return {from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border}\n } else { // \"characterData\"\n return {\n from: desc.posAtStart,\n to: desc.posAtEnd,\n // An event was generated for a text change that didn't change\n // any text. Mark the dom change to fall back to assuming the\n // selection was typed over with an identical value if it can't\n // find another change.\n typeOver: mut.target.nodeValue == mut.oldValue\n }\n }\n};\n\nvar cssChecked = false;\n\nfunction checkCSS(view) {\n if (cssChecked) { return }\n cssChecked = true;\n if (getComputedStyle(view.dom).whiteSpace == \"normal\")\n { console[\"warn\"](\"ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.\"); }\n}\n\n// A collection of DOM events that occur within the editor, and callback functions\n// to invoke when the event fires.\nvar handlers = {}, editHandlers = {};\n\nfunction initInput(view) {\n view.shiftKey = false;\n view.mouseDown = null;\n view.lastKeyCode = null;\n view.lastKeyCodeTime = 0;\n view.lastClick = {time: 0, x: 0, y: 0, type: \"\"};\n view.lastSelectionOrigin = null;\n view.lastSelectionTime = 0;\n\n view.lastIOSEnter = 0;\n\n view.composing = false;\n view.composingTimeout = null;\n view.compositionNodes = [];\n view.compositionEndedAt = -2e8;\n\n view.domObserver = new DOMObserver(view, function (from, to, typeOver, added) { return readDOMChange(view, from, to, typeOver, added); });\n view.domObserver.start();\n // Used by hacks like the beforeinput handler to check whether anything happened in the DOM\n view.domChangeCount = 0;\n\n view.eventHandlers = Object.create(null);\n var loop = function ( event ) {\n var handler = handlers[event];\n view.dom.addEventListener(event, view.eventHandlers[event] = function (event) {\n if (eventBelongsToView(view, event) && !runCustomHandler(view, event) &&\n (view.editable || !(event.type in editHandlers)))\n { handler(view, event); }\n });\n };\n\n for (var event in handlers) loop( event );\n // On Safari, for reasons beyond my understanding, adding an input\n // event handler makes an issue where the composition vanishes when\n // you press enter go away.\n if (result.safari) { view.dom.addEventListener(\"input\", function () { return null; }); }\n\n ensureListeners(view);\n}\n\nfunction setSelectionOrigin(view, origin) {\n view.lastSelectionOrigin = origin;\n view.lastSelectionTime = Date.now();\n}\n\nfunction destroyInput(view) {\n view.domObserver.stop();\n for (var type in view.eventHandlers)\n { view.dom.removeEventListener(type, view.eventHandlers[type]); }\n clearTimeout(view.composingTimeout);\n}\n\nfunction ensureListeners(view) {\n view.someProp(\"handleDOMEvents\", function (currentHandlers) {\n for (var type in currentHandlers) { if (!view.eventHandlers[type])\n { view.dom.addEventListener(type, view.eventHandlers[type] = function (event) { return runCustomHandler(view, event); }); } }\n });\n}\n\nfunction runCustomHandler(view, event) {\n return view.someProp(\"handleDOMEvents\", function (handlers) {\n var handler = handlers[event.type];\n return handler ? handler(view, event) || event.defaultPrevented : false\n })\n}\n\nfunction eventBelongsToView(view, event) {\n if (!event.bubbles) { return true }\n if (event.defaultPrevented) { return false }\n for (var node = event.target; node != view.dom; node = node.parentNode)\n { if (!node || node.nodeType == 11 ||\n (node.pmViewDesc && node.pmViewDesc.stopEvent(event)))\n { return false } }\n return true\n}\n\nfunction dispatchEvent(view, event) {\n if (!runCustomHandler(view, event) && handlers[event.type] &&\n (view.editable || !(event.type in editHandlers)))\n { handlers[event.type](view, event); }\n}\n\neditHandlers.keydown = function (view, event) {\n view.shiftKey = event.keyCode == 16 || event.shiftKey;\n if (inOrNearComposition(view, event)) { return }\n view.lastKeyCode = event.keyCode;\n view.lastKeyCodeTime = Date.now();\n // On iOS, if we preventDefault enter key presses, the virtual\n // keyboard gets confused. So the hack here is to set a flag that\n // makes the DOM change code recognize that what just happens should\n // be replaced by whatever the Enter key handlers do.\n if (result.ios && event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.metaKey)\n { view.lastIOSEnter = Date.now(); }\n else if (view.someProp(\"handleKeyDown\", function (f) { return f(view, event); }) || captureKeyDown(view, event))\n { event.preventDefault(); }\n else\n { setSelectionOrigin(view, \"key\"); }\n};\n\neditHandlers.keyup = function (view, e) {\n if (e.keyCode == 16) { view.shiftKey = false; }\n};\n\neditHandlers.keypress = function (view, event) {\n if (inOrNearComposition(view, event) || !event.charCode ||\n event.ctrlKey && !event.altKey || result.mac && event.metaKey) { return }\n\n if (view.someProp(\"handleKeyPress\", function (f) { return f(view, event); })) {\n event.preventDefault();\n return\n }\n\n var sel = view.state.selection;\n if (!(sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) || !sel.$from.sameParent(sel.$to)) {\n var text = String.fromCharCode(event.charCode);\n if (!view.someProp(\"handleTextInput\", function (f) { return f(view, sel.$from.pos, sel.$to.pos, text); }))\n { view.dispatch(view.state.tr.insertText(text).scrollIntoView()); }\n event.preventDefault();\n }\n};\n\nfunction eventCoords(event) { return {left: event.clientX, top: event.clientY} }\n\nfunction isNear(event, click) {\n var dx = click.x - event.clientX, dy = click.y - event.clientY;\n return dx * dx + dy * dy < 100\n}\n\nfunction runHandlerOnContext(view, propName, pos, inside, event) {\n if (inside == -1) { return false }\n var $pos = view.state.doc.resolve(inside);\n var loop = function ( i ) {\n if (view.someProp(propName, function (f) { return i > $pos.depth ? f(view, pos, $pos.nodeAfter, $pos.before(i), event, true)\n : f(view, pos, $pos.node(i), $pos.before(i), event, false); }))\n { return { v: true } }\n };\n\n for (var i = $pos.depth + 1; i > 0; i--) {\n var returned = loop( i );\n\n if ( returned ) return returned.v;\n }\n return false\n}\n\nfunction updateSelection(view, selection, origin) {\n if (!view.focused) { view.focus(); }\n var tr = view.state.tr.setSelection(selection);\n if (origin == \"pointer\") { tr.setMeta(\"pointer\", true); }\n view.dispatch(tr);\n}\n\nfunction selectClickedLeaf(view, inside) {\n if (inside == -1) { return false }\n var $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;\n if (node && node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n updateSelection(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]($pos), \"pointer\");\n return true\n }\n return false\n}\n\nfunction selectClickedNode(view, inside) {\n if (inside == -1) { return false }\n var sel = view.state.selection, selectedNode, selectAt;\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) { selectedNode = sel.node; }\n\n var $pos = view.state.doc.resolve(inside);\n for (var i = $pos.depth + 1; i > 0; i--) {\n var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);\n if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n if (selectedNode && sel.$from.depth > 0 &&\n i >= sel.$from.depth && $pos.before(sel.$from.depth + 1) == sel.$from.pos)\n { selectAt = $pos.before(sel.$from.depth); }\n else\n { selectAt = $pos.before(i); }\n break\n }\n }\n\n if (selectAt != null) {\n updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(view.state.doc, selectAt), \"pointer\");\n return true\n } else {\n return false\n }\n}\n\nfunction handleSingleClick(view, pos, inside, event, selectNode) {\n return runHandlerOnContext(view, \"handleClickOn\", pos, inside, event) ||\n view.someProp(\"handleClick\", function (f) { return f(view, pos, event); }) ||\n (selectNode ? selectClickedNode(view, inside) : selectClickedLeaf(view, inside))\n}\n\nfunction handleDoubleClick(view, pos, inside, event) {\n return runHandlerOnContext(view, \"handleDoubleClickOn\", pos, inside, event) ||\n view.someProp(\"handleDoubleClick\", function (f) { return f(view, pos, event); })\n}\n\nfunction handleTripleClick(view, pos, inside, event) {\n return runHandlerOnContext(view, \"handleTripleClickOn\", pos, inside, event) ||\n view.someProp(\"handleTripleClick\", function (f) { return f(view, pos, event); }) ||\n defaultTripleClick(view, inside)\n}\n\nfunction defaultTripleClick(view, inside) {\n var doc = view.state.doc;\n if (inside == -1) {\n if (doc.inlineContent) {\n updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"].create(doc, 0, doc.content.size), \"pointer\");\n return true\n }\n return false\n }\n\n var $pos = doc.resolve(inside);\n for (var i = $pos.depth + 1; i > 0; i--) {\n var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);\n var nodePos = $pos.before(i);\n if (node.inlineContent)\n { updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"].create(doc, nodePos + 1, nodePos + 1 + node.content.size), \"pointer\"); }\n else if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node))\n { updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(doc, nodePos), \"pointer\"); }\n else\n { continue }\n return true\n }\n}\n\nfunction forceDOMFlush(view) {\n return endComposition(view)\n}\n\nvar selectNodeModifier = result.mac ? \"metaKey\" : \"ctrlKey\";\n\nhandlers.mousedown = function (view, event) {\n view.shiftKey = event.shiftKey;\n var flushed = forceDOMFlush(view);\n var now = Date.now(), type = \"singleClick\";\n if (now - view.lastClick.time < 500 && isNear(event, view.lastClick) && !event[selectNodeModifier]) {\n if (view.lastClick.type == \"singleClick\") { type = \"doubleClick\"; }\n else if (view.lastClick.type == \"doubleClick\") { type = \"tripleClick\"; }\n }\n view.lastClick = {time: now, x: event.clientX, y: event.clientY, type: type};\n\n var pos = view.posAtCoords(eventCoords(event));\n if (!pos) { return }\n\n if (type == \"singleClick\")\n { view.mouseDown = new MouseDown(view, pos, event, flushed); }\n else if ((type == \"doubleClick\" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event))\n { event.preventDefault(); }\n else\n { setSelectionOrigin(view, \"pointer\"); }\n};\n\nvar MouseDown = function MouseDown(view, pos, event, flushed) {\n var this$1 = this;\n\n this.view = view;\n this.startDoc = view.state.doc;\n this.pos = pos;\n this.event = event;\n this.flushed = flushed;\n this.selectNode = event[selectNodeModifier];\n this.allowDefault = event.shiftKey;\n\n var targetNode, targetPos;\n if (pos.inside > -1) {\n targetNode = view.state.doc.nodeAt(pos.inside);\n targetPos = pos.inside;\n } else {\n var $pos = view.state.doc.resolve(pos.pos);\n targetNode = $pos.parent;\n targetPos = $pos.depth ? $pos.before() : 0;\n }\n\n this.mightDrag = null;\n\n var target = flushed ? null : event.target;\n var targetDesc = target ? view.docView.nearestDesc(target, true) : null;\n this.target = targetDesc ? targetDesc.dom : null;\n\n if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||\n view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"] && targetPos == view.state.selection.from)\n { this.mightDrag = {node: targetNode,\n pos: targetPos,\n addAttr: this.target && !this.target.draggable,\n setUneditable: this.target && result.gecko && !this.target.hasAttribute(\"contentEditable\")}; }\n\n if (this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable)) {\n this.view.domObserver.stop();\n if (this.mightDrag.addAttr) { this.target.draggable = true; }\n if (this.mightDrag.setUneditable)\n { setTimeout(function () { return this$1.target.setAttribute(\"contentEditable\", \"false\"); }, 20); }\n this.view.domObserver.start();\n }\n\n view.root.addEventListener(\"mouseup\", this.up = this.up.bind(this));\n view.root.addEventListener(\"mousemove\", this.move = this.move.bind(this));\n setSelectionOrigin(view, \"pointer\");\n};\n\nMouseDown.prototype.done = function done () {\n this.view.root.removeEventListener(\"mouseup\", this.up);\n this.view.root.removeEventListener(\"mousemove\", this.move);\n if (this.mightDrag && this.target) {\n this.view.domObserver.stop();\n if (this.mightDrag.addAttr) { this.target.draggable = false; }\n if (this.mightDrag.setUneditable) { this.target.removeAttribute(\"contentEditable\"); }\n this.view.domObserver.start();\n }\n this.view.mouseDown = null;\n};\n\nMouseDown.prototype.up = function up (event) {\n this.done();\n\n if (!this.view.dom.contains(event.target.nodeType == 3 ? event.target.parentNode : event.target))\n { return }\n\n var pos = this.pos;\n if (this.view.state.doc != this.startDoc) { pos = this.view.posAtCoords(eventCoords(event)); }\n\n if (this.allowDefault || !pos) {\n setSelectionOrigin(this.view, \"pointer\");\n } else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) {\n event.preventDefault();\n } else if (this.flushed ||\n // Chrome will sometimes treat a node selection as a\n // cursor, but still report that the node is selected\n // when asked through getSelection. You'll then get a\n // situation where clicking at the point where that\n // (hidden) cursor is doesn't change the selection, and\n // thus doesn't get a reaction from ProseMirror. This\n // works around that.\n (result.chrome && !(this.view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) &&\n (pos.pos == this.view.state.selection.from || pos.pos == this.view.state.selection.to))) {\n updateSelection(this.view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].near(this.view.state.doc.resolve(pos.pos)), \"pointer\");\n event.preventDefault();\n } else {\n setSelectionOrigin(this.view, \"pointer\");\n }\n};\n\nMouseDown.prototype.move = function move (event) {\n if (!this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 ||\n Math.abs(this.event.y - event.clientY) > 4))\n { this.allowDefault = true; }\n setSelectionOrigin(this.view, \"pointer\");\n};\n\nhandlers.touchdown = function (view) {\n forceDOMFlush(view);\n setSelectionOrigin(view, \"pointer\");\n};\n\nhandlers.contextmenu = function (view) { return forceDOMFlush(view); };\n\nfunction inOrNearComposition(view, event) {\n if (view.composing) { return true }\n // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.\n // On Japanese input method editors (IMEs), the Enter key is used to confirm character\n // selection. On Safari, when Enter is pressed, compositionend and keydown events are\n // emitted. The keydown event triggers newline insertion, which we don't want.\n // This method returns true if the keydown event should be ignored.\n // We only ignore it once, as pressing Enter a second time *should* insert a newline.\n // Furthermore, the keydown event timestamp must be close to the compositionEndedAt timestamp.\n // This guards against the case where compositionend is triggered without the keyboard\n // (e.g. character confirmation may be done with the mouse), and keydown is triggered\n // afterwards- we wouldn't want to ignore the keydown event in this case.\n if (result.safari && Math.abs(event.timeStamp - view.compositionEndedAt) < 500) {\n view.compositionEndedAt = -2e8;\n return true\n }\n return false\n}\n\n// Drop active composition after 5 seconds of inactivity on Android\nvar timeoutComposition = result.android ? 5000 : -1;\n\neditHandlers.compositionstart = editHandlers.compositionupdate = function (view) {\n if (!view.composing) {\n view.domObserver.flush();\n var state = view.state;\n var $pos = state.selection.$from;\n if (state.selection.empty &&\n (state.storedMarks || (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(function (m) { return m.type.spec.inclusive === false; })))) {\n // Need to wrap the cursor in mark nodes different from the ones in the DOM context\n view.markCursor = view.state.storedMarks || $pos.marks();\n endComposition(view, true);\n view.markCursor = null;\n } else {\n endComposition(view);\n // In firefox, if the cursor is after but outside a marked node,\n // the inserted text won't inherit the marks. So this moves it\n // inside if necessary.\n if (result.gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {\n var sel = view.root.getSelection();\n for (var node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0;) {\n var before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];\n if (!before) { break }\n if (before.nodeType == 3) {\n sel.collapse(before, before.nodeValue.length);\n break\n } else {\n node = before;\n offset = -1;\n }\n }\n }\n }\n view.composing = true;\n }\n scheduleComposeEnd(view, timeoutComposition);\n};\n\neditHandlers.compositionend = function (view, event) {\n if (view.composing) {\n view.composing = false;\n view.compositionEndedAt = event.timeStamp;\n scheduleComposeEnd(view, 20);\n }\n};\n\nfunction scheduleComposeEnd(view, delay) {\n clearTimeout(view.composingTimeout);\n if (delay > -1) { view.composingTimeout = setTimeout(function () { return endComposition(view); }, delay); }\n}\n\nfunction endComposition(view, forceUpdate) {\n view.composing = false;\n while (view.compositionNodes.length > 0) { view.compositionNodes.pop().markParentsDirty(); }\n if (forceUpdate || view.docView.dirty) {\n view.updateState(view.state);\n return true\n }\n return false\n}\n\nfunction captureCopy(view, dom) {\n // The extra wrapper is somehow necessary on IE/Edge to prevent the\n // content from being mangled when it is put onto the clipboard\n var doc = view.dom.ownerDocument;\n var wrap = doc.body.appendChild(doc.createElement(\"div\"));\n wrap.appendChild(dom);\n wrap.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n var sel = getSelection(), range = doc.createRange();\n range.selectNodeContents(dom);\n // Done because IE will fire a selectionchange moving the selection\n // to its start when removeAllRanges is called and the editor still\n // has focus (which will mess up the editor's selection state).\n view.dom.blur();\n sel.removeAllRanges();\n sel.addRange(range);\n setTimeout(function () {\n doc.body.removeChild(wrap);\n view.focus();\n }, 50);\n}\n\n// This is very crude, but unfortunately both these browsers _pretend_\n// that they have a clipboard API—all the objects and methods are\n// there, they just don't work, and they are hard to test.\nvar brokenClipboardAPI = (result.ie && result.ie_version < 15) ||\n (result.ios && result.webkit_version < 604);\n\nhandlers.copy = editHandlers.cut = function (view, e) {\n var sel = view.state.selection, cut = e.type == \"cut\";\n if (sel.empty) { return }\n\n // IE and Edge's clipboard interface is completely broken\n var data = brokenClipboardAPI ? null : e.clipboardData;\n var slice = sel.content();\n var ref = serializeForClipboard(view, slice);\n var dom = ref.dom;\n var text = ref.text;\n if (data) {\n e.preventDefault();\n data.clearData();\n data.setData(\"text/html\", dom.innerHTML);\n data.setData(\"text/plain\", text);\n } else {\n captureCopy(view, dom);\n }\n if (cut) { view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta(\"uiEvent\", \"cut\")); }\n};\n\nfunction sliceSingleNode(slice) {\n return slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1 ? slice.content.firstChild : null\n}\n\nfunction capturePaste(view, e) {\n var doc = view.dom.ownerDocument;\n var plainText = view.shiftKey || view.state.selection.$from.parent.type.spec.code;\n var target = doc.body.appendChild(doc.createElement(plainText ? \"textarea\" : \"div\"));\n if (!plainText) { target.contentEditable = \"true\"; }\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.focus();\n setTimeout(function () {\n view.focus();\n doc.body.removeChild(target);\n if (plainText) { doPaste(view, target.value, null, e); }\n else { doPaste(view, target.textContent, target.innerHTML, e); }\n }, 50);\n}\n\nfunction doPaste(view, text, html, e) {\n var slice = parseFromClipboard(view, text, html, view.shiftKey, view.state.selection.$from);\n if (view.someProp(\"handlePaste\", function (f) { return f(view, e, slice || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"].empty); }) || !slice) { return }\n\n var singleNode = sliceSingleNode(slice);\n var tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, view.shiftKey) : view.state.tr.replaceSelection(slice);\n view.dispatch(tr.scrollIntoView().setMeta(\"paste\", true).setMeta(\"uiEvent\", \"paste\"));\n}\n\neditHandlers.paste = function (view, e) {\n var data = brokenClipboardAPI ? null : e.clipboardData;\n var html = data && data.getData(\"text/html\"), text = data && data.getData(\"text/plain\");\n if (data && (html || text || data.files.length)) {\n doPaste(view, text, html, e);\n e.preventDefault();\n } else {\n capturePaste(view, e);\n }\n};\n\nvar Dragging = function Dragging(slice, move) {\n this.slice = slice;\n this.move = move;\n};\n\nvar dragCopyModifier = result.mac ? \"altKey\" : \"ctrlKey\";\n\nhandlers.dragstart = function (view, e) {\n var mouseDown = view.mouseDown;\n if (mouseDown) { mouseDown.done(); }\n if (!e.dataTransfer) { return }\n\n var sel = view.state.selection;\n var pos = sel.empty ? null : view.posAtCoords(eventCoords(e));\n if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"] ? sel.to - 1: sel.to)) ; else if (mouseDown && mouseDown.mightDrag) {\n view.dispatch(view.state.tr.setSelection(prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(view.state.doc, mouseDown.mightDrag.pos)));\n } else if (e.target && e.target.nodeType == 1) {\n var desc = view.docView.nearestDesc(e.target, true);\n if (!desc || !desc.node.type.spec.draggable || desc == view.docView) { return }\n view.dispatch(view.state.tr.setSelection(prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(view.state.doc, desc.posBefore)));\n }\n var slice = view.state.selection.content();\n var ref = serializeForClipboard(view, slice);\n var dom = ref.dom;\n var text = ref.text;\n e.dataTransfer.clearData();\n e.dataTransfer.setData(brokenClipboardAPI ? \"Text\" : \"text/html\", dom.innerHTML);\n if (!brokenClipboardAPI) { e.dataTransfer.setData(\"text/plain\", text); }\n view.dragging = new Dragging(slice, !e[dragCopyModifier]);\n};\n\nhandlers.dragend = function (view) {\n window.setTimeout(function () { return view.dragging = null; }, 50);\n};\n\neditHandlers.dragover = editHandlers.dragenter = function (_, e) { return e.preventDefault(); };\n\neditHandlers.drop = function (view, e) {\n var dragging = view.dragging;\n view.dragging = null;\n\n if (!e.dataTransfer) { return }\n\n var eventPos = view.posAtCoords(eventCoords(e));\n if (!eventPos) { return }\n var $mouse = view.state.doc.resolve(eventPos.pos);\n if (!$mouse) { return }\n var slice = dragging && dragging.slice ||\n parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? \"Text\" : \"text/plain\"),\n brokenClipboardAPI ? null : e.dataTransfer.getData(\"text/html\"), false, $mouse);\n if (!slice) { return }\n\n e.preventDefault();\n if (view.someProp(\"handleDrop\", function (f) { return f(view, e, slice, dragging && dragging.move); })) { return }\n var insertPos = slice ? Object(prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__[\"dropPoint\"])(view.state.doc, $mouse.pos, slice) : $mouse.pos;\n if (insertPos == null) { insertPos = $mouse.pos; }\n\n var tr = view.state.tr;\n if (dragging && dragging.move) { tr.deleteSelection(); }\n\n var pos = tr.mapping.map(insertPos);\n var isNode = slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1;\n var beforeInsert = tr.doc;\n if (isNode)\n { tr.replaceRangeWith(pos, pos, slice.content.firstChild); }\n else\n { tr.replaceRange(pos, pos, slice); }\n if (tr.doc.eq(beforeInsert)) { return }\n\n var $pos = tr.doc.resolve(pos);\n if (isNode && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(slice.content.firstChild) &&\n $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild))\n { tr.setSelection(new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]($pos)); }\n else\n { tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(tr.mapping.map(insertPos)))); }\n view.focus();\n view.dispatch(tr.setMeta(\"uiEvent\", \"drop\"));\n};\n\nhandlers.focus = function (view) {\n if (!view.focused) {\n view.domObserver.stop();\n view.dom.classList.add(\"ProseMirror-focused\");\n view.domObserver.start();\n view.focused = true;\n setTimeout(function () {\n if (view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq(view.root.getSelection()))\n { selectionToDOM(view); }\n }, 20);\n }\n};\n\nhandlers.blur = function (view) {\n if (view.focused) {\n view.domObserver.stop();\n view.dom.classList.remove(\"ProseMirror-focused\");\n view.domObserver.start();\n view.domObserver.currentSelection.set({});\n view.focused = false;\n }\n};\n\nhandlers.beforeinput = function (view, event) {\n // We should probably do more with beforeinput events, but support\n // is so spotty that I'm still waiting to see where they are going.\n\n // Very specific hack to deal with backspace sometimes failing on\n // Chrome Android when after an uneditable node.\n if (result.chrome && result.android && event.inputType == \"deleteContentBackward\") {\n var domChangeCount = view.domChangeCount;\n setTimeout(function () {\n if (view.domChangeCount != domChangeCount) { return } // Event already had some effect\n // This bug tends to close the virtual keyboard, so we refocus\n view.dom.blur();\n view.focus();\n if (view.someProp(\"handleKeyDown\", function (f) { return f(view, keyEvent(8, \"Backspace\")); })) { return }\n var ref = view.state.selection;\n var $cursor = ref.$cursor;\n // Crude approximation of backspace behavior when no command handled it\n if ($cursor && $cursor.pos > 0) { view.dispatch(view.state.tr.delete($cursor.pos - 1, $cursor.pos).scrollIntoView()); }\n }, 50);\n }\n};\n\n// Make sure all handlers get registered\nfor (var prop in editHandlers) { handlers[prop] = editHandlers[prop]; }\n\nfunction compareObjs(a, b) {\n if (a == b) { return true }\n for (var p in a) { if (a[p] !== b[p]) { return false } }\n for (var p$1 in b) { if (!(p$1 in a)) { return false } }\n return true\n}\n\nvar WidgetType = function WidgetType(toDOM, spec) {\n this.spec = spec || noSpec;\n this.side = this.spec.side || 0;\n this.toDOM = toDOM;\n};\n\nWidgetType.prototype.map = function map (mapping, span, offset, oldOffset) {\n var ref = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);\n var pos = ref.pos;\n var deleted = ref.deleted;\n return deleted ? null : new Decoration(pos - offset, pos - offset, this)\n};\n\nWidgetType.prototype.valid = function valid () { return true };\n\nWidgetType.prototype.eq = function eq (other) {\n return this == other ||\n (other instanceof WidgetType &&\n (this.spec.key && this.spec.key == other.spec.key ||\n this.toDOM == other.toDOM && compareObjs(this.spec, other.spec)))\n};\n\nvar InlineType = function InlineType(attrs, spec) {\n this.spec = spec || noSpec;\n this.attrs = attrs;\n};\n\nInlineType.prototype.map = function map (mapping, span, offset, oldOffset) {\n var from = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset;\n var to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset;\n return from >= to ? null : new Decoration(from, to, this)\n};\n\nInlineType.prototype.valid = function valid (_, span) { return span.from < span.to };\n\nInlineType.prototype.eq = function eq (other) {\n return this == other ||\n (other instanceof InlineType && compareObjs(this.attrs, other.attrs) &&\n compareObjs(this.spec, other.spec))\n};\n\nInlineType.is = function is (span) { return span.type instanceof InlineType };\n\nvar NodeType = function NodeType(attrs, spec) {\n this.spec = spec || noSpec;\n this.attrs = attrs;\n};\n\nNodeType.prototype.map = function map (mapping, span, offset, oldOffset) {\n var from = mapping.mapResult(span.from + oldOffset, 1);\n if (from.deleted) { return null }\n var to = mapping.mapResult(span.to + oldOffset, -1);\n if (to.deleted || to.pos <= from.pos) { return null }\n return new Decoration(from.pos - offset, to.pos - offset, this)\n};\n\nNodeType.prototype.valid = function valid (node, span) {\n var ref = node.content.findIndex(span.from);\n var index = ref.index;\n var offset = ref.offset;\n return offset == span.from && offset + node.child(index).nodeSize == span.to\n};\n\nNodeType.prototype.eq = function eq (other) {\n return this == other ||\n (other instanceof NodeType && compareObjs(this.attrs, other.attrs) &&\n compareObjs(this.spec, other.spec))\n};\n\n// ::- Decoration objects can be provided to the view through the\n// [`decorations` prop](#view.EditorProps.decorations). They come in\n// several variants—see the static members of this class for details.\nvar Decoration = function Decoration(from, to, type) {\n // :: number\n // The start position of the decoration.\n this.from = from;\n // :: number\n // The end position. Will be the same as `from` for [widget\n // decorations](#view.Decoration^widget).\n this.to = to;\n this.type = type;\n};\n\nvar prototypeAccessors$1 = { spec: { configurable: true } };\n\nDecoration.prototype.copy = function copy (from, to) {\n return new Decoration(from, to, this.type)\n};\n\nDecoration.prototype.eq = function eq (other) {\n return this.type.eq(other.type) && this.from == other.from && this.to == other.to\n};\n\nDecoration.prototype.map = function map (mapping, offset, oldOffset) {\n return this.type.map(mapping, this, offset, oldOffset)\n};\n\n// :: (number, union<(view: EditorView, getPos: () → number) → dom.Node, dom.Node>, ?Object) → Decoration\n// Creates a widget decoration, which is a DOM node that's shown in\n// the document at the given position. It is recommended that you\n// delay rendering the widget by passing a function that will be\n// called when the widget is actually drawn in a view, but you can\n// also directly pass a DOM node. `getPos` can be used to find the\n// widget's current document position.\n//\n// spec::- These options are supported:\n//\n// side:: ?number\n// Controls which side of the document position this widget is\n// associated with. When negative, it is drawn before a cursor\n// at its position, and content inserted at that position ends\n// up after the widget. When zero (the default) or positive, the\n// widget is drawn after the cursor and content inserted there\n// ends up before the widget.\n//\n// When there are multiple widgets at a given position, their\n// `side` values determine the order in which they appear. Those\n// with lower values appear first. The ordering of widgets with\n// the same `side` value is unspecified.\n//\n// When `marks` is null, `side` also determines the marks that\n// the widget is wrapped in—those of the node before when\n// negative, those of the node after when positive.\n//\n// marks:: ?[Mark]\n// The precise set of marks to draw around the widget.\n//\n// stopEvent:: ?(event: dom.Event) → bool\n// Can be used to control which DOM events, when they bubble out\n// of this widget, the editor view should ignore.\n//\n// ignoreSelection:: ?bool\n// When set (defaults to false), selection changes inside the\n// widget are ignored, and don't cause ProseMirror to try and\n// re-sync the selection with its selection state.\n//\n// key:: ?string\n// When comparing decorations of this type (in order to decide\n// whether it needs to be redrawn), ProseMirror will by default\n// compare the widget DOM node by identity. If you pass a key,\n// that key will be compared instead, which can be useful when\n// you generate decorations on the fly and don't want to store\n// and reuse DOM nodes. Make sure that any widgets with the same\n// key are interchangeable—if widgets differ in, for example,\n// the behavior of some event handler, they should get\n// different keys.\nDecoration.widget = function widget (pos, toDOM, spec) {\n return new Decoration(pos, pos, new WidgetType(toDOM, spec))\n};\n\n// :: (number, number, DecorationAttrs, ?Object) → Decoration\n// Creates an inline decoration, which adds the given attributes to\n// each inline node between `from` and `to`.\n//\n// spec::- These options are recognized:\n//\n// inclusiveStart:: ?bool\n// Determines how the left side of the decoration is\n// [mapped](#transform.Position_Mapping) when content is\n// inserted directly at that position. By default, the decoration\n// won't include the new content, but you can set this to `true`\n// to make it inclusive.\n//\n// inclusiveEnd:: ?bool\n// Determines how the right side of the decoration is mapped.\n// See\n// [`inclusiveStart`](#view.Decoration^inline^spec.inclusiveStart).\nDecoration.inline = function inline (from, to, attrs, spec) {\n return new Decoration(from, to, new InlineType(attrs, spec))\n};\n\n// :: (number, number, DecorationAttrs, ?Object) → Decoration\n// Creates a node decoration. `from` and `to` should point precisely\n// before and after a node in the document. That node, and only that\n// node, will receive the given attributes.\n//\n// spec::-\n//\n// Optional information to store with the decoration. It\n// is also used when comparing decorators for equality.\nDecoration.node = function node (from, to, attrs, spec) {\n return new Decoration(from, to, new NodeType(attrs, spec))\n};\n\n// :: Object\n// The spec provided when creating this decoration. Can be useful\n// if you've stored extra information in that object.\nprototypeAccessors$1.spec.get = function () { return this.type.spec };\n\nObject.defineProperties( Decoration.prototype, prototypeAccessors$1 );\n\n// DecorationAttrs:: interface\n// A set of attributes to add to a decorated node. Most properties\n// simply directly correspond to DOM attributes of the same name,\n// which will be set to the property's value. These are exceptions:\n//\n// class:: ?string\n// A CSS class name or a space-separated set of class names to be\n// _added_ to the classes that the node already had.\n//\n// style:: ?string\n// A string of CSS to be _added_ to the node's existing `style` property.\n//\n// nodeName:: ?string\n// When non-null, the target node is wrapped in a DOM element of\n// this type (and the other attributes are applied to this element).\n\nvar none = [], noSpec = {};\n\n// ::- A collection of [decorations](#view.Decoration), organized in\n// such a way that the drawing algorithm can efficiently use and\n// compare them. This is a persistent data structure—it is not\n// modified, updates create a new value.\nvar DecorationSet = function DecorationSet(local, children) {\n this.local = local && local.length ? local : none;\n this.children = children && children.length ? children : none;\n};\n\n// :: (Node, [Decoration]) → DecorationSet\n// Create a set of decorations, using the structure of the given\n// document.\nDecorationSet.create = function create (doc, decorations) {\n return decorations.length ? buildTree(decorations, doc, 0, noSpec) : empty\n};\n\n// :: (?number, ?number, ?(spec: Object) → bool) → [Decoration]\n// Find all decorations in this set which touch the given range\n// (including decorations that start or end directly at the\n// boundaries) and match the given predicate on their spec. When\n// `start` and `end` are omitted, all decorations in the set are\n// considered. When `predicate` isn't given, all decorations are\n// assumed to match.\nDecorationSet.prototype.find = function find (start, end, predicate) {\n var result = [];\n this.findInner(start == null ? 0 : start, end == null ? 1e9 : end, result, 0, predicate);\n return result\n};\n\nDecorationSet.prototype.findInner = function findInner (start, end, result, offset, predicate) {\n for (var i = 0; i < this.local.length; i++) {\n var span = this.local[i];\n if (span.from <= end && span.to >= start && (!predicate || predicate(span.spec)))\n { result.push(span.copy(span.from + offset, span.to + offset)); }\n }\n for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {\n if (this.children[i$1] < end && this.children[i$1 + 1] > start) {\n var childOff = this.children[i$1] + 1;\n this.children[i$1 + 2].findInner(start - childOff, end - childOff, result, offset + childOff, predicate);\n }\n }\n};\n\n// :: (Mapping, Node, ?Object) → DecorationSet\n// Map the set of decorations in response to a change in the\n// document.\n//\n// options::- An optional set of options.\n//\n// onRemove:: ?(decorationSpec: Object)\n// When given, this function will be called for each decoration\n// that gets dropped as a result of the mapping, passing the\n// spec of that decoration.\nDecorationSet.prototype.map = function map (mapping, doc, options) {\n if (this == empty || mapping.maps.length == 0) { return this }\n return this.mapInner(mapping, doc, 0, 0, options || noSpec)\n};\n\nDecorationSet.prototype.mapInner = function mapInner (mapping, node, offset, oldOffset, options) {\n var newLocal;\n for (var i = 0; i < this.local.length; i++) {\n var mapped = this.local[i].map(mapping, offset, oldOffset);\n if (mapped && mapped.type.valid(node, mapped)) { (newLocal || (newLocal = [])).push(mapped); }\n else if (options.onRemove) { options.onRemove(this.local[i].spec); }\n }\n\n if (this.children.length)\n { return mapChildren(this.children, newLocal, mapping, node, offset, oldOffset, options) }\n else\n { return newLocal ? new DecorationSet(newLocal.sort(byPos)) : empty }\n};\n\n// :: (Node, [Decoration]) → DecorationSet\n// Add the given array of decorations to the ones in the set,\n// producing a new set. Needs access to the current document to\n// create the appropriate tree structure.\nDecorationSet.prototype.add = function add (doc, decorations) {\n if (!decorations.length) { return this }\n if (this == empty) { return DecorationSet.create(doc, decorations) }\n return this.addInner(doc, decorations, 0)\n};\n\nDecorationSet.prototype.addInner = function addInner (doc, decorations, offset) {\n var this$1 = this;\n\n var children, childIndex = 0;\n doc.forEach(function (childNode, childOffset) {\n var baseOffset = childOffset + offset, found;\n if (!(found = takeSpansForNode(decorations, childNode, baseOffset))) { return }\n\n if (!children) { children = this$1.children.slice(); }\n while (childIndex < children.length && children[childIndex] < childOffset) { childIndex += 3; }\n if (children[childIndex] == childOffset)\n { children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found, baseOffset + 1); }\n else\n { children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noSpec)); }\n childIndex += 3;\n });\n\n var local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset);\n return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local,\n children || this.children)\n};\n\n// :: ([Decoration]) → DecorationSet\n// Create a new set that contains the decorations in this set, minus\n// the ones in the given array.\nDecorationSet.prototype.remove = function remove (decorations) {\n if (decorations.length == 0 || this == empty) { return this }\n return this.removeInner(decorations, 0)\n};\n\nDecorationSet.prototype.removeInner = function removeInner (decorations, offset) {\n var children = this.children, local = this.local;\n for (var i = 0; i < children.length; i += 3) {\n var found = (void 0), from = children[i] + offset, to = children[i + 1] + offset;\n for (var j = 0, span = (void 0); j < decorations.length; j++) { if (span = decorations[j]) {\n if (span.from > from && span.to < to) {\n decorations[j] = null\n ;(found || (found = [])).push(span);\n }\n } }\n if (!found) { continue }\n if (children == this.children) { children = this.children.slice(); }\n var removed = children[i + 2].removeInner(found, from + 1);\n if (removed != empty) {\n children[i + 2] = removed;\n } else {\n children.splice(i, 3);\n i -= 3;\n }\n }\n if (local.length) { for (var i$1 = 0, span$1 = (void 0); i$1 < decorations.length; i$1++) { if (span$1 = decorations[i$1]) {\n for (var j$1 = 0; j$1 < local.length; j$1++) { if (local[j$1].type.eq(span$1.type)) {\n if (local == this.local) { local = this.local.slice(); }\n local.splice(j$1--, 1);\n } }\n } } }\n if (children == this.children && local == this.local) { return this }\n return local.length || children.length ? new DecorationSet(local, children) : empty\n};\n\nDecorationSet.prototype.forChild = function forChild (offset, node) {\n if (this == empty) { return this }\n if (node.isLeaf) { return DecorationSet.empty }\n\n var child, local;\n for (var i = 0; i < this.children.length; i += 3) { if (this.children[i] >= offset) {\n if (this.children[i] == offset) { child = this.children[i + 2]; }\n break\n } }\n var start = offset + 1, end = start + node.content.size;\n for (var i$1 = 0; i$1 < this.local.length; i$1++) {\n var dec = this.local[i$1];\n if (dec.from < end && dec.to > start && (dec.type instanceof InlineType)) {\n var from = Math.max(start, dec.from) - start, to = Math.min(end, dec.to) - start;\n if (from < to) { (local || (local = [])).push(dec.copy(from, to)); }\n }\n }\n if (local) {\n var localSet = new DecorationSet(local.sort(byPos));\n return child ? new DecorationGroup([localSet, child]) : localSet\n }\n return child || empty\n};\n\nDecorationSet.prototype.eq = function eq (other) {\n if (this == other) { return true }\n if (!(other instanceof DecorationSet) ||\n this.local.length != other.local.length ||\n this.children.length != other.children.length) { return false }\n for (var i = 0; i < this.local.length; i++)\n { if (!this.local[i].eq(other.local[i])) { return false } }\n for (var i$1 = 0; i$1 < this.children.length; i$1 += 3)\n { if (this.children[i$1] != other.children[i$1] ||\n this.children[i$1 + 1] != other.children[i$1 + 1] ||\n !this.children[i$1 + 2].eq(other.children[i$1 + 2])) { return false } }\n return true\n};\n\nDecorationSet.prototype.locals = function locals (node) {\n return removeOverlap(this.localsInner(node))\n};\n\nDecorationSet.prototype.localsInner = function localsInner (node) {\n if (this == empty) { return none }\n if (node.inlineContent || !this.local.some(InlineType.is)) { return this.local }\n var result = [];\n for (var i = 0; i < this.local.length; i++) {\n if (!(this.local[i].type instanceof InlineType))\n { result.push(this.local[i]); }\n }\n return result\n};\n\nvar empty = new DecorationSet();\n\n// :: DecorationSet\n// The empty set of decorations.\nDecorationSet.empty = empty;\n\nDecorationSet.removeOverlap = removeOverlap;\n\n// :- An abstraction that allows the code dealing with decorations to\n// treat multiple DecorationSet objects as if it were a single object\n// with (a subset of) the same interface.\nvar DecorationGroup = function DecorationGroup(members) {\n this.members = members;\n};\n\nDecorationGroup.prototype.forChild = function forChild (offset, child) {\n if (child.isLeaf) { return DecorationSet.empty }\n var found = [];\n for (var i = 0; i < this.members.length; i++) {\n var result = this.members[i].forChild(offset, child);\n if (result == empty) { continue }\n if (result instanceof DecorationGroup) { found = found.concat(result.members); }\n else { found.push(result); }\n }\n return DecorationGroup.from(found)\n};\n\nDecorationGroup.prototype.eq = function eq (other) {\n if (!(other instanceof DecorationGroup) ||\n other.members.length != this.members.length) { return false }\n for (var i = 0; i < this.members.length; i++)\n { if (!this.members[i].eq(other.members[i])) { return false } }\n return true\n};\n\nDecorationGroup.prototype.locals = function locals (node) {\n var result, sorted = true;\n for (var i = 0; i < this.members.length; i++) {\n var locals = this.members[i].localsInner(node);\n if (!locals.length) { continue }\n if (!result) {\n result = locals;\n } else {\n if (sorted) {\n result = result.slice();\n sorted = false;\n }\n for (var j = 0; j < locals.length; j++) { result.push(locals[j]); }\n }\n }\n return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none\n};\n\n// : ([DecorationSet]) → union\n// Create a group for the given array of decoration sets, or return\n// a single set when possible.\nDecorationGroup.from = function from (members) {\n switch (members.length) {\n case 0: return empty\n case 1: return members[0]\n default: return new DecorationGroup(members)\n }\n};\n\nfunction mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, options) {\n var children = oldChildren.slice();\n\n // Mark the children that are directly touched by changes, and\n // move those that are after the changes.\n var shift = function (oldStart, oldEnd, newStart, newEnd) {\n for (var i = 0; i < children.length; i += 3) {\n var end = children[i + 1], dSize = (void 0);\n if (end == -1 || oldStart > end + oldOffset) { continue }\n if (oldEnd >= children[i] + oldOffset) {\n children[i + 1] = -1;\n } else if (dSize = (newEnd - newStart) - (oldEnd - oldStart) + (oldOffset - offset)) {\n children[i] += dSize;\n children[i + 1] += dSize;\n }\n }\n };\n for (var i = 0; i < mapping.maps.length; i++) { mapping.maps[i].forEach(shift); }\n\n // Find the child nodes that still correspond to a single node,\n // recursively call mapInner on them and update their positions.\n var mustRebuild = false;\n for (var i$1 = 0; i$1 < children.length; i$1 += 3) { if (children[i$1 + 1] == -1) { // Touched nodes\n var from = mapping.map(children[i$1] + oldOffset), fromLocal = from - offset;\n if (fromLocal < 0 || fromLocal >= node.content.size) {\n mustRebuild = true;\n continue\n }\n // Must read oldChildren because children was tagged with -1\n var to = mapping.map(oldChildren[i$1 + 1] + oldOffset, -1), toLocal = to - offset;\n var ref = node.content.findIndex(fromLocal);\n var index = ref.index;\n var childOffset = ref.offset;\n var childNode = node.maybeChild(index);\n if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {\n var mapped = children[i$1 + 2].mapInner(mapping, childNode, from + 1, children[i$1] + oldOffset + 1, options);\n if (mapped != empty) {\n children[i$1] = fromLocal;\n children[i$1 + 1] = toLocal;\n children[i$1 + 2] = mapped;\n } else {\n children[i$1 + 1] = -2;\n mustRebuild = true;\n }\n } else {\n mustRebuild = true;\n }\n } }\n\n // Remaining children must be collected and rebuilt into the appropriate structure\n if (mustRebuild) {\n var decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal || [], mapping,\n offset, oldOffset, options);\n var built = buildTree(decorations, node, 0, options);\n newLocal = built.local;\n for (var i$2 = 0; i$2 < children.length; i$2 += 3) { if (children[i$2 + 1] < 0) {\n children.splice(i$2, 3);\n i$2 -= 3;\n } }\n for (var i$3 = 0, j = 0; i$3 < built.children.length; i$3 += 3) {\n var from$1 = built.children[i$3];\n while (j < children.length && children[j] < from$1) { j += 3; }\n children.splice(j, 0, built.children[i$3], built.children[i$3 + 1], built.children[i$3 + 2]);\n }\n }\n\n return new DecorationSet(newLocal && newLocal.sort(byPos), children)\n}\n\nfunction moveSpans(spans, offset) {\n if (!offset || !spans.length) { return spans }\n var result = [];\n for (var i = 0; i < spans.length; i++) {\n var span = spans[i];\n result.push(new Decoration(span.from + offset, span.to + offset, span.type));\n }\n return result\n}\n\nfunction mapAndGatherRemainingDecorations(children, oldChildren, decorations, mapping, offset, oldOffset, options) {\n // Gather all decorations from the remaining marked children\n function gather(set, oldOffset) {\n for (var i = 0; i < set.local.length; i++) {\n var mapped = set.local[i].map(mapping, offset, oldOffset);\n if (mapped) { decorations.push(mapped); }\n else if (options.onRemove) { options.onRemove(set.local[i].spec); }\n }\n for (var i$1 = 0; i$1 < set.children.length; i$1 += 3)\n { gather(set.children[i$1 + 2], set.children[i$1] + oldOffset + 1); }\n }\n for (var i = 0; i < children.length; i += 3) { if (children[i + 1] == -1)\n { gather(children[i + 2], oldChildren[i] + oldOffset + 1); } }\n\n return decorations\n}\n\nfunction takeSpansForNode(spans, node, offset) {\n if (node.isLeaf) { return null }\n var end = offset + node.nodeSize, found = null;\n for (var i = 0, span = (void 0); i < spans.length; i++) {\n if ((span = spans[i]) && span.from > offset && span.to < end) {\n(found || (found = [])).push(span);\n spans[i] = null;\n }\n }\n return found\n}\n\nfunction withoutNulls(array) {\n var result = [];\n for (var i = 0; i < array.length; i++)\n { if (array[i] != null) { result.push(array[i]); } }\n return result\n}\n\n// : ([Decoration], Node, number) → DecorationSet\n// Build up a tree that corresponds to a set of decorations. `offset`\n// is a base offset that should be subtractet from the `from` and `to`\n// positions in the spans (so that we don't have to allocate new spans\n// for recursive calls).\nfunction buildTree(spans, node, offset, options) {\n var children = [], hasNulls = false;\n node.forEach(function (childNode, localStart) {\n var found = takeSpansForNode(spans, childNode, localStart + offset);\n if (found) {\n hasNulls = true;\n var subtree = buildTree(found, childNode, offset + localStart + 1, options);\n if (subtree != empty)\n { children.push(localStart, localStart + childNode.nodeSize, subtree); }\n }\n });\n var locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset).sort(byPos);\n for (var i = 0; i < locals.length; i++) { if (!locals[i].type.valid(node, locals[i])) {\n if (options.onRemove) { options.onRemove(locals[i].spec); }\n locals.splice(i--, 1);\n } }\n return locals.length || children.length ? new DecorationSet(locals, children) : empty\n}\n\n// : (Decoration, Decoration) → number\n// Used to sort decorations so that ones with a low start position\n// come first, and within a set with the same start position, those\n// with an smaller end position come first.\nfunction byPos(a, b) {\n return a.from - b.from || a.to - b.to\n}\n\n// : ([Decoration]) → [Decoration]\n// Scan a sorted array of decorations for partially overlapping spans,\n// and split those so that only fully overlapping spans are left (to\n// make subsequent rendering easier). Will return the input array if\n// no partially overlapping spans are found (the common case).\nfunction removeOverlap(spans) {\n var working = spans;\n for (var i = 0; i < working.length - 1; i++) {\n var span = working[i];\n if (span.from != span.to) { for (var j = i + 1; j < working.length; j++) {\n var next = working[j];\n if (next.from == span.from) {\n if (next.to != span.to) {\n if (working == spans) { working = spans.slice(); }\n // Followed by a partially overlapping larger span. Split that\n // span.\n working[j] = next.copy(next.from, span.to);\n insertAhead(working, j + 1, next.copy(span.to, next.to));\n }\n continue\n } else {\n if (next.from < span.to) {\n if (working == spans) { working = spans.slice(); }\n // The end of this one overlaps with a subsequent span. Split\n // this one.\n working[i] = span.copy(span.from, next.from);\n insertAhead(working, j, span.copy(next.from, span.to));\n }\n break\n }\n } }\n }\n return working\n}\n\nfunction insertAhead(array, i, deco) {\n while (i < array.length && byPos(deco, array[i]) > 0) { i++; }\n array.splice(i, 0, deco);\n}\n\n// : (EditorView) → union\n// Get the decorations associated with the current props of a view.\nfunction viewDecorations(view) {\n var found = [];\n view.someProp(\"decorations\", function (f) {\n var result = f(view.state);\n if (result && result != empty) { found.push(result); }\n });\n if (view.cursorWrapper)\n { found.push(DecorationSet.create(view.state.doc, [view.cursorWrapper.deco])); }\n return DecorationGroup.from(found)\n}\n\n// ::- An editor view manages the DOM structure that represents an\n// editable document. Its state and behavior are determined by its\n// [props](#view.DirectEditorProps).\nvar EditorView = function EditorView(place, props) {\n this._props = props;\n // :: EditorState\n // The view's current [state](#state.EditorState).\n this.state = props.state;\n\n this.dispatch = this.dispatch.bind(this);\n\n this._root = null;\n this.focused = false;\n\n // :: dom.Element\n // An editable DOM node containing the document. (You probably\n // should not directly interfere with its content.)\n this.dom = (place && place.mount) || document.createElement(\"div\");\n if (place) {\n if (place.appendChild) { place.appendChild(this.dom); }\n else if (place.apply) { place(this.dom); }\n else if (place.mount) { this.mounted = true; }\n }\n\n // :: bool\n // Indicates whether the editor is currently [editable](#view.EditorProps.editable).\n this.editable = getEditable(this);\n this.markCursor = null;\n this.cursorWrapper = null;\n updateCursorWrapper(this);\n this.nodeViews = buildNodeViews(this);\n this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this);\n\n this.lastSelectedViewDesc = null;\n // :: ?{slice: Slice, move: bool}\n // When editor content is being dragged, this object contains\n // information about the dragged slice and whether it is being\n // copied or moved. At any other time, it is null.\n this.dragging = null;\n\n initInput(this);\n\n this.pluginViews = [];\n this.updatePluginViews();\n};\n\nvar prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true } };\n\n// composing:: boolean\n// Holds `true` when a\n// [composition](https://developer.mozilla.org/en-US/docs/Mozilla/IME_handling_guide)\n// is active.\n\n// :: DirectEditorProps\n// The view's current [props](#view.EditorProps).\nprototypeAccessors$2.props.get = function () {\n if (this._props.state != this.state) {\n var prev = this._props;\n this._props = {};\n for (var name in prev) { this._props[name] = prev[name]; }\n this._props.state = this.state;\n }\n return this._props\n};\n\n// :: (DirectEditorProps)\n// Update the view's props. Will immediately cause an update to\n// the DOM.\nEditorView.prototype.update = function update (props) {\n if (props.handleDOMEvents != this._props.handleDOMEvents) { ensureListeners(this); }\n this._props = props;\n this.updateStateInner(props.state, true);\n};\n\n// :: (DirectEditorProps)\n// Update the view by updating existing props object with the object\n// given as argument. Equivalent to `view.update(Object.assign({},\n// view.props, props))`.\nEditorView.prototype.setProps = function setProps (props) {\n var updated = {};\n for (var name in this._props) { updated[name] = this._props[name]; }\n updated.state = this.state;\n for (var name$1 in props) { updated[name$1] = props[name$1]; }\n this.update(updated);\n};\n\n// :: (EditorState)\n// Update the editor's `state` prop, without touching any of the\n// other props.\nEditorView.prototype.updateState = function updateState (state) {\n this.updateStateInner(state, this.state.plugins != state.plugins);\n};\n\nEditorView.prototype.updateStateInner = function updateStateInner (state, reconfigured) {\n var this$1 = this;\n\n var prev = this.state, redraw = false;\n this.state = state;\n if (reconfigured) {\n var nodeViews = buildNodeViews(this);\n if (changedNodeViews(nodeViews, this.nodeViews)) {\n this.nodeViews = nodeViews;\n redraw = true;\n }\n ensureListeners(this);\n }\n\n this.editable = getEditable(this);\n updateCursorWrapper(this);\n var innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this);\n\n var scroll = reconfigured ? \"reset\"\n : state.scrollToSelection > prev.scrollToSelection ? \"to selection\" : \"preserve\";\n var updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);\n var updateSel = updateDoc || !state.selection.eq(prev.selection);\n var oldScrollPos = scroll == \"preserve\" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);\n\n if (updateSel) {\n this.domObserver.stop();\n // Work around an issue in Chrome, IE, and Edge where changing\n // the DOM around an active selection puts it into a broken\n // state where the thing the user sees differs from the\n // selection reported by the Selection object (#710, #973,\n // #1011, #1013).\n var forceSelUpdate = updateDoc && (result.ie || result.chrome) &&\n !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);\n if (updateDoc) {\n if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {\n this.docView.destroy();\n this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);\n }\n }\n // Work around for an issue where an update arriving right between\n // a DOM selection change and the \"selectionchange\" event for it\n // can cause a spurious DOM selection update, disrupting mouse\n // drag selection.\n if (forceSelUpdate ||\n !(this.mouseDown && this.domObserver.currentSelection.eq(this.root.getSelection()) && anchorInRightPlace(this))) {\n selectionToDOM(this, forceSelUpdate);\n } else {\n syncNodeSelection(this, state.selection);\n this.domObserver.setCurSelection();\n }\n this.domObserver.start();\n }\n\n this.updatePluginViews(prev);\n\n if (scroll == \"reset\") {\n this.dom.scrollTop = 0;\n } else if (scroll == \"to selection\") {\n var startDOM = this.root.getSelection().focusNode;\n if (this.someProp(\"handleScrollToSelection\", function (f) { return f(this$1); }))\n ; // Handled\n else if (state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"])\n { scrollRectIntoView(this, this.docView.domAfterPos(state.selection.from).getBoundingClientRect(), startDOM); }\n else\n { scrollRectIntoView(this, this.coordsAtPos(state.selection.head), startDOM); }\n } else if (oldScrollPos) {\n resetScrollPos(oldScrollPos);\n }\n};\n\nEditorView.prototype.destroyPluginViews = function destroyPluginViews () {\n var view;\n while (view = this.pluginViews.pop()) { if (view.destroy) { view.destroy(); } }\n};\n\nEditorView.prototype.updatePluginViews = function updatePluginViews (prevState) {\n if (!prevState || prevState.plugins != this.state.plugins) {\n this.destroyPluginViews();\n for (var i = 0; i < this.state.plugins.length; i++) {\n var plugin = this.state.plugins[i];\n if (plugin.spec.view) { this.pluginViews.push(plugin.spec.view(this)); }\n }\n } else {\n for (var i$1 = 0; i$1 < this.pluginViews.length; i$1++) {\n var pluginView = this.pluginViews[i$1];\n if (pluginView.update) { pluginView.update(this, prevState); }\n }\n }\n};\n\n// :: (string, ?(prop: *) → *) → *\n// Goes over the values of a prop, first those provided directly,\n// then those from plugins (in order), and calls `f` every time a\n// non-undefined value is found. When `f` returns a truthy value,\n// that is immediately returned. When `f` isn't provided, it is\n// treated as the identity function (the prop value is returned\n// directly).\nEditorView.prototype.someProp = function someProp (propName, f) {\n var prop = this._props && this._props[propName], value;\n if (prop != null && (value = f ? f(prop) : prop)) { return value }\n var plugins = this.state.plugins;\n if (plugins) { for (var i = 0; i < plugins.length; i++) {\n var prop$1 = plugins[i].props[propName];\n if (prop$1 != null && (value = f ? f(prop$1) : prop$1)) { return value }\n } }\n};\n\n// :: () → bool\n// Query whether the view has focus.\nEditorView.prototype.hasFocus = function hasFocus () {\n return this.root.activeElement == this.dom\n};\n\n// :: ()\n// Focus the editor.\nEditorView.prototype.focus = function focus () {\n this.domObserver.stop();\n if (this.editable) { focusPreventScroll(this.dom); }\n selectionToDOM(this);\n this.domObserver.start();\n};\n\n// :: union\n// Get the document root in which the editor exists. This will\n// usually be the top-level `document`, but might be a [shadow\n// DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM)\n// root if the editor is inside one.\nprototypeAccessors$2.root.get = function () {\n var cached = this._root;\n if (cached == null) { for (var search = this.dom.parentNode; search; search = search.parentNode) {\n if (search.nodeType == 9 || (search.nodeType == 11 && search.host)) {\n if (!search.getSelection) { Object.getPrototypeOf(search).getSelection = function () { return document.getSelection(); }; }\n return this._root = search\n }\n } }\n return cached || document\n};\n\n// :: ({left: number, top: number}) → ?{pos: number, inside: number}\n// Given a pair of viewport coordinates, return the document\n// position that corresponds to them. May return null if the given\n// coordinates aren't inside of the editor. When an object is\n// returned, its `pos` property is the position nearest to the\n// coordinates, and its `inside` property holds the position of the\n// inner node that the position falls inside of, or -1 if it is at\n// the top level, not in any node.\nEditorView.prototype.posAtCoords = function posAtCoords$1 (coords) {\n return posAtCoords(this, coords)\n};\n\n// :: (number) → {left: number, right: number, top: number, bottom: number}\n// Returns the viewport rectangle at a given document position. `left`\n// and `right` will be the same number, as this returns a flat\n// cursor-ish rectangle.\nEditorView.prototype.coordsAtPos = function coordsAtPos$1 (pos) {\n return coordsAtPos(this, pos)\n};\n\n// :: (number) → {node: dom.Node, offset: number}\n// Find the DOM position that corresponds to the given document\n// position. Note that you should **not** mutate the editor's\n// internal DOM, only inspect it (and even that is usually not\n// necessary).\nEditorView.prototype.domAtPos = function domAtPos (pos) {\n return this.docView.domFromPos(pos)\n};\n\n// :: (number) → ?dom.Node\n// Find the DOM node that represents the document node after the\n// given position. May return `null` when the position doesn't point\n// in front of a node or if the node is inside an opaque node view.\n//\n// This is intended to be able to call things like\n// `getBoundingClientRect` on that DOM node. Do **not** mutate the\n// editor DOM directly, or add styling this way, since that will be\n// immediately overriden by the editor as it redraws the node.\nEditorView.prototype.nodeDOM = function nodeDOM (pos) {\n var desc = this.docView.descAt(pos);\n return desc ? desc.nodeDOM : null\n};\n\n// :: (dom.Node, number, ?number) → number\n// Find the document position that corresponds to a given DOM\n// position. (Whenever possible, it is preferable to inspect the\n// document structure directly, rather than poking around in the\n// DOM, but sometimes—for example when interpreting an event\n// target—you don't have a choice.)\n//\n// The `bias` parameter can be used to influence which side of a DOM\n// node to use when the position is inside a leaf node.\nEditorView.prototype.posAtDOM = function posAtDOM (node, offset, bias) {\n if ( bias === void 0 ) bias = -1;\n\n var pos = this.docView.posFromDOM(node, offset, bias);\n if (pos == null) { throw new RangeError(\"DOM position not inside the editor\") }\n return pos\n};\n\n// :: (union<\"up\", \"down\", \"left\", \"right\", \"forward\", \"backward\">, ?EditorState) → bool\n// Find out whether the selection is at the end of a textblock when\n// moving in a given direction. When, for example, given `\"left\"`,\n// it will return true if moving left from the current cursor\n// position would leave that position's parent textblock. Will apply\n// to the view's current state by default, but it is possible to\n// pass a different state.\nEditorView.prototype.endOfTextblock = function endOfTextblock$1 (dir, state) {\n return endOfTextblock(this, state || this.state, dir)\n};\n\n// :: ()\n// Removes the editor from the DOM and destroys all [node\n// views](#view.NodeView).\nEditorView.prototype.destroy = function destroy () {\n if (!this.docView) { return }\n destroyInput(this);\n this.destroyPluginViews();\n if (this.mounted) {\n this.docView.update(this.state.doc, [], viewDecorations(this), this);\n this.dom.textContent = \"\";\n } else if (this.dom.parentNode) {\n this.dom.parentNode.removeChild(this.dom);\n }\n this.docView.destroy();\n this.docView = null;\n};\n\n// Used for testing.\nEditorView.prototype.dispatchEvent = function dispatchEvent$1 (event) {\n return dispatchEvent(this, event)\n};\n\n// :: (Transaction)\n// Dispatch a transaction. Will call\n// [`dispatchTransaction`](#view.DirectEditorProps.dispatchTransaction)\n// when given, and otherwise defaults to applying the transaction to\n// the current state and calling\n// [`updateState`](#view.EditorView.updateState) with the result.\n// This method is bound to the view instance, so that it can be\n// easily passed around.\nEditorView.prototype.dispatch = function dispatch (tr) {\n var dispatchTransaction = this._props.dispatchTransaction;\n if (dispatchTransaction) { dispatchTransaction.call(this, tr); }\n else { this.updateState(this.state.apply(tr)); }\n};\n\nObject.defineProperties( EditorView.prototype, prototypeAccessors$2 );\n\nfunction computeDocDeco(view) {\n var attrs = Object.create(null);\n attrs.class = \"ProseMirror\";\n attrs.contenteditable = String(view.editable);\n\n view.someProp(\"attributes\", function (value) {\n if (typeof value == \"function\") { value = value(view.state); }\n if (value) { for (var attr in value) {\n if (attr == \"class\")\n { attrs.class += \" \" + value[attr]; }\n else if (!attrs[attr] && attr != \"contenteditable\" && attr != \"nodeName\")\n { attrs[attr] = String(value[attr]); }\n } }\n });\n\n return [Decoration.node(0, view.state.doc.content.size, attrs)]\n}\n\nfunction updateCursorWrapper(view) {\n var ref = view.state.selection;\n var $head = ref.$head;\n var $anchor = ref.$anchor;\n var visible = ref.visible;\n if (view.markCursor) {\n var dom = document.createElement(\"img\");\n dom.setAttribute(\"mark-placeholder\", \"true\");\n view.cursorWrapper = {dom: dom, deco: Decoration.widget($head.pos, dom, {raw: true, marks: view.markCursor})};\n } else if (visible || $head.pos != $anchor.pos) {\n view.cursorWrapper = null;\n } else {\n var dom$1;\n if (!view.cursorWrapper || view.cursorWrapper.dom.childNodes.length) {\n dom$1 = document.createElement(\"div\");\n dom$1.style.position = \"absolute\";\n dom$1.style.left = \"-100000px\";\n } else if (view.cursorWrapper.deco.pos != $head.pos) {\n dom$1 = view.cursorWrapper.dom;\n }\n if (dom$1)\n { view.cursorWrapper = {dom: dom$1, deco: Decoration.widget($head.pos, dom$1, {raw: true})}; }\n }\n}\n\nfunction getEditable(view) {\n return !view.someProp(\"editable\", function (value) { return value(view.state) === false; })\n}\n\nfunction selectionContextChanged(sel1, sel2) {\n var depth = Math.min(sel1.$anchor.sharedDepth(sel1.head), sel2.$anchor.sharedDepth(sel2.head));\n return sel1.$anchor.node(depth) != sel2.$anchor.node(depth)\n}\n\nfunction buildNodeViews(view) {\n var result = {};\n view.someProp(\"nodeViews\", function (obj) {\n for (var prop in obj) { if (!Object.prototype.hasOwnProperty.call(result, prop))\n { result[prop] = obj[prop]; } }\n });\n return result\n}\n\nfunction changedNodeViews(a, b) {\n var nA = 0, nB = 0;\n for (var prop in a) {\n if (a[prop] != b[prop]) { return true }\n nA++;\n }\n for (var _ in b) { nB++; }\n return nA != nB\n}\n\n// EditorProps:: interface\n//\n// Props are configuration values that can be passed to an editor view\n// or included in a plugin. This interface lists the supported props.\n//\n// The various event-handling functions may all return `true` to\n// indicate that they handled the given event. The view will then take\n// care to call `preventDefault` on the event, except with\n// `handleDOMEvents`, where the handler itself is responsible for that.\n//\n// How a prop is resolved depends on the prop. Handler functions are\n// called one at a time, starting with the base props and then\n// searching through the plugins (in order of appearance) until one of\n// them returns true. For some props, the first plugin that yields a\n// value gets precedence.\n//\n// handleDOMEvents:: ?Object<(view: EditorView, event: dom.Event) → bool>\n// Can be an object mapping DOM event type names to functions that\n// handle them. Such functions will be called before any handling\n// ProseMirror does of events fired on the editable DOM element.\n// Contrary to the other event handling props, when returning true\n// from such a function, you are responsible for calling\n// `preventDefault` yourself (or not, if you want to allow the\n// default behavior).\n//\n// handleKeyDown:: ?(view: EditorView, event: dom.KeyboardEvent) → bool\n// Called when the editor receives a `keydown` event.\n//\n// handleKeyPress:: ?(view: EditorView, event: dom.KeyboardEvent) → bool\n// Handler for `keypress` events.\n//\n// handleTextInput:: ?(view: EditorView, from: number, to: number, text: string) → bool\n// Whenever the user directly input text, this handler is called\n// before the input is applied. If it returns `true`, the default\n// behavior of actually inserting the text is suppressed.\n//\n// handleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool\n// Called for each node around a click, from the inside out. The\n// `direct` flag will be true for the inner node.\n//\n// handleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool\n// Called when the editor is clicked, after `handleClickOn` handlers\n// have been called.\n//\n// handleDoubleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool\n// Called for each node around a double click.\n//\n// handleDoubleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool\n// Called when the editor is double-clicked, after `handleDoubleClickOn`.\n//\n// handleTripleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool\n// Called for each node around a triple click.\n//\n// handleTripleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool\n// Called when the editor is triple-clicked, after `handleTripleClickOn`.\n//\n// handlePaste:: ?(view: EditorView, event: dom.Event, slice: Slice) → bool\n// Can be used to override the behavior of pasting. `slice` is the\n// pasted content parsed by the editor, but you can directly access\n// the event to get at the raw content.\n//\n// handleDrop:: ?(view: EditorView, event: dom.Event, slice: Slice, moved: bool) → bool\n// Called when something is dropped on the editor. `moved` will be\n// true if this drop moves from the current selection (which should\n// thus be deleted).\n//\n// handleScrollToSelection:: ?(view: EditorView) → bool\n// Called when the view, after updating its state, tries to scroll\n// the selection into view. A handler function may return false to\n// indicate that it did not handle the scrolling and further\n// handlers or the default behavior should be tried.\n//\n// createSelectionBetween:: ?(view: EditorView, anchor: ResolvedPos, head: ResolvedPos) → ?Selection\n// Can be used to override the way a selection is created when\n// reading a DOM selection between the given anchor and head.\n//\n// domParser:: ?DOMParser\n// The [parser](#model.DOMParser) to use when reading editor changes\n// from the DOM. Defaults to calling\n// [`DOMParser.fromSchema`](#model.DOMParser^fromSchema) on the\n// editor's schema.\n//\n// transformPastedHTML:: ?(html: string) → string\n// Can be used to transform pasted HTML text, _before_ it is parsed,\n// for example to clean it up.\n//\n// clipboardParser:: ?DOMParser\n// The [parser](#model.DOMParser) to use when reading content from\n// the clipboard. When not given, the value of the\n// [`domParser`](#view.EditorProps.domParser) prop is used.\n//\n// transformPastedText:: ?(text: string) → string\n// Transform pasted plain text.\n//\n// clipboardTextParser:: ?(text: string, $context: ResolvedPos) → Slice\n// A function to parse text from the clipboard into a document\n// slice. Called after\n// [`transformPastedText`](#view.EditorProps.transformPastedText).\n// The default behavior is to split the text into lines, wrap them\n// in `` tags, and call\n// [`clipboardParser`](#view.EditorProps.clipboardParser) on it.\n//\n// transformPasted:: ?(Slice) → Slice\n// Can be used to transform pasted content before it is applied to\n// the document.\n//\n// nodeViews:: ?Object<(node: Node, view: EditorView, getPos: () → number, decorations: [Decoration]) → NodeView>\n// Allows you to pass custom rendering and behavior logic for nodes\n// and marks. Should map node and mark names to constructor\n// functions that produce a [`NodeView`](#view.NodeView) object\n// implementing the node's display behavior. For nodes, the third\n// argument `getPos` is a function that can be called to get the\n// node's current position, which can be useful when creating\n// transactions to update it. For marks, the third argument is a\n// boolean that indicates whether the mark's content is inline.\n//\n// `decorations` is an array of node or inline decorations that are\n// active around the node. They are automatically drawn in the\n// normal way, and you will usually just want to ignore this, but\n// they can also be used as a way to provide context information to\n// the node view without adding it to the document itself.\n//\n// clipboardSerializer:: ?DOMSerializer\n// The DOM serializer to use when putting content onto the\n// clipboard. If not given, the result of\n// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)\n// will be used.\n//\n// clipboardTextSerializer:: ?(Slice) → string\n// A function that will be called to get the text for the current\n// selection when copying text to the clipboard. By default, the\n// editor will use [`textBetween`](#model.Node.textBetween) on the\n// selected range.\n//\n// decorations:: ?(state: EditorState) → ?DecorationSet\n// A set of [document decorations](#view.Decoration) to show in the\n// view.\n//\n// editable:: ?(state: EditorState) → bool\n// When this returns false, the content of the view is not directly\n// editable.\n//\n// attributes:: ?union, (EditorState) → ?Object>\n// Control the DOM attributes of the editable element. May be either\n// an object or a function going from an editor state to an object.\n// By default, the element will get a class `\"ProseMirror\"`, and\n// will have its `contentEditable` attribute determined by the\n// [`editable` prop](#view.EditorProps.editable). Additional classes\n// provided here will be added to the class. For other attributes,\n// the value provided first (as in\n// [`someProp`](#view.EditorView.someProp)) will be used.\n//\n// scrollThreshold:: ?union\n// Determines the distance (in pixels) between the cursor and the\n// end of the visible viewport at which point, when scrolling the\n// cursor into view, scrolling takes place. Defaults to 0.\n//\n// scrollMargin:: ?union\n// Determines the extra space (in pixels) that is left above or\n// below the cursor when it is scrolled into view. Defaults to 5.\n\n// DirectEditorProps:: interface extends EditorProps\n//\n// The props object given directly to the editor view supports two\n// fields that can't be used in plugins:\n//\n// state:: EditorState\n// The current state of the editor.\n//\n// dispatchTransaction:: ?(tr: Transaction)\n// The callback over which to send transactions (state updates)\n// produced by the view. If you specify this, you probably want to\n// make sure this ends up calling the view's\n// [`updateState`](#view.EditorView.updateState) method with a new\n// state that has the transaction\n// [applied](#state.EditorState.apply). The callback will be bound to have\n// the view instance as its `this` binding.\n\n\n//# sourceMappingURL=index.es.js.map\n\n\n//# sourceURL=webpack:///./node_modules/prosemirror-view/dist/index.es.js?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Decoration\", function() { return Decoration; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"DecorationSet\", function() { return DecorationSet; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"EditorView\", function() { return EditorView; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__endComposition\", function() { return endComposition; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__parseFromClipboard\", function() { return parseFromClipboard; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__serializeForClipboard\", function() { return serializeForClipboard; });\n/* harmony import */ var prosemirror_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prosemirror-state */ \"./node_modules/prosemirror-state/dist/index.es.js\");\n/* harmony import */ var prosemirror_model__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prosemirror-model */ \"./node_modules/prosemirror-model/dist/index.es.js\");\n/* harmony import */ var prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prosemirror-transform */ \"./node_modules/prosemirror-transform/dist/index.es.js\");\n\n\n\nvar result = {};\n\nif (typeof navigator != \"undefined\" && typeof document != \"undefined\") {\n var ie_edge = /Edge\\/(\\d+)/.exec(navigator.userAgent);\n var ie_upto10 = /MSIE \\d/.test(navigator.userAgent);\n var ie_11up = /Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);\n result.mac = /Mac/.test(navigator.platform);\n var ie = result.ie = !!(ie_upto10 || ie_11up || ie_edge);\n result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null;\n result.gecko = !ie && /gecko\\/(\\d+)/i.test(navigator.userAgent);\n result.gecko_version = result.gecko && +(/Firefox\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1];\n var chrome = !ie && /Chrome\\/(\\d+)/.exec(navigator.userAgent);\n result.chrome = !!chrome;\n result.chrome_version = chrome && +chrome[1];\n result.ios = !ie && /AppleWebKit/.test(navigator.userAgent) && /Mobile\\/\\w+/.test(navigator.userAgent);\n result.android = /Android \\d/.test(navigator.userAgent);\n result.webkit = !ie && 'WebkitAppearance' in document.documentElement.style;\n result.safari = /Apple Computer/.test(navigator.vendor);\n result.webkit_version = result.webkit && +(/\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1];\n}\n\nvar domIndex = function domIndex(node) {\n for (var index = 0;; index++) {\n node = node.previousSibling;\n\n if (!node) {\n return index;\n }\n }\n};\n\nvar parentNode = function parentNode(node) {\n var parent = node.parentNode;\n return parent && parent.nodeType == 11 ? parent.host : parent;\n};\n\nvar textRange = function textRange(node, from, to) {\n var range = document.createRange();\n range.setEnd(node, to == null ? node.nodeValue.length : to);\n range.setStart(node, from || 0);\n return range;\n}; // Scans forward and backward through DOM positions equivalent to the\n// given one to see if the two are in the same place (i.e. after a\n// text node vs at the end of that text node)\n\n\nvar isEquivalentPosition = function isEquivalentPosition(node, off, targetNode, targetOff) {\n return targetNode && (scanFor(node, off, targetNode, targetOff, -1) || scanFor(node, off, targetNode, targetOff, 1));\n};\n\nvar atomElements = /^(img|br|input|textarea|hr)$/i;\n\nfunction scanFor(node, off, targetNode, targetOff, dir) {\n for (;;) {\n if (node == targetNode && off == targetOff) {\n return true;\n }\n\n if (off == (dir < 0 ? 0 : nodeSize(node))) {\n var parent = node.parentNode;\n\n if (parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == \"false\") {\n return false;\n }\n\n off = domIndex(node) + (dir < 0 ? 0 : 1);\n node = parent;\n } else if (node.nodeType == 1) {\n node = node.childNodes[off + (dir < 0 ? -1 : 0)];\n\n if (node.contentEditable == \"false\") {\n return false;\n }\n\n off = dir < 0 ? nodeSize(node) : 0;\n } else {\n return false;\n }\n }\n}\n\nfunction nodeSize(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\n\nfunction isOnEdge(node, offset, parent) {\n for (var atStart = offset == 0, atEnd = offset == nodeSize(node); atStart || atEnd;) {\n if (node == parent) {\n return true;\n }\n\n var index = domIndex(node);\n node = node.parentNode;\n\n if (!node) {\n return false;\n }\n\n atStart = atStart && index == 0;\n atEnd = atEnd && index == nodeSize(node);\n }\n}\n\nfunction hasBlockDesc(dom) {\n var desc;\n\n for (var cur = dom; cur; cur = cur.parentNode) {\n if (desc = cur.pmViewDesc) {\n break;\n }\n }\n\n return desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom);\n} // Work around Chrome issue https://bugs.chromium.org/p/chromium/issues/detail?id=447523\n// (isCollapsed inappropriately returns true in shadow dom)\n\n\nvar selectionCollapsed = function selectionCollapsed(domSel) {\n var collapsed = domSel.isCollapsed;\n\n if (collapsed && result.chrome && domSel.rangeCount && !domSel.getRangeAt(0).collapsed) {\n collapsed = false;\n }\n\n return collapsed;\n};\n\nfunction keyEvent(keyCode, key) {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"keydown\", true, true);\n event.keyCode = keyCode;\n event.key = event.code = key;\n return event;\n}\n\nfunction windowRect(win) {\n return {\n left: 0,\n right: win.innerWidth,\n top: 0,\n bottom: win.innerHeight\n };\n}\n\nfunction getSide(value, side) {\n return typeof value == \"number\" ? value : value[side];\n}\n\nfunction scrollRectIntoView(view, rect, startDOM) {\n var scrollThreshold = view.someProp(\"scrollThreshold\") || 0,\n scrollMargin = view.someProp(\"scrollMargin\") || 5;\n var doc = view.dom.ownerDocument,\n win = doc.defaultView;\n\n for (var parent = startDOM || view.dom;; parent = parentNode(parent)) {\n if (!parent) {\n break;\n }\n\n if (parent.nodeType != 1) {\n continue;\n }\n\n var atTop = parent == doc.body || parent.nodeType != 1;\n var bounding = atTop ? windowRect(win) : parent.getBoundingClientRect();\n var moveX = 0,\n moveY = 0;\n\n if (rect.top < bounding.top + getSide(scrollThreshold, \"top\")) {\n moveY = -(bounding.top - rect.top + getSide(scrollMargin, \"top\"));\n } else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, \"bottom\")) {\n moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, \"bottom\");\n }\n\n if (rect.left < bounding.left + getSide(scrollThreshold, \"left\")) {\n moveX = -(bounding.left - rect.left + getSide(scrollMargin, \"left\"));\n } else if (rect.right > bounding.right - getSide(scrollThreshold, \"right\")) {\n moveX = rect.right - bounding.right + getSide(scrollMargin, \"right\");\n }\n\n if (moveX || moveY) {\n if (atTop) {\n win.scrollBy(moveX, moveY);\n } else {\n if (moveY) {\n parent.scrollTop += moveY;\n }\n\n if (moveX) {\n parent.scrollLeft += moveX;\n }\n\n rect = {\n left: rect.left - moveX,\n top: rect.top - moveY,\n right: rect.right - moveX,\n bottom: rect.bottom - moveY\n };\n }\n }\n\n if (atTop) {\n break;\n }\n }\n} // Store the scroll position of the editor's parent nodes, along with\n// the top position of an element near the top of the editor, which\n// will be used to make sure the visible viewport remains stable even\n// when the size of the content above changes.\n\n\nfunction storeScrollPos(view) {\n var rect = view.dom.getBoundingClientRect(),\n startY = Math.max(0, rect.top);\n var refDOM, refTop;\n\n for (var x = (rect.left + rect.right) / 2, y = startY + 1; y < Math.min(innerHeight, rect.bottom); y += 5) {\n var dom = view.root.elementFromPoint(x, y);\n\n if (dom == view.dom || !view.dom.contains(dom)) {\n continue;\n }\n\n var localRect = dom.getBoundingClientRect();\n\n if (localRect.top >= startY - 20) {\n refDOM = dom;\n refTop = localRect.top;\n break;\n }\n }\n\n return {\n refDOM: refDOM,\n refTop: refTop,\n stack: scrollStack(view.dom)\n };\n}\n\nfunction scrollStack(dom) {\n var stack = [],\n doc = dom.ownerDocument;\n\n for (; dom; dom = parentNode(dom)) {\n stack.push({\n dom: dom,\n top: dom.scrollTop,\n left: dom.scrollLeft\n });\n\n if (dom == doc) {\n break;\n }\n }\n\n return stack;\n} // Reset the scroll position of the editor's parent nodes to that what\n// it was before, when storeScrollPos was called.\n\n\nfunction resetScrollPos(ref) {\n var refDOM = ref.refDOM;\n var refTop = ref.refTop;\n var stack = ref.stack;\n var newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0;\n restoreScrollStack(stack, newRefTop == 0 ? 0 : newRefTop - refTop);\n}\n\nfunction restoreScrollStack(stack, dTop) {\n for (var i = 0; i < stack.length; i++) {\n var ref = stack[i];\n var dom = ref.dom;\n var top = ref.top;\n var left = ref.left;\n\n if (dom.scrollTop != top + dTop) {\n dom.scrollTop = top + dTop;\n }\n\n if (dom.scrollLeft != left) {\n dom.scrollLeft = left;\n }\n }\n}\n\nvar preventScrollSupported = null; // Feature-detects support for .focus({preventScroll: true}), and uses\n// a fallback kludge when not supported.\n\nfunction focusPreventScroll(dom) {\n if (dom.setActive) {\n return dom.setActive();\n } // in IE\n\n\n if (preventScrollSupported) {\n return dom.focus(preventScrollSupported);\n }\n\n var stored = scrollStack(dom);\n dom.focus(preventScrollSupported == null ? {\n get preventScroll() {\n preventScrollSupported = {\n preventScroll: true\n };\n return true;\n }\n\n } : undefined);\n\n if (!preventScrollSupported) {\n preventScrollSupported = false;\n restoreScrollStack(stored, 0);\n }\n}\n\nfunction findOffsetInNode(node, coords) {\n var closest,\n dxClosest = 2e8,\n coordsClosest,\n offset = 0;\n var rowBot = coords.top,\n rowTop = coords.top;\n\n for (var child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {\n var rects = void 0;\n\n if (child.nodeType == 1) {\n rects = child.getClientRects();\n } else if (child.nodeType == 3) {\n rects = textRange(child).getClientRects();\n } else {\n continue;\n }\n\n for (var i = 0; i < rects.length; i++) {\n var rect = rects[i];\n\n if (rect.top <= rowBot && rect.bottom >= rowTop) {\n rowBot = Math.max(rect.bottom, rowBot);\n rowTop = Math.min(rect.top, rowTop);\n var dx = rect.left > coords.left ? rect.left - coords.left : rect.right < coords.left ? coords.left - rect.right : 0;\n\n if (dx < dxClosest) {\n closest = child;\n dxClosest = dx;\n coordsClosest = dx && closest.nodeType == 3 ? {\n left: rect.right < coords.left ? rect.right : rect.left,\n top: coords.top\n } : coords;\n\n if (child.nodeType == 1 && dx) {\n offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);\n }\n\n continue;\n }\n }\n\n if (!closest && (coords.left >= rect.right && coords.top >= rect.top || coords.left >= rect.left && coords.top >= rect.bottom)) {\n offset = childIndex + 1;\n }\n }\n }\n\n if (closest && closest.nodeType == 3) {\n return findOffsetInText(closest, coordsClosest);\n }\n\n if (!closest || dxClosest && closest.nodeType == 1) {\n return {\n node: node,\n offset: offset\n };\n }\n\n return findOffsetInNode(closest, coordsClosest);\n}\n\nfunction findOffsetInText(node, coords) {\n var len = node.nodeValue.length;\n var range = document.createRange();\n\n for (var i = 0; i < len; i++) {\n range.setEnd(node, i + 1);\n range.setStart(node, i);\n var rect = singleRect(range, 1);\n\n if (rect.top == rect.bottom) {\n continue;\n }\n\n if (inRect(coords, rect)) {\n return {\n node: node,\n offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0)\n };\n }\n }\n\n return {\n node: node,\n offset: 0\n };\n}\n\nfunction inRect(coords, rect) {\n return coords.left >= rect.left - 1 && coords.left <= rect.right + 1 && coords.top >= rect.top - 1 && coords.top <= rect.bottom + 1;\n}\n\nfunction targetKludge(dom, coords) {\n var parent = dom.parentNode;\n\n if (parent && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left) {\n return parent;\n }\n\n return dom;\n}\n\nfunction posFromElement(view, elt, coords) {\n var ref = findOffsetInNode(elt, coords);\n var node = ref.node;\n var offset = ref.offset;\n var bias = -1;\n\n if (node.nodeType == 1 && !node.firstChild) {\n var rect = node.getBoundingClientRect();\n bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;\n }\n\n return view.docView.posFromDOM(node, offset, bias);\n}\n\nfunction posFromCaret(view, node, offset, coords) {\n // Browser (in caretPosition/RangeFromPoint) will agressively\n // normalize towards nearby inline nodes. Since we are interested in\n // positions between block nodes too, we first walk up the hierarchy\n // of nodes to see if there are block nodes that the coordinates\n // fall outside of. If so, we take the position before/after that\n // block. If not, we call `posFromDOM` on the raw node/offset.\n var outside = -1;\n\n for (var cur = node;;) {\n if (cur == view.dom) {\n break;\n }\n\n var desc = view.docView.nearestDesc(cur, true);\n\n if (!desc) {\n return null;\n }\n\n if (desc.node.isBlock && desc.parent) {\n var rect = desc.dom.getBoundingClientRect();\n\n if (rect.left > coords.left || rect.top > coords.top) {\n outside = desc.posBefore;\n } else if (rect.right < coords.left || rect.bottom < coords.top) {\n outside = desc.posAfter;\n } else {\n break;\n }\n }\n\n cur = desc.dom.parentNode;\n }\n\n return outside > -1 ? outside : view.docView.posFromDOM(node, offset);\n}\n\nfunction elementFromPoint(element, coords, box) {\n var len = element.childNodes.length;\n\n if (len && box.top < box.bottom) {\n for (var startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {\n var child = element.childNodes[i];\n\n if (child.nodeType == 1) {\n var rects = child.getClientRects();\n\n for (var j = 0; j < rects.length; j++) {\n var rect = rects[j];\n\n if (inRect(coords, rect)) {\n return elementFromPoint(child, coords, rect);\n }\n }\n }\n\n if ((i = (i + 1) % len) == startI) {\n break;\n }\n }\n }\n\n return element;\n} // Given an x,y position on the editor, get the position in the document.\n\n\nfunction posAtCoords(view, coords) {\n var assign, assign$1;\n var root = view.root,\n node,\n offset;\n\n if (root.caretPositionFromPoint) {\n try {\n // Firefox throws for this call in hard-to-predict circumstances (#994)\n var pos$1 = root.caretPositionFromPoint(coords.left, coords.top);\n\n if (pos$1) {\n assign = pos$1, node = assign.offsetNode, offset = assign.offset;\n }\n } catch (_) {}\n }\n\n if (!node && root.caretRangeFromPoint) {\n var range = root.caretRangeFromPoint(coords.left, coords.top);\n\n if (range) {\n assign$1 = range, node = assign$1.startContainer, offset = assign$1.startOffset;\n }\n }\n\n var elt = root.elementFromPoint(coords.left, coords.top + 1),\n pos;\n\n if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {\n var box = view.dom.getBoundingClientRect();\n\n if (!inRect(coords, box)) {\n return null;\n }\n\n elt = elementFromPoint(view.dom, coords, box);\n\n if (!elt) {\n return null;\n }\n }\n\n elt = targetKludge(elt, coords);\n\n if (node) {\n if (result.gecko && node.nodeType == 1) {\n // Firefox will sometimes return offsets into nodes, which\n // have no actual children, from caretPositionFromPoint (#953)\n offset = Math.min(offset, node.childNodes.length); // It'll also move the returned position before image nodes,\n // even if those are behind it.\n\n if (offset < node.childNodes.length) {\n var next = node.childNodes[offset],\n box$1;\n\n if (next.nodeName == \"IMG\" && (box$1 = next.getBoundingClientRect()).right <= coords.left && box$1.bottom > coords.top) {\n offset++;\n }\n }\n } // Suspiciously specific kludge to work around caret*FromPoint\n // never returning a position at the end of the document\n\n\n if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom) {\n pos = view.state.doc.content.size;\n } // Ignore positions directly after a BR, since caret*FromPoint\n // 'round up' positions that would be more accurately placed\n // before the BR node.\n else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != \"BR\") {\n pos = posFromCaret(view, node, offset, coords);\n }\n }\n\n if (pos == null) {\n pos = posFromElement(view, elt, coords);\n }\n\n var desc = view.docView.nearestDesc(elt, true);\n return {\n pos: pos,\n inside: desc ? desc.posAtStart - desc.border : -1\n };\n}\n\nfunction singleRect(object, bias) {\n var rects = object.getClientRects();\n return !rects.length ? object.getBoundingClientRect() : rects[bias < 0 ? 0 : rects.length - 1];\n} // : (EditorView, number) → {left: number, top: number, right: number, bottom: number}\n// Given a position in the document model, get a bounding box of the\n// character at that position, relative to the window.\n\n\nfunction coordsAtPos(view, pos) {\n var ref = view.docView.domFromPos(pos);\n var node = ref.node;\n var offset = ref.offset; // These browsers support querying empty text ranges\n\n if (node.nodeType == 3 && (result.chrome || result.gecko)) {\n var rect = singleRect(textRange(node, offset, offset), 0); // Firefox returns bad results (the position before the space)\n // when querying a position directly after line-broken\n // whitespace. Detect this situation and and kludge around it\n\n if (result.gecko && offset && /\\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {\n var rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1);\n\n if (Math.abs(rectBefore.left - rect.left) < 1 && rectBefore.top == rect.top) {\n var rectAfter = singleRect(textRange(node, offset, offset + 1), -1);\n return flattenV(rectAfter, rectAfter.left < rectBefore.left);\n }\n }\n\n return rect;\n }\n\n if (node.nodeType == 1 && !view.state.doc.resolve(pos).parent.inlineContent) {\n // Return a horizontal line in block context\n var top = true,\n rect$1;\n\n if (offset < node.childNodes.length) {\n var after = node.childNodes[offset];\n\n if (after.nodeType == 1) {\n rect$1 = after.getBoundingClientRect();\n }\n }\n\n if (!rect$1 && offset) {\n var before = node.childNodes[offset - 1];\n\n if (before.nodeType == 1) {\n rect$1 = before.getBoundingClientRect();\n top = false;\n }\n }\n\n return flattenH(rect$1 || node.getBoundingClientRect(), top);\n } // Not Firefox/Chrome, or not in a text node, so we have to use\n // actual element/character rectangles to get a solution (this part\n // is not very bidi-safe)\n //\n // Try the left side first, fall back to the right one if that\n // doesn't work.\n\n\n for (var dir = -1; dir < 2; dir += 2) {\n if (dir < 0 && offset) {\n var prev = void 0,\n target = node.nodeType == 3 ? textRange(node, offset - 1, offset) : (prev = node.childNodes[offset - 1]).nodeType == 3 ? textRange(prev) : prev.nodeType == 1 && prev.nodeName != \"BR\" ? prev : null; // BR nodes tend to only return the rectangle before them\n\n if (target) {\n var rect$2 = singleRect(target, 1);\n\n if (rect$2.top < rect$2.bottom) {\n return flattenV(rect$2, false);\n }\n }\n } else if (dir > 0 && offset < nodeSize(node)) {\n var next = void 0,\n target$1 = node.nodeType == 3 ? textRange(node, offset, offset + 1) : (next = node.childNodes[offset]).nodeType == 3 ? textRange(next) : next.nodeType == 1 ? next : null;\n\n if (target$1) {\n var rect$3 = singleRect(target$1, -1);\n\n if (rect$3.top < rect$3.bottom) {\n return flattenV(rect$3, true);\n }\n }\n }\n } // All else failed, just try to get a rectangle for the target node\n\n\n return flattenV(singleRect(node.nodeType == 3 ? textRange(node) : node, 0), false);\n}\n\nfunction flattenV(rect, left) {\n if (rect.width == 0) {\n return rect;\n }\n\n var x = left ? rect.left : rect.right;\n return {\n top: rect.top,\n bottom: rect.bottom,\n left: x,\n right: x\n };\n}\n\nfunction flattenH(rect, top) {\n if (rect.height == 0) {\n return rect;\n }\n\n var y = top ? rect.top : rect.bottom;\n return {\n top: y,\n bottom: y,\n left: rect.left,\n right: rect.right\n };\n}\n\nfunction withFlushedState(view, state, f) {\n var viewState = view.state,\n active = view.root.activeElement;\n\n if (viewState != state) {\n view.updateState(state);\n }\n\n if (active != view.dom) {\n view.focus();\n }\n\n try {\n return f();\n } finally {\n if (viewState != state) {\n view.updateState(viewState);\n }\n\n if (active != view.dom) {\n active.focus();\n }\n }\n} // : (EditorView, number, number)\n// Whether vertical position motion in a given direction\n// from a position would leave a text block.\n\n\nfunction endOfTextblockVertical(view, state, dir) {\n var sel = state.selection;\n var $pos = dir == \"up\" ? sel.$anchor.min(sel.$head) : sel.$anchor.max(sel.$head);\n return withFlushedState(view, state, function () {\n var ref = view.docView.domFromPos($pos.pos);\n var dom = ref.node;\n\n for (;;) {\n var nearest = view.docView.nearestDesc(dom, true);\n\n if (!nearest) {\n break;\n }\n\n if (nearest.node.isBlock) {\n dom = nearest.dom;\n break;\n }\n\n dom = nearest.dom.parentNode;\n }\n\n var coords = coordsAtPos(view, $pos.pos);\n\n for (var child = dom.firstChild; child; child = child.nextSibling) {\n var boxes = void 0;\n\n if (child.nodeType == 1) {\n boxes = child.getClientRects();\n } else if (child.nodeType == 3) {\n boxes = textRange(child, 0, child.nodeValue.length).getClientRects();\n } else {\n continue;\n }\n\n for (var i = 0; i < boxes.length; i++) {\n var box = boxes[i];\n\n if (box.bottom > box.top && (dir == \"up\" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1)) {\n return false;\n }\n }\n }\n\n return true;\n });\n}\n\nvar maybeRTL = /[\\u0590-\\u08ac]/;\n\nfunction endOfTextblockHorizontal(view, state, dir) {\n var ref = state.selection;\n var $head = ref.$head;\n\n if (!$head.parent.isTextblock) {\n return false;\n }\n\n var offset = $head.parentOffset,\n atStart = !offset,\n atEnd = offset == $head.parent.content.size;\n var sel = getSelection(); // If the textblock is all LTR, or the browser doesn't support\n // Selection.modify (Edge), fall back to a primitive approach\n\n if (!maybeRTL.test($head.parent.textContent) || !sel.modify) {\n return dir == \"left\" || dir == \"backward\" ? atStart : atEnd;\n }\n\n return withFlushedState(view, state, function () {\n // This is a huge hack, but appears to be the best we can\n // currently do: use `Selection.modify` to move the selection by\n // one character, and see if that moves the cursor out of the\n // textblock (or doesn't move it at all, when at the start/end of\n // the document).\n var oldRange = sel.getRangeAt(0),\n oldNode = sel.focusNode,\n oldOff = sel.focusOffset;\n var oldBidiLevel = sel.caretBidiLevel; // Only for Firefox\n\n sel.modify(\"move\", dir, \"character\");\n var parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;\n var result = !parentDOM.contains(sel.focusNode.nodeType == 1 ? sel.focusNode : sel.focusNode.parentNode) || oldNode == sel.focusNode && oldOff == sel.focusOffset; // Restore the previous selection\n\n sel.removeAllRanges();\n sel.addRange(oldRange);\n\n if (oldBidiLevel != null) {\n sel.caretBidiLevel = oldBidiLevel;\n }\n\n return result;\n });\n}\n\nvar cachedState = null,\n cachedDir = null,\n cachedResult = false;\n\nfunction endOfTextblock(view, state, dir) {\n if (cachedState == state && cachedDir == dir) {\n return cachedResult;\n }\n\n cachedState = state;\n cachedDir = dir;\n return cachedResult = dir == \"up\" || dir == \"down\" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir);\n} // NodeView:: interface\n//\n// By default, document nodes are rendered using the result of the\n// [`toDOM`](#model.NodeSpec.toDOM) method of their spec, and managed\n// entirely by the editor. For some use cases, such as embedded\n// node-specific editing interfaces, you want more control over\n// the behavior of a node's in-editor representation, and need to\n// [define](#view.EditorProps.nodeViews) a custom node view.\n//\n// Objects returned as node views must conform to this interface.\n//\n// dom:: ?dom.Node\n// The outer DOM node that represents the document node. When not\n// given, the default strategy is used to create a DOM node.\n//\n// contentDOM:: ?dom.Node\n// The DOM node that should hold the node's content. Only meaningful\n// if the node view also defines a `dom` property and if its node\n// type is not a leaf node type. When this is present, ProseMirror\n// will take care of rendering the node's children into it. When it\n// is not present, the node view itself is responsible for rendering\n// (or deciding not to render) its child nodes.\n//\n// update:: ?(node: Node, decorations: [Decoration]) → bool\n// When given, this will be called when the view is updating itself.\n// It will be given a node (possibly of a different type), and an\n// array of active decorations (which are automatically drawn, and\n// the node view may ignore if it isn't interested in them), and\n// should return true if it was able to update to that node, and\n// false otherwise. If the node view has a `contentDOM` property (or\n// no `dom` property), updating its child nodes will be handled by\n// ProseMirror.\n//\n// selectNode:: ?()\n// Can be used to override the way the node's selected status (as a\n// node selection) is displayed.\n//\n// deselectNode:: ?()\n// When defining a `selectNode` method, you should also provide a\n// `deselectNode` method to remove the effect again.\n//\n// setSelection:: ?(anchor: number, head: number, root: dom.Document)\n// This will be called to handle setting the selection inside the\n// node. The `anchor` and `head` positions are relative to the start\n// of the node. By default, a DOM selection will be created between\n// the DOM positions corresponding to those positions, but if you\n// override it you can do something else.\n//\n// stopEvent:: ?(event: dom.Event) → bool\n// Can be used to prevent the editor view from trying to handle some\n// or all DOM events that bubble up from the node view. Events for\n// which this returns true are not handled by the editor.\n//\n// ignoreMutation:: ?(dom.MutationRecord) → bool\n// Called when a DOM\n// [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver)\n// or a selection change happens within the view. When the change is\n// a selection change, the record will have a `type` property of\n// `\"selection\"` (which doesn't occur for native mutation records).\n// Return false if the editor should re-read the selection or\n// re-parse the range around the mutation, true if it can safely be\n// ignored.\n//\n// destroy:: ?()\n// Called when the node view is removed from the editor or the whole\n// editor is destroyed.\n// View descriptions are data structures that describe the DOM that is\n// used to represent the editor's content. They are used for:\n//\n// - Incremental redrawing when the document changes\n//\n// - Figuring out what part of the document a given DOM position\n// corresponds to\n//\n// - Wiring in custom implementations of the editing interface for a\n// given node\n//\n// They form a doubly-linked mutable tree, starting at `view.docView`.\n\n\nvar NOT_DIRTY = 0,\n CHILD_DIRTY = 1,\n CONTENT_DIRTY = 2,\n NODE_DIRTY = 3; // Superclass for the various kinds of descriptions. Defines their\n// basic structure and shared methods.\n\nvar ViewDesc = function ViewDesc(parent, children, dom, contentDOM) {\n this.parent = parent;\n this.children = children;\n this.dom = dom; // An expando property on the DOM node provides a link back to its\n // description.\n\n dom.pmViewDesc = this; // This is the node that holds the child views. It may be null for\n // descs that don't have children.\n\n this.contentDOM = contentDOM;\n this.dirty = NOT_DIRTY;\n};\n\nvar prototypeAccessors = {\n beforePosition: {\n configurable: true\n },\n size: {\n configurable: true\n },\n border: {\n configurable: true\n },\n posBefore: {\n configurable: true\n },\n posAtStart: {\n configurable: true\n },\n posAfter: {\n configurable: true\n },\n posAtEnd: {\n configurable: true\n },\n contentLost: {\n configurable: true\n }\n}; // Used to check whether a given description corresponds to a\n// widget/mark/node.\n\nViewDesc.prototype.matchesWidget = function matchesWidget() {\n return false;\n};\n\nViewDesc.prototype.matchesMark = function matchesMark() {\n return false;\n};\n\nViewDesc.prototype.matchesNode = function matchesNode() {\n return false;\n};\n\nViewDesc.prototype.matchesHack = function matchesHack() {\n return false;\n};\n\nprototypeAccessors.beforePosition.get = function () {\n return false;\n}; // : () → ?ParseRule\n// When parsing in-editor content (in domchange.js), we allow\n// descriptions to determine the parse rules that should be used to\n// parse them.\n\n\nViewDesc.prototype.parseRule = function parseRule() {\n return null;\n}; // : (dom.Event) → bool\n// Used by the editor's event handler to ignore events that come\n// from certain descs.\n\n\nViewDesc.prototype.stopEvent = function stopEvent() {\n return false;\n}; // The size of the content represented by this desc.\n\n\nprototypeAccessors.size.get = function () {\n var size = 0;\n\n for (var i = 0; i < this.children.length; i++) {\n size += this.children[i].size;\n }\n\n return size;\n}; // For block nodes, this represents the space taken up by their\n// start/end tokens.\n\n\nprototypeAccessors.border.get = function () {\n return 0;\n};\n\nViewDesc.prototype.destroy = function destroy() {\n this.parent = null;\n\n if (this.dom.pmViewDesc == this) {\n this.dom.pmViewDesc = null;\n }\n\n for (var i = 0; i < this.children.length; i++) {\n this.children[i].destroy();\n }\n};\n\nViewDesc.prototype.posBeforeChild = function posBeforeChild(child) {\n for (var i = 0, pos = this.posAtStart; i < this.children.length; i++) {\n var cur = this.children[i];\n\n if (cur == child) {\n return pos;\n }\n\n pos += cur.size;\n }\n};\n\nprototypeAccessors.posBefore.get = function () {\n return this.parent.posBeforeChild(this);\n};\n\nprototypeAccessors.posAtStart.get = function () {\n return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;\n};\n\nprototypeAccessors.posAfter.get = function () {\n return this.posBefore + this.size;\n};\n\nprototypeAccessors.posAtEnd.get = function () {\n return this.posAtStart + this.size - 2 * this.border;\n}; // : (dom.Node, number, ?number) → number\n\n\nViewDesc.prototype.localPosFromDOM = function localPosFromDOM(dom, offset, bias) {\n // If the DOM position is in the content, use the child desc after\n // it to figure out a position.\n if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) {\n if (bias < 0) {\n var domBefore, desc;\n\n if (dom == this.contentDOM) {\n domBefore = dom.childNodes[offset - 1];\n } else {\n while (dom.parentNode != this.contentDOM) {\n dom = dom.parentNode;\n }\n\n domBefore = dom.previousSibling;\n }\n\n while (domBefore && !((desc = domBefore.pmViewDesc) && desc.parent == this)) {\n domBefore = domBefore.previousSibling;\n }\n\n return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart;\n } else {\n var domAfter, desc$1;\n\n if (dom == this.contentDOM) {\n domAfter = dom.childNodes[offset];\n } else {\n while (dom.parentNode != this.contentDOM) {\n dom = dom.parentNode;\n }\n\n domAfter = dom.nextSibling;\n }\n\n while (domAfter && !((desc$1 = domAfter.pmViewDesc) && desc$1.parent == this)) {\n domAfter = domAfter.nextSibling;\n }\n\n return domAfter ? this.posBeforeChild(desc$1) : this.posAtEnd;\n }\n } // Otherwise, use various heuristics, falling back on the bias\n // parameter, to determine whether to return the position at the\n // start or at the end of this view desc.\n\n\n var atEnd;\n\n if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {\n atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;\n } else if (this.dom.firstChild) {\n if (offset == 0) {\n for (var search = dom;; search = search.parentNode) {\n if (search == this.dom) {\n atEnd = false;\n break;\n }\n\n if (search.parentNode.firstChild != search) {\n break;\n }\n }\n }\n\n if (atEnd == null && offset == dom.childNodes.length) {\n for (var search$1 = dom;; search$1 = search$1.parentNode) {\n if (search$1 == this.dom) {\n atEnd = true;\n break;\n }\n\n if (search$1.parentNode.lastChild != search$1) {\n break;\n }\n }\n }\n }\n\n return (atEnd == null ? bias > 0 : atEnd) ? this.posAtEnd : this.posAtStart;\n}; // Scan up the dom finding the first desc that is a descendant of\n// this one.\n\n\nViewDesc.prototype.nearestDesc = function nearestDesc(dom, onlyNodes) {\n for (var first = true, cur = dom; cur; cur = cur.parentNode) {\n var desc = this.getDesc(cur);\n\n if (desc && (!onlyNodes || desc.node)) {\n // If dom is outside of this desc's nodeDOM, don't count it.\n if (first && desc.nodeDOM && !(desc.nodeDOM.nodeType == 1 ? desc.nodeDOM.contains(dom) : desc.nodeDOM == dom)) {\n first = false;\n } else {\n return desc;\n }\n }\n }\n};\n\nViewDesc.prototype.getDesc = function getDesc(dom) {\n var desc = dom.pmViewDesc;\n\n for (var cur = desc; cur; cur = cur.parent) {\n if (cur == this) {\n return desc;\n }\n }\n};\n\nViewDesc.prototype.posFromDOM = function posFromDOM(dom, offset, bias) {\n for (var scan = dom;; scan = scan.parentNode) {\n var desc = this.getDesc(scan);\n\n if (desc) {\n return desc.localPosFromDOM(dom, offset, bias);\n }\n }\n}; // : (number) → ?NodeViewDesc\n// Find the desc for the node after the given pos, if any. (When a\n// parent node overrode rendering, there might not be one.)\n\n\nViewDesc.prototype.descAt = function descAt(pos) {\n for (var i = 0, offset = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = offset + child.size;\n\n if (offset == pos && end != offset) {\n while (!child.border && child.children.length) {\n child = child.children[0];\n }\n\n return child;\n }\n\n if (pos < end) {\n return child.descAt(pos - offset - child.border);\n }\n\n offset = end;\n }\n}; // : (number) → {node: dom.Node, offset: number}\n\n\nViewDesc.prototype.domFromPos = function domFromPos(pos) {\n if (!this.contentDOM) {\n return {\n node: this.dom,\n offset: 0\n };\n }\n\n for (var offset = 0, i = 0;; i++) {\n if (offset == pos) {\n while (i < this.children.length && (this.children[i].beforePosition || this.children[i].dom.parentNode != this.contentDOM)) {\n i++;\n }\n\n return {\n node: this.contentDOM,\n offset: i == this.children.length ? this.contentDOM.childNodes.length : domIndex(this.children[i].dom)\n };\n }\n\n if (i == this.children.length) {\n throw new Error(\"Invalid position \" + pos);\n }\n\n var child = this.children[i],\n end = offset + child.size;\n\n if (pos < end) {\n return child.domFromPos(pos - offset - child.border);\n }\n\n offset = end;\n }\n}; // Used to find a DOM range in a single parent for a given changed\n// range.\n\n\nViewDesc.prototype.parseRange = function parseRange(from, to, base) {\n if (base === void 0) base = 0;\n\n if (this.children.length == 0) {\n return {\n node: this.contentDOM,\n from: from,\n to: to,\n fromOffset: 0,\n toOffset: this.contentDOM.childNodes.length\n };\n }\n\n var fromOffset = -1,\n toOffset = -1;\n\n for (var offset = base, i = 0;; i++) {\n var child = this.children[i],\n end = offset + child.size;\n\n if (fromOffset == -1 && from <= end) {\n var childBase = offset + child.border; // FIXME maybe descend mark views to parse a narrower range?\n\n if (from >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM)) {\n return child.parseRange(from, to, childBase);\n }\n\n from = offset;\n\n for (var j = i; j > 0; j--) {\n var prev = this.children[j - 1];\n\n if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) {\n fromOffset = domIndex(prev.dom) + 1;\n break;\n }\n\n from -= prev.size;\n }\n\n if (fromOffset == -1) {\n fromOffset = 0;\n }\n }\n\n if (fromOffset > -1 && to <= end) {\n to = end;\n\n for (var j$1 = i + 1; j$1 < this.children.length; j$1++) {\n var next = this.children[j$1];\n\n if (next.size && next.dom.parentNode == this.contentDOM && !next.emptyChildAt(-1)) {\n toOffset = domIndex(next.dom);\n break;\n }\n\n to += next.size;\n }\n\n if (toOffset == -1) {\n toOffset = this.contentDOM.childNodes.length;\n }\n\n break;\n }\n\n offset = end;\n }\n\n return {\n node: this.contentDOM,\n from: from,\n to: to,\n fromOffset: fromOffset,\n toOffset: toOffset\n };\n};\n\nViewDesc.prototype.emptyChildAt = function emptyChildAt(side) {\n if (this.border || !this.contentDOM || !this.children.length) {\n return false;\n }\n\n var child = this.children[side < 0 ? 0 : this.children.length - 1];\n return child.size == 0 || child.emptyChildAt(side);\n}; // : (number) → dom.Node\n\n\nViewDesc.prototype.domAfterPos = function domAfterPos(pos) {\n var ref = this.domFromPos(pos);\n var node = ref.node;\n var offset = ref.offset;\n\n if (node.nodeType != 1 || offset == node.childNodes.length) {\n throw new RangeError(\"No node after pos \" + pos);\n }\n\n return node.childNodes[offset];\n}; // : (number, number, dom.Document)\n// View descs are responsible for setting any selection that falls\n// entirely inside of them, so that custom implementations can do\n// custom things with the selection. Note that this falls apart when\n// a selection starts in such a node and ends in another, in which\n// case we just use whatever domFromPos produces as a best effort.\n\n\nViewDesc.prototype.setSelection = function setSelection(anchor, head, root, force) {\n // If the selection falls entirely in a child, give it to that child\n var from = Math.min(anchor, head),\n to = Math.max(anchor, head);\n\n for (var i = 0, offset = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = offset + child.size;\n\n if (from > offset && to < end) {\n return child.setSelection(anchor - offset - child.border, head - offset - child.border, root, force);\n }\n\n offset = end;\n }\n\n var anchorDOM = this.domFromPos(anchor),\n headDOM = this.domFromPos(head);\n var domSel = root.getSelection(),\n range = document.createRange();\n\n if (!force && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, domSel.focusNode, domSel.focusOffset)) {\n return;\n } // Selection.extend can be used to create an 'inverted' selection\n // (one where the focus is before the anchor), but not all\n // browsers support it yet.\n\n\n if (domSel.extend) {\n range.setEnd(anchorDOM.node, anchorDOM.offset);\n range.collapse(false);\n } else {\n if (anchor > head) {\n var tmp = anchorDOM;\n anchorDOM = headDOM;\n headDOM = tmp;\n }\n\n range.setEnd(headDOM.node, headDOM.offset);\n range.setStart(anchorDOM.node, anchorDOM.offset);\n }\n\n domSel.removeAllRanges();\n domSel.addRange(range);\n\n if (domSel.extend) {\n domSel.extend(headDOM.node, headDOM.offset);\n }\n}; // : (dom.MutationRecord) → bool\n\n\nViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) {\n return !this.contentDOM && mutation.type != \"selection\";\n};\n\nprototypeAccessors.contentLost.get = function () {\n return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);\n}; // Remove a subtree of the element tree that has been touched\n// by a DOM change, so that the next update will redraw it.\n\n\nViewDesc.prototype.markDirty = function markDirty(from, to) {\n for (var offset = 0, i = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = offset + child.size;\n\n if (offset == end ? from <= end && to >= offset : from < end && to > offset) {\n var startInside = offset + child.border,\n endInside = end - child.border;\n\n if (from >= startInside && to <= endInside) {\n this.dirty = from == offset || to == end ? CONTENT_DIRTY : CHILD_DIRTY;\n\n if (from == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM)) {\n child.dirty = NODE_DIRTY;\n } else {\n child.markDirty(from - startInside, to - startInside);\n }\n\n return;\n } else {\n child.dirty = NODE_DIRTY;\n }\n }\n\n offset = end;\n }\n\n this.dirty = CONTENT_DIRTY;\n};\n\nViewDesc.prototype.markParentsDirty = function markParentsDirty() {\n for (var node = this.parent; node; node = node.parent) {\n var dirty = CONTENT_DIRTY;\n\n if (node.dirty < dirty) {\n node.dirty = dirty;\n }\n }\n};\n\nObject.defineProperties(ViewDesc.prototype, prototypeAccessors); // Reused array to avoid allocating fresh arrays for things that will\n// stay empty anyway.\n\nvar nothing = []; // A widget desc represents a widget decoration, which is a DOM node\n// drawn between the document nodes.\n\nvar WidgetViewDesc = /*@__PURE__*/function (ViewDesc) {\n function WidgetViewDesc(parent, widget, view, pos) {\n var self,\n dom = widget.type.toDOM;\n\n if (typeof dom == \"function\") {\n dom = dom(view, function () {\n if (!self) {\n return pos;\n }\n\n if (self.parent) {\n return self.parent.posBeforeChild(self);\n }\n });\n }\n\n if (!widget.type.spec.raw) {\n if (dom.nodeType != 1) {\n var wrap = document.createElement(\"span\");\n wrap.appendChild(dom);\n dom = wrap;\n }\n\n dom.contentEditable = false;\n dom.classList.add(\"ProseMirror-widget\");\n }\n\n ViewDesc.call(this, parent, nothing, dom, null);\n this.widget = widget;\n self = this;\n }\n\n if (ViewDesc) WidgetViewDesc.__proto__ = ViewDesc;\n WidgetViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);\n WidgetViewDesc.prototype.constructor = WidgetViewDesc;\n var prototypeAccessors$1 = {\n beforePosition: {\n configurable: true\n }\n };\n\n prototypeAccessors$1.beforePosition.get = function () {\n return this.widget.type.side < 0;\n };\n\n WidgetViewDesc.prototype.matchesWidget = function matchesWidget(widget) {\n return this.dirty == NOT_DIRTY && widget.type.eq(this.widget.type);\n };\n\n WidgetViewDesc.prototype.parseRule = function parseRule() {\n return {\n ignore: true\n };\n };\n\n WidgetViewDesc.prototype.stopEvent = function stopEvent(event) {\n var stop = this.widget.spec.stopEvent;\n return stop ? stop(event) : false;\n };\n\n WidgetViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) {\n return mutation.type != \"selection\" || this.widget.spec.ignoreSelection;\n };\n\n Object.defineProperties(WidgetViewDesc.prototype, prototypeAccessors$1);\n return WidgetViewDesc;\n}(ViewDesc);\n\nvar CompositionViewDesc = /*@__PURE__*/function (ViewDesc) {\n function CompositionViewDesc(parent, dom, textDOM, text) {\n ViewDesc.call(this, parent, nothing, dom, null);\n this.textDOM = textDOM;\n this.text = text;\n }\n\n if (ViewDesc) CompositionViewDesc.__proto__ = ViewDesc;\n CompositionViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);\n CompositionViewDesc.prototype.constructor = CompositionViewDesc;\n var prototypeAccessors$2 = {\n size: {\n configurable: true\n }\n };\n\n prototypeAccessors$2.size.get = function () {\n return this.text.length;\n };\n\n CompositionViewDesc.prototype.localPosFromDOM = function localPosFromDOM(dom, offset) {\n if (dom != this.textDOM) {\n return this.posAtStart + (offset ? this.size : 0);\n }\n\n return this.posAtStart + offset;\n };\n\n CompositionViewDesc.prototype.domFromPos = function domFromPos(pos) {\n return {\n node: this.textDOM,\n offset: pos\n };\n };\n\n CompositionViewDesc.prototype.ignoreMutation = function ignoreMutation(mut) {\n return mut.type === 'characterData' && mut.target.nodeValue == mut.oldValue;\n };\n\n Object.defineProperties(CompositionViewDesc.prototype, prototypeAccessors$2);\n return CompositionViewDesc;\n}(ViewDesc); // A mark desc represents a mark. May have multiple children,\n// depending on how the mark is split. Note that marks are drawn using\n// a fixed nesting order, for simplicity and predictability, so in\n// some cases they will be split more often than would appear\n// necessary.\n\n\nvar MarkViewDesc = /*@__PURE__*/function (ViewDesc) {\n function MarkViewDesc(parent, mark, dom, contentDOM) {\n ViewDesc.call(this, parent, [], dom, contentDOM);\n this.mark = mark;\n }\n\n if (ViewDesc) MarkViewDesc.__proto__ = ViewDesc;\n MarkViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);\n MarkViewDesc.prototype.constructor = MarkViewDesc;\n\n MarkViewDesc.create = function create(parent, mark, inline, view) {\n var custom = view.nodeViews[mark.type.name];\n var spec = custom && custom(mark, view, inline);\n\n if (!spec || !spec.dom) {\n spec = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMSerializer\"].renderSpec(document, mark.type.spec.toDOM(mark, inline));\n }\n\n return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom);\n };\n\n MarkViewDesc.prototype.parseRule = function parseRule() {\n return {\n mark: this.mark.type.name,\n attrs: this.mark.attrs,\n contentElement: this.contentDOM\n };\n };\n\n MarkViewDesc.prototype.matchesMark = function matchesMark(mark) {\n return this.dirty != NODE_DIRTY && this.mark.eq(mark);\n };\n\n MarkViewDesc.prototype.markDirty = function markDirty(from, to) {\n ViewDesc.prototype.markDirty.call(this, from, to); // Move dirty info to nearest node view\n\n if (this.dirty != NOT_DIRTY) {\n var parent = this.parent;\n\n while (!parent.node) {\n parent = parent.parent;\n }\n\n if (parent.dirty < this.dirty) {\n parent.dirty = this.dirty;\n }\n\n this.dirty = NOT_DIRTY;\n }\n };\n\n MarkViewDesc.prototype.slice = function slice(from, to, view) {\n var copy = MarkViewDesc.create(this.parent, this.mark, true, view);\n var nodes = this.children,\n size = this.size;\n\n if (to < size) {\n nodes = replaceNodes(nodes, to, size, view);\n }\n\n if (from > 0) {\n nodes = replaceNodes(nodes, 0, from, view);\n }\n\n for (var i = 0; i < nodes.length; i++) {\n nodes[i].parent = copy;\n }\n\n copy.children = nodes;\n return copy;\n };\n\n return MarkViewDesc;\n}(ViewDesc); // Node view descs are the main, most common type of view desc, and\n// correspond to an actual node in the document. Unlike mark descs,\n// they populate their child array themselves.\n\n\nvar NodeViewDesc = /*@__PURE__*/function (ViewDesc) {\n function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos) {\n ViewDesc.call(this, parent, node.isLeaf ? nothing : [], dom, contentDOM);\n this.nodeDOM = nodeDOM;\n this.node = node;\n this.outerDeco = outerDeco;\n this.innerDeco = innerDeco;\n\n if (contentDOM) {\n this.updateChildren(view, pos);\n }\n }\n\n if (ViewDesc) NodeViewDesc.__proto__ = ViewDesc;\n NodeViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);\n NodeViewDesc.prototype.constructor = NodeViewDesc;\n var prototypeAccessors$3 = {\n size: {\n configurable: true\n },\n border: {\n configurable: true\n }\n }; // By default, a node is rendered using the `toDOM` method from the\n // node type spec. But client code can use the `nodeViews` spec to\n // supply a custom node view, which can influence various aspects of\n // the way the node works.\n //\n // (Using subclassing for this was intentionally decided against,\n // since it'd require exposing a whole slew of finnicky\n // implementation details to the user code that they probably will\n // never need.)\n\n NodeViewDesc.create = function create(parent, node, outerDeco, innerDeco, view, pos) {\n var assign;\n var custom = view.nodeViews[node.type.name],\n descObj;\n var spec = custom && custom(node, view, function () {\n // (This is a function that allows the custom view to find its\n // own position)\n if (!descObj) {\n return pos;\n }\n\n if (descObj.parent) {\n return descObj.parent.posBeforeChild(descObj);\n }\n }, outerDeco);\n var dom = spec && spec.dom,\n contentDOM = spec && spec.contentDOM;\n\n if (node.isText) {\n if (!dom) {\n dom = document.createTextNode(node.text);\n } else if (dom.nodeType != 3) {\n throw new RangeError(\"Text must be rendered as a DOM text node\");\n }\n } else if (!dom) {\n assign = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMSerializer\"].renderSpec(document, node.type.spec.toDOM(node)), dom = assign.dom, contentDOM = assign.contentDOM;\n }\n\n if (!contentDOM && !node.isText && dom.nodeName != \"BR\") {\n // Chrome gets confused by \n if (!dom.hasAttribute(\"contenteditable\")) {\n dom.contentEditable = false;\n }\n\n if (node.type.spec.draggable) {\n dom.draggable = true;\n }\n }\n\n var nodeDOM = dom;\n dom = applyOuterDeco(dom, outerDeco, node);\n\n if (spec) {\n return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos + 1);\n } else if (node.isText) {\n return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view);\n } else {\n return new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos + 1);\n }\n };\n\n NodeViewDesc.prototype.parseRule = function parseRule() {\n var this$1 = this; // Experimental kludge to allow opt-in re-parsing of nodes\n\n if (this.node.type.spec.reparseInView) {\n return null;\n } // FIXME the assumption that this can always return the current\n // attrs means that if the user somehow manages to change the\n // attrs in the dom, that won't be picked up. Not entirely sure\n // whether this is a problem\n\n\n var rule = {\n node: this.node.type.name,\n attrs: this.node.attrs\n };\n\n if (this.node.type.spec.code) {\n rule.preserveWhitespace = \"full\";\n }\n\n if (this.contentDOM && !this.contentLost) {\n rule.contentElement = this.contentDOM;\n } else {\n rule.getContent = function () {\n return this$1.contentDOM ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].empty : this$1.node.content;\n };\n }\n\n return rule;\n };\n\n NodeViewDesc.prototype.matchesNode = function matchesNode(node, outerDeco, innerDeco) {\n return this.dirty == NOT_DIRTY && node.eq(this.node) && sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco);\n };\n\n prototypeAccessors$3.size.get = function () {\n return this.node.nodeSize;\n };\n\n prototypeAccessors$3.border.get = function () {\n return this.node.isLeaf ? 0 : 1;\n }; // Syncs `this.children` to match `this.node.content` and the local\n // decorations, possibly introducing nesting for marks. Then, in a\n // separate step, syncs the DOM inside `this.contentDOM` to\n // `this.children`.\n\n\n NodeViewDesc.prototype.updateChildren = function updateChildren(view, pos) {\n var this$1 = this;\n var inline = this.node.inlineContent,\n off = pos;\n var composition = inline && view.composing && this.localCompositionNode(view, pos);\n var updater = new ViewTreeUpdater(this, composition && composition.node);\n iterDeco(this.node, this.innerDeco, function (widget, i, insideNode) {\n if (widget.spec.marks) {\n updater.syncToMarks(widget.spec.marks, inline, view);\n } else if (widget.type.side >= 0 && !insideNode) {\n updater.syncToMarks(i == this$1.node.childCount ? prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Mark\"].none : this$1.node.child(i).marks, inline, view);\n } // If the next node is a desc matching this widget, reuse it,\n // otherwise insert the widget as a new view desc.\n\n\n updater.placeWidget(widget, view, off);\n }, function (child, outerDeco, innerDeco, i) {\n // Make sure the wrapping mark descs match the node's marks.\n updater.syncToMarks(child.marks, inline, view); // Either find an existing desc that exactly matches this node,\n // and drop the descs before it.\n\n updater.findNodeMatch(child, outerDeco, innerDeco, i) || // Or try updating the next desc to reflect this node.\n updater.updateNextNode(child, outerDeco, innerDeco, view, i) || // Or just add it as a new desc.\n updater.addNode(child, outerDeco, innerDeco, view, off);\n off += child.nodeSize;\n }); // Drop all remaining descs after the current position.\n\n updater.syncToMarks(nothing, inline, view);\n\n if (this.node.isTextblock) {\n updater.addTextblockHacks();\n }\n\n updater.destroyRest(); // Sync the DOM if anything changed\n\n if (updater.changed || this.dirty == CONTENT_DIRTY) {\n // May have to protect focused DOM from being changed if a composition is active\n if (composition) {\n this.protectLocalComposition(view, composition);\n }\n\n this.renderChildren();\n }\n };\n\n NodeViewDesc.prototype.renderChildren = function renderChildren() {\n renderDescs(this.contentDOM, this.children);\n\n if (result.ios) {\n iosHacks(this.dom);\n }\n };\n\n NodeViewDesc.prototype.localCompositionNode = function localCompositionNode(view, pos) {\n // Only do something if both the selection and a focused text node\n // are inside of this node, and the node isn't already part of a\n // view that's a child of this view\n var ref = view.state.selection;\n var from = ref.from;\n var to = ref.to;\n\n if (!(view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) || from < pos || to > pos + this.node.content.size) {\n return;\n }\n\n var sel = view.root.getSelection();\n var textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);\n\n if (!textNode || !this.dom.contains(textNode.parentNode)) {\n return;\n } // Find the text in the focused node in the node, stop if it's not\n // there (may have been modified through other means, in which\n // case it should overwritten)\n\n\n var text = textNode.nodeValue;\n var textPos = findTextInFragment(this.node.content, text, from - pos, to - pos);\n return textPos < 0 ? null : {\n node: textNode,\n pos: textPos,\n text: text\n };\n };\n\n NodeViewDesc.prototype.protectLocalComposition = function protectLocalComposition(view, ref) {\n var node = ref.node;\n var pos = ref.pos;\n var text = ref.text; // The node is already part of a local view desc, leave it there\n\n if (this.getDesc(node)) {\n return;\n } // Create a composition view for the orphaned nodes\n\n\n var topNode = node;\n\n for (;; topNode = topNode.parentNode) {\n if (topNode.parentNode == this.contentDOM) {\n break;\n }\n\n while (topNode.previousSibling) {\n topNode.parentNode.removeChild(topNode.previousSibling);\n }\n\n while (topNode.nextSibling) {\n topNode.parentNode.removeChild(topNode.nextSibling);\n }\n\n if (topNode.pmViewDesc) {\n topNode.pmViewDesc = null;\n }\n }\n\n var desc = new CompositionViewDesc(this, topNode, node, text);\n view.compositionNodes.push(desc); // Patch up this.children to contain the composition view\n\n this.children = replaceNodes(this.children, pos, pos + text.length, view, desc);\n }; // : (Node, [Decoration], DecorationSet, EditorView) → bool\n // If this desc be updated to match the given node decoration,\n // do so and return true.\n\n\n NodeViewDesc.prototype.update = function update(node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY || !node.sameMarkup(this.node)) {\n return false;\n }\n\n this.updateInner(node, outerDeco, innerDeco, view);\n return true;\n };\n\n NodeViewDesc.prototype.updateInner = function updateInner(node, outerDeco, innerDeco, view) {\n this.updateOuterDeco(outerDeco);\n this.node = node;\n this.innerDeco = innerDeco;\n\n if (this.contentDOM) {\n this.updateChildren(view, this.posAtStart);\n }\n\n this.dirty = NOT_DIRTY;\n };\n\n NodeViewDesc.prototype.updateOuterDeco = function updateOuterDeco(outerDeco) {\n if (sameOuterDeco(outerDeco, this.outerDeco)) {\n return;\n }\n\n var needsWrap = this.nodeDOM.nodeType != 1;\n var oldDOM = this.dom;\n this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));\n\n if (this.dom != oldDOM) {\n oldDOM.pmViewDesc = null;\n this.dom.pmViewDesc = this;\n }\n\n this.outerDeco = outerDeco;\n }; // Mark this node as being the selected node.\n\n\n NodeViewDesc.prototype.selectNode = function selectNode() {\n this.nodeDOM.classList.add(\"ProseMirror-selectednode\");\n\n if (this.contentDOM || !this.node.type.spec.draggable) {\n this.dom.draggable = true;\n }\n }; // Remove selected node marking from this node.\n\n\n NodeViewDesc.prototype.deselectNode = function deselectNode() {\n this.nodeDOM.classList.remove(\"ProseMirror-selectednode\");\n\n if (this.contentDOM || !this.node.type.spec.draggable) {\n this.dom.draggable = false;\n }\n };\n\n Object.defineProperties(NodeViewDesc.prototype, prototypeAccessors$3);\n return NodeViewDesc;\n}(ViewDesc); // Create a view desc for the top-level document node, to be exported\n// and used by the view class.\n\n\nfunction docViewDesc(doc, outerDeco, innerDeco, dom, view) {\n applyOuterDeco(dom, outerDeco, doc);\n return new NodeViewDesc(null, doc, outerDeco, innerDeco, dom, dom, dom, view, 0);\n}\n\nvar TextViewDesc = /*@__PURE__*/function (NodeViewDesc) {\n function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view) {\n NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM, view);\n }\n\n if (NodeViewDesc) TextViewDesc.__proto__ = NodeViewDesc;\n TextViewDesc.prototype = Object.create(NodeViewDesc && NodeViewDesc.prototype);\n TextViewDesc.prototype.constructor = TextViewDesc;\n\n TextViewDesc.prototype.parseRule = function parseRule() {\n return {\n skip: this.nodeDOM.parentNode || true\n };\n };\n\n TextViewDesc.prototype.update = function update(node, outerDeco) {\n if (this.dirty == NODE_DIRTY || this.dirty != NOT_DIRTY && !this.inParent() || !node.sameMarkup(this.node)) {\n return false;\n }\n\n this.updateOuterDeco(outerDeco);\n\n if ((this.dirty != NOT_DIRTY || node.text != this.node.text) && node.text != this.nodeDOM.nodeValue) {\n this.nodeDOM.nodeValue = node.text;\n }\n\n this.node = node;\n this.dirty = NOT_DIRTY;\n return true;\n };\n\n TextViewDesc.prototype.inParent = function inParent() {\n var parentDOM = this.parent.contentDOM;\n\n for (var n = this.nodeDOM; n; n = n.parentNode) {\n if (n == parentDOM) {\n return true;\n }\n }\n\n return false;\n };\n\n TextViewDesc.prototype.domFromPos = function domFromPos(pos) {\n return {\n node: this.nodeDOM,\n offset: pos\n };\n };\n\n TextViewDesc.prototype.localPosFromDOM = function localPosFromDOM(dom, offset, bias) {\n if (dom == this.nodeDOM) {\n return this.posAtStart + Math.min(offset, this.node.text.length);\n }\n\n return NodeViewDesc.prototype.localPosFromDOM.call(this, dom, offset, bias);\n };\n\n TextViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) {\n return mutation.type != \"characterData\" && mutation.type != \"selection\";\n };\n\n TextViewDesc.prototype.slice = function slice(from, to, view) {\n var node = this.node.cut(from, to),\n dom = document.createTextNode(node.text);\n return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom, view);\n };\n\n return TextViewDesc;\n}(NodeViewDesc); // A dummy desc used to tag trailing BR or span nodes created to work\n// around contentEditable terribleness.\n\n\nvar BRHackViewDesc = /*@__PURE__*/function (ViewDesc) {\n function BRHackViewDesc() {\n ViewDesc.apply(this, arguments);\n }\n\n if (ViewDesc) BRHackViewDesc.__proto__ = ViewDesc;\n BRHackViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);\n BRHackViewDesc.prototype.constructor = BRHackViewDesc;\n\n BRHackViewDesc.prototype.parseRule = function parseRule() {\n return {\n ignore: true\n };\n };\n\n BRHackViewDesc.prototype.matchesHack = function matchesHack() {\n return this.dirty == NOT_DIRTY;\n };\n\n return BRHackViewDesc;\n}(ViewDesc); // A separate subclass is used for customized node views, so that the\n// extra checks only have to be made for nodes that are actually\n// customized.\n\n\nvar CustomNodeViewDesc = /*@__PURE__*/function (NodeViewDesc) {\n function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view, pos) {\n NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos);\n this.spec = spec;\n }\n\n if (NodeViewDesc) CustomNodeViewDesc.__proto__ = NodeViewDesc;\n CustomNodeViewDesc.prototype = Object.create(NodeViewDesc && NodeViewDesc.prototype);\n CustomNodeViewDesc.prototype.constructor = CustomNodeViewDesc; // A custom `update` method gets to decide whether the update goes\n // through. If it does, and there's a `contentDOM` node, our logic\n // updates the children.\n\n CustomNodeViewDesc.prototype.update = function update(node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY) {\n return false;\n }\n\n if (this.spec.update) {\n var result = this.spec.update(node, outerDeco);\n\n if (result) {\n this.updateInner(node, outerDeco, innerDeco, view);\n }\n\n return result;\n } else if (!this.contentDOM && !node.isLeaf) {\n return false;\n } else {\n return NodeViewDesc.prototype.update.call(this, node, outerDeco, innerDeco, view);\n }\n };\n\n CustomNodeViewDesc.prototype.selectNode = function selectNode() {\n this.spec.selectNode ? this.spec.selectNode() : NodeViewDesc.prototype.selectNode.call(this);\n };\n\n CustomNodeViewDesc.prototype.deselectNode = function deselectNode() {\n this.spec.deselectNode ? this.spec.deselectNode() : NodeViewDesc.prototype.deselectNode.call(this);\n };\n\n CustomNodeViewDesc.prototype.setSelection = function setSelection(anchor, head, root, force) {\n this.spec.setSelection ? this.spec.setSelection(anchor, head, root) : NodeViewDesc.prototype.setSelection.call(this, anchor, head, root, force);\n };\n\n CustomNodeViewDesc.prototype.destroy = function destroy() {\n if (this.spec.destroy) {\n this.spec.destroy();\n }\n\n NodeViewDesc.prototype.destroy.call(this);\n };\n\n CustomNodeViewDesc.prototype.stopEvent = function stopEvent(event) {\n return this.spec.stopEvent ? this.spec.stopEvent(event) : false;\n };\n\n CustomNodeViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) {\n return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : NodeViewDesc.prototype.ignoreMutation.call(this, mutation);\n };\n\n return CustomNodeViewDesc;\n}(NodeViewDesc); // : (dom.Node, [ViewDesc])\n// Sync the content of the given DOM node with the nodes associated\n// with the given array of view descs, recursing into mark descs\n// because this should sync the subtree for a whole node at a time.\n\n\nfunction renderDescs(parentDOM, descs) {\n var dom = parentDOM.firstChild;\n\n for (var i = 0; i < descs.length; i++) {\n var desc = descs[i],\n childDOM = desc.dom;\n\n if (childDOM.parentNode == parentDOM) {\n while (childDOM != dom) {\n dom = rm(dom);\n }\n\n dom = dom.nextSibling;\n } else {\n parentDOM.insertBefore(childDOM, dom);\n }\n\n if (desc instanceof MarkViewDesc) {\n var pos = dom ? dom.previousSibling : parentDOM.lastChild;\n renderDescs(desc.contentDOM, desc.children);\n dom = pos ? pos.nextSibling : parentDOM.firstChild;\n }\n }\n\n while (dom) {\n dom = rm(dom);\n }\n}\n\nfunction OuterDecoLevel(nodeName) {\n if (nodeName) {\n this.nodeName = nodeName;\n }\n}\n\nOuterDecoLevel.prototype = Object.create(null);\nvar noDeco = [new OuterDecoLevel()];\n\nfunction computeOuterDeco(outerDeco, node, needsWrap) {\n if (outerDeco.length == 0) {\n return noDeco;\n }\n\n var top = needsWrap ? noDeco[0] : new OuterDecoLevel(),\n result = [top];\n\n for (var i = 0; i < outerDeco.length; i++) {\n var attrs = outerDeco[i].type.attrs,\n cur = top;\n\n if (!attrs) {\n continue;\n }\n\n if (attrs.nodeName) {\n result.push(cur = new OuterDecoLevel(attrs.nodeName));\n }\n\n for (var name in attrs) {\n var val = attrs[name];\n\n if (val == null) {\n continue;\n }\n\n if (needsWrap && result.length == 1) {\n result.push(cur = top = new OuterDecoLevel(node.isInline ? \"span\" : \"div\"));\n }\n\n if (name == \"class\") {\n cur[\"class\"] = (cur[\"class\"] ? cur[\"class\"] + \" \" : \"\") + val;\n } else if (name == \"style\") {\n cur.style = (cur.style ? cur.style + \";\" : \"\") + val;\n } else if (name != \"nodeName\") {\n cur[name] = val;\n }\n }\n }\n\n return result;\n}\n\nfunction patchOuterDeco(outerDOM, nodeDOM, prevComputed, curComputed) {\n // Shortcut for trivial case\n if (prevComputed == noDeco && curComputed == noDeco) {\n return nodeDOM;\n }\n\n var curDOM = nodeDOM;\n\n for (var i = 0; i < curComputed.length; i++) {\n var deco = curComputed[i],\n prev = prevComputed[i];\n\n if (i) {\n var parent = void 0;\n\n if (prev && prev.nodeName == deco.nodeName && curDOM != outerDOM && (parent = curDOM.parentNode) && parent.tagName.toLowerCase() == deco.nodeName) {\n curDOM = parent;\n } else {\n parent = document.createElement(deco.nodeName);\n parent.appendChild(curDOM);\n prev = noDeco[0];\n curDOM = parent;\n }\n }\n\n patchAttributes(curDOM, prev || noDeco[0], deco);\n }\n\n return curDOM;\n}\n\nfunction patchAttributes(dom, prev, cur) {\n for (var name in prev) {\n if (name != \"class\" && name != \"style\" && name != \"nodeName\" && !(name in cur)) {\n dom.removeAttribute(name);\n }\n }\n\n for (var name$1 in cur) {\n if (name$1 != \"class\" && name$1 != \"style\" && name$1 != \"nodeName\" && cur[name$1] != prev[name$1]) {\n dom.setAttribute(name$1, cur[name$1]);\n }\n }\n\n if (prev[\"class\"] != cur[\"class\"]) {\n var prevList = prev[\"class\"] ? prev[\"class\"].split(\" \") : nothing;\n var curList = cur[\"class\"] ? cur[\"class\"].split(\" \") : nothing;\n\n for (var i = 0; i < prevList.length; i++) {\n if (curList.indexOf(prevList[i]) == -1) {\n dom.classList.remove(prevList[i]);\n }\n }\n\n for (var i$1 = 0; i$1 < curList.length; i$1++) {\n if (prevList.indexOf(curList[i$1]) == -1) {\n dom.classList.add(curList[i$1]);\n }\n }\n }\n\n if (prev.style != cur.style) {\n if (prev.style) {\n var prop = /\\s*([\\w\\-\\xa1-\\uffff]+)\\s*:(?:\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|\\(.*?\\)|[^;])*/g,\n m;\n\n while (m = prop.exec(prev.style)) {\n dom.style.removeProperty(m[1]);\n }\n }\n\n if (cur.style) {\n dom.style.cssText += cur.style;\n }\n }\n}\n\nfunction applyOuterDeco(dom, deco, node) {\n return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1));\n} // : ([Decoration], [Decoration]) → bool\n\n\nfunction sameOuterDeco(a, b) {\n if (a.length != b.length) {\n return false;\n }\n\n for (var i = 0; i < a.length; i++) {\n if (!a[i].type.eq(b[i].type)) {\n return false;\n }\n }\n\n return true;\n} // Remove a DOM node and return its next sibling.\n\n\nfunction rm(dom) {\n var next = dom.nextSibling;\n dom.parentNode.removeChild(dom);\n return next;\n} // Helper class for incrementally updating a tree of mark descs and\n// the widget and node descs inside of them.\n\n\nvar ViewTreeUpdater = function ViewTreeUpdater(top, lockedNode) {\n this.top = top;\n this.lock = lockedNode; // Index into `this.top`'s child array, represents the current\n // update position.\n\n this.index = 0; // When entering a mark, the current top and index are pushed\n // onto this.\n\n this.stack = []; // Tracks whether anything was changed\n\n this.changed = false;\n var pre = preMatch(top.node.content, top.children);\n this.preMatched = pre.nodes;\n this.preMatchOffset = pre.offset;\n};\n\nViewTreeUpdater.prototype.getPreMatch = function getPreMatch(index) {\n return index >= this.preMatchOffset ? this.preMatched[index - this.preMatchOffset] : null;\n}; // Destroy and remove the children between the given indices in\n// `this.top`.\n\n\nViewTreeUpdater.prototype.destroyBetween = function destroyBetween(start, end) {\n if (start == end) {\n return;\n }\n\n for (var i = start; i < end; i++) {\n this.top.children[i].destroy();\n }\n\n this.top.children.splice(start, end - start);\n this.changed = true;\n}; // Destroy all remaining children in `this.top`.\n\n\nViewTreeUpdater.prototype.destroyRest = function destroyRest() {\n this.destroyBetween(this.index, this.top.children.length);\n}; // : ([Mark], EditorView)\n// Sync the current stack of mark descs with the given array of\n// marks, reusing existing mark descs when possible.\n\n\nViewTreeUpdater.prototype.syncToMarks = function syncToMarks(marks, inline, view) {\n var keep = 0,\n depth = this.stack.length >> 1;\n var maxKeep = Math.min(depth, marks.length);\n\n while (keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[keep + 1 << 1]).matchesMark(marks[keep]) && marks[keep].type.spec.spanning !== false) {\n keep++;\n }\n\n while (keep < depth) {\n this.destroyRest();\n this.top.dirty = NOT_DIRTY;\n this.index = this.stack.pop();\n this.top = this.stack.pop();\n depth--;\n }\n\n while (depth < marks.length) {\n this.stack.push(this.top, this.index + 1);\n var found = -1;\n\n for (var i = this.index; i < Math.min(this.index + 3, this.top.children.length); i++) {\n if (this.top.children[i].matchesMark(marks[depth])) {\n found = i;\n break;\n }\n }\n\n if (found > -1) {\n if (found > this.index) {\n this.changed = true;\n this.destroyBetween(this.index, found);\n }\n\n this.top = this.top.children[this.index];\n } else {\n var markDesc = MarkViewDesc.create(this.top, marks[depth], inline, view);\n this.top.children.splice(this.index, 0, markDesc);\n this.top = markDesc;\n this.changed = true;\n }\n\n this.index = 0;\n depth++;\n }\n}; // : (Node, [Decoration], DecorationSet) → bool\n// Try to find a node desc matching the given data. Skip over it and\n// return true when successful.\n\n\nViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch(node, outerDeco, innerDeco, index) {\n var found = -1,\n preMatch = index < 0 ? undefined : this.getPreMatch(index),\n children = this.top.children;\n\n if (preMatch && preMatch.matchesNode(node, outerDeco, innerDeco)) {\n found = children.indexOf(preMatch);\n } else {\n for (var i = this.index, e = Math.min(children.length, i + 5); i < e; i++) {\n var child = children[i];\n\n if (child.matchesNode(node, outerDeco, innerDeco) && this.preMatched.indexOf(child) < 0) {\n found = i;\n break;\n }\n }\n }\n\n if (found < 0) {\n return false;\n }\n\n this.destroyBetween(this.index, found);\n this.index++;\n return true;\n}; // : (Node, [Decoration], DecorationSet, EditorView, Fragment, number) → bool\n// Try to update the next node, if any, to the given data. Checks\n// pre-matches to avoid overwriting nodes that could still be used.\n\n\nViewTreeUpdater.prototype.updateNextNode = function updateNextNode(node, outerDeco, innerDeco, view, index) {\n if (this.index == this.top.children.length) {\n return false;\n }\n\n var next = this.top.children[this.index];\n\n if (next instanceof NodeViewDesc) {\n var preMatch = this.preMatched.indexOf(next);\n\n if (preMatch > -1 && preMatch + this.preMatchOffset != index) {\n return false;\n }\n\n var nextDOM = next.dom; // Can't update if nextDOM is or contains this.lock, except if\n // it's a text node whose content already matches the new text\n // and whose decorations match the new ones.\n\n var locked = this.lock && (nextDOM == this.lock || nextDOM.nodeType == 1 && nextDOM.contains(this.lock.parentNode)) && !(node.isText && next.node && next.node.isText && next.nodeDOM.nodeValue == node.text && next.dirty != NODE_DIRTY && sameOuterDeco(outerDeco, next.outerDeco));\n\n if (!locked && next.update(node, outerDeco, innerDeco, view)) {\n if (next.dom != nextDOM) {\n this.changed = true;\n }\n\n this.index++;\n return true;\n }\n }\n\n return false;\n}; // : (Node, [Decoration], DecorationSet, EditorView)\n// Insert the node as a newly created node desc.\n\n\nViewTreeUpdater.prototype.addNode = function addNode(node, outerDeco, innerDeco, view, pos) {\n this.top.children.splice(this.index++, 0, NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view, pos));\n this.changed = true;\n};\n\nViewTreeUpdater.prototype.placeWidget = function placeWidget(widget, view, pos) {\n if (this.index < this.top.children.length && this.top.children[this.index].matchesWidget(widget)) {\n this.index++;\n } else {\n var desc = new WidgetViewDesc(this.top, widget, view, pos);\n this.top.children.splice(this.index++, 0, desc);\n this.changed = true;\n }\n}; // Make sure a textblock looks and behaves correctly in\n// contentEditable.\n\n\nViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks() {\n var lastChild = this.top.children[this.index - 1];\n\n while (lastChild instanceof MarkViewDesc) {\n lastChild = lastChild.children[lastChild.children.length - 1];\n }\n\n if (!lastChild || // Empty textblock\n !(lastChild instanceof TextViewDesc) || /\\n$/.test(lastChild.node.text)) {\n if (this.index < this.top.children.length && this.top.children[this.index].matchesHack()) {\n this.index++;\n } else {\n var dom = document.createElement(\"br\");\n this.top.children.splice(this.index++, 0, new BRHackViewDesc(this.top, nothing, dom, null));\n this.changed = true;\n }\n }\n}; // : (Fragment, [ViewDesc]) → [ViewDesc]\n// Iterate from the end of the fragment and array of descs to find\n// directly matching ones, in order to avoid overeagerly reusing\n// those for other nodes. Returns an array whose positions correspond\n// to node positions in the fragment, and whose elements are either\n// descs matched to the child at that index, or empty.\n\n\nfunction preMatch(frag, descs) {\n var result = [],\n end = frag.childCount;\n\n for (var i = descs.length - 1; end > 0 && i >= 0; i--) {\n var desc = descs[i],\n node = desc.node;\n\n if (!node) {\n continue;\n }\n\n if (node != frag.child(end - 1)) {\n break;\n }\n\n result.push(desc);\n --end;\n }\n\n return {\n nodes: result.reverse(),\n offset: end\n };\n}\n\nfunction compareSide(a, b) {\n return a.type.side - b.type.side;\n} // : (ViewDesc, DecorationSet, (Decoration, number), (Node, [Decoration], DecorationSet, number))\n// This function abstracts iterating over the nodes and decorations in\n// a fragment. Calls `onNode` for each node, with its local and child\n// decorations. Splits text nodes when there is a decoration starting\n// or ending inside of them. Calls `onWidget` for each widget.\n\n\nfunction iterDeco(parent, deco, onWidget, onNode) {\n var locals = deco.locals(parent),\n offset = 0; // Simple, cheap variant for when there are no local decorations\n\n if (locals.length == 0) {\n for (var i = 0; i < parent.childCount; i++) {\n var child = parent.child(i);\n onNode(child, locals, deco.forChild(offset, child), i);\n offset += child.nodeSize;\n }\n\n return;\n }\n\n var decoIndex = 0,\n active = [],\n restNode = null;\n\n for (var parentIndex = 0;;) {\n if (decoIndex < locals.length && locals[decoIndex].to == offset) {\n var widget = locals[decoIndex++],\n widgets = void 0;\n\n while (decoIndex < locals.length && locals[decoIndex].to == offset) {\n (widgets || (widgets = [widget])).push(locals[decoIndex++]);\n }\n\n if (widgets) {\n widgets.sort(compareSide);\n\n for (var i$1 = 0; i$1 < widgets.length; i$1++) {\n onWidget(widgets[i$1], parentIndex, !!restNode);\n }\n } else {\n onWidget(widget, parentIndex, !!restNode);\n }\n }\n\n var child$1 = void 0,\n index = void 0;\n\n if (restNode) {\n index = -1;\n child$1 = restNode;\n restNode = null;\n } else if (parentIndex < parent.childCount) {\n index = parentIndex;\n child$1 = parent.child(parentIndex++);\n } else {\n break;\n }\n\n for (var i$2 = 0; i$2 < active.length; i$2++) {\n if (active[i$2].to <= offset) {\n active.splice(i$2--, 1);\n }\n }\n\n while (decoIndex < locals.length && locals[decoIndex].from == offset) {\n active.push(locals[decoIndex++]);\n }\n\n var end = offset + child$1.nodeSize;\n\n if (child$1.isText) {\n var cutAt = end;\n\n if (decoIndex < locals.length && locals[decoIndex].from < cutAt) {\n cutAt = locals[decoIndex].from;\n }\n\n for (var i$3 = 0; i$3 < active.length; i$3++) {\n if (active[i$3].to < cutAt) {\n cutAt = active[i$3].to;\n }\n }\n\n if (cutAt < end) {\n restNode = child$1.cut(cutAt - offset);\n child$1 = child$1.cut(0, cutAt - offset);\n end = cutAt;\n index = -1;\n }\n }\n\n onNode(child$1, active.length ? active.slice() : nothing, deco.forChild(offset, child$1), index);\n offset = end;\n }\n} // List markers in Mobile Safari will mysteriously disappear\n// sometimes. This works around that.\n\n\nfunction iosHacks(dom) {\n if (dom.nodeName == \"UL\" || dom.nodeName == \"OL\") {\n var oldCSS = dom.style.cssText;\n dom.style.cssText = oldCSS + \"; list-style: square !important\";\n window.getComputedStyle(dom).listStyle;\n dom.style.cssText = oldCSS;\n }\n}\n\nfunction nearbyTextNode(node, offset) {\n for (;;) {\n if (node.nodeType == 3) {\n return node;\n }\n\n if (node.nodeType == 1 && offset > 0) {\n if (node.childNodes.length > offset && node.childNodes[offset].nodeType == 3) {\n return node.childNodes[offset];\n }\n\n node = node.childNodes[offset - 1];\n offset = nodeSize(node);\n } else if (node.nodeType == 1 && offset < node.childNodes.length) {\n node = node.childNodes[offset];\n offset = 0;\n } else {\n return null;\n }\n }\n} // Find a piece of text in an inline fragment, overlapping from-to\n\n\nfunction findTextInFragment(frag, text, from, to) {\n for (var i = 0, pos = 0; i < frag.childCount && pos <= to;) {\n var child = frag.child(i++),\n childStart = pos;\n pos += child.nodeSize;\n\n if (!child.isText) {\n continue;\n }\n\n var str = child.text;\n\n while (i < frag.childCount) {\n var next = frag.child(i++);\n pos += next.nodeSize;\n\n if (!next.isText) {\n break;\n }\n\n str += next.text;\n }\n\n if (pos >= from) {\n var found = str.lastIndexOf(text, to - childStart);\n\n if (found >= 0 && found + text.length + childStart >= from) {\n return childStart + found;\n }\n }\n }\n\n return -1;\n} // Replace range from-to in an array of view descs with replacement\n// (may be null to just delete). This goes very much against the grain\n// of the rest of this code, which tends to create nodes with the\n// right shape in one go, rather than messing with them after\n// creation, but is necessary in the composition hack.\n\n\nfunction replaceNodes(nodes, from, to, view, replacement) {\n var result = [];\n\n for (var i = 0, off = 0; i < nodes.length; i++) {\n var child = nodes[i],\n start = off,\n end = off += child.size;\n\n if (start >= to || end <= from) {\n result.push(child);\n } else {\n if (start < from) {\n result.push(child.slice(0, from - start, view));\n }\n\n if (replacement) {\n result.push(replacement);\n replacement = null;\n }\n\n if (end > to) {\n result.push(child.slice(to - start, child.size, view));\n }\n }\n }\n\n return result;\n}\n\nfunction moveSelectionBlock(state, dir) {\n var ref = state.selection;\n var $anchor = ref.$anchor;\n var $head = ref.$head;\n var $side = dir > 0 ? $anchor.max($head) : $anchor.min($head);\n var $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;\n return $start && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].findFrom($start, dir);\n}\n\nfunction apply(view, sel) {\n view.dispatch(view.state.tr.setSelection(sel).scrollIntoView());\n return true;\n}\n\nfunction selectHorizontally(view, dir, mods) {\n var sel = view.state.selection;\n\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) {\n if (!sel.empty || mods.indexOf(\"s\") > -1) {\n return false;\n } else if (view.endOfTextblock(dir > 0 ? \"right\" : \"left\")) {\n var next = moveSelectionBlock(view.state, dir);\n\n if (next && next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) {\n return apply(view, next);\n }\n\n return false;\n } else {\n var $head = sel.$head,\n node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter,\n desc;\n\n if (!node || node.isText) {\n return false;\n }\n\n var nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;\n\n if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) {\n return false;\n }\n\n if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"](dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));\n } else if (result.webkit) {\n // Chrome and Safari will introduce extra pointless cursor\n // positions around inline uneditable nodes, so we have to\n // take over and move the cursor past them (#937)\n return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"](view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));\n } else {\n return false;\n }\n }\n } else if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"] && sel.node.isInline) {\n return apply(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"](dir > 0 ? sel.$to : sel.$from));\n } else {\n var next$1 = moveSelectionBlock(view.state, dir);\n\n if (next$1) {\n return apply(view, next$1);\n }\n\n return false;\n }\n}\n\nfunction nodeLen(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\n\nfunction isIgnorable(dom) {\n var desc = dom.pmViewDesc;\n return desc && desc.size == 0 && (dom.nextSibling || dom.nodeName != \"BR\");\n} // Make sure the cursor isn't directly after one or more ignored\n// nodes, which will confuse the browser's cursor motion logic.\n\n\nfunction skipIgnoredNodesLeft(view) {\n var sel = view.root.getSelection();\n var node = sel.focusNode,\n offset = sel.focusOffset;\n\n if (!node) {\n return;\n }\n\n var moveNode,\n moveOffset,\n force = false; // Gecko will do odd things when the selection is directly in front\n // of a non-editable node, so in that case, move it into the next\n // node if possible. Issue prosemirror/prosemirror#832.\n\n if (result.gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset])) {\n force = true;\n }\n\n for (;;) {\n if (offset > 0) {\n if (node.nodeType != 1) {\n break;\n } else {\n var before = node.childNodes[offset - 1];\n\n if (isIgnorable(before)) {\n moveNode = node;\n moveOffset = --offset;\n } else if (before.nodeType == 3) {\n node = before;\n offset = node.nodeValue.length;\n } else {\n break;\n }\n }\n } else if (isBlockNode(node)) {\n break;\n } else {\n var prev = node.previousSibling;\n\n while (prev && isIgnorable(prev)) {\n moveNode = node.parentNode;\n moveOffset = domIndex(prev);\n prev = prev.previousSibling;\n }\n\n if (!prev) {\n node = node.parentNode;\n\n if (node == view.dom) {\n break;\n }\n\n offset = 0;\n } else {\n node = prev;\n offset = nodeLen(node);\n }\n }\n }\n\n if (force) {\n setSelFocus(view, sel, node, offset);\n } else if (moveNode) {\n setSelFocus(view, sel, moveNode, moveOffset);\n }\n} // Make sure the cursor isn't directly before one or more ignored\n// nodes.\n\n\nfunction skipIgnoredNodesRight(view) {\n var sel = view.root.getSelection();\n var node = sel.focusNode,\n offset = sel.focusOffset;\n\n if (!node) {\n return;\n }\n\n var len = nodeLen(node);\n var moveNode, moveOffset;\n\n for (;;) {\n if (offset < len) {\n if (node.nodeType != 1) {\n break;\n }\n\n var after = node.childNodes[offset];\n\n if (isIgnorable(after)) {\n moveNode = node;\n moveOffset = ++offset;\n } else {\n break;\n }\n } else if (isBlockNode(node)) {\n break;\n } else {\n var next = node.nextSibling;\n\n while (next && isIgnorable(next)) {\n moveNode = next.parentNode;\n moveOffset = domIndex(next) + 1;\n next = next.nextSibling;\n }\n\n if (!next) {\n node = node.parentNode;\n\n if (node == view.dom) {\n break;\n }\n\n offset = len = 0;\n } else {\n node = next;\n offset = 0;\n len = nodeLen(node);\n }\n }\n }\n\n if (moveNode) {\n setSelFocus(view, sel, moveNode, moveOffset);\n }\n}\n\nfunction isBlockNode(dom) {\n var desc = dom.pmViewDesc;\n return desc && desc.node && desc.node.isBlock;\n}\n\nfunction setSelFocus(view, sel, node, offset) {\n if (selectionCollapsed(sel)) {\n var range = document.createRange();\n range.setEnd(node, offset);\n range.setStart(node, offset);\n sel.removeAllRanges();\n sel.addRange(range);\n } else if (sel.extend) {\n sel.extend(node, offset);\n }\n\n view.domObserver.setCurSelection();\n} // : (EditorState, number)\n// Check whether vertical selection motion would involve node\n// selections. If so, apply it (if not, the result is left to the\n// browser)\n\n\nfunction selectVertically(view, dir, mods) {\n var sel = view.state.selection;\n\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"] && !sel.empty || mods.indexOf(\"s\") > -1) {\n return false;\n }\n\n var $from = sel.$from;\n var $to = sel.$to;\n\n if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? \"up\" : \"down\")) {\n var next = moveSelectionBlock(view.state, dir);\n\n if (next && next instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) {\n return apply(view, next);\n }\n }\n\n if (!$from.parent.inlineContent) {\n var beyond = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].findFrom(dir < 0 ? $from : $to, dir);\n return beyond ? apply(view, beyond) : true;\n }\n\n return false;\n}\n\nfunction stopNativeHorizontalDelete(view, dir) {\n if (!(view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"])) {\n return true;\n }\n\n var ref = view.state.selection;\n var $head = ref.$head;\n var $anchor = ref.$anchor;\n var empty = ref.empty;\n\n if (!$head.sameParent($anchor)) {\n return true;\n }\n\n if (!empty) {\n return false;\n }\n\n if (view.endOfTextblock(dir > 0 ? \"forward\" : \"backward\")) {\n return true;\n }\n\n var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter);\n\n if (nextNode && !nextNode.isText) {\n var tr = view.state.tr;\n\n if (dir < 0) {\n tr[\"delete\"]($head.pos - nextNode.nodeSize, $head.pos);\n } else {\n tr[\"delete\"]($head.pos, $head.pos + nextNode.nodeSize);\n }\n\n view.dispatch(tr);\n return true;\n }\n\n return false;\n}\n\nfunction switchEditable(view, node, state) {\n view.domObserver.stop();\n node.contentEditable = state;\n view.domObserver.start();\n} // Issue #867 / https://bugs.chromium.org/p/chromium/issues/detail?id=903821\n// In which Chrome does really wrong things when the down arrow is\n// pressed when the cursor is directly at the start of a textblock and\n// has an uneditable node after it\n\n\nfunction chromeDownArrowBug(view) {\n if (!result.chrome || view.state.selection.$head.parentOffset > 0) {\n return;\n }\n\n var ref = view.root.getSelection();\n var focusNode = ref.focusNode;\n var focusOffset = ref.focusOffset;\n\n if (focusNode && focusNode.nodeType == 1 && focusOffset == 0 && focusNode.firstChild && focusNode.firstChild.contentEditable == \"false\") {\n var child = focusNode.firstChild;\n switchEditable(view, child, true);\n setTimeout(function () {\n return switchEditable(view, child, false);\n }, 20);\n }\n} // A backdrop key mapping used to make sure we always suppress keys\n// that have a dangerous default effect, even if the commands they are\n// bound to return false, and to make sure that cursor-motion keys\n// find a cursor (as opposed to a node selection) when pressed. For\n// cursor-motion keys, the code in the handlers also takes care of\n// block selections.\n\n\nfunction getMods(event) {\n var result = \"\";\n\n if (event.ctrlKey) {\n result += \"c\";\n }\n\n if (event.metaKey) {\n result += \"m\";\n }\n\n if (event.altKey) {\n result += \"a\";\n }\n\n if (event.shiftKey) {\n result += \"s\";\n }\n\n return result;\n}\n\nfunction captureKeyDown(view, event) {\n var code = event.keyCode,\n mods = getMods(event);\n\n if (code == 8 || result.mac && code == 72 && mods == \"c\") {\n // Backspace, Ctrl-h on Mac\n return stopNativeHorizontalDelete(view, -1) || skipIgnoredNodesLeft(view);\n } else if (code == 46 || result.mac && code == 68 && mods == \"c\") {\n // Delete, Ctrl-d on Mac\n return stopNativeHorizontalDelete(view, 1) || skipIgnoredNodesRight(view);\n } else if (code == 13 && !result.ios || code == 27) {\n // Enter (let through on iOS, to avoid keyboard sync issues), Esc\n return true;\n } else if (code == 37) {\n // Left arrow\n return selectHorizontally(view, -1, mods) || skipIgnoredNodesLeft(view);\n } else if (code == 39) {\n // Right arrow\n return selectHorizontally(view, 1, mods) || skipIgnoredNodesRight(view);\n } else if (code == 38) {\n // Up arrow\n return selectVertically(view, -1, mods) || skipIgnoredNodesLeft(view);\n } else if (code == 40) {\n // Down arrow\n return chromeDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodesRight(view);\n } else if (mods == (result.mac ? \"m\" : \"c\") && (code == 66 || code == 73 || code == 89 || code == 90)) {\n // Mod-[biyz]\n return true;\n }\n\n return false;\n}\n\nfunction selectionFromDOM(view, origin) {\n var domSel = view.root.getSelection(),\n doc = view.state.doc;\n var nearestDesc = view.docView.nearestDesc(domSel.focusNode),\n inWidget = nearestDesc && nearestDesc.size == 0;\n var head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);\n var $head = doc.resolve(head),\n $anchor,\n selection;\n\n if (selectionCollapsed(domSel)) {\n $anchor = $head;\n\n while (nearestDesc && !nearestDesc.node) {\n nearestDesc = nearestDesc.parent;\n }\n\n if (nearestDesc && nearestDesc.node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(nearestDesc.node) && nearestDesc.parent && !(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {\n var pos = nearestDesc.posBefore;\n selection = new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"](head == pos ? $head : doc.resolve(pos));\n }\n } else {\n $anchor = doc.resolve(view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset));\n }\n\n if (!selection) {\n var bias = origin == \"pointer\" || view.state.selection.head < $head.pos && !inWidget ? 1 : -1;\n selection = selectionBetween(view, $anchor, $head, bias);\n }\n\n return selection;\n}\n\nfunction selectionToDOM(view, force) {\n var sel = view.state.selection;\n syncNodeSelection(view, sel);\n\n if (view.editable ? !view.hasFocus() : !(hasSelection(view) && document.activeElement.contains(view.dom))) {\n return;\n }\n\n view.domObserver.disconnectSelection();\n\n if (view.cursorWrapper) {\n selectCursorWrapper(view);\n } else {\n var anchor = sel.anchor;\n var head = sel.head;\n var resetEditableFrom, resetEditableTo;\n\n if (brokenSelectBetweenUneditable && !(sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"])) {\n if (!sel.$from.parent.inlineContent) {\n resetEditableFrom = temporarilyEditableNear(view, sel.from);\n }\n\n if (!sel.empty && !sel.$from.parent.inlineContent) {\n resetEditableTo = temporarilyEditableNear(view, sel.to);\n }\n }\n\n view.docView.setSelection(anchor, head, view.root, force);\n\n if (brokenSelectBetweenUneditable) {\n if (resetEditableFrom) {\n resetEditable(resetEditableFrom);\n }\n\n if (resetEditableTo) {\n resetEditable(resetEditableTo);\n }\n }\n\n if (sel.visible) {\n view.dom.classList.remove(\"ProseMirror-hideselection\");\n } else if (anchor != head) {\n view.dom.classList.add(\"ProseMirror-hideselection\");\n\n if (\"onselectionchange\" in document) {\n removeClassOnSelectionChange(view);\n }\n }\n }\n\n view.domObserver.setCurSelection();\n view.domObserver.connectSelection();\n} // Kludge to work around Webkit not allowing a selection to start/end\n// between non-editable block nodes. We briefly make something\n// editable, set the selection, then set it uneditable again.\n\n\nvar brokenSelectBetweenUneditable = result.safari || result.chrome && result.chrome_version < 63;\n\nfunction temporarilyEditableNear(view, pos) {\n var ref = view.docView.domFromPos(pos);\n var node = ref.node;\n var offset = ref.offset;\n var after = offset < node.childNodes.length ? node.childNodes[offset] : null;\n var before = offset ? node.childNodes[offset - 1] : null;\n\n if (result.safari && after && after.contentEditable == \"false\") {\n return setEditable(after);\n }\n\n if ((!after || after.contentEditable == \"false\") && (!before || before.contentEditable == \"false\")) {\n if (after) {\n return setEditable(after);\n } else if (before) {\n return setEditable(before);\n }\n }\n}\n\nfunction setEditable(element) {\n element.contentEditable = \"true\";\n\n if (result.safari && element.draggable) {\n element.draggable = false;\n element.wasDraggable = true;\n }\n\n return element;\n}\n\nfunction resetEditable(element) {\n element.contentEditable = \"false\";\n\n if (element.wasDraggable) {\n element.draggable = true;\n element.wasDraggable = null;\n }\n}\n\nfunction removeClassOnSelectionChange(view) {\n var doc = view.dom.ownerDocument;\n doc.removeEventListener(\"selectionchange\", view.hideSelectionGuard);\n var domSel = view.root.getSelection();\n var node = domSel.anchorNode,\n offset = domSel.anchorOffset;\n doc.addEventListener(\"selectionchange\", view.hideSelectionGuard = function () {\n if (domSel.anchorNode != node || domSel.anchorOffset != offset) {\n doc.removeEventListener(\"selectionchange\", view.hideSelectionGuard);\n view.dom.classList.remove(\"ProseMirror-hideselection\");\n }\n });\n}\n\nfunction selectCursorWrapper(view) {\n var domSel = view.root.getSelection(),\n range = document.createRange();\n var node = view.cursorWrapper.dom,\n img = node.nodeName == \"IMG\";\n\n if (img) {\n range.setEnd(node.parentNode, domIndex(node) + 1);\n } else {\n range.setEnd(node, 0);\n }\n\n range.collapse(false);\n domSel.removeAllRanges();\n domSel.addRange(range); // Kludge to kill 'control selection' in IE11 when selecting an\n // invisible cursor wrapper, since that would result in those weird\n // resize handles and a selection that considers the absolutely\n // positioned wrapper, rather than the root editable node, the\n // focused element.\n\n if (!img && !view.state.selection.visible && result.ie && result.ie_version <= 11) {\n node.disabled = true;\n node.disabled = false;\n }\n}\n\nfunction syncNodeSelection(view, sel) {\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) {\n var desc = view.docView.descAt(sel.from);\n\n if (desc != view.lastSelectedViewDesc) {\n clearNodeSelection(view);\n\n if (desc) {\n desc.selectNode();\n }\n\n view.lastSelectedViewDesc = desc;\n }\n } else {\n clearNodeSelection(view);\n }\n} // Clear all DOM statefulness of the last node selection.\n\n\nfunction clearNodeSelection(view) {\n if (view.lastSelectedViewDesc) {\n if (view.lastSelectedViewDesc.parent) {\n view.lastSelectedViewDesc.deselectNode();\n }\n\n view.lastSelectedViewDesc = null;\n }\n}\n\nfunction selectionBetween(view, $anchor, $head, bias) {\n return view.someProp(\"createSelectionBetween\", function (f) {\n return f(view, $anchor, $head);\n }) || prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"].between($anchor, $head, bias);\n}\n\nfunction hasFocusAndSelection(view) {\n if (view.editable && view.root.activeElement != view.dom) {\n return false;\n }\n\n return hasSelection(view);\n}\n\nfunction hasSelection(view) {\n var sel = view.root.getSelection();\n\n if (!sel.anchorNode) {\n return false;\n }\n\n try {\n // Firefox will raise 'permission denied' errors when accessing\n // properties of `sel.anchorNode` when it's in a generated CSS\n // element.\n return view.dom.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode) && (view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));\n } catch (_) {\n return false;\n }\n}\n\nfunction anchorInRightPlace(view) {\n var anchorDOM = view.docView.domFromPos(view.state.selection.anchor);\n var domSel = view.root.getSelection();\n return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset);\n} // Note that all referencing and parsing is done with the\n// start-of-operation selection and document, since that's the one\n// that the DOM represents. If any changes came in in the meantime,\n// the modification is mapped over those before it is applied, in\n// readDOMChange.\n\n\nfunction parseBetween(view, from_, to_) {\n var ref = view.docView.parseRange(from_, to_);\n var parent = ref.node;\n var fromOffset = ref.fromOffset;\n var toOffset = ref.toOffset;\n var from = ref.from;\n var to = ref.to;\n var domSel = view.root.getSelection(),\n find = null,\n anchor = domSel.anchorNode;\n\n if (anchor && view.dom.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {\n find = [{\n node: anchor,\n offset: domSel.anchorOffset\n }];\n\n if (!selectionCollapsed(domSel)) {\n find.push({\n node: domSel.focusNode,\n offset: domSel.focusOffset\n });\n }\n } // Work around issue in Chrome where backspacing sometimes replaces\n // the deleted content with a random BR node (issues #799, #831)\n\n\n if (result.chrome && view.lastKeyCode === 8) {\n for (var off = toOffset; off > fromOffset; off--) {\n var node = parent.childNodes[off - 1],\n desc = node.pmViewDesc;\n\n if (node.nodeType == \"BR\" && !desc) {\n toOffset = off;\n break;\n }\n\n if (!desc || desc.size) {\n break;\n }\n }\n }\n\n var startDoc = view.state.doc;\n var parser = view.someProp(\"domParser\") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMParser\"].fromSchema(view.state.schema);\n var $from = startDoc.resolve(from);\n var sel = null,\n doc = parser.parse(parent, {\n topNode: $from.parent,\n topMatch: $from.parent.contentMatchAt($from.index()),\n topOpen: true,\n from: fromOffset,\n to: toOffset,\n preserveWhitespace: $from.parent.type.spec.code ? \"full\" : true,\n editableContent: true,\n findPositions: find,\n ruleFromNode: ruleFromNode,\n context: $from\n });\n\n if (find && find[0].pos != null) {\n var anchor$1 = find[0].pos,\n head = find[1] && find[1].pos;\n\n if (head == null) {\n head = anchor$1;\n }\n\n sel = {\n anchor: anchor$1 + from,\n head: head + from\n };\n }\n\n return {\n doc: doc,\n sel: sel,\n from: from,\n to: to\n };\n}\n\nfunction ruleFromNode(dom) {\n var desc = dom.pmViewDesc;\n\n if (desc) {\n return desc.parseRule();\n } else if (dom.nodeName == \"BR\" && dom.parentNode) {\n // Safari replaces the list item or table cell with a BR\n // directly in the list node (?!) if you delete the last\n // character in a list item or table cell (#708, #862)\n if (result.safari && /^(ul|ol)$/i.test(dom.parentNode.nodeName)) {\n var skip = document.createElement(\"div\");\n skip.appendChild(document.createElement(\"li\"));\n return {\n skip: skip\n };\n } else if (dom.parentNode.lastChild == dom || result.safari && /^(tr|table)$/i.test(dom.parentNode.nodeName)) {\n return {\n ignore: true\n };\n }\n } else if (dom.nodeName == \"IMG\" && dom.getAttribute(\"mark-placeholder\")) {\n return {\n ignore: true\n };\n }\n}\n\nfunction readDOMChange(view, from, to, typeOver, addedNodes) {\n if (from < 0) {\n var origin = view.lastSelectionTime > Date.now() - 50 ? view.lastSelectionOrigin : null;\n var newSel = selectionFromDOM(view, origin);\n\n if (!view.state.selection.eq(newSel)) {\n var tr$1 = view.state.tr.setSelection(newSel);\n\n if (origin == \"pointer\") {\n tr$1.setMeta(\"pointer\", true);\n } else if (origin == \"key\") {\n tr$1.scrollIntoView();\n }\n\n view.dispatch(tr$1);\n }\n\n return;\n }\n\n var $before = view.state.doc.resolve(from);\n var shared = $before.sharedDepth(to);\n from = $before.before(shared + 1);\n to = view.state.doc.resolve(to).after(shared + 1);\n var sel = view.state.selection;\n var parse = parseBetween(view, from, to);\n var doc = view.state.doc,\n compare = doc.slice(parse.from, parse.to);\n var preferredPos, preferredSide; // Prefer anchoring to end when Backspace is pressed\n\n if (view.lastKeyCode === 8 && Date.now() - 100 < view.lastKeyCodeTime) {\n preferredPos = view.state.selection.to;\n preferredSide = \"end\";\n } else {\n preferredPos = view.state.selection.from;\n preferredSide = \"start\";\n }\n\n view.lastKeyCode = null;\n var change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);\n\n if (!change) {\n if (typeOver && sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"] && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {\n change = {\n start: sel.from,\n endA: sel.to,\n endB: sel.to\n };\n } else {\n if (parse.sel) {\n var sel$1 = resolveSelection(view, view.state.doc, parse.sel);\n\n if (sel$1 && !sel$1.eq(view.state.selection)) {\n view.dispatch(view.state.tr.setSelection(sel$1));\n }\n }\n\n return;\n }\n }\n\n view.domChangeCount++; // Handle the case where overwriting a selection by typing matches\n // the start or end of the selected content, creating a change\n // that's smaller than what was actually overwritten.\n\n if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) {\n if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2) {\n change.start = view.state.selection.from;\n } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2) {\n change.endB += view.state.selection.to - change.endA;\n change.endA = view.state.selection.to;\n }\n } // IE11 will insert a non-breaking space _ahead_ of the space after\n // the cursor space when adding a space before another space. When\n // that happened, adjust the change to cover the space instead.\n\n\n if (result.ie && result.ie_version <= 11 && change.endB == change.start + 1 && change.endA == change.start && change.start > parse.from && parse.doc.textBetween(change.start - parse.from - 1, change.start - parse.from + 1) == \" \\xA0\") {\n change.start--;\n change.endA--;\n change.endB--;\n }\n\n var $from = parse.doc.resolveNoCache(change.start - parse.from);\n var $to = parse.doc.resolveNoCache(change.endB - parse.from);\n var nextSel; // If this looks like the effect of pressing Enter (or was recorded\n // as being an iOS enter press), just dispatch an Enter key instead.\n\n if ((result.ios && view.lastIOSEnter > Date.now() - 100 && (!$from.sameParent($to) || addedNodes.some(function (n) {\n return n.nodeName == \"DIV\";\n })) || !$from.sameParent($to) && $from.pos < parse.doc.content.size && (nextSel = prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].findFrom(parse.doc.resolve($from.pos + 1), 1, true)) && nextSel.head == $to.pos) && view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(13, \"Enter\"));\n })) {\n view.lastIOSEnter = 0;\n return;\n } // Same for backspace\n\n\n if (view.state.selection.anchor > change.start && looksLikeJoin(doc, change.start, change.endA, $from, $to) && view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(8, \"Backspace\"));\n })) {\n if (result.android && result.chrome) {\n view.domObserver.suppressSelectionUpdates();\n } // #820\n\n\n return;\n }\n\n var chFrom = change.start,\n chTo = change.endA;\n var tr, storedMarks, markChange, $from1;\n\n if ($from.sameParent($to) && $from.parent.inlineContent) {\n if ($from.pos == $to.pos) {\n // Deletion\n // IE11 sometimes weirdly moves the DOM selection around after\n // backspacing out the first element in a textblock\n if (result.ie && result.ie_version <= 11 && $from.parentOffset == 0) {\n view.domObserver.suppressSelectionUpdates();\n setTimeout(function () {\n return selectionToDOM(view);\n }, 20);\n }\n\n tr = view.state.tr[\"delete\"](chFrom, chTo);\n storedMarks = doc.resolve(change.start).marksAcross(doc.resolve(change.endA));\n } else if ( // Adding or removing a mark\n change.endA == change.endB && ($from1 = doc.resolve(change.start)) && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))) {\n tr = view.state.tr;\n\n if (markChange.type == \"add\") {\n tr.addMark(chFrom, chTo, markChange.mark);\n } else {\n tr.removeMark(chFrom, chTo, markChange.mark);\n }\n } else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {\n // Both positions in the same text node -- simply insert text\n var text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);\n\n if (view.someProp(\"handleTextInput\", function (f) {\n return f(view, chFrom, chTo, text);\n })) {\n return;\n }\n\n tr = view.state.tr.insertText(text, chFrom, chTo);\n }\n }\n\n if (!tr) {\n tr = view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));\n }\n\n if (parse.sel) {\n var sel$2 = resolveSelection(view, tr.doc, parse.sel); // Chrome Android will sometimes, during composition, report the\n // selection in the wrong place. If it looks like that is\n // happening, don't update the selection.\n // Edge just doesn't move the cursor forward when you start typing\n // in an empty block or between br nodes.\n\n if (sel$2 && !(result.chrome && result.android && view.composing && sel$2.empty && sel$2.head == chFrom || result.ie && sel$2.empty && sel$2.head == chFrom)) {\n tr.setSelection(sel$2);\n }\n }\n\n if (storedMarks) {\n tr.ensureMarks(storedMarks);\n }\n\n view.dispatch(tr.scrollIntoView());\n}\n\nfunction resolveSelection(view, doc, parsedSel) {\n if (Math.max(parsedSel.anchor, parsedSel.head) > doc.content.size) {\n return null;\n }\n\n return selectionBetween(view, doc.resolve(parsedSel.anchor), doc.resolve(parsedSel.head));\n} // : (Fragment, Fragment) → ?{mark: Mark, type: string}\n// Given two same-length, non-empty fragments of inline content,\n// determine whether the first could be created from the second by\n// removing or adding a single mark type.\n\n\nfunction isMarkChange(cur, prev) {\n var curMarks = cur.firstChild.marks,\n prevMarks = prev.firstChild.marks;\n var added = curMarks,\n removed = prevMarks,\n type,\n mark,\n update;\n\n for (var i = 0; i < prevMarks.length; i++) {\n added = prevMarks[i].removeFromSet(added);\n }\n\n for (var i$1 = 0; i$1 < curMarks.length; i$1++) {\n removed = curMarks[i$1].removeFromSet(removed);\n }\n\n if (added.length == 1 && removed.length == 0) {\n mark = added[0];\n type = \"add\";\n\n update = function update(node) {\n return node.mark(mark.addToSet(node.marks));\n };\n } else if (added.length == 0 && removed.length == 1) {\n mark = removed[0];\n type = \"remove\";\n\n update = function update(node) {\n return node.mark(mark.removeFromSet(node.marks));\n };\n } else {\n return null;\n }\n\n var updated = [];\n\n for (var i$2 = 0; i$2 < prev.childCount; i$2++) {\n updated.push(update(prev.child(i$2)));\n }\n\n if (prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(updated).eq(cur)) {\n return {\n mark: mark,\n type: type\n };\n }\n}\n\nfunction looksLikeJoin(old, start, end, $newStart, $newEnd) {\n if (!$newStart.parent.isTextblock || // The content must have shrunk\n end - start <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into\n skipClosingAndOpening($newStart, true, false) < $newEnd.pos) {\n return false;\n }\n\n var $start = old.resolve(start); // Start must be at the end of a block\n\n if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock) {\n return false;\n }\n\n var $next = old.resolve(skipClosingAndOpening($start, true, true)); // The next textblock must start before end and end near it\n\n if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) {\n return false;\n } // The fragments after the join point must match\n\n\n return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);\n}\n\nfunction skipClosingAndOpening($pos, fromEnd, mayOpen) {\n var depth = $pos.depth,\n end = fromEnd ? $pos.end() : $pos.pos;\n\n while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {\n depth--;\n end++;\n fromEnd = false;\n }\n\n if (mayOpen) {\n var next = $pos.node(depth).maybeChild($pos.indexAfter(depth));\n\n while (next && !next.isLeaf) {\n next = next.firstChild;\n end++;\n }\n }\n\n return end;\n}\n\nfunction findDiff(a, b, pos, preferredPos, preferredSide) {\n var start = a.findDiffStart(b, pos);\n\n if (start == null) {\n return null;\n }\n\n var ref = a.findDiffEnd(b, pos + a.size, pos + b.size);\n var endA = ref.a;\n var endB = ref.b;\n\n if (preferredSide == \"end\") {\n var adjust = Math.max(0, start - Math.min(endA, endB));\n preferredPos -= endA + adjust - start;\n }\n\n if (endA < start && a.size < b.size) {\n var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0;\n start -= move;\n endB = start + (endB - endA);\n endA = start;\n } else if (endB < start) {\n var move$1 = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0;\n start -= move$1;\n endA = start + (endA - endB);\n endB = start;\n }\n\n return {\n start: start,\n endA: endA,\n endB: endB\n };\n}\n\nfunction serializeForClipboard(view, slice) {\n var context = [];\n var content = slice.content;\n var openStart = slice.openStart;\n var openEnd = slice.openEnd;\n\n while (openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild.childCount == 1) {\n openStart--;\n openEnd--;\n var node = content.firstChild;\n context.push(node.type.name, node.type.hasRequiredAttrs() ? node.attrs : null);\n content = node.content;\n }\n\n var serializer = view.someProp(\"clipboardSerializer\") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMSerializer\"].fromSchema(view.state.schema);\n var doc = detachedDoc(),\n wrap = doc.createElement(\"div\");\n wrap.appendChild(serializer.serializeFragment(content, {\n document: doc\n }));\n var firstChild = wrap.firstChild,\n needsWrap;\n\n while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {\n for (var i = needsWrap.length - 1; i >= 0; i--) {\n var wrapper = doc.createElement(needsWrap[i]);\n\n while (wrap.firstChild) {\n wrapper.appendChild(wrap.firstChild);\n }\n\n wrap.appendChild(wrapper);\n }\n\n firstChild = wrap.firstChild;\n }\n\n if (firstChild && firstChild.nodeType == 1) {\n firstChild.setAttribute(\"data-pm-slice\", openStart + \" \" + openEnd + \" \" + JSON.stringify(context));\n }\n\n var text = view.someProp(\"clipboardTextSerializer\", function (f) {\n return f(slice);\n }) || slice.content.textBetween(0, slice.content.size, \"\\n\\n\");\n return {\n dom: wrap,\n text: text\n };\n} // : (EditorView, string, string, ?bool, ResolvedPos) → ?Slice\n// Read a slice of content from the clipboard (or drop data).\n\n\nfunction parseFromClipboard(view, text, html, plainText, $context) {\n var dom,\n inCode = $context.parent.type.spec.code,\n slice;\n\n if (!html && !text) {\n return null;\n }\n\n var asText = text && (plainText || inCode || !html);\n\n if (asText) {\n view.someProp(\"transformPastedText\", function (f) {\n text = f(text);\n });\n\n if (inCode) {\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(view.state.schema.text(text)), 0, 0);\n }\n\n var parsed = view.someProp(\"clipboardTextParser\", function (f) {\n return f(text, $context);\n });\n\n if (parsed) {\n slice = parsed;\n } else {\n dom = document.createElement(\"div\");\n text.trim().split(/(?:\\r\\n?|\\n)+/).forEach(function (block) {\n dom.appendChild(document.createElement(\"p\")).textContent = block;\n });\n }\n } else {\n view.someProp(\"transformPastedHTML\", function (f) {\n html = f(html);\n });\n dom = readHTML(html);\n }\n\n var contextNode = dom && dom.querySelector(\"[data-pm-slice]\");\n var sliceData = contextNode && /^(\\d+) (\\d+) (.*)/.exec(contextNode.getAttribute(\"data-pm-slice\"));\n\n if (!slice) {\n var parser = view.someProp(\"clipboardParser\") || view.someProp(\"domParser\") || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"DOMParser\"].fromSchema(view.state.schema);\n slice = parser.parseSlice(dom, {\n preserveWhitespace: !!(asText || sliceData),\n context: $context\n });\n }\n\n if (sliceData) {\n slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[3]);\n } else // HTML wasn't created by ProseMirror. Make sure top-level siblings are coherent\n {\n slice = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"].maxOpen(normalizeSiblings(slice.content, $context), false);\n }\n\n view.someProp(\"transformPasted\", function (f) {\n slice = f(slice);\n });\n return slice;\n} // Takes a slice parsed with parseSlice, which means there hasn't been\n// any content-expression checking done on the top nodes, tries to\n// find a parent node in the current context that might fit the nodes,\n// and if successful, rebuilds the slice so that it fits into that parent.\n//\n// This addresses the problem that Transform.replace expects a\n// coherent slice, and will fail to place a set of siblings that don't\n// fit anywhere in the schema.\n\n\nfunction normalizeSiblings(fragment, $context) {\n if (fragment.childCount < 2) {\n return fragment;\n }\n\n var loop = function loop(d) {\n var parent = $context.node(d);\n var match = parent.contentMatchAt($context.index(d));\n var lastWrap = void 0,\n result = [];\n fragment.forEach(function (node) {\n if (!result) {\n return;\n }\n\n var wrap = match.findWrapping(node.type),\n inLast;\n\n if (!wrap) {\n return result = null;\n }\n\n if (inLast = result.length && lastWrap.length && addToSibling(wrap, lastWrap, node, result[result.length - 1], 0)) {\n result[result.length - 1] = inLast;\n } else {\n if (result.length) {\n result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length);\n }\n\n var wrapped = withWrappers(node, wrap);\n result.push(wrapped);\n match = match.matchType(wrapped.type, wrapped.attrs);\n lastWrap = wrap;\n }\n });\n\n if (result) {\n return {\n v: prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(result)\n };\n }\n };\n\n for (var d = $context.depth; d >= 0; d--) {\n var returned = loop(d);\n if (returned) return returned.v;\n }\n\n return fragment;\n}\n\nfunction withWrappers(node, wrap, from) {\n if (from === void 0) from = 0;\n\n for (var i = wrap.length - 1; i >= from; i--) {\n node = wrap[i].create(null, prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(node));\n }\n\n return node;\n} // Used to group adjacent nodes wrapped in similar parents by\n// normalizeSiblings into the same parent node\n\n\nfunction addToSibling(wrap, lastWrap, node, sibling, depth) {\n if (depth < wrap.length && depth < lastWrap.length && wrap[depth] == lastWrap[depth]) {\n var inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1);\n\n if (inner) {\n return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));\n }\n\n var match = sibling.contentMatchAt(sibling.childCount);\n\n if (match.matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1])) {\n return sibling.copy(sibling.content.append(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(withWrappers(node, wrap, depth + 1))));\n }\n }\n}\n\nfunction closeRight(node, depth) {\n if (depth == 0) {\n return node;\n }\n\n var fragment = node.content.replaceChild(node.childCount - 1, closeRight(node.lastChild, depth - 1));\n var fill = node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].empty, true);\n return node.copy(fragment.append(fill));\n}\n\nfunction closeRange(fragment, side, from, to, depth, openEnd) {\n var node = side < 0 ? fragment.firstChild : fragment.lastChild,\n inner = node.content;\n\n if (depth < to - 1) {\n inner = closeRange(inner, side, from, to, depth + 1, openEnd);\n }\n\n if (depth >= from) {\n inner = side < 0 ? node.contentMatchAt(0).fillBefore(inner, fragment.childCount > 1 || openEnd <= depth).append(inner) : inner.append(node.contentMatchAt(node.childCount).fillBefore(prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].empty, true));\n }\n\n return fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node.copy(inner));\n}\n\nfunction closeSlice(slice, openStart, openEnd) {\n if (openStart < slice.openStart) {\n slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd);\n }\n\n if (openEnd < slice.openEnd) {\n slice = new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](closeRange(slice.content, 1, openEnd, slice.openEnd, 0, 0), slice.openStart, openEnd);\n }\n\n return slice;\n} // Trick from jQuery -- some elements must be wrapped in other\n// elements for innerHTML to work. I.e. if you do `div.innerHTML =\n// \".. \"` the table cells are ignored.\n\n\nvar wrapMap = {\n thead: [\"table\"],\n tbody: [\"table\"],\n tfoot: [\"table\"],\n caption: [\"table\"],\n colgroup: [\"table\"],\n col: [\"table\", \"colgroup\"],\n tr: [\"table\", \"tbody\"],\n td: [\"table\", \"tbody\", \"tr\"],\n th: [\"table\", \"tbody\", \"tr\"]\n};\nvar _detachedDoc = null;\n\nfunction detachedDoc() {\n return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument(\"title\"));\n}\n\nfunction readHTML(html) {\n var metas = /(\\s* ]*>)*/.exec(html);\n\n if (metas) {\n html = html.slice(metas[0].length);\n }\n\n var elt = detachedDoc().createElement(\"div\");\n var firstTag = /(?: ]*>)*<([a-z][^>\\s]+)/i.exec(html),\n wrap,\n depth = 0;\n\n if (wrap = firstTag && wrapMap[firstTag[1].toLowerCase()]) {\n html = wrap.map(function (n) {\n return \"<\" + n + \">\";\n }).join(\"\") + html + wrap.map(function (n) {\n return \"\" + n + \">\";\n }).reverse().join(\"\");\n depth = wrap.length;\n }\n\n elt.innerHTML = html;\n\n for (var i = 0; i < depth; i++) {\n elt = elt.firstChild;\n }\n\n return elt;\n}\n\nfunction addContext(slice, context) {\n if (!slice.size) {\n return slice;\n }\n\n var schema = slice.content.firstChild.type.schema,\n array;\n\n try {\n array = JSON.parse(context);\n } catch (e) {\n return slice;\n }\n\n var content = slice.content;\n var openStart = slice.openStart;\n var openEnd = slice.openEnd;\n\n for (var i = array.length - 2; i >= 0; i -= 2) {\n var type = schema.nodes[array[i]];\n\n if (!type || type.hasRequiredAttrs()) {\n break;\n }\n\n content = prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Fragment\"].from(type.create(array[i + 1], content));\n openStart++;\n openEnd++;\n }\n\n return new prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"](content, openStart, openEnd);\n}\n\nvar observeOptions = {\n childList: true,\n characterData: true,\n characterDataOldValue: true,\n attributes: true,\n attributeOldValue: true,\n subtree: true\n}; // IE11 has very broken mutation observers, so we also listen to DOMCharacterDataModified\n\nvar useCharData = result.ie && result.ie_version <= 11;\n\nvar SelectionState = function SelectionState() {\n this.anchorNode = this.anchorOffset = this.focusNode = this.focusOffset = null;\n};\n\nSelectionState.prototype.set = function set(sel) {\n this.anchorNode = sel.anchorNode;\n this.anchorOffset = sel.anchorOffset;\n this.focusNode = sel.focusNode;\n this.focusOffset = sel.focusOffset;\n};\n\nSelectionState.prototype.eq = function eq(sel) {\n return sel.anchorNode == this.anchorNode && sel.anchorOffset == this.anchorOffset && sel.focusNode == this.focusNode && sel.focusOffset == this.focusOffset;\n};\n\nvar DOMObserver = function DOMObserver(view, handleDOMChange) {\n var this$1 = this;\n this.view = view;\n this.handleDOMChange = handleDOMChange;\n this.queue = [];\n this.flushingSoon = false;\n this.observer = window.MutationObserver && new window.MutationObserver(function (mutations) {\n for (var i = 0; i < mutations.length; i++) {\n this$1.queue.push(mutations[i]);\n } // IE11 will sometimes (on backspacing out a single character\n // text node after a BR node) call the observer callback\n // before actually updating the DOM, which will cause\n // ProseMirror to miss the change (see #930)\n\n\n if (result.ie && result.ie_version <= 11 && mutations.some(function (m) {\n return m.type == \"childList\" && m.removedNodes.length || m.type == \"characterData\" && m.oldValue.length > m.target.nodeValue.length;\n })) {\n this$1.flushSoon();\n } else {\n this$1.flush();\n }\n });\n this.currentSelection = new SelectionState();\n\n if (useCharData) {\n this.onCharData = function (e) {\n this$1.queue.push({\n target: e.target,\n type: \"characterData\",\n oldValue: e.prevValue\n });\n this$1.flushSoon();\n };\n }\n\n this.onSelectionChange = this.onSelectionChange.bind(this);\n this.suppressingSelectionUpdates = false;\n};\n\nDOMObserver.prototype.flushSoon = function flushSoon() {\n var this$1 = this;\n\n if (!this.flushingSoon) {\n this.flushingSoon = true;\n window.setTimeout(function () {\n this$1.flushingSoon = false;\n this$1.flush();\n }, 20);\n }\n};\n\nDOMObserver.prototype.start = function start() {\n if (this.observer) {\n this.observer.observe(this.view.dom, observeOptions);\n }\n\n if (useCharData) {\n this.view.dom.addEventListener(\"DOMCharacterDataModified\", this.onCharData);\n }\n\n this.connectSelection();\n};\n\nDOMObserver.prototype.stop = function stop() {\n var this$1 = this;\n\n if (this.observer) {\n var take = this.observer.takeRecords();\n\n if (take.length) {\n for (var i = 0; i < take.length; i++) {\n this.queue.push(take[i]);\n }\n\n window.setTimeout(function () {\n return this$1.flush();\n }, 20);\n }\n\n this.observer.disconnect();\n }\n\n if (useCharData) {\n this.view.dom.removeEventListener(\"DOMCharacterDataModified\", this.onCharData);\n }\n\n this.disconnectSelection();\n};\n\nDOMObserver.prototype.connectSelection = function connectSelection() {\n this.view.dom.ownerDocument.addEventListener(\"selectionchange\", this.onSelectionChange);\n};\n\nDOMObserver.prototype.disconnectSelection = function disconnectSelection() {\n this.view.dom.ownerDocument.removeEventListener(\"selectionchange\", this.onSelectionChange);\n};\n\nDOMObserver.prototype.suppressSelectionUpdates = function suppressSelectionUpdates() {\n var this$1 = this;\n this.suppressingSelectionUpdates = true;\n setTimeout(function () {\n return this$1.suppressingSelectionUpdates = false;\n }, 50);\n};\n\nDOMObserver.prototype.onSelectionChange = function onSelectionChange() {\n if (!hasFocusAndSelection(this.view)) {\n return;\n }\n\n if (this.suppressingSelectionUpdates) {\n return selectionToDOM(this.view);\n } // Deletions on IE11 fire their events in the wrong order, giving\n // us a selection change event before the DOM changes are\n // reported.\n\n\n if (result.ie && result.ie_version <= 11 && !this.view.state.selection.empty) {\n var sel = this.view.root.getSelection(); // Selection.isCollapsed isn't reliable on IE\n\n if (sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset)) {\n return this.flushSoon();\n }\n }\n\n this.flush();\n};\n\nDOMObserver.prototype.setCurSelection = function setCurSelection() {\n this.currentSelection.set(this.view.root.getSelection());\n};\n\nDOMObserver.prototype.ignoreSelectionChange = function ignoreSelectionChange(sel) {\n if (sel.rangeCount == 0) {\n return true;\n }\n\n var container = sel.getRangeAt(0).commonAncestorContainer;\n var desc = this.view.docView.nearestDesc(container);\n\n if (desc && desc.ignoreMutation({\n type: \"selection\",\n target: container.nodeType == 3 ? container.parentNode : container\n })) {\n this.setCurSelection();\n return true;\n }\n};\n\nDOMObserver.prototype.flush = function flush() {\n if (!this.view.docView || this.flushingSoon) {\n return;\n }\n\n var mutations = this.observer ? this.observer.takeRecords() : [];\n\n if (this.queue.length) {\n mutations = this.queue.concat(mutations);\n this.queue.length = 0;\n }\n\n var sel = this.view.root.getSelection();\n var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel);\n var from = -1,\n to = -1,\n typeOver = false,\n added = [];\n\n if (this.view.editable) {\n for (var i = 0; i < mutations.length; i++) {\n var result$1 = this.registerMutation(mutations[i], added);\n\n if (result$1) {\n from = from < 0 ? result$1.from : Math.min(result$1.from, from);\n to = to < 0 ? result$1.to : Math.max(result$1.to, to);\n\n if (result$1.typeOver && !this.view.composing) {\n typeOver = true;\n }\n }\n }\n }\n\n if (result.gecko && added.length > 1) {\n var brs = added.filter(function (n) {\n return n.nodeName == \"BR\";\n });\n\n if (brs.length == 2) {\n var a = brs[0];\n var b = brs[1];\n\n if (a.parentNode && a.parentNode.parentNode == b.parentNode) {\n b.remove();\n } else {\n a.remove();\n }\n }\n }\n\n if (from > -1 || newSel) {\n if (from > -1) {\n this.view.docView.markDirty(from, to);\n checkCSS(this.view);\n }\n\n this.handleDOMChange(from, to, typeOver, added);\n\n if (this.view.docView.dirty) {\n this.view.updateState(this.view.state);\n } else if (!this.currentSelection.eq(sel)) {\n selectionToDOM(this.view);\n }\n }\n};\n\nDOMObserver.prototype.registerMutation = function registerMutation(mut, added) {\n // Ignore mutations inside nodes that were already noted as inserted\n if (added.indexOf(mut.target) > -1) {\n return null;\n }\n\n var desc = this.view.docView.nearestDesc(mut.target);\n\n if (mut.type == \"attributes\" && (desc == this.view.docView || mut.attributeName == \"contenteditable\" || // Firefox sometimes fires spurious events for null/empty styles\n mut.attributeName == \"style\" && !mut.oldValue && !mut.target.getAttribute(\"style\"))) {\n return null;\n }\n\n if (!desc || desc.ignoreMutation(mut)) {\n return null;\n }\n\n if (mut.type == \"childList\") {\n var prev = mut.previousSibling,\n next = mut.nextSibling;\n\n if (result.ie && result.ie_version <= 11 && mut.addedNodes.length) {\n // IE11 gives us incorrect next/prev siblings for some\n // insertions, so if there are added nodes, recompute those\n for (var i = 0; i < mut.addedNodes.length; i++) {\n var ref = mut.addedNodes[i];\n var previousSibling = ref.previousSibling;\n var nextSibling = ref.nextSibling;\n\n if (!previousSibling || Array.prototype.indexOf.call(mut.addedNodes, previousSibling) < 0) {\n prev = previousSibling;\n }\n\n if (!nextSibling || Array.prototype.indexOf.call(mut.addedNodes, nextSibling) < 0) {\n next = nextSibling;\n }\n }\n }\n\n var fromOffset = prev && prev.parentNode == mut.target ? domIndex(prev) + 1 : 0;\n var from = desc.localPosFromDOM(mut.target, fromOffset, -1);\n var toOffset = next && next.parentNode == mut.target ? domIndex(next) : mut.target.childNodes.length;\n\n for (var i$1 = 0; i$1 < mut.addedNodes.length; i$1++) {\n added.push(mut.addedNodes[i$1]);\n }\n\n var to = desc.localPosFromDOM(mut.target, toOffset, 1);\n return {\n from: from,\n to: to\n };\n } else if (mut.type == \"attributes\") {\n return {\n from: desc.posAtStart - desc.border,\n to: desc.posAtEnd + desc.border\n };\n } else {\n // \"characterData\"\n return {\n from: desc.posAtStart,\n to: desc.posAtEnd,\n // An event was generated for a text change that didn't change\n // any text. Mark the dom change to fall back to assuming the\n // selection was typed over with an identical value if it can't\n // find another change.\n typeOver: mut.target.nodeValue == mut.oldValue\n };\n }\n};\n\nvar cssChecked = false;\n\nfunction checkCSS(view) {\n if (cssChecked) {\n return;\n }\n\n cssChecked = true;\n\n if (getComputedStyle(view.dom).whiteSpace == \"normal\") {\n console[\"warn\"](\"ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.\");\n }\n} // A collection of DOM events that occur within the editor, and callback functions\n// to invoke when the event fires.\n\n\nvar handlers = {},\n editHandlers = {};\n\nfunction initInput(view) {\n view.shiftKey = false;\n view.mouseDown = null;\n view.lastKeyCode = null;\n view.lastKeyCodeTime = 0;\n view.lastClick = {\n time: 0,\n x: 0,\n y: 0,\n type: \"\"\n };\n view.lastSelectionOrigin = null;\n view.lastSelectionTime = 0;\n view.lastIOSEnter = 0;\n view.composing = false;\n view.composingTimeout = null;\n view.compositionNodes = [];\n view.compositionEndedAt = -2e8;\n view.domObserver = new DOMObserver(view, function (from, to, typeOver, added) {\n return readDOMChange(view, from, to, typeOver, added);\n });\n view.domObserver.start(); // Used by hacks like the beforeinput handler to check whether anything happened in the DOM\n\n view.domChangeCount = 0;\n view.eventHandlers = Object.create(null);\n\n var loop = function loop(event) {\n var handler = handlers[event];\n view.dom.addEventListener(event, view.eventHandlers[event] = function (event) {\n if (eventBelongsToView(view, event) && !runCustomHandler(view, event) && (view.editable || !(event.type in editHandlers))) {\n handler(view, event);\n }\n });\n };\n\n for (var event in handlers) {\n loop(event);\n } // On Safari, for reasons beyond my understanding, adding an input\n // event handler makes an issue where the composition vanishes when\n // you press enter go away.\n\n\n if (result.safari) {\n view.dom.addEventListener(\"input\", function () {\n return null;\n });\n }\n\n ensureListeners(view);\n}\n\nfunction setSelectionOrigin(view, origin) {\n view.lastSelectionOrigin = origin;\n view.lastSelectionTime = Date.now();\n}\n\nfunction destroyInput(view) {\n view.domObserver.stop();\n\n for (var type in view.eventHandlers) {\n view.dom.removeEventListener(type, view.eventHandlers[type]);\n }\n\n clearTimeout(view.composingTimeout);\n}\n\nfunction ensureListeners(view) {\n view.someProp(\"handleDOMEvents\", function (currentHandlers) {\n for (var type in currentHandlers) {\n if (!view.eventHandlers[type]) {\n view.dom.addEventListener(type, view.eventHandlers[type] = function (event) {\n return runCustomHandler(view, event);\n });\n }\n }\n });\n}\n\nfunction runCustomHandler(view, event) {\n return view.someProp(\"handleDOMEvents\", function (handlers) {\n var handler = handlers[event.type];\n return handler ? handler(view, event) || event.defaultPrevented : false;\n });\n}\n\nfunction eventBelongsToView(view, event) {\n if (!event.bubbles) {\n return true;\n }\n\n if (event.defaultPrevented) {\n return false;\n }\n\n for (var node = event.target; node != view.dom; node = node.parentNode) {\n if (!node || node.nodeType == 11 || node.pmViewDesc && node.pmViewDesc.stopEvent(event)) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction dispatchEvent(view, event) {\n if (!runCustomHandler(view, event) && handlers[event.type] && (view.editable || !(event.type in editHandlers))) {\n handlers[event.type](view, event);\n }\n}\n\neditHandlers.keydown = function (view, event) {\n view.shiftKey = event.keyCode == 16 || event.shiftKey;\n\n if (inOrNearComposition(view, event)) {\n return;\n }\n\n view.lastKeyCode = event.keyCode;\n view.lastKeyCodeTime = Date.now(); // On iOS, if we preventDefault enter key presses, the virtual\n // keyboard gets confused. So the hack here is to set a flag that\n // makes the DOM change code recognize that what just happens should\n // be replaced by whatever the Enter key handlers do.\n\n if (result.ios && event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.metaKey) {\n view.lastIOSEnter = Date.now();\n } else if (view.someProp(\"handleKeyDown\", function (f) {\n return f(view, event);\n }) || captureKeyDown(view, event)) {\n event.preventDefault();\n } else {\n setSelectionOrigin(view, \"key\");\n }\n};\n\neditHandlers.keyup = function (view, e) {\n if (e.keyCode == 16) {\n view.shiftKey = false;\n }\n};\n\neditHandlers.keypress = function (view, event) {\n if (inOrNearComposition(view, event) || !event.charCode || event.ctrlKey && !event.altKey || result.mac && event.metaKey) {\n return;\n }\n\n if (view.someProp(\"handleKeyPress\", function (f) {\n return f(view, event);\n })) {\n event.preventDefault();\n return;\n }\n\n var sel = view.state.selection;\n\n if (!(sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) || !sel.$from.sameParent(sel.$to)) {\n var text = String.fromCharCode(event.charCode);\n\n if (!view.someProp(\"handleTextInput\", function (f) {\n return f(view, sel.$from.pos, sel.$to.pos, text);\n })) {\n view.dispatch(view.state.tr.insertText(text).scrollIntoView());\n }\n\n event.preventDefault();\n }\n};\n\nfunction eventCoords(event) {\n return {\n left: event.clientX,\n top: event.clientY\n };\n}\n\nfunction isNear(event, click) {\n var dx = click.x - event.clientX,\n dy = click.y - event.clientY;\n return dx * dx + dy * dy < 100;\n}\n\nfunction runHandlerOnContext(view, propName, pos, inside, event) {\n if (inside == -1) {\n return false;\n }\n\n var $pos = view.state.doc.resolve(inside);\n\n var loop = function loop(i) {\n if (view.someProp(propName, function (f) {\n return i > $pos.depth ? f(view, pos, $pos.nodeAfter, $pos.before(i), event, true) : f(view, pos, $pos.node(i), $pos.before(i), event, false);\n })) {\n return {\n v: true\n };\n }\n };\n\n for (var i = $pos.depth + 1; i > 0; i--) {\n var returned = loop(i);\n if (returned) return returned.v;\n }\n\n return false;\n}\n\nfunction updateSelection(view, selection, origin) {\n if (!view.focused) {\n view.focus();\n }\n\n var tr = view.state.tr.setSelection(selection);\n\n if (origin == \"pointer\") {\n tr.setMeta(\"pointer\", true);\n }\n\n view.dispatch(tr);\n}\n\nfunction selectClickedLeaf(view, inside) {\n if (inside == -1) {\n return false;\n }\n\n var $pos = view.state.doc.resolve(inside),\n node = $pos.nodeAfter;\n\n if (node && node.isAtom && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n updateSelection(view, new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]($pos), \"pointer\");\n return true;\n }\n\n return false;\n}\n\nfunction selectClickedNode(view, inside) {\n if (inside == -1) {\n return false;\n }\n\n var sel = view.state.selection,\n selectedNode,\n selectAt;\n\n if (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) {\n selectedNode = sel.node;\n }\n\n var $pos = view.state.doc.resolve(inside);\n\n for (var i = $pos.depth + 1; i > 0; i--) {\n var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);\n\n if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n if (selectedNode && sel.$from.depth > 0 && i >= sel.$from.depth && $pos.before(sel.$from.depth + 1) == sel.$from.pos) {\n selectAt = $pos.before(sel.$from.depth);\n } else {\n selectAt = $pos.before(i);\n }\n\n break;\n }\n }\n\n if (selectAt != null) {\n updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(view.state.doc, selectAt), \"pointer\");\n return true;\n } else {\n return false;\n }\n}\n\nfunction handleSingleClick(view, pos, inside, event, selectNode) {\n return runHandlerOnContext(view, \"handleClickOn\", pos, inside, event) || view.someProp(\"handleClick\", function (f) {\n return f(view, pos, event);\n }) || (selectNode ? selectClickedNode(view, inside) : selectClickedLeaf(view, inside));\n}\n\nfunction handleDoubleClick(view, pos, inside, event) {\n return runHandlerOnContext(view, \"handleDoubleClickOn\", pos, inside, event) || view.someProp(\"handleDoubleClick\", function (f) {\n return f(view, pos, event);\n });\n}\n\nfunction handleTripleClick(view, pos, inside, event) {\n return runHandlerOnContext(view, \"handleTripleClickOn\", pos, inside, event) || view.someProp(\"handleTripleClick\", function (f) {\n return f(view, pos, event);\n }) || defaultTripleClick(view, inside);\n}\n\nfunction defaultTripleClick(view, inside) {\n var doc = view.state.doc;\n\n if (inside == -1) {\n if (doc.inlineContent) {\n updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"].create(doc, 0, doc.content.size), \"pointer\");\n return true;\n }\n\n return false;\n }\n\n var $pos = doc.resolve(inside);\n\n for (var i = $pos.depth + 1; i > 0; i--) {\n var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);\n var nodePos = $pos.before(i);\n\n if (node.inlineContent) {\n updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"].create(doc, nodePos + 1, nodePos + 1 + node.content.size), \"pointer\");\n } else if (prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(node)) {\n updateSelection(view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(doc, nodePos), \"pointer\");\n } else {\n continue;\n }\n\n return true;\n }\n}\n\nfunction forceDOMFlush(view) {\n return endComposition(view);\n}\n\nvar selectNodeModifier = result.mac ? \"metaKey\" : \"ctrlKey\";\n\nhandlers.mousedown = function (view, event) {\n view.shiftKey = event.shiftKey;\n var flushed = forceDOMFlush(view);\n var now = Date.now(),\n type = \"singleClick\";\n\n if (now - view.lastClick.time < 500 && isNear(event, view.lastClick) && !event[selectNodeModifier]) {\n if (view.lastClick.type == \"singleClick\") {\n type = \"doubleClick\";\n } else if (view.lastClick.type == \"doubleClick\") {\n type = \"tripleClick\";\n }\n }\n\n view.lastClick = {\n time: now,\n x: event.clientX,\n y: event.clientY,\n type: type\n };\n var pos = view.posAtCoords(eventCoords(event));\n\n if (!pos) {\n return;\n }\n\n if (type == \"singleClick\") {\n view.mouseDown = new MouseDown(view, pos, event, flushed);\n } else if ((type == \"doubleClick\" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {\n event.preventDefault();\n } else {\n setSelectionOrigin(view, \"pointer\");\n }\n};\n\nvar MouseDown = function MouseDown(view, pos, event, flushed) {\n var this$1 = this;\n this.view = view;\n this.startDoc = view.state.doc;\n this.pos = pos;\n this.event = event;\n this.flushed = flushed;\n this.selectNode = event[selectNodeModifier];\n this.allowDefault = event.shiftKey;\n var targetNode, targetPos;\n\n if (pos.inside > -1) {\n targetNode = view.state.doc.nodeAt(pos.inside);\n targetPos = pos.inside;\n } else {\n var $pos = view.state.doc.resolve(pos.pos);\n targetNode = $pos.parent;\n targetPos = $pos.depth ? $pos.before() : 0;\n }\n\n this.mightDrag = null;\n var target = flushed ? null : event.target;\n var targetDesc = target ? view.docView.nearestDesc(target, true) : null;\n this.target = targetDesc ? targetDesc.dom : null;\n\n if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"] && targetPos == view.state.selection.from) {\n this.mightDrag = {\n node: targetNode,\n pos: targetPos,\n addAttr: this.target && !this.target.draggable,\n setUneditable: this.target && result.gecko && !this.target.hasAttribute(\"contentEditable\")\n };\n }\n\n if (this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable)) {\n this.view.domObserver.stop();\n\n if (this.mightDrag.addAttr) {\n this.target.draggable = true;\n }\n\n if (this.mightDrag.setUneditable) {\n setTimeout(function () {\n return this$1.target.setAttribute(\"contentEditable\", \"false\");\n }, 20);\n }\n\n this.view.domObserver.start();\n }\n\n view.root.addEventListener(\"mouseup\", this.up = this.up.bind(this));\n view.root.addEventListener(\"mousemove\", this.move = this.move.bind(this));\n setSelectionOrigin(view, \"pointer\");\n};\n\nMouseDown.prototype.done = function done() {\n this.view.root.removeEventListener(\"mouseup\", this.up);\n this.view.root.removeEventListener(\"mousemove\", this.move);\n\n if (this.mightDrag && this.target) {\n this.view.domObserver.stop();\n\n if (this.mightDrag.addAttr) {\n this.target.draggable = false;\n }\n\n if (this.mightDrag.setUneditable) {\n this.target.removeAttribute(\"contentEditable\");\n }\n\n this.view.domObserver.start();\n }\n\n this.view.mouseDown = null;\n};\n\nMouseDown.prototype.up = function up(event) {\n this.done();\n\n if (!this.view.dom.contains(event.target.nodeType == 3 ? event.target.parentNode : event.target)) {\n return;\n }\n\n var pos = this.pos;\n\n if (this.view.state.doc != this.startDoc) {\n pos = this.view.posAtCoords(eventCoords(event));\n }\n\n if (this.allowDefault || !pos) {\n setSelectionOrigin(this.view, \"pointer\");\n } else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) {\n event.preventDefault();\n } else if (this.flushed || // Chrome will sometimes treat a node selection as a\n // cursor, but still report that the node is selected\n // when asked through getSelection. You'll then get a\n // situation where clicking at the point where that\n // (hidden) cursor is doesn't change the selection, and\n // thus doesn't get a reaction from ProseMirror. This\n // works around that.\n result.chrome && !(this.view.state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"TextSelection\"]) && (pos.pos == this.view.state.selection.from || pos.pos == this.view.state.selection.to)) {\n updateSelection(this.view, prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"Selection\"].near(this.view.state.doc.resolve(pos.pos)), \"pointer\");\n event.preventDefault();\n } else {\n setSelectionOrigin(this.view, \"pointer\");\n }\n};\n\nMouseDown.prototype.move = function move(event) {\n if (!this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4)) {\n this.allowDefault = true;\n }\n\n setSelectionOrigin(this.view, \"pointer\");\n};\n\nhandlers.touchdown = function (view) {\n forceDOMFlush(view);\n setSelectionOrigin(view, \"pointer\");\n};\n\nhandlers.contextmenu = function (view) {\n return forceDOMFlush(view);\n};\n\nfunction inOrNearComposition(view, event) {\n if (view.composing) {\n return true;\n } // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.\n // On Japanese input method editors (IMEs), the Enter key is used to confirm character\n // selection. On Safari, when Enter is pressed, compositionend and keydown events are\n // emitted. The keydown event triggers newline insertion, which we don't want.\n // This method returns true if the keydown event should be ignored.\n // We only ignore it once, as pressing Enter a second time *should* insert a newline.\n // Furthermore, the keydown event timestamp must be close to the compositionEndedAt timestamp.\n // This guards against the case where compositionend is triggered without the keyboard\n // (e.g. character confirmation may be done with the mouse), and keydown is triggered\n // afterwards- we wouldn't want to ignore the keydown event in this case.\n\n\n if (result.safari && Math.abs(event.timeStamp - view.compositionEndedAt) < 500) {\n view.compositionEndedAt = -2e8;\n return true;\n }\n\n return false;\n} // Drop active composition after 5 seconds of inactivity on Android\n\n\nvar timeoutComposition = result.android ? 5000 : -1;\n\neditHandlers.compositionstart = editHandlers.compositionupdate = function (view) {\n if (!view.composing) {\n view.domObserver.flush();\n var state = view.state;\n var $pos = state.selection.$from;\n\n if (state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(function (m) {\n return m.type.spec.inclusive === false;\n }))) {\n // Need to wrap the cursor in mark nodes different from the ones in the DOM context\n view.markCursor = view.state.storedMarks || $pos.marks();\n endComposition(view, true);\n view.markCursor = null;\n } else {\n endComposition(view); // In firefox, if the cursor is after but outside a marked node,\n // the inserted text won't inherit the marks. So this moves it\n // inside if necessary.\n\n if (result.gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {\n var sel = view.root.getSelection();\n\n for (var node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0;) {\n var before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];\n\n if (!before) {\n break;\n }\n\n if (before.nodeType == 3) {\n sel.collapse(before, before.nodeValue.length);\n break;\n } else {\n node = before;\n offset = -1;\n }\n }\n }\n }\n\n view.composing = true;\n }\n\n scheduleComposeEnd(view, timeoutComposition);\n};\n\neditHandlers.compositionend = function (view, event) {\n if (view.composing) {\n view.composing = false;\n view.compositionEndedAt = event.timeStamp;\n scheduleComposeEnd(view, 20);\n }\n};\n\nfunction scheduleComposeEnd(view, delay) {\n clearTimeout(view.composingTimeout);\n\n if (delay > -1) {\n view.composingTimeout = setTimeout(function () {\n return endComposition(view);\n }, delay);\n }\n}\n\nfunction endComposition(view, forceUpdate) {\n view.composing = false;\n\n while (view.compositionNodes.length > 0) {\n view.compositionNodes.pop().markParentsDirty();\n }\n\n if (forceUpdate || view.docView.dirty) {\n view.updateState(view.state);\n return true;\n }\n\n return false;\n}\n\nfunction captureCopy(view, dom) {\n // The extra wrapper is somehow necessary on IE/Edge to prevent the\n // content from being mangled when it is put onto the clipboard\n var doc = view.dom.ownerDocument;\n var wrap = doc.body.appendChild(doc.createElement(\"div\"));\n wrap.appendChild(dom);\n wrap.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n var sel = getSelection(),\n range = doc.createRange();\n range.selectNodeContents(dom); // Done because IE will fire a selectionchange moving the selection\n // to its start when removeAllRanges is called and the editor still\n // has focus (which will mess up the editor's selection state).\n\n view.dom.blur();\n sel.removeAllRanges();\n sel.addRange(range);\n setTimeout(function () {\n doc.body.removeChild(wrap);\n view.focus();\n }, 50);\n} // This is very crude, but unfortunately both these browsers _pretend_\n// that they have a clipboard API—all the objects and methods are\n// there, they just don't work, and they are hard to test.\n\n\nvar brokenClipboardAPI = result.ie && result.ie_version < 15 || result.ios && result.webkit_version < 604;\n\nhandlers.copy = editHandlers.cut = function (view, e) {\n var sel = view.state.selection,\n cut = e.type == \"cut\";\n\n if (sel.empty) {\n return;\n } // IE and Edge's clipboard interface is completely broken\n\n\n var data = brokenClipboardAPI ? null : e.clipboardData;\n var slice = sel.content();\n var ref = serializeForClipboard(view, slice);\n var dom = ref.dom;\n var text = ref.text;\n\n if (data) {\n e.preventDefault();\n data.clearData();\n data.setData(\"text/html\", dom.innerHTML);\n data.setData(\"text/plain\", text);\n } else {\n captureCopy(view, dom);\n }\n\n if (cut) {\n view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta(\"uiEvent\", \"cut\"));\n }\n};\n\nfunction sliceSingleNode(slice) {\n return slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1 ? slice.content.firstChild : null;\n}\n\nfunction capturePaste(view, e) {\n var doc = view.dom.ownerDocument;\n var plainText = view.shiftKey || view.state.selection.$from.parent.type.spec.code;\n var target = doc.body.appendChild(doc.createElement(plainText ? \"textarea\" : \"div\"));\n\n if (!plainText) {\n target.contentEditable = \"true\";\n }\n\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.focus();\n setTimeout(function () {\n view.focus();\n doc.body.removeChild(target);\n\n if (plainText) {\n doPaste(view, target.value, null, e);\n } else {\n doPaste(view, target.textContent, target.innerHTML, e);\n }\n }, 50);\n}\n\nfunction doPaste(view, text, html, e) {\n var slice = parseFromClipboard(view, text, html, view.shiftKey, view.state.selection.$from);\n\n if (view.someProp(\"handlePaste\", function (f) {\n return f(view, e, slice || prosemirror_model__WEBPACK_IMPORTED_MODULE_1__[\"Slice\"].empty);\n }) || !slice) {\n return;\n }\n\n var singleNode = sliceSingleNode(slice);\n var tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, view.shiftKey) : view.state.tr.replaceSelection(slice);\n view.dispatch(tr.scrollIntoView().setMeta(\"paste\", true).setMeta(\"uiEvent\", \"paste\"));\n}\n\neditHandlers.paste = function (view, e) {\n var data = brokenClipboardAPI ? null : e.clipboardData;\n var html = data && data.getData(\"text/html\"),\n text = data && data.getData(\"text/plain\");\n\n if (data && (html || text || data.files.length)) {\n doPaste(view, text, html, e);\n e.preventDefault();\n } else {\n capturePaste(view, e);\n }\n};\n\nvar Dragging = function Dragging(slice, move) {\n this.slice = slice;\n this.move = move;\n};\n\nvar dragCopyModifier = result.mac ? \"altKey\" : \"ctrlKey\";\n\nhandlers.dragstart = function (view, e) {\n var mouseDown = view.mouseDown;\n\n if (mouseDown) {\n mouseDown.done();\n }\n\n if (!e.dataTransfer) {\n return;\n }\n\n var sel = view.state.selection;\n var pos = sel.empty ? null : view.posAtCoords(eventCoords(e));\n if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"] ? sel.to - 1 : sel.to)) ;else if (mouseDown && mouseDown.mightDrag) {\n view.dispatch(view.state.tr.setSelection(prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(view.state.doc, mouseDown.mightDrag.pos)));\n } else if (e.target && e.target.nodeType == 1) {\n var desc = view.docView.nearestDesc(e.target, true);\n\n if (!desc || !desc.node.type.spec.draggable || desc == view.docView) {\n return;\n }\n\n view.dispatch(view.state.tr.setSelection(prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].create(view.state.doc, desc.posBefore)));\n }\n var slice = view.state.selection.content();\n var ref = serializeForClipboard(view, slice);\n var dom = ref.dom;\n var text = ref.text;\n e.dataTransfer.clearData();\n e.dataTransfer.setData(brokenClipboardAPI ? \"Text\" : \"text/html\", dom.innerHTML);\n\n if (!brokenClipboardAPI) {\n e.dataTransfer.setData(\"text/plain\", text);\n }\n\n view.dragging = new Dragging(slice, !e[dragCopyModifier]);\n};\n\nhandlers.dragend = function (view) {\n window.setTimeout(function () {\n return view.dragging = null;\n }, 50);\n};\n\neditHandlers.dragover = editHandlers.dragenter = function (_, e) {\n return e.preventDefault();\n};\n\neditHandlers.drop = function (view, e) {\n var dragging = view.dragging;\n view.dragging = null;\n\n if (!e.dataTransfer) {\n return;\n }\n\n var eventPos = view.posAtCoords(eventCoords(e));\n\n if (!eventPos) {\n return;\n }\n\n var $mouse = view.state.doc.resolve(eventPos.pos);\n\n if (!$mouse) {\n return;\n }\n\n var slice = dragging && dragging.slice || parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? \"Text\" : \"text/plain\"), brokenClipboardAPI ? null : e.dataTransfer.getData(\"text/html\"), false, $mouse);\n\n if (!slice) {\n return;\n }\n\n e.preventDefault();\n\n if (view.someProp(\"handleDrop\", function (f) {\n return f(view, e, slice, dragging && dragging.move);\n })) {\n return;\n }\n\n var insertPos = slice ? Object(prosemirror_transform__WEBPACK_IMPORTED_MODULE_2__[\"dropPoint\"])(view.state.doc, $mouse.pos, slice) : $mouse.pos;\n\n if (insertPos == null) {\n insertPos = $mouse.pos;\n }\n\n var tr = view.state.tr;\n\n if (dragging && dragging.move) {\n tr.deleteSelection();\n }\n\n var pos = tr.mapping.map(insertPos);\n var isNode = slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1;\n var beforeInsert = tr.doc;\n\n if (isNode) {\n tr.replaceRangeWith(pos, pos, slice.content.firstChild);\n } else {\n tr.replaceRange(pos, pos, slice);\n }\n\n if (tr.doc.eq(beforeInsert)) {\n return;\n }\n\n var $pos = tr.doc.resolve(pos);\n\n if (isNode && prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"].isSelectable(slice.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild)) {\n tr.setSelection(new prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]($pos));\n } else {\n tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(tr.mapping.map(insertPos))));\n }\n\n view.focus();\n view.dispatch(tr.setMeta(\"uiEvent\", \"drop\"));\n};\n\nhandlers.focus = function (view) {\n if (!view.focused) {\n view.domObserver.stop();\n view.dom.classList.add(\"ProseMirror-focused\");\n view.domObserver.start();\n view.focused = true;\n setTimeout(function () {\n if (view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq(view.root.getSelection())) {\n selectionToDOM(view);\n }\n }, 20);\n }\n};\n\nhandlers.blur = function (view) {\n if (view.focused) {\n view.domObserver.stop();\n view.dom.classList.remove(\"ProseMirror-focused\");\n view.domObserver.start();\n view.domObserver.currentSelection.set({});\n view.focused = false;\n }\n};\n\nhandlers.beforeinput = function (view, event) {\n // We should probably do more with beforeinput events, but support\n // is so spotty that I'm still waiting to see where they are going.\n // Very specific hack to deal with backspace sometimes failing on\n // Chrome Android when after an uneditable node.\n if (result.chrome && result.android && event.inputType == \"deleteContentBackward\") {\n var domChangeCount = view.domChangeCount;\n setTimeout(function () {\n if (view.domChangeCount != domChangeCount) {\n return;\n } // Event already had some effect\n // This bug tends to close the virtual keyboard, so we refocus\n\n\n view.dom.blur();\n view.focus();\n\n if (view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(8, \"Backspace\"));\n })) {\n return;\n }\n\n var ref = view.state.selection;\n var $cursor = ref.$cursor; // Crude approximation of backspace behavior when no command handled it\n\n if ($cursor && $cursor.pos > 0) {\n view.dispatch(view.state.tr[\"delete\"]($cursor.pos - 1, $cursor.pos).scrollIntoView());\n }\n }, 50);\n }\n}; // Make sure all handlers get registered\n\n\nfor (var prop in editHandlers) {\n handlers[prop] = editHandlers[prop];\n}\n\nfunction compareObjs(a, b) {\n if (a == b) {\n return true;\n }\n\n for (var p in a) {\n if (a[p] !== b[p]) {\n return false;\n }\n }\n\n for (var p$1 in b) {\n if (!(p$1 in a)) {\n return false;\n }\n }\n\n return true;\n}\n\nvar WidgetType = function WidgetType(toDOM, spec) {\n this.spec = spec || noSpec;\n this.side = this.spec.side || 0;\n this.toDOM = toDOM;\n};\n\nWidgetType.prototype.map = function map(mapping, span, offset, oldOffset) {\n var ref = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);\n var pos = ref.pos;\n var deleted = ref.deleted;\n return deleted ? null : new Decoration(pos - offset, pos - offset, this);\n};\n\nWidgetType.prototype.valid = function valid() {\n return true;\n};\n\nWidgetType.prototype.eq = function eq(other) {\n return this == other || other instanceof WidgetType && (this.spec.key && this.spec.key == other.spec.key || this.toDOM == other.toDOM && compareObjs(this.spec, other.spec));\n};\n\nvar InlineType = function InlineType(attrs, spec) {\n this.spec = spec || noSpec;\n this.attrs = attrs;\n};\n\nInlineType.prototype.map = function map(mapping, span, offset, oldOffset) {\n var from = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset;\n var to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset;\n return from >= to ? null : new Decoration(from, to, this);\n};\n\nInlineType.prototype.valid = function valid(_, span) {\n return span.from < span.to;\n};\n\nInlineType.prototype.eq = function eq(other) {\n return this == other || other instanceof InlineType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);\n};\n\nInlineType.is = function is(span) {\n return span.type instanceof InlineType;\n};\n\nvar NodeType = function NodeType(attrs, spec) {\n this.spec = spec || noSpec;\n this.attrs = attrs;\n};\n\nNodeType.prototype.map = function map(mapping, span, offset, oldOffset) {\n var from = mapping.mapResult(span.from + oldOffset, 1);\n\n if (from.deleted) {\n return null;\n }\n\n var to = mapping.mapResult(span.to + oldOffset, -1);\n\n if (to.deleted || to.pos <= from.pos) {\n return null;\n }\n\n return new Decoration(from.pos - offset, to.pos - offset, this);\n};\n\nNodeType.prototype.valid = function valid(node, span) {\n var ref = node.content.findIndex(span.from);\n var index = ref.index;\n var offset = ref.offset;\n return offset == span.from && offset + node.child(index).nodeSize == span.to;\n};\n\nNodeType.prototype.eq = function eq(other) {\n return this == other || other instanceof NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);\n}; // ::- Decoration objects can be provided to the view through the\n// [`decorations` prop](#view.EditorProps.decorations). They come in\n// several variants—see the static members of this class for details.\n\n\nvar Decoration = function Decoration(from, to, type) {\n // :: number\n // The start position of the decoration.\n this.from = from; // :: number\n // The end position. Will be the same as `from` for [widget\n // decorations](#view.Decoration^widget).\n\n this.to = to;\n this.type = type;\n};\n\nvar prototypeAccessors$1 = {\n spec: {\n configurable: true\n }\n};\n\nDecoration.prototype.copy = function copy(from, to) {\n return new Decoration(from, to, this.type);\n};\n\nDecoration.prototype.eq = function eq(other) {\n return this.type.eq(other.type) && this.from == other.from && this.to == other.to;\n};\n\nDecoration.prototype.map = function map(mapping, offset, oldOffset) {\n return this.type.map(mapping, this, offset, oldOffset);\n}; // :: (number, union<(view: EditorView, getPos: () → number) → dom.Node, dom.Node>, ?Object) → Decoration\n// Creates a widget decoration, which is a DOM node that's shown in\n// the document at the given position. It is recommended that you\n// delay rendering the widget by passing a function that will be\n// called when the widget is actually drawn in a view, but you can\n// also directly pass a DOM node. `getPos` can be used to find the\n// widget's current document position.\n//\n// spec::- These options are supported:\n//\n// side:: ?number\n// Controls which side of the document position this widget is\n// associated with. When negative, it is drawn before a cursor\n// at its position, and content inserted at that position ends\n// up after the widget. When zero (the default) or positive, the\n// widget is drawn after the cursor and content inserted there\n// ends up before the widget.\n//\n// When there are multiple widgets at a given position, their\n// `side` values determine the order in which they appear. Those\n// with lower values appear first. The ordering of widgets with\n// the same `side` value is unspecified.\n//\n// When `marks` is null, `side` also determines the marks that\n// the widget is wrapped in—those of the node before when\n// negative, those of the node after when positive.\n//\n// marks:: ?[Mark]\n// The precise set of marks to draw around the widget.\n//\n// stopEvent:: ?(event: dom.Event) → bool\n// Can be used to control which DOM events, when they bubble out\n// of this widget, the editor view should ignore.\n//\n// ignoreSelection:: ?bool\n// When set (defaults to false), selection changes inside the\n// widget are ignored, and don't cause ProseMirror to try and\n// re-sync the selection with its selection state.\n//\n// key:: ?string\n// When comparing decorations of this type (in order to decide\n// whether it needs to be redrawn), ProseMirror will by default\n// compare the widget DOM node by identity. If you pass a key,\n// that key will be compared instead, which can be useful when\n// you generate decorations on the fly and don't want to store\n// and reuse DOM nodes. Make sure that any widgets with the same\n// key are interchangeable—if widgets differ in, for example,\n// the behavior of some event handler, they should get\n// different keys.\n\n\nDecoration.widget = function widget(pos, toDOM, spec) {\n return new Decoration(pos, pos, new WidgetType(toDOM, spec));\n}; // :: (number, number, DecorationAttrs, ?Object) → Decoration\n// Creates an inline decoration, which adds the given attributes to\n// each inline node between `from` and `to`.\n//\n// spec::- These options are recognized:\n//\n// inclusiveStart:: ?bool\n// Determines how the left side of the decoration is\n// [mapped](#transform.Position_Mapping) when content is\n// inserted directly at that position. By default, the decoration\n// won't include the new content, but you can set this to `true`\n// to make it inclusive.\n//\n// inclusiveEnd:: ?bool\n// Determines how the right side of the decoration is mapped.\n// See\n// [`inclusiveStart`](#view.Decoration^inline^spec.inclusiveStart).\n\n\nDecoration.inline = function inline(from, to, attrs, spec) {\n return new Decoration(from, to, new InlineType(attrs, spec));\n}; // :: (number, number, DecorationAttrs, ?Object) → Decoration\n// Creates a node decoration. `from` and `to` should point precisely\n// before and after a node in the document. That node, and only that\n// node, will receive the given attributes.\n//\n// spec::-\n//\n// Optional information to store with the decoration. It\n// is also used when comparing decorators for equality.\n\n\nDecoration.node = function node(from, to, attrs, spec) {\n return new Decoration(from, to, new NodeType(attrs, spec));\n}; // :: Object\n// The spec provided when creating this decoration. Can be useful\n// if you've stored extra information in that object.\n\n\nprototypeAccessors$1.spec.get = function () {\n return this.type.spec;\n};\n\nObject.defineProperties(Decoration.prototype, prototypeAccessors$1); // DecorationAttrs:: interface\n// A set of attributes to add to a decorated node. Most properties\n// simply directly correspond to DOM attributes of the same name,\n// which will be set to the property's value. These are exceptions:\n//\n// class:: ?string\n// A CSS class name or a space-separated set of class names to be\n// _added_ to the classes that the node already had.\n//\n// style:: ?string\n// A string of CSS to be _added_ to the node's existing `style` property.\n//\n// nodeName:: ?string\n// When non-null, the target node is wrapped in a DOM element of\n// this type (and the other attributes are applied to this element).\n\nvar none = [],\n noSpec = {}; // ::- A collection of [decorations](#view.Decoration), organized in\n// such a way that the drawing algorithm can efficiently use and\n// compare them. This is a persistent data structure—it is not\n// modified, updates create a new value.\n\nvar DecorationSet = function DecorationSet(local, children) {\n this.local = local && local.length ? local : none;\n this.children = children && children.length ? children : none;\n}; // :: (Node, [Decoration]) → DecorationSet\n// Create a set of decorations, using the structure of the given\n// document.\n\n\nDecorationSet.create = function create(doc, decorations) {\n return decorations.length ? buildTree(decorations, doc, 0, noSpec) : empty;\n}; // :: (?number, ?number, ?(spec: Object) → bool) → [Decoration]\n// Find all decorations in this set which touch the given range\n// (including decorations that start or end directly at the\n// boundaries) and match the given predicate on their spec. When\n// `start` and `end` are omitted, all decorations in the set are\n// considered. When `predicate` isn't given, all decorations are\n// assumed to match.\n\n\nDecorationSet.prototype.find = function find(start, end, predicate) {\n var result = [];\n this.findInner(start == null ? 0 : start, end == null ? 1e9 : end, result, 0, predicate);\n return result;\n};\n\nDecorationSet.prototype.findInner = function findInner(start, end, result, offset, predicate) {\n for (var i = 0; i < this.local.length; i++) {\n var span = this.local[i];\n\n if (span.from <= end && span.to >= start && (!predicate || predicate(span.spec))) {\n result.push(span.copy(span.from + offset, span.to + offset));\n }\n }\n\n for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {\n if (this.children[i$1] < end && this.children[i$1 + 1] > start) {\n var childOff = this.children[i$1] + 1;\n this.children[i$1 + 2].findInner(start - childOff, end - childOff, result, offset + childOff, predicate);\n }\n }\n}; // :: (Mapping, Node, ?Object) → DecorationSet\n// Map the set of decorations in response to a change in the\n// document.\n//\n// options::- An optional set of options.\n//\n// onRemove:: ?(decorationSpec: Object)\n// When given, this function will be called for each decoration\n// that gets dropped as a result of the mapping, passing the\n// spec of that decoration.\n\n\nDecorationSet.prototype.map = function map(mapping, doc, options) {\n if (this == empty || mapping.maps.length == 0) {\n return this;\n }\n\n return this.mapInner(mapping, doc, 0, 0, options || noSpec);\n};\n\nDecorationSet.prototype.mapInner = function mapInner(mapping, node, offset, oldOffset, options) {\n var newLocal;\n\n for (var i = 0; i < this.local.length; i++) {\n var mapped = this.local[i].map(mapping, offset, oldOffset);\n\n if (mapped && mapped.type.valid(node, mapped)) {\n (newLocal || (newLocal = [])).push(mapped);\n } else if (options.onRemove) {\n options.onRemove(this.local[i].spec);\n }\n }\n\n if (this.children.length) {\n return mapChildren(this.children, newLocal, mapping, node, offset, oldOffset, options);\n } else {\n return newLocal ? new DecorationSet(newLocal.sort(byPos)) : empty;\n }\n}; // :: (Node, [Decoration]) → DecorationSet\n// Add the given array of decorations to the ones in the set,\n// producing a new set. Needs access to the current document to\n// create the appropriate tree structure.\n\n\nDecorationSet.prototype.add = function add(doc, decorations) {\n if (!decorations.length) {\n return this;\n }\n\n if (this == empty) {\n return DecorationSet.create(doc, decorations);\n }\n\n return this.addInner(doc, decorations, 0);\n};\n\nDecorationSet.prototype.addInner = function addInner(doc, decorations, offset) {\n var this$1 = this;\n var children,\n childIndex = 0;\n doc.forEach(function (childNode, childOffset) {\n var baseOffset = childOffset + offset,\n found;\n\n if (!(found = takeSpansForNode(decorations, childNode, baseOffset))) {\n return;\n }\n\n if (!children) {\n children = this$1.children.slice();\n }\n\n while (childIndex < children.length && children[childIndex] < childOffset) {\n childIndex += 3;\n }\n\n if (children[childIndex] == childOffset) {\n children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found, baseOffset + 1);\n } else {\n children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noSpec));\n }\n\n childIndex += 3;\n });\n var local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset);\n return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children);\n}; // :: ([Decoration]) → DecorationSet\n// Create a new set that contains the decorations in this set, minus\n// the ones in the given array.\n\n\nDecorationSet.prototype.remove = function remove(decorations) {\n if (decorations.length == 0 || this == empty) {\n return this;\n }\n\n return this.removeInner(decorations, 0);\n};\n\nDecorationSet.prototype.removeInner = function removeInner(decorations, offset) {\n var children = this.children,\n local = this.local;\n\n for (var i = 0; i < children.length; i += 3) {\n var found = void 0,\n from = children[i] + offset,\n to = children[i + 1] + offset;\n\n for (var j = 0, span = void 0; j < decorations.length; j++) {\n if (span = decorations[j]) {\n if (span.from > from && span.to < to) {\n decorations[j] = null;\n (found || (found = [])).push(span);\n }\n }\n }\n\n if (!found) {\n continue;\n }\n\n if (children == this.children) {\n children = this.children.slice();\n }\n\n var removed = children[i + 2].removeInner(found, from + 1);\n\n if (removed != empty) {\n children[i + 2] = removed;\n } else {\n children.splice(i, 3);\n i -= 3;\n }\n }\n\n if (local.length) {\n for (var i$1 = 0, span$1 = void 0; i$1 < decorations.length; i$1++) {\n if (span$1 = decorations[i$1]) {\n for (var j$1 = 0; j$1 < local.length; j$1++) {\n if (local[j$1].type.eq(span$1.type)) {\n if (local == this.local) {\n local = this.local.slice();\n }\n\n local.splice(j$1--, 1);\n }\n }\n }\n }\n }\n\n if (children == this.children && local == this.local) {\n return this;\n }\n\n return local.length || children.length ? new DecorationSet(local, children) : empty;\n};\n\nDecorationSet.prototype.forChild = function forChild(offset, node) {\n if (this == empty) {\n return this;\n }\n\n if (node.isLeaf) {\n return DecorationSet.empty;\n }\n\n var child, local;\n\n for (var i = 0; i < this.children.length; i += 3) {\n if (this.children[i] >= offset) {\n if (this.children[i] == offset) {\n child = this.children[i + 2];\n }\n\n break;\n }\n }\n\n var start = offset + 1,\n end = start + node.content.size;\n\n for (var i$1 = 0; i$1 < this.local.length; i$1++) {\n var dec = this.local[i$1];\n\n if (dec.from < end && dec.to > start && dec.type instanceof InlineType) {\n var from = Math.max(start, dec.from) - start,\n to = Math.min(end, dec.to) - start;\n\n if (from < to) {\n (local || (local = [])).push(dec.copy(from, to));\n }\n }\n }\n\n if (local) {\n var localSet = new DecorationSet(local.sort(byPos));\n return child ? new DecorationGroup([localSet, child]) : localSet;\n }\n\n return child || empty;\n};\n\nDecorationSet.prototype.eq = function eq(other) {\n if (this == other) {\n return true;\n }\n\n if (!(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length) {\n return false;\n }\n\n for (var i = 0; i < this.local.length; i++) {\n if (!this.local[i].eq(other.local[i])) {\n return false;\n }\n }\n\n for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {\n if (this.children[i$1] != other.children[i$1] || this.children[i$1 + 1] != other.children[i$1 + 1] || !this.children[i$1 + 2].eq(other.children[i$1 + 2])) {\n return false;\n }\n }\n\n return true;\n};\n\nDecorationSet.prototype.locals = function locals(node) {\n return removeOverlap(this.localsInner(node));\n};\n\nDecorationSet.prototype.localsInner = function localsInner(node) {\n if (this == empty) {\n return none;\n }\n\n if (node.inlineContent || !this.local.some(InlineType.is)) {\n return this.local;\n }\n\n var result = [];\n\n for (var i = 0; i < this.local.length; i++) {\n if (!(this.local[i].type instanceof InlineType)) {\n result.push(this.local[i]);\n }\n }\n\n return result;\n};\n\nvar empty = new DecorationSet(); // :: DecorationSet\n// The empty set of decorations.\n\nDecorationSet.empty = empty;\nDecorationSet.removeOverlap = removeOverlap; // :- An abstraction that allows the code dealing with decorations to\n// treat multiple DecorationSet objects as if it were a single object\n// with (a subset of) the same interface.\n\nvar DecorationGroup = function DecorationGroup(members) {\n this.members = members;\n};\n\nDecorationGroup.prototype.forChild = function forChild(offset, child) {\n if (child.isLeaf) {\n return DecorationSet.empty;\n }\n\n var found = [];\n\n for (var i = 0; i < this.members.length; i++) {\n var result = this.members[i].forChild(offset, child);\n\n if (result == empty) {\n continue;\n }\n\n if (result instanceof DecorationGroup) {\n found = found.concat(result.members);\n } else {\n found.push(result);\n }\n }\n\n return DecorationGroup.from(found);\n};\n\nDecorationGroup.prototype.eq = function eq(other) {\n if (!(other instanceof DecorationGroup) || other.members.length != this.members.length) {\n return false;\n }\n\n for (var i = 0; i < this.members.length; i++) {\n if (!this.members[i].eq(other.members[i])) {\n return false;\n }\n }\n\n return true;\n};\n\nDecorationGroup.prototype.locals = function locals(node) {\n var result,\n sorted = true;\n\n for (var i = 0; i < this.members.length; i++) {\n var locals = this.members[i].localsInner(node);\n\n if (!locals.length) {\n continue;\n }\n\n if (!result) {\n result = locals;\n } else {\n if (sorted) {\n result = result.slice();\n sorted = false;\n }\n\n for (var j = 0; j < locals.length; j++) {\n result.push(locals[j]);\n }\n }\n }\n\n return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none;\n}; // : ([DecorationSet]) → union\n// Create a group for the given array of decoration sets, or return\n// a single set when possible.\n\n\nDecorationGroup.from = function from(members) {\n switch (members.length) {\n case 0:\n return empty;\n\n case 1:\n return members[0];\n\n default:\n return new DecorationGroup(members);\n }\n};\n\nfunction mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, options) {\n var children = oldChildren.slice(); // Mark the children that are directly touched by changes, and\n // move those that are after the changes.\n\n var shift = function shift(oldStart, oldEnd, newStart, newEnd) {\n for (var i = 0; i < children.length; i += 3) {\n var end = children[i + 1],\n dSize = void 0;\n\n if (end == -1 || oldStart > end + oldOffset) {\n continue;\n }\n\n if (oldEnd >= children[i] + oldOffset) {\n children[i + 1] = -1;\n } else if (dSize = newEnd - newStart - (oldEnd - oldStart) + (oldOffset - offset)) {\n children[i] += dSize;\n children[i + 1] += dSize;\n }\n }\n };\n\n for (var i = 0; i < mapping.maps.length; i++) {\n mapping.maps[i].forEach(shift);\n } // Find the child nodes that still correspond to a single node,\n // recursively call mapInner on them and update their positions.\n\n\n var mustRebuild = false;\n\n for (var i$1 = 0; i$1 < children.length; i$1 += 3) {\n if (children[i$1 + 1] == -1) {\n // Touched nodes\n var from = mapping.map(children[i$1] + oldOffset),\n fromLocal = from - offset;\n\n if (fromLocal < 0 || fromLocal >= node.content.size) {\n mustRebuild = true;\n continue;\n } // Must read oldChildren because children was tagged with -1\n\n\n var to = mapping.map(oldChildren[i$1 + 1] + oldOffset, -1),\n toLocal = to - offset;\n var ref = node.content.findIndex(fromLocal);\n var index = ref.index;\n var childOffset = ref.offset;\n var childNode = node.maybeChild(index);\n\n if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {\n var mapped = children[i$1 + 2].mapInner(mapping, childNode, from + 1, children[i$1] + oldOffset + 1, options);\n\n if (mapped != empty) {\n children[i$1] = fromLocal;\n children[i$1 + 1] = toLocal;\n children[i$1 + 2] = mapped;\n } else {\n children[i$1 + 1] = -2;\n mustRebuild = true;\n }\n } else {\n mustRebuild = true;\n }\n }\n } // Remaining children must be collected and rebuilt into the appropriate structure\n\n\n if (mustRebuild) {\n var decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal || [], mapping, offset, oldOffset, options);\n var built = buildTree(decorations, node, 0, options);\n newLocal = built.local;\n\n for (var i$2 = 0; i$2 < children.length; i$2 += 3) {\n if (children[i$2 + 1] < 0) {\n children.splice(i$2, 3);\n i$2 -= 3;\n }\n }\n\n for (var i$3 = 0, j = 0; i$3 < built.children.length; i$3 += 3) {\n var from$1 = built.children[i$3];\n\n while (j < children.length && children[j] < from$1) {\n j += 3;\n }\n\n children.splice(j, 0, built.children[i$3], built.children[i$3 + 1], built.children[i$3 + 2]);\n }\n }\n\n return new DecorationSet(newLocal && newLocal.sort(byPos), children);\n}\n\nfunction moveSpans(spans, offset) {\n if (!offset || !spans.length) {\n return spans;\n }\n\n var result = [];\n\n for (var i = 0; i < spans.length; i++) {\n var span = spans[i];\n result.push(new Decoration(span.from + offset, span.to + offset, span.type));\n }\n\n return result;\n}\n\nfunction mapAndGatherRemainingDecorations(children, oldChildren, decorations, mapping, offset, oldOffset, options) {\n // Gather all decorations from the remaining marked children\n function gather(set, oldOffset) {\n for (var i = 0; i < set.local.length; i++) {\n var mapped = set.local[i].map(mapping, offset, oldOffset);\n\n if (mapped) {\n decorations.push(mapped);\n } else if (options.onRemove) {\n options.onRemove(set.local[i].spec);\n }\n }\n\n for (var i$1 = 0; i$1 < set.children.length; i$1 += 3) {\n gather(set.children[i$1 + 2], set.children[i$1] + oldOffset + 1);\n }\n }\n\n for (var i = 0; i < children.length; i += 3) {\n if (children[i + 1] == -1) {\n gather(children[i + 2], oldChildren[i] + oldOffset + 1);\n }\n }\n\n return decorations;\n}\n\nfunction takeSpansForNode(spans, node, offset) {\n if (node.isLeaf) {\n return null;\n }\n\n var end = offset + node.nodeSize,\n found = null;\n\n for (var i = 0, span = void 0; i < spans.length; i++) {\n if ((span = spans[i]) && span.from > offset && span.to < end) {\n (found || (found = [])).push(span);\n spans[i] = null;\n }\n }\n\n return found;\n}\n\nfunction withoutNulls(array) {\n var result = [];\n\n for (var i = 0; i < array.length; i++) {\n if (array[i] != null) {\n result.push(array[i]);\n }\n }\n\n return result;\n} // : ([Decoration], Node, number) → DecorationSet\n// Build up a tree that corresponds to a set of decorations. `offset`\n// is a base offset that should be subtractet from the `from` and `to`\n// positions in the spans (so that we don't have to allocate new spans\n// for recursive calls).\n\n\nfunction buildTree(spans, node, offset, options) {\n var children = [],\n hasNulls = false;\n node.forEach(function (childNode, localStart) {\n var found = takeSpansForNode(spans, childNode, localStart + offset);\n\n if (found) {\n hasNulls = true;\n var subtree = buildTree(found, childNode, offset + localStart + 1, options);\n\n if (subtree != empty) {\n children.push(localStart, localStart + childNode.nodeSize, subtree);\n }\n }\n });\n var locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset).sort(byPos);\n\n for (var i = 0; i < locals.length; i++) {\n if (!locals[i].type.valid(node, locals[i])) {\n if (options.onRemove) {\n options.onRemove(locals[i].spec);\n }\n\n locals.splice(i--, 1);\n }\n }\n\n return locals.length || children.length ? new DecorationSet(locals, children) : empty;\n} // : (Decoration, Decoration) → number\n// Used to sort decorations so that ones with a low start position\n// come first, and within a set with the same start position, those\n// with an smaller end position come first.\n\n\nfunction byPos(a, b) {\n return a.from - b.from || a.to - b.to;\n} // : ([Decoration]) → [Decoration]\n// Scan a sorted array of decorations for partially overlapping spans,\n// and split those so that only fully overlapping spans are left (to\n// make subsequent rendering easier). Will return the input array if\n// no partially overlapping spans are found (the common case).\n\n\nfunction removeOverlap(spans) {\n var working = spans;\n\n for (var i = 0; i < working.length - 1; i++) {\n var span = working[i];\n\n if (span.from != span.to) {\n for (var j = i + 1; j < working.length; j++) {\n var next = working[j];\n\n if (next.from == span.from) {\n if (next.to != span.to) {\n if (working == spans) {\n working = spans.slice();\n } // Followed by a partially overlapping larger span. Split that\n // span.\n\n\n working[j] = next.copy(next.from, span.to);\n insertAhead(working, j + 1, next.copy(span.to, next.to));\n }\n\n continue;\n } else {\n if (next.from < span.to) {\n if (working == spans) {\n working = spans.slice();\n } // The end of this one overlaps with a subsequent span. Split\n // this one.\n\n\n working[i] = span.copy(span.from, next.from);\n insertAhead(working, j, span.copy(next.from, span.to));\n }\n\n break;\n }\n }\n }\n }\n\n return working;\n}\n\nfunction insertAhead(array, i, deco) {\n while (i < array.length && byPos(deco, array[i]) > 0) {\n i++;\n }\n\n array.splice(i, 0, deco);\n} // : (EditorView) → union\n// Get the decorations associated with the current props of a view.\n\n\nfunction viewDecorations(view) {\n var found = [];\n view.someProp(\"decorations\", function (f) {\n var result = f(view.state);\n\n if (result && result != empty) {\n found.push(result);\n }\n });\n\n if (view.cursorWrapper) {\n found.push(DecorationSet.create(view.state.doc, [view.cursorWrapper.deco]));\n }\n\n return DecorationGroup.from(found);\n} // ::- An editor view manages the DOM structure that represents an\n// editable document. Its state and behavior are determined by its\n// [props](#view.DirectEditorProps).\n\n\nvar EditorView = function EditorView(place, props) {\n this._props = props; // :: EditorState\n // The view's current [state](#state.EditorState).\n\n this.state = props.state;\n this.dispatch = this.dispatch.bind(this);\n this._root = null;\n this.focused = false; // :: dom.Element\n // An editable DOM node containing the document. (You probably\n // should not directly interfere with its content.)\n\n this.dom = place && place.mount || document.createElement(\"div\");\n\n if (place) {\n if (place.appendChild) {\n place.appendChild(this.dom);\n } else if (place.apply) {\n place(this.dom);\n } else if (place.mount) {\n this.mounted = true;\n }\n } // :: bool\n // Indicates whether the editor is currently [editable](#view.EditorProps.editable).\n\n\n this.editable = getEditable(this);\n this.markCursor = null;\n this.cursorWrapper = null;\n updateCursorWrapper(this);\n this.nodeViews = buildNodeViews(this);\n this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this);\n this.lastSelectedViewDesc = null; // :: ?{slice: Slice, move: bool}\n // When editor content is being dragged, this object contains\n // information about the dragged slice and whether it is being\n // copied or moved. At any other time, it is null.\n\n this.dragging = null;\n initInput(this);\n this.pluginViews = [];\n this.updatePluginViews();\n};\n\nvar prototypeAccessors$2 = {\n props: {\n configurable: true\n },\n root: {\n configurable: true\n }\n}; // composing:: boolean\n// Holds `true` when a\n// [composition](https://developer.mozilla.org/en-US/docs/Mozilla/IME_handling_guide)\n// is active.\n// :: DirectEditorProps\n// The view's current [props](#view.EditorProps).\n\nprototypeAccessors$2.props.get = function () {\n if (this._props.state != this.state) {\n var prev = this._props;\n this._props = {};\n\n for (var name in prev) {\n this._props[name] = prev[name];\n }\n\n this._props.state = this.state;\n }\n\n return this._props;\n}; // :: (DirectEditorProps)\n// Update the view's props. Will immediately cause an update to\n// the DOM.\n\n\nEditorView.prototype.update = function update(props) {\n if (props.handleDOMEvents != this._props.handleDOMEvents) {\n ensureListeners(this);\n }\n\n this._props = props;\n this.updateStateInner(props.state, true);\n}; // :: (DirectEditorProps)\n// Update the view by updating existing props object with the object\n// given as argument. Equivalent to `view.update(Object.assign({},\n// view.props, props))`.\n\n\nEditorView.prototype.setProps = function setProps(props) {\n var updated = {};\n\n for (var name in this._props) {\n updated[name] = this._props[name];\n }\n\n updated.state = this.state;\n\n for (var name$1 in props) {\n updated[name$1] = props[name$1];\n }\n\n this.update(updated);\n}; // :: (EditorState)\n// Update the editor's `state` prop, without touching any of the\n// other props.\n\n\nEditorView.prototype.updateState = function updateState(state) {\n this.updateStateInner(state, this.state.plugins != state.plugins);\n};\n\nEditorView.prototype.updateStateInner = function updateStateInner(state, reconfigured) {\n var this$1 = this;\n var prev = this.state,\n redraw = false;\n this.state = state;\n\n if (reconfigured) {\n var nodeViews = buildNodeViews(this);\n\n if (changedNodeViews(nodeViews, this.nodeViews)) {\n this.nodeViews = nodeViews;\n redraw = true;\n }\n\n ensureListeners(this);\n }\n\n this.editable = getEditable(this);\n updateCursorWrapper(this);\n var innerDeco = viewDecorations(this),\n outerDeco = computeDocDeco(this);\n var scroll = reconfigured ? \"reset\" : state.scrollToSelection > prev.scrollToSelection ? \"to selection\" : \"preserve\";\n var updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);\n var updateSel = updateDoc || !state.selection.eq(prev.selection);\n var oldScrollPos = scroll == \"preserve\" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);\n\n if (updateSel) {\n this.domObserver.stop(); // Work around an issue in Chrome, IE, and Edge where changing\n // the DOM around an active selection puts it into a broken\n // state where the thing the user sees differs from the\n // selection reported by the Selection object (#710, #973,\n // #1011, #1013).\n\n var forceSelUpdate = updateDoc && (result.ie || result.chrome) && !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);\n\n if (updateDoc) {\n if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {\n this.docView.destroy();\n this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);\n }\n } // Work around for an issue where an update arriving right between\n // a DOM selection change and the \"selectionchange\" event for it\n // can cause a spurious DOM selection update, disrupting mouse\n // drag selection.\n\n\n if (forceSelUpdate || !(this.mouseDown && this.domObserver.currentSelection.eq(this.root.getSelection()) && anchorInRightPlace(this))) {\n selectionToDOM(this, forceSelUpdate);\n } else {\n syncNodeSelection(this, state.selection);\n this.domObserver.setCurSelection();\n }\n\n this.domObserver.start();\n }\n\n this.updatePluginViews(prev);\n\n if (scroll == \"reset\") {\n this.dom.scrollTop = 0;\n } else if (scroll == \"to selection\") {\n var startDOM = this.root.getSelection().focusNode;\n if (this.someProp(\"handleScrollToSelection\", function (f) {\n return f(this$1);\n })) ; // Handled\n else if (state.selection instanceof prosemirror_state__WEBPACK_IMPORTED_MODULE_0__[\"NodeSelection\"]) {\n scrollRectIntoView(this, this.docView.domAfterPos(state.selection.from).getBoundingClientRect(), startDOM);\n } else {\n scrollRectIntoView(this, this.coordsAtPos(state.selection.head), startDOM);\n }\n } else if (oldScrollPos) {\n resetScrollPos(oldScrollPos);\n }\n};\n\nEditorView.prototype.destroyPluginViews = function destroyPluginViews() {\n var view;\n\n while (view = this.pluginViews.pop()) {\n if (view.destroy) {\n view.destroy();\n }\n }\n};\n\nEditorView.prototype.updatePluginViews = function updatePluginViews(prevState) {\n if (!prevState || prevState.plugins != this.state.plugins) {\n this.destroyPluginViews();\n\n for (var i = 0; i < this.state.plugins.length; i++) {\n var plugin = this.state.plugins[i];\n\n if (plugin.spec.view) {\n this.pluginViews.push(plugin.spec.view(this));\n }\n }\n } else {\n for (var i$1 = 0; i$1 < this.pluginViews.length; i$1++) {\n var pluginView = this.pluginViews[i$1];\n\n if (pluginView.update) {\n pluginView.update(this, prevState);\n }\n }\n }\n}; // :: (string, ?(prop: *) → *) → *\n// Goes over the values of a prop, first those provided directly,\n// then those from plugins (in order), and calls `f` every time a\n// non-undefined value is found. When `f` returns a truthy value,\n// that is immediately returned. When `f` isn't provided, it is\n// treated as the identity function (the prop value is returned\n// directly).\n\n\nEditorView.prototype.someProp = function someProp(propName, f) {\n var prop = this._props && this._props[propName],\n value;\n\n if (prop != null && (value = f ? f(prop) : prop)) {\n return value;\n }\n\n var plugins = this.state.plugins;\n\n if (plugins) {\n for (var i = 0; i < plugins.length; i++) {\n var prop$1 = plugins[i].props[propName];\n\n if (prop$1 != null && (value = f ? f(prop$1) : prop$1)) {\n return value;\n }\n }\n }\n}; // :: () → bool\n// Query whether the view has focus.\n\n\nEditorView.prototype.hasFocus = function hasFocus() {\n return this.root.activeElement == this.dom;\n}; // :: ()\n// Focus the editor.\n\n\nEditorView.prototype.focus = function focus() {\n this.domObserver.stop();\n\n if (this.editable) {\n focusPreventScroll(this.dom);\n }\n\n selectionToDOM(this);\n this.domObserver.start();\n}; // :: union\n// Get the document root in which the editor exists. This will\n// usually be the top-level `document`, but might be a [shadow\n// DOM](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Shadow_DOM)\n// root if the editor is inside one.\n\n\nprototypeAccessors$2.root.get = function () {\n var cached = this._root;\n\n if (cached == null) {\n for (var search = this.dom.parentNode; search; search = search.parentNode) {\n if (search.nodeType == 9 || search.nodeType == 11 && search.host) {\n if (!search.getSelection) {\n Object.getPrototypeOf(search).getSelection = function () {\n return document.getSelection();\n };\n }\n\n return this._root = search;\n }\n }\n }\n\n return cached || document;\n}; // :: ({left: number, top: number}) → ?{pos: number, inside: number}\n// Given a pair of viewport coordinates, return the document\n// position that corresponds to them. May return null if the given\n// coordinates aren't inside of the editor. When an object is\n// returned, its `pos` property is the position nearest to the\n// coordinates, and its `inside` property holds the position of the\n// inner node that the position falls inside of, or -1 if it is at\n// the top level, not in any node.\n\n\nEditorView.prototype.posAtCoords = function posAtCoords$1(coords) {\n return posAtCoords(this, coords);\n}; // :: (number) → {left: number, right: number, top: number, bottom: number}\n// Returns the viewport rectangle at a given document position. `left`\n// and `right` will be the same number, as this returns a flat\n// cursor-ish rectangle.\n\n\nEditorView.prototype.coordsAtPos = function coordsAtPos$1(pos) {\n return coordsAtPos(this, pos);\n}; // :: (number) → {node: dom.Node, offset: number}\n// Find the DOM position that corresponds to the given document\n// position. Note that you should **not** mutate the editor's\n// internal DOM, only inspect it (and even that is usually not\n// necessary).\n\n\nEditorView.prototype.domAtPos = function domAtPos(pos) {\n return this.docView.domFromPos(pos);\n}; // :: (number) → ?dom.Node\n// Find the DOM node that represents the document node after the\n// given position. May return `null` when the position doesn't point\n// in front of a node or if the node is inside an opaque node view.\n//\n// This is intended to be able to call things like\n// `getBoundingClientRect` on that DOM node. Do **not** mutate the\n// editor DOM directly, or add styling this way, since that will be\n// immediately overriden by the editor as it redraws the node.\n\n\nEditorView.prototype.nodeDOM = function nodeDOM(pos) {\n var desc = this.docView.descAt(pos);\n return desc ? desc.nodeDOM : null;\n}; // :: (dom.Node, number, ?number) → number\n// Find the document position that corresponds to a given DOM\n// position. (Whenever possible, it is preferable to inspect the\n// document structure directly, rather than poking around in the\n// DOM, but sometimes—for example when interpreting an event\n// target—you don't have a choice.)\n//\n// The `bias` parameter can be used to influence which side of a DOM\n// node to use when the position is inside a leaf node.\n\n\nEditorView.prototype.posAtDOM = function posAtDOM(node, offset, bias) {\n if (bias === void 0) bias = -1;\n var pos = this.docView.posFromDOM(node, offset, bias);\n\n if (pos == null) {\n throw new RangeError(\"DOM position not inside the editor\");\n }\n\n return pos;\n}; // :: (union<\"up\", \"down\", \"left\", \"right\", \"forward\", \"backward\">, ?EditorState) → bool\n// Find out whether the selection is at the end of a textblock when\n// moving in a given direction. When, for example, given `\"left\"`,\n// it will return true if moving left from the current cursor\n// position would leave that position's parent textblock. Will apply\n// to the view's current state by default, but it is possible to\n// pass a different state.\n\n\nEditorView.prototype.endOfTextblock = function endOfTextblock$1(dir, state) {\n return endOfTextblock(this, state || this.state, dir);\n}; // :: ()\n// Removes the editor from the DOM and destroys all [node\n// views](#view.NodeView).\n\n\nEditorView.prototype.destroy = function destroy() {\n if (!this.docView) {\n return;\n }\n\n destroyInput(this);\n this.destroyPluginViews();\n\n if (this.mounted) {\n this.docView.update(this.state.doc, [], viewDecorations(this), this);\n this.dom.textContent = \"\";\n } else if (this.dom.parentNode) {\n this.dom.parentNode.removeChild(this.dom);\n }\n\n this.docView.destroy();\n this.docView = null;\n}; // Used for testing.\n\n\nEditorView.prototype.dispatchEvent = function dispatchEvent$1(event) {\n return dispatchEvent(this, event);\n}; // :: (Transaction)\n// Dispatch a transaction. Will call\n// [`dispatchTransaction`](#view.DirectEditorProps.dispatchTransaction)\n// when given, and otherwise defaults to applying the transaction to\n// the current state and calling\n// [`updateState`](#view.EditorView.updateState) with the result.\n// This method is bound to the view instance, so that it can be\n// easily passed around.\n\n\nEditorView.prototype.dispatch = function dispatch(tr) {\n var dispatchTransaction = this._props.dispatchTransaction;\n\n if (dispatchTransaction) {\n dispatchTransaction.call(this, tr);\n } else {\n this.updateState(this.state.apply(tr));\n }\n};\n\nObject.defineProperties(EditorView.prototype, prototypeAccessors$2);\n\nfunction computeDocDeco(view) {\n var attrs = Object.create(null);\n attrs[\"class\"] = \"ProseMirror\";\n attrs.contenteditable = String(view.editable);\n view.someProp(\"attributes\", function (value) {\n if (typeof value == \"function\") {\n value = value(view.state);\n }\n\n if (value) {\n for (var attr in value) {\n if (attr == \"class\") {\n attrs[\"class\"] += \" \" + value[attr];\n } else if (!attrs[attr] && attr != \"contenteditable\" && attr != \"nodeName\") {\n attrs[attr] = String(value[attr]);\n }\n }\n }\n });\n return [Decoration.node(0, view.state.doc.content.size, attrs)];\n}\n\nfunction updateCursorWrapper(view) {\n var ref = view.state.selection;\n var $head = ref.$head;\n var $anchor = ref.$anchor;\n var visible = ref.visible;\n\n if (view.markCursor) {\n var dom = document.createElement(\"img\");\n dom.setAttribute(\"mark-placeholder\", \"true\");\n view.cursorWrapper = {\n dom: dom,\n deco: Decoration.widget($head.pos, dom, {\n raw: true,\n marks: view.markCursor\n })\n };\n } else if (visible || $head.pos != $anchor.pos) {\n view.cursorWrapper = null;\n } else {\n var dom$1;\n\n if (!view.cursorWrapper || view.cursorWrapper.dom.childNodes.length) {\n dom$1 = document.createElement(\"div\");\n dom$1.style.position = \"absolute\";\n dom$1.style.left = \"-100000px\";\n } else if (view.cursorWrapper.deco.pos != $head.pos) {\n dom$1 = view.cursorWrapper.dom;\n }\n\n if (dom$1) {\n view.cursorWrapper = {\n dom: dom$1,\n deco: Decoration.widget($head.pos, dom$1, {\n raw: true\n })\n };\n }\n }\n}\n\nfunction getEditable(view) {\n return !view.someProp(\"editable\", function (value) {\n return value(view.state) === false;\n });\n}\n\nfunction selectionContextChanged(sel1, sel2) {\n var depth = Math.min(sel1.$anchor.sharedDepth(sel1.head), sel2.$anchor.sharedDepth(sel2.head));\n return sel1.$anchor.node(depth) != sel2.$anchor.node(depth);\n}\n\nfunction buildNodeViews(view) {\n var result = {};\n view.someProp(\"nodeViews\", function (obj) {\n for (var prop in obj) {\n if (!Object.prototype.hasOwnProperty.call(result, prop)) {\n result[prop] = obj[prop];\n }\n }\n });\n return result;\n}\n\nfunction changedNodeViews(a, b) {\n var nA = 0,\n nB = 0;\n\n for (var prop in a) {\n if (a[prop] != b[prop]) {\n return true;\n }\n\n nA++;\n }\n\n for (var _ in b) {\n nB++;\n }\n\n return nA != nB;\n} // EditorProps:: interface\n//\n// Props are configuration values that can be passed to an editor view\n// or included in a plugin. This interface lists the supported props.\n//\n// The various event-handling functions may all return `true` to\n// indicate that they handled the given event. The view will then take\n// care to call `preventDefault` on the event, except with\n// `handleDOMEvents`, where the handler itself is responsible for that.\n//\n// How a prop is resolved depends on the prop. Handler functions are\n// called one at a time, starting with the base props and then\n// searching through the plugins (in order of appearance) until one of\n// them returns true. For some props, the first plugin that yields a\n// value gets precedence.\n//\n// handleDOMEvents:: ?Object<(view: EditorView, event: dom.Event) → bool>\n// Can be an object mapping DOM event type names to functions that\n// handle them. Such functions will be called before any handling\n// ProseMirror does of events fired on the editable DOM element.\n// Contrary to the other event handling props, when returning true\n// from such a function, you are responsible for calling\n// `preventDefault` yourself (or not, if you want to allow the\n// default behavior).\n//\n// handleKeyDown:: ?(view: EditorView, event: dom.KeyboardEvent) → bool\n// Called when the editor receives a `keydown` event.\n//\n// handleKeyPress:: ?(view: EditorView, event: dom.KeyboardEvent) → bool\n// Handler for `keypress` events.\n//\n// handleTextInput:: ?(view: EditorView, from: number, to: number, text: string) → bool\n// Whenever the user directly input text, this handler is called\n// before the input is applied. If it returns `true`, the default\n// behavior of actually inserting the text is suppressed.\n//\n// handleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool\n// Called for each node around a click, from the inside out. The\n// `direct` flag will be true for the inner node.\n//\n// handleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool\n// Called when the editor is clicked, after `handleClickOn` handlers\n// have been called.\n//\n// handleDoubleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool\n// Called for each node around a double click.\n//\n// handleDoubleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool\n// Called when the editor is double-clicked, after `handleDoubleClickOn`.\n//\n// handleTripleClickOn:: ?(view: EditorView, pos: number, node: Node, nodePos: number, event: dom.MouseEvent, direct: bool) → bool\n// Called for each node around a triple click.\n//\n// handleTripleClick:: ?(view: EditorView, pos: number, event: dom.MouseEvent) → bool\n// Called when the editor is triple-clicked, after `handleTripleClickOn`.\n//\n// handlePaste:: ?(view: EditorView, event: dom.Event, slice: Slice) → bool\n// Can be used to override the behavior of pasting. `slice` is the\n// pasted content parsed by the editor, but you can directly access\n// the event to get at the raw content.\n//\n// handleDrop:: ?(view: EditorView, event: dom.Event, slice: Slice, moved: bool) → bool\n// Called when something is dropped on the editor. `moved` will be\n// true if this drop moves from the current selection (which should\n// thus be deleted).\n//\n// handleScrollToSelection:: ?(view: EditorView) → bool\n// Called when the view, after updating its state, tries to scroll\n// the selection into view. A handler function may return false to\n// indicate that it did not handle the scrolling and further\n// handlers or the default behavior should be tried.\n//\n// createSelectionBetween:: ?(view: EditorView, anchor: ResolvedPos, head: ResolvedPos) → ?Selection\n// Can be used to override the way a selection is created when\n// reading a DOM selection between the given anchor and head.\n//\n// domParser:: ?DOMParser\n// The [parser](#model.DOMParser) to use when reading editor changes\n// from the DOM. Defaults to calling\n// [`DOMParser.fromSchema`](#model.DOMParser^fromSchema) on the\n// editor's schema.\n//\n// transformPastedHTML:: ?(html: string) → string\n// Can be used to transform pasted HTML text, _before_ it is parsed,\n// for example to clean it up.\n//\n// clipboardParser:: ?DOMParser\n// The [parser](#model.DOMParser) to use when reading content from\n// the clipboard. When not given, the value of the\n// [`domParser`](#view.EditorProps.domParser) prop is used.\n//\n// transformPastedText:: ?(text: string) → string\n// Transform pasted plain text.\n//\n// clipboardTextParser:: ?(text: string, $context: ResolvedPos) → Slice\n// A function to parse text from the clipboard into a document\n// slice. Called after\n// [`transformPastedText`](#view.EditorProps.transformPastedText).\n// The default behavior is to split the text into lines, wrap them\n// in `` tags, and call\n// [`clipboardParser`](#view.EditorProps.clipboardParser) on it.\n//\n// transformPasted:: ?(Slice) → Slice\n// Can be used to transform pasted content before it is applied to\n// the document.\n//\n// nodeViews:: ?Object<(node: Node, view: EditorView, getPos: () → number, decorations: [Decoration]) → NodeView>\n// Allows you to pass custom rendering and behavior logic for nodes\n// and marks. Should map node and mark names to constructor\n// functions that produce a [`NodeView`](#view.NodeView) object\n// implementing the node's display behavior. For nodes, the third\n// argument `getPos` is a function that can be called to get the\n// node's current position, which can be useful when creating\n// transactions to update it. For marks, the third argument is a\n// boolean that indicates whether the mark's content is inline.\n//\n// `decorations` is an array of node or inline decorations that are\n// active around the node. They are automatically drawn in the\n// normal way, and you will usually just want to ignore this, but\n// they can also be used as a way to provide context information to\n// the node view without adding it to the document itself.\n//\n// clipboardSerializer:: ?DOMSerializer\n// The DOM serializer to use when putting content onto the\n// clipboard. If not given, the result of\n// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)\n// will be used.\n//\n// clipboardTextSerializer:: ?(Slice) → string\n// A function that will be called to get the text for the current\n// selection when copying text to the clipboard. By default, the\n// editor will use [`textBetween`](#model.Node.textBetween) on the\n// selected range.\n//\n// decorations:: ?(state: EditorState) → ?DecorationSet\n// A set of [document decorations](#view.Decoration) to show in the\n// view.\n//\n// editable:: ?(state: EditorState) → bool\n// When this returns false, the content of the view is not directly\n// editable.\n//\n// attributes:: ?union, (EditorState) → ?Object>\n// Control the DOM attributes of the editable element. May be either\n// an object or a function going from an editor state to an object.\n// By default, the element will get a class `\"ProseMirror\"`, and\n// will have its `contentEditable` attribute determined by the\n// [`editable` prop](#view.EditorProps.editable). Additional classes\n// provided here will be added to the class. For other attributes,\n// the value provided first (as in\n// [`someProp`](#view.EditorView.someProp)) will be used.\n//\n// scrollThreshold:: ?union\n// Determines the distance (in pixels) between the cursor and the\n// end of the visible viewport at which point, when scrolling the\n// cursor into view, scrolling takes place. Defaults to 0.\n//\n// scrollMargin:: ?union\n// Determines the extra space (in pixels) that is left above or\n// below the cursor when it is scrolled into view. Defaults to 5.\n// DirectEditorProps:: interface extends EditorProps\n//\n// The props object given directly to the editor view supports two\n// fields that can't be used in plugins:\n//\n// state:: EditorState\n// The current state of the editor.\n//\n// dispatchTransaction:: ?(tr: Transaction)\n// The callback over which to send transactions (state updates)\n// produced by the view. If you specify this, you probably want to\n// make sure this ends up calling the view's\n// [`updateState`](#view.EditorView.updateState) method with a new\n// state that has the transaction\n// [applied](#state.EditorState.apply). The callback will be bound to have\n// the view instance as its `this` binding.\n\n\n\n\n//# sourceURL=webpack:///./node_modules/prosemirror-view/dist/index.es.js?");
/***/ }),
/***/ "./node_modules/rope-sequence/dist/index.es.js":
/*!*****************************************************!*\
!*** ./node_modules/rope-sequence/dist/index.es.js ***!
\*****************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\nvar GOOD_LEAF_SIZE = 200;\n\n// :: class A rope sequence is a persistent sequence data structure\n// that supports appending, prepending, and slicing without doing a\n// full copy. It is represented as a mostly-balanced tree.\nvar RopeSequence = function RopeSequence () {};\n\nRopeSequence.prototype.append = function append (other) {\n if (!other.length) { return this }\n other = RopeSequence.from(other);\n\n return (!this.length && other) ||\n (other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) ||\n (this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) ||\n this.appendInner(other)\n};\n\n// :: (union<[T], RopeSequence>) → RopeSequence\n// Prepend an array or other rope to this one, returning a new rope.\nRopeSequence.prototype.prepend = function prepend (other) {\n if (!other.length) { return this }\n return RopeSequence.from(other).append(this)\n};\n\nRopeSequence.prototype.appendInner = function appendInner (other) {\n return new Append(this, other)\n};\n\n// :: (?number, ?number) → RopeSequence\n// Create a rope repesenting a sub-sequence of this rope.\nRopeSequence.prototype.slice = function slice (from, to) {\n if ( from === void 0 ) from = 0;\n if ( to === void 0 ) to = this.length;\n\n if (from >= to) { return RopeSequence.empty }\n return this.sliceInner(Math.max(0, from), Math.min(this.length, to))\n};\n\n// :: (number) → T\n// Retrieve the element at the given position from this rope.\nRopeSequence.prototype.get = function get (i) {\n if (i < 0 || i >= this.length) { return undefined }\n return this.getInner(i)\n};\n\n// :: ((element: T, index: number) → ?bool, ?number, ?number)\n// Call the given function for each element between the given\n// indices. This tends to be more efficient than looping over the\n// indices and calling `get`, because it doesn't have to descend the\n// tree for every element.\nRopeSequence.prototype.forEach = function forEach (f, from, to) {\n if ( from === void 0 ) from = 0;\n if ( to === void 0 ) to = this.length;\n\n if (from <= to)\n { this.forEachInner(f, from, to, 0); }\n else\n { this.forEachInvertedInner(f, from, to, 0); }\n};\n\n// :: ((element: T, index: number) → U, ?number, ?number) → [U]\n// Map the given functions over the elements of the rope, producing\n// a flat array.\nRopeSequence.prototype.map = function map (f, from, to) {\n if ( from === void 0 ) from = 0;\n if ( to === void 0 ) to = this.length;\n\n var result = [];\n this.forEach(function (elt, i) { return result.push(f(elt, i)); }, from, to);\n return result\n};\n\n// :: (?union<[T], RopeSequence>) → RopeSequence\n// Create a rope representing the given array, or return the rope\n// itself if a rope was given.\nRopeSequence.from = function from (values) {\n if (values instanceof RopeSequence) { return values }\n return values && values.length ? new Leaf(values) : RopeSequence.empty\n};\n\nvar Leaf = /*@__PURE__*/(function (RopeSequence) {\n function Leaf(values) {\n RopeSequence.call(this);\n this.values = values;\n }\n\n if ( RopeSequence ) Leaf.__proto__ = RopeSequence;\n Leaf.prototype = Object.create( RopeSequence && RopeSequence.prototype );\n Leaf.prototype.constructor = Leaf;\n\n var prototypeAccessors = { length: { configurable: true },depth: { configurable: true } };\n\n Leaf.prototype.flatten = function flatten () {\n return this.values\n };\n\n Leaf.prototype.sliceInner = function sliceInner (from, to) {\n if (from == 0 && to == this.length) { return this }\n return new Leaf(this.values.slice(from, to))\n };\n\n Leaf.prototype.getInner = function getInner (i) {\n return this.values[i]\n };\n\n Leaf.prototype.forEachInner = function forEachInner (f, from, to, start) {\n for (var i = from; i < to; i++)\n { if (f(this.values[i], start + i) === false) { return false } }\n };\n\n Leaf.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {\n for (var i = from - 1; i >= to; i--)\n { if (f(this.values[i], start + i) === false) { return false } }\n };\n\n Leaf.prototype.leafAppend = function leafAppend (other) {\n if (this.length + other.length <= GOOD_LEAF_SIZE)\n { return new Leaf(this.values.concat(other.flatten())) }\n };\n\n Leaf.prototype.leafPrepend = function leafPrepend (other) {\n if (this.length + other.length <= GOOD_LEAF_SIZE)\n { return new Leaf(other.flatten().concat(this.values)) }\n };\n\n prototypeAccessors.length.get = function () { return this.values.length };\n\n prototypeAccessors.depth.get = function () { return 0 };\n\n Object.defineProperties( Leaf.prototype, prototypeAccessors );\n\n return Leaf;\n}(RopeSequence));\n\n// :: RopeSequence\n// The empty rope sequence.\nRopeSequence.empty = new Leaf([]);\n\nvar Append = /*@__PURE__*/(function (RopeSequence) {\n function Append(left, right) {\n RopeSequence.call(this);\n this.left = left;\n this.right = right;\n this.length = left.length + right.length;\n this.depth = Math.max(left.depth, right.depth) + 1;\n }\n\n if ( RopeSequence ) Append.__proto__ = RopeSequence;\n Append.prototype = Object.create( RopeSequence && RopeSequence.prototype );\n Append.prototype.constructor = Append;\n\n Append.prototype.flatten = function flatten () {\n return this.left.flatten().concat(this.right.flatten())\n };\n\n Append.prototype.getInner = function getInner (i) {\n return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length)\n };\n\n Append.prototype.forEachInner = function forEachInner (f, from, to, start) {\n var leftLen = this.left.length;\n if (from < leftLen &&\n this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false)\n { return false }\n if (to > leftLen &&\n this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false)\n { return false }\n };\n\n Append.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {\n var leftLen = this.left.length;\n if (from > leftLen &&\n this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false)\n { return false }\n if (to < leftLen &&\n this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false)\n { return false }\n };\n\n Append.prototype.sliceInner = function sliceInner (from, to) {\n if (from == 0 && to == this.length) { return this }\n var leftLen = this.left.length;\n if (to <= leftLen) { return this.left.slice(from, to) }\n if (from >= leftLen) { return this.right.slice(from - leftLen, to - leftLen) }\n return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen))\n };\n\n Append.prototype.leafAppend = function leafAppend (other) {\n var inner = this.right.leafAppend(other);\n if (inner) { return new Append(this.left, inner) }\n };\n\n Append.prototype.leafPrepend = function leafPrepend (other) {\n var inner = this.left.leafPrepend(other);\n if (inner) { return new Append(inner, this.right) }\n };\n\n Append.prototype.appendInner = function appendInner (other) {\n if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1)\n { return new Append(this.left, new Append(this.right, other)) }\n return new Append(this, other)\n };\n\n return Append;\n}(RopeSequence));\n\nvar ropeSequence = RopeSequence;\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (ropeSequence);\n\n\n//# sourceURL=webpack:///./node_modules/rope-sequence/dist/index.es.js?");
+eval("__webpack_require__.r(__webpack_exports__);\nvar GOOD_LEAF_SIZE = 200; // :: class A rope sequence is a persistent sequence data structure\n// that supports appending, prepending, and slicing without doing a\n// full copy. It is represented as a mostly-balanced tree.\n\nvar RopeSequence = function RopeSequence() {};\n\nRopeSequence.prototype.append = function append(other) {\n if (!other.length) {\n return this;\n }\n\n other = RopeSequence.from(other);\n return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other);\n}; // :: (union<[T], RopeSequence>) → RopeSequence\n// Prepend an array or other rope to this one, returning a new rope.\n\n\nRopeSequence.prototype.prepend = function prepend(other) {\n if (!other.length) {\n return this;\n }\n\n return RopeSequence.from(other).append(this);\n};\n\nRopeSequence.prototype.appendInner = function appendInner(other) {\n return new Append(this, other);\n}; // :: (?number, ?number) → RopeSequence\n// Create a rope repesenting a sub-sequence of this rope.\n\n\nRopeSequence.prototype.slice = function slice(from, to) {\n if (from === void 0) from = 0;\n if (to === void 0) to = this.length;\n\n if (from >= to) {\n return RopeSequence.empty;\n }\n\n return this.sliceInner(Math.max(0, from), Math.min(this.length, to));\n}; // :: (number) → T\n// Retrieve the element at the given position from this rope.\n\n\nRopeSequence.prototype.get = function get(i) {\n if (i < 0 || i >= this.length) {\n return undefined;\n }\n\n return this.getInner(i);\n}; // :: ((element: T, index: number) → ?bool, ?number, ?number)\n// Call the given function for each element between the given\n// indices. This tends to be more efficient than looping over the\n// indices and calling `get`, because it doesn't have to descend the\n// tree for every element.\n\n\nRopeSequence.prototype.forEach = function forEach(f, from, to) {\n if (from === void 0) from = 0;\n if (to === void 0) to = this.length;\n\n if (from <= to) {\n this.forEachInner(f, from, to, 0);\n } else {\n this.forEachInvertedInner(f, from, to, 0);\n }\n}; // :: ((element: T, index: number) → U, ?number, ?number) → [U]\n// Map the given functions over the elements of the rope, producing\n// a flat array.\n\n\nRopeSequence.prototype.map = function map(f, from, to) {\n if (from === void 0) from = 0;\n if (to === void 0) to = this.length;\n var result = [];\n this.forEach(function (elt, i) {\n return result.push(f(elt, i));\n }, from, to);\n return result;\n}; // :: (?union<[T], RopeSequence>) → RopeSequence\n// Create a rope representing the given array, or return the rope\n// itself if a rope was given.\n\n\nRopeSequence.from = function from(values) {\n if (values instanceof RopeSequence) {\n return values;\n }\n\n return values && values.length ? new Leaf(values) : RopeSequence.empty;\n};\n\nvar Leaf = /*@__PURE__*/function (RopeSequence) {\n function Leaf(values) {\n RopeSequence.call(this);\n this.values = values;\n }\n\n if (RopeSequence) Leaf.__proto__ = RopeSequence;\n Leaf.prototype = Object.create(RopeSequence && RopeSequence.prototype);\n Leaf.prototype.constructor = Leaf;\n var prototypeAccessors = {\n length: {\n configurable: true\n },\n depth: {\n configurable: true\n }\n };\n\n Leaf.prototype.flatten = function flatten() {\n return this.values;\n };\n\n Leaf.prototype.sliceInner = function sliceInner(from, to) {\n if (from == 0 && to == this.length) {\n return this;\n }\n\n return new Leaf(this.values.slice(from, to));\n };\n\n Leaf.prototype.getInner = function getInner(i) {\n return this.values[i];\n };\n\n Leaf.prototype.forEachInner = function forEachInner(f, from, to, start) {\n for (var i = from; i < to; i++) {\n if (f(this.values[i], start + i) === false) {\n return false;\n }\n }\n };\n\n Leaf.prototype.forEachInvertedInner = function forEachInvertedInner(f, from, to, start) {\n for (var i = from - 1; i >= to; i--) {\n if (f(this.values[i], start + i) === false) {\n return false;\n }\n }\n };\n\n Leaf.prototype.leafAppend = function leafAppend(other) {\n if (this.length + other.length <= GOOD_LEAF_SIZE) {\n return new Leaf(this.values.concat(other.flatten()));\n }\n };\n\n Leaf.prototype.leafPrepend = function leafPrepend(other) {\n if (this.length + other.length <= GOOD_LEAF_SIZE) {\n return new Leaf(other.flatten().concat(this.values));\n }\n };\n\n prototypeAccessors.length.get = function () {\n return this.values.length;\n };\n\n prototypeAccessors.depth.get = function () {\n return 0;\n };\n\n Object.defineProperties(Leaf.prototype, prototypeAccessors);\n return Leaf;\n}(RopeSequence); // :: RopeSequence\n// The empty rope sequence.\n\n\nRopeSequence.empty = new Leaf([]);\n\nvar Append = /*@__PURE__*/function (RopeSequence) {\n function Append(left, right) {\n RopeSequence.call(this);\n this.left = left;\n this.right = right;\n this.length = left.length + right.length;\n this.depth = Math.max(left.depth, right.depth) + 1;\n }\n\n if (RopeSequence) Append.__proto__ = RopeSequence;\n Append.prototype = Object.create(RopeSequence && RopeSequence.prototype);\n Append.prototype.constructor = Append;\n\n Append.prototype.flatten = function flatten() {\n return this.left.flatten().concat(this.right.flatten());\n };\n\n Append.prototype.getInner = function getInner(i) {\n return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);\n };\n\n Append.prototype.forEachInner = function forEachInner(f, from, to, start) {\n var leftLen = this.left.length;\n\n if (from < leftLen && this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false) {\n return false;\n }\n\n if (to > leftLen && this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) {\n return false;\n }\n };\n\n Append.prototype.forEachInvertedInner = function forEachInvertedInner(f, from, to, start) {\n var leftLen = this.left.length;\n\n if (from > leftLen && this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) {\n return false;\n }\n\n if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false) {\n return false;\n }\n };\n\n Append.prototype.sliceInner = function sliceInner(from, to) {\n if (from == 0 && to == this.length) {\n return this;\n }\n\n var leftLen = this.left.length;\n\n if (to <= leftLen) {\n return this.left.slice(from, to);\n }\n\n if (from >= leftLen) {\n return this.right.slice(from - leftLen, to - leftLen);\n }\n\n return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen));\n };\n\n Append.prototype.leafAppend = function leafAppend(other) {\n var inner = this.right.leafAppend(other);\n\n if (inner) {\n return new Append(this.left, inner);\n }\n };\n\n Append.prototype.leafPrepend = function leafPrepend(other) {\n var inner = this.left.leafPrepend(other);\n\n if (inner) {\n return new Append(inner, this.right);\n }\n };\n\n Append.prototype.appendInner = function appendInner(other) {\n if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {\n return new Append(this.left, new Append(this.right, other));\n }\n\n return new Append(this, other);\n };\n\n return Append;\n}(RopeSequence);\n\nvar ropeSequence = RopeSequence;\n/* harmony default export */ __webpack_exports__[\"default\"] = (ropeSequence);\n\n//# sourceURL=webpack:///./node_modules/rope-sequence/dist/index.es.js?");
/***/ }),
/***/ "./node_modules/uc.micro/categories/Cc/regex.js":
/*!******************************************************!*\
!*** ./node_modules/uc.micro/categories/Cc/regex.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("module.exports=/[\\0-\\x1F\\x7F-\\x9F]/\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/Cc/regex.js?");
+eval("module.exports = /[\\0-\\x1F\\x7F-\\x9F]/;\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/Cc/regex.js?");
/***/ }),
/***/ "./node_modules/uc.micro/categories/Cf/regex.js":
/*!******************************************************!*\
!*** ./node_modules/uc.micro/categories/Cf/regex.js ***!
\******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("module.exports=/[\\xAD\\u0600-\\u0605\\u061C\\u06DD\\u070F\\u08E2\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u206F\\uFEFF\\uFFF9-\\uFFFB]|\\uD804[\\uDCBD\\uDCCD]|\\uD82F[\\uDCA0-\\uDCA3]|\\uD834[\\uDD73-\\uDD7A]|\\uDB40[\\uDC01\\uDC20-\\uDC7F]/\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/Cf/regex.js?");
+eval("module.exports = /[\\xAD\\u0600-\\u0605\\u061C\\u06DD\\u070F\\u08E2\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u206F\\uFEFF\\uFFF9-\\uFFFB]|\\uD804[\\uDCBD\\uDCCD]|\\uD82F[\\uDCA0-\\uDCA3]|\\uD834[\\uDD73-\\uDD7A]|\\uDB40[\\uDC01\\uDC20-\\uDC7F]/;\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/Cf/regex.js?");
/***/ }),
/***/ "./node_modules/uc.micro/categories/P/regex.js":
/*!*****************************************************!*\
!*** ./node_modules/uc.micro/categories/P/regex.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("module.exports=/[!-#%-\\*,-\\/:;\\?@\\[-\\]_\\{\\}\\xA1\\xA7\\xAB\\xB6\\xB7\\xBB\\xBF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u09FD\\u0A76\\u0AF0\\u0C84\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2308-\\u230B\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E4E\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA8FC\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]|\\uD800[\\uDD00-\\uDD02\\uDF9F\\uDFD0]|\\uD801\\uDD6F|\\uD802[\\uDC57\\uDD1F\\uDD3F\\uDE50-\\uDE58\\uDE7F\\uDEF0-\\uDEF6\\uDF39-\\uDF3F\\uDF99-\\uDF9C]|\\uD803[\\uDF55-\\uDF59]|\\uD804[\\uDC47-\\uDC4D\\uDCBB\\uDCBC\\uDCBE-\\uDCC1\\uDD40-\\uDD43\\uDD74\\uDD75\\uDDC5-\\uDDC8\\uDDCD\\uDDDB\\uDDDD-\\uDDDF\\uDE38-\\uDE3D\\uDEA9]|\\uD805[\\uDC4B-\\uDC4F\\uDC5B\\uDC5D\\uDCC6\\uDDC1-\\uDDD7\\uDE41-\\uDE43\\uDE60-\\uDE6C\\uDF3C-\\uDF3E]|\\uD806[\\uDC3B\\uDE3F-\\uDE46\\uDE9A-\\uDE9C\\uDE9E-\\uDEA2]|\\uD807[\\uDC41-\\uDC45\\uDC70\\uDC71\\uDEF7\\uDEF8]|\\uD809[\\uDC70-\\uDC74]|\\uD81A[\\uDE6E\\uDE6F\\uDEF5\\uDF37-\\uDF3B\\uDF44]|\\uD81B[\\uDE97-\\uDE9A]|\\uD82F\\uDC9F|\\uD836[\\uDE87-\\uDE8B]|\\uD83A[\\uDD5E\\uDD5F]/\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/P/regex.js?");
+eval("module.exports = /[!-#%-\\*,-\\/:;\\?@\\[-\\]_\\{\\}\\xA1\\xA7\\xAB\\xB6\\xB7\\xBB\\xBF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u09FD\\u0A76\\u0AF0\\u0C84\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2308-\\u230B\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E4E\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA8FC\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]|\\uD800[\\uDD00-\\uDD02\\uDF9F\\uDFD0]|\\uD801\\uDD6F|\\uD802[\\uDC57\\uDD1F\\uDD3F\\uDE50-\\uDE58\\uDE7F\\uDEF0-\\uDEF6\\uDF39-\\uDF3F\\uDF99-\\uDF9C]|\\uD803[\\uDF55-\\uDF59]|\\uD804[\\uDC47-\\uDC4D\\uDCBB\\uDCBC\\uDCBE-\\uDCC1\\uDD40-\\uDD43\\uDD74\\uDD75\\uDDC5-\\uDDC8\\uDDCD\\uDDDB\\uDDDD-\\uDDDF\\uDE38-\\uDE3D\\uDEA9]|\\uD805[\\uDC4B-\\uDC4F\\uDC5B\\uDC5D\\uDCC6\\uDDC1-\\uDDD7\\uDE41-\\uDE43\\uDE60-\\uDE6C\\uDF3C-\\uDF3E]|\\uD806[\\uDC3B\\uDE3F-\\uDE46\\uDE9A-\\uDE9C\\uDE9E-\\uDEA2]|\\uD807[\\uDC41-\\uDC45\\uDC70\\uDC71\\uDEF7\\uDEF8]|\\uD809[\\uDC70-\\uDC74]|\\uD81A[\\uDE6E\\uDE6F\\uDEF5\\uDF37-\\uDF3B\\uDF44]|\\uD81B[\\uDE97-\\uDE9A]|\\uD82F\\uDC9F|\\uD836[\\uDE87-\\uDE8B]|\\uD83A[\\uDD5E\\uDD5F]/;\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/P/regex.js?");
/***/ }),
/***/ "./node_modules/uc.micro/categories/Z/regex.js":
/*!*****************************************************!*\
!*** ./node_modules/uc.micro/categories/Z/regex.js ***!
\*****************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("module.exports=/[ \\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]/\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/Z/regex.js?");
+eval("module.exports = /[ \\xA0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]/;\n\n//# sourceURL=webpack:///./node_modules/uc.micro/categories/Z/regex.js?");
/***/ }),
/***/ "./node_modules/uc.micro/index.js":
/*!****************************************!*\
!*** ./node_modules/uc.micro/index.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
-eval("\n\nexports.Any = __webpack_require__(/*! ./properties/Any/regex */ \"./node_modules/uc.micro/properties/Any/regex.js\");\nexports.Cc = __webpack_require__(/*! ./categories/Cc/regex */ \"./node_modules/uc.micro/categories/Cc/regex.js\");\nexports.Cf = __webpack_require__(/*! ./categories/Cf/regex */ \"./node_modules/uc.micro/categories/Cf/regex.js\");\nexports.P = __webpack_require__(/*! ./categories/P/regex */ \"./node_modules/uc.micro/categories/P/regex.js\");\nexports.Z = __webpack_require__(/*! ./categories/Z/regex */ \"./node_modules/uc.micro/categories/Z/regex.js\");\n\n\n//# sourceURL=webpack:///./node_modules/uc.micro/index.js?");
+eval("\n\nexports.Any = __webpack_require__(/*! ./properties/Any/regex */ \"./node_modules/uc.micro/properties/Any/regex.js\");\nexports.Cc = __webpack_require__(/*! ./categories/Cc/regex */ \"./node_modules/uc.micro/categories/Cc/regex.js\");\nexports.Cf = __webpack_require__(/*! ./categories/Cf/regex */ \"./node_modules/uc.micro/categories/Cf/regex.js\");\nexports.P = __webpack_require__(/*! ./categories/P/regex */ \"./node_modules/uc.micro/categories/P/regex.js\");\nexports.Z = __webpack_require__(/*! ./categories/Z/regex */ \"./node_modules/uc.micro/categories/Z/regex.js\");\n\n//# sourceURL=webpack:///./node_modules/uc.micro/index.js?");
/***/ }),
/***/ "./node_modules/uc.micro/properties/Any/regex.js":
/*!*******************************************************!*\
!*** ./node_modules/uc.micro/properties/Any/regex.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("module.exports=/[\\0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/\n\n//# sourceURL=webpack:///./node_modules/uc.micro/properties/Any/regex.js?");
+eval("module.exports = /[\\0-\\uD7FF\\uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/;\n\n//# sourceURL=webpack:///./node_modules/uc.micro/properties/Any/regex.js?");
/***/ }),
/***/ "./node_modules/w3c-keyname/index.es.js":
/*!**********************************************!*\
!*** ./node_modules/w3c-keyname/index.es.js ***!
\**********************************************/
/*! exports provided: default, base, keyName, shift */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"base\", function() { return base_1; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"keyName\", function() { return keyName; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"shift\", function() { return shift_1; });\nvar base = {\n 8: \"Backspace\",\n 9: \"Tab\",\n 10: \"Enter\",\n 12: \"NumLock\",\n 13: \"Enter\",\n 16: \"Shift\",\n 17: \"Control\",\n 18: \"Alt\",\n 20: \"CapsLock\",\n 27: \"Escape\",\n 32: \" \",\n 33: \"PageUp\",\n 34: \"PageDown\",\n 35: \"End\",\n 36: \"Home\",\n 37: \"ArrowLeft\",\n 38: \"ArrowUp\",\n 39: \"ArrowRight\",\n 40: \"ArrowDown\",\n 44: \"PrintScreen\",\n 45: \"Insert\",\n 46: \"Delete\",\n 59: \";\",\n 61: \"=\",\n 91: \"Meta\",\n 92: \"Meta\",\n 106: \"*\",\n 107: \"+\",\n 108: \",\",\n 109: \"-\",\n 110: \".\",\n 111: \"/\",\n 144: \"NumLock\",\n 145: \"ScrollLock\",\n 160: \"Shift\",\n 161: \"Shift\",\n 162: \"Control\",\n 163: \"Control\",\n 164: \"Alt\",\n 165: \"Alt\",\n 173: \"-\",\n 186: \";\",\n 187: \"=\",\n 188: \",\",\n 189: \"-\",\n 190: \".\",\n 191: \"/\",\n 192: \"`\",\n 219: \"[\",\n 220: \"\\\\\",\n 221: \"]\",\n 222: \"'\",\n 229: \"q\"\n};\nvar base_1 = base;\n\nvar shift = {\n 48: \")\",\n 49: \"!\",\n 50: \"@\",\n 51: \"#\",\n 52: \"$\",\n 53: \"%\",\n 54: \"^\",\n 55: \"&\",\n 56: \"*\",\n 57: \"(\",\n 59: \";\",\n 61: \"+\",\n 173: \"_\",\n 186: \":\",\n 187: \"+\",\n 188: \"<\",\n 189: \"_\",\n 190: \">\",\n 191: \"?\",\n 192: \"~\",\n 219: \"{\",\n 220: \"|\",\n 221: \"}\",\n 222: \"\\\"\",\n 229: \"Q\"\n};\nvar shift_1 = shift;\n\nvar chrome = typeof navigator != \"undefined\" && /Chrome\\/(\\d+)/.exec(navigator.userAgent);\nvar safari = typeof navigator != \"undefined\" && /Apple Computer/.test(navigator.vendor);\nvar gecko = typeof navigator != \"undefined\" && /Gecko\\/\\d+/.test(navigator.userAgent);\nvar mac = typeof navigator != \"undefined\" && /Mac/.test(navigator.platform);\nvar ie = typeof navigator != \"undefined\" && /MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);\nvar brokenModifierNames = chrome && (mac || +chrome[1] < 57) || gecko && mac;\n\n// Fill in the digit keys\nfor (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);\n\n// The function keys\nfor (var i = 1; i <= 24; i++) base[i + 111] = \"F\" + i;\n\n// And the alphabetic keys\nfor (var i = 65; i <= 90; i++) {\n base[i] = String.fromCharCode(i + 32);\n shift[i] = String.fromCharCode(i);\n}\n\n// For each code that doesn't have a shift-equivalent, copy the base name\nfor (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];\n\nvar keyName = function(event) {\n // Don't trust event.key in Chrome when there are modifiers until\n // they fix https://bugs.chromium.org/p/chromium/issues/detail?id=633838\n var ignoreKey = brokenModifierNames && (event.ctrlKey || event.altKey || event.metaKey) ||\n (safari || ie) && event.shiftKey && event.key && event.key.length == 1;\n var name = (!ignoreKey && event.key) ||\n (event.shiftKey ? shift : base)[event.keyCode] ||\n event.key || \"Unidentified\";\n // Edge sometimes produces wrong names (Issue #3)\n if (name == \"Esc\") name = \"Escape\";\n if (name == \"Del\") name = \"Delete\";\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/\n if (name == \"Left\") name = \"ArrowLeft\";\n if (name == \"Up\") name = \"ArrowUp\";\n if (name == \"Right\") name = \"ArrowRight\";\n if (name == \"Down\") name = \"ArrowDown\";\n return name\n};\n\nvar w3cKeyname = {\n\tbase: base_1,\n\tshift: shift_1,\n\tkeyName: keyName\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (w3cKeyname);\n\n\n\n//# sourceURL=webpack:///./node_modules/w3c-keyname/index.es.js?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"base\", function() { return base_1; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"keyName\", function() { return keyName; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"shift\", function() { return shift_1; });\nvar base = {\n 8: \"Backspace\",\n 9: \"Tab\",\n 10: \"Enter\",\n 12: \"NumLock\",\n 13: \"Enter\",\n 16: \"Shift\",\n 17: \"Control\",\n 18: \"Alt\",\n 20: \"CapsLock\",\n 27: \"Escape\",\n 32: \" \",\n 33: \"PageUp\",\n 34: \"PageDown\",\n 35: \"End\",\n 36: \"Home\",\n 37: \"ArrowLeft\",\n 38: \"ArrowUp\",\n 39: \"ArrowRight\",\n 40: \"ArrowDown\",\n 44: \"PrintScreen\",\n 45: \"Insert\",\n 46: \"Delete\",\n 59: \";\",\n 61: \"=\",\n 91: \"Meta\",\n 92: \"Meta\",\n 106: \"*\",\n 107: \"+\",\n 108: \",\",\n 109: \"-\",\n 110: \".\",\n 111: \"/\",\n 144: \"NumLock\",\n 145: \"ScrollLock\",\n 160: \"Shift\",\n 161: \"Shift\",\n 162: \"Control\",\n 163: \"Control\",\n 164: \"Alt\",\n 165: \"Alt\",\n 173: \"-\",\n 186: \";\",\n 187: \"=\",\n 188: \",\",\n 189: \"-\",\n 190: \".\",\n 191: \"/\",\n 192: \"`\",\n 219: \"[\",\n 220: \"\\\\\",\n 221: \"]\",\n 222: \"'\",\n 229: \"q\"\n};\nvar base_1 = base;\nvar shift = {\n 48: \")\",\n 49: \"!\",\n 50: \"@\",\n 51: \"#\",\n 52: \"$\",\n 53: \"%\",\n 54: \"^\",\n 55: \"&\",\n 56: \"*\",\n 57: \"(\",\n 59: \";\",\n 61: \"+\",\n 173: \"_\",\n 186: \":\",\n 187: \"+\",\n 188: \"<\",\n 189: \"_\",\n 190: \">\",\n 191: \"?\",\n 192: \"~\",\n 219: \"{\",\n 220: \"|\",\n 221: \"}\",\n 222: \"\\\"\",\n 229: \"Q\"\n};\nvar shift_1 = shift;\nvar chrome = typeof navigator != \"undefined\" && /Chrome\\/(\\d+)/.exec(navigator.userAgent);\nvar safari = typeof navigator != \"undefined\" && /Apple Computer/.test(navigator.vendor);\nvar gecko = typeof navigator != \"undefined\" && /Gecko\\/\\d+/.test(navigator.userAgent);\nvar mac = typeof navigator != \"undefined\" && /Mac/.test(navigator.platform);\nvar ie = typeof navigator != \"undefined\" && /MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);\nvar brokenModifierNames = chrome && (mac || +chrome[1] < 57) || gecko && mac; // Fill in the digit keys\n\nfor (var i = 0; i < 10; i++) {\n base[48 + i] = base[96 + i] = String(i);\n} // The function keys\n\n\nfor (var i = 1; i <= 24; i++) {\n base[i + 111] = \"F\" + i;\n} // And the alphabetic keys\n\n\nfor (var i = 65; i <= 90; i++) {\n base[i] = String.fromCharCode(i + 32);\n shift[i] = String.fromCharCode(i);\n} // For each code that doesn't have a shift-equivalent, copy the base name\n\n\nfor (var code in base) {\n if (!shift.hasOwnProperty(code)) shift[code] = base[code];\n}\n\nvar keyName = function keyName(event) {\n // Don't trust event.key in Chrome when there are modifiers until\n // they fix https://bugs.chromium.org/p/chromium/issues/detail?id=633838\n var ignoreKey = brokenModifierNames && (event.ctrlKey || event.altKey || event.metaKey) || (safari || ie) && event.shiftKey && event.key && event.key.length == 1;\n var name = !ignoreKey && event.key || (event.shiftKey ? shift : base)[event.keyCode] || event.key || \"Unidentified\"; // Edge sometimes produces wrong names (Issue #3)\n\n if (name == \"Esc\") name = \"Escape\";\n if (name == \"Del\") name = \"Delete\"; // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/\n\n if (name == \"Left\") name = \"ArrowLeft\";\n if (name == \"Up\") name = \"ArrowUp\";\n if (name == \"Right\") name = \"ArrowRight\";\n if (name == \"Down\") name = \"ArrowDown\";\n return name;\n};\n\nvar w3cKeyname = {\n base: base_1,\n shift: shift_1,\n keyName: keyName\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (w3cKeyname);\n\n\n//# sourceURL=webpack:///./node_modules/w3c-keyname/index.es.js?");
+
+/***/ }),
+
+/***/ "./node_modules/webpack/buildin/amd-options.js":
+/*!****************************************!*\
+ !*** (webpack)/buildin/amd-options.js ***!
+ \****************************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+eval("/* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */\nmodule.exports = __webpack_amd_options__;\n\n/* WEBPACK VAR INJECTION */}.call(this, {}))\n\n//# sourceURL=webpack:///(webpack)/buildin/amd-options.js?");
/***/ }),
/***/ "./node_modules/webpack/buildin/global.js":
/*!***********************************!*\
!*** (webpack)/buildin/global.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack:///(webpack)/buildin/global.js?");
+eval("function _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar g; // This works in non-strict mode\n\ng = function () {\n return this;\n}();\n\ntry {\n // This works if eval is allowed (see CSP)\n g = g || new Function(\"return this\")();\n} catch (e) {\n // This works if the window reference is available\n if ((typeof window === \"undefined\" ? \"undefined\" : _typeof(window)) === \"object\") g = window;\n} // g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\n\nmodule.exports = g;\n\n//# sourceURL=webpack:///(webpack)/buildin/global.js?");
/***/ }),
/***/ "./node_modules/webpack/buildin/module.js":
/*!***********************************!*\
!*** (webpack)/buildin/module.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports) {
-eval("module.exports = function(module) {\n\tif (!module.webpackPolyfill) {\n\t\tmodule.deprecate = function() {};\n\t\tmodule.paths = [];\n\t\t// module.parent = undefined by default\n\t\tif (!module.children) module.children = [];\n\t\tObject.defineProperty(module, \"loaded\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.l;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"id\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.i;\n\t\t\t}\n\t\t});\n\t\tmodule.webpackPolyfill = 1;\n\t}\n\treturn module;\n};\n\n\n//# sourceURL=webpack:///(webpack)/buildin/module.js?");
+eval("module.exports = function (module) {\n if (!module.webpackPolyfill) {\n module.deprecate = function () {};\n\n module.paths = []; // module.parent = undefined by default\n\n if (!module.children) module.children = [];\n Object.defineProperty(module, \"loaded\", {\n enumerable: true,\n get: function get() {\n return module.l;\n }\n });\n Object.defineProperty(module, \"id\", {\n enumerable: true,\n get: function get() {\n return module.i;\n }\n });\n module.webpackPolyfill = 1;\n }\n\n return module;\n};\n\n//# sourceURL=webpack:///(webpack)/buildin/module.js?");
/***/ }),
/***/ "./prose.js":
/*!******************!*\
!*** ./prose.js ***!
\******************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var prosemirror_view__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prosemirror-view */ \"./node_modules/prosemirror-view/dist/index.es.js\");\n/* harmony import */ var prosemirror_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prosemirror-state */ \"./node_modules/prosemirror-state/dist/index.es.js\");\n/* harmony import */ var prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prosemirror-markdown */ \"./node_modules/prosemirror-markdown/dist/index.es.js\");\n/* harmony import */ var prosemirror_example_setup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prosemirror-example-setup */ \"./node_modules/prosemirror-example-setup/dist/index.es.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n// class MarkdownView {\n// constructor(target, content) {\n// this.textarea = target.appendChild(document.createElement(\"textarea\"))\n// this.textarea.value = content\n// }\n// get content() { return this.textarea.value }\n// focus() { this.textarea.focus() }\n// destroy() { this.textarea.remove() }\n// }\n\n\n\n\nvar $title = document.querySelector('#title');\nvar $content = document.querySelector('#content');\n\nvar ProseMirrorView = /*#__PURE__*/function () {\n function ProseMirrorView(target, content) {\n _classCallCheck(this, ProseMirrorView);\n\n this.view = new prosemirror_view__WEBPACK_IMPORTED_MODULE_0__[\"EditorView\"](target, {\n state: prosemirror_state__WEBPACK_IMPORTED_MODULE_1__[\"EditorState\"].create({\n doc: function (content) {\n // console.log('loading '+window.draftKey)\n var localDraft = localStorage.getItem(window.draftKey);\n\n if (localDraft != null) {\n content = localDraft;\n }\n\n if (content.indexOf(\"# \") === 0) {\n var eol = content.indexOf(\"\\n\");\n var title = content.substring(\"# \".length, eol);\n content = content.substring(eol + \"\\n\\n\".length);\n $title.value = title;\n }\n\n return prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"defaultMarkdownParser\"].parse(content);\n }(content),\n plugins: Object(prosemirror_example_setup__WEBPACK_IMPORTED_MODULE_3__[\"exampleSetup\"])({\n schema: prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"schema\"]\n })\n }),\n dispatchTransaction: function dispatchTransaction(transaction) {\n // console.log('saving to '+window.draftKey)\n $content.value = prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"defaultMarkdownSerializer\"].serialize(transaction.doc);\n localStorage.setItem(window.draftKey, function () {\n var draft = \"\";\n\n if ($title.value != null && $title.value !== \"\") {\n draft = \"# \" + $title.value + \"\\n\\n\";\n }\n\n draft += $content.value;\n return draft;\n }());\n var newState = this.state.apply(transaction);\n this.updateState(newState);\n }\n });\n }\n\n _createClass(ProseMirrorView, [{\n key: \"focus\",\n value: function focus() {\n this.view.focus();\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.view.destroy();\n }\n }, {\n key: \"content\",\n get: function get() {\n return prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"defaultMarkdownSerializer\"].serialize(this.view.state.doc);\n }\n }]);\n\n return ProseMirrorView;\n}();\n\nvar place = document.querySelector(\"#editor\");\nvar view = new ProseMirrorView(place, $content.value); // document.querySelectorAll(\"input[type=radio]\").forEach(button => {\n// button.addEventListener(\"change\", () => {\n// if (!button.checked) return\n// let View = button.value == \"markdown\" ? MarkdownView : ProseMirrorView\n// if (view instanceof View) return\n// let content = view.content\n// view.destroy()\n// view = new View(place, content)\n// view.focus()\n// })\n// })\n\n//# sourceURL=webpack:///./prose.js?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var prosemirror_view__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! prosemirror-view */ \"./node_modules/prosemirror-view/dist/index.es.js\");\n/* harmony import */ var prosemirror_state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prosemirror-state */ \"./node_modules/prosemirror-state/dist/index.es.js\");\n/* harmony import */ var prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prosemirror-markdown */ \"./node_modules/prosemirror-markdown/dist/index.es.js\");\n/* harmony import */ var prosemirror_example_setup__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prosemirror-example-setup */ \"./node_modules/prosemirror-example-setup/dist/index.es.js\");\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n// class MarkdownView {\n// constructor(target, content) {\n// this.textarea = target.appendChild(document.createElement(\"textarea\"))\n// this.textarea.value = content\n// }\n// get content() { return this.textarea.value }\n// focus() { this.textarea.focus() }\n// destroy() { this.textarea.remove() }\n// }\n\n\n\n\nvar $title = document.querySelector(\"#title\");\n\nvar ProseMirrorView = /*#__PURE__*/function () {\n function ProseMirrorView(target) {\n _classCallCheck(this, ProseMirrorView);\n\n var divContent = document.querySelector(\"#content\");\n var defaultContent = divContent.value;\n var wordCounter = document.querySelector(\"#wc\");\n var content = \"\";\n var localDraft = localStorage.getItem(window.draftKey);\n\n if (localDraft) {\n content = localDraft; // setting initial word count\n\n var wordCount = content.split(\" \").filter(function (i) {\n return i;\n }).length;\n wordCounter.innerText = wordCount + \" word\" + (wordCount != 1 ? \"s\" : \"\");\n } // if no draft+PostId in the localStorage use hidden div.value as content\n\n\n if (window.draftKey && window.draftKey != \"lastDoc\" && content == \"\") {\n content = defaultContent;\n }\n\n if (content.indexOf(\"# \") === 0) {\n var eol = content.indexOf(\"\\n\");\n var title = content.substring(\"# \".length, eol);\n content = content.substring(eol + \"\\n\\n\".length);\n $title.value = title;\n }\n\n var doc = prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"defaultMarkdownParser\"].parse(content);\n this.view = new prosemirror_view__WEBPACK_IMPORTED_MODULE_0__[\"EditorView\"](target, {\n state: prosemirror_state__WEBPACK_IMPORTED_MODULE_1__[\"EditorState\"].create({\n doc: doc,\n plugins: Object(prosemirror_example_setup__WEBPACK_IMPORTED_MODULE_3__[\"exampleSetup\"])({\n schema: prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"schema\"]\n })\n }),\n dispatchTransaction: function dispatchTransaction(transaction) {\n var content = prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"defaultMarkdownSerializer\"].serialize(transaction.doc); // set hidden div for backup\n\n divContent.value = content;\n var draft = \"\";\n\n if ($title.value != null && $title.value !== \"\") {\n draft = \"# \" + $title.value + \"\\n\\n\";\n }\n\n draft += content;\n localStorage.setItem(window.draftKey, draft); //setting word counter value\n\n var wordCount = draft.split(\" \").filter(function (i) {\n return i;\n }).length;\n wordCounter.innerText = wordCount + \" word\" + (wordCount != 1 ? \"s\" : \"\");\n var newState = this.state.apply(transaction);\n this.updateState(newState);\n }\n });\n }\n\n _createClass(ProseMirrorView, [{\n key: \"focus\",\n value: function focus() {\n this.view.focus();\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.view.destroy();\n }\n }, {\n key: \"content\",\n get: function get() {\n return prosemirror_markdown__WEBPACK_IMPORTED_MODULE_2__[\"defaultMarkdownSerializer\"].serialize(this.view.state.doc);\n }\n }]);\n\n return ProseMirrorView;\n}();\n\nvar place = document.querySelector(\"#editor\");\nsetTimeout(function () {\n var view = new ProseMirrorView(place);\n window.editorInstance = view;\n}, 0); // document.querySelectorAll(\"input[type=radio]\").forEach(button => {\n// button.addEventListener(\"change\", () => {\n// if (!button.checked) return\n// let View = button.value == \"markdown\" ? MarkdownView : ProseMirrorView\n// if (view instanceof View) return\n// let content = view.content\n// view.destroy()\n// view = new View(place, content)\n// view.focus()\n// })\n// })\n\n//# sourceURL=webpack:///./prose.js?");
/***/ })
/******/ });
\ No newline at end of file
diff --git a/templates/wysiwyg.tmpl b/templates/wysiwyg.tmpl
index 235c590..a380651 100644
--- a/templates/wysiwyg.tmpl
+++ b/templates/wysiwyg.tmpl
@@ -1,400 +1,402 @@
{{define "pad"}}
{{if .Editing}}Editing {{if .Post.Title}}{{.Post.Title}}{{else}}{{.Post.Id}}{{end}}{{else}}New Post{{end}} — {{.SiteName}}
+
-
{{end}}