) → 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\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\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// This class tracks the state of the placement progress in the\n// following properties:\n//\n// - `frontier` holds a stack of `{type, match}` objects that\n// represent the open side of the replacement. It starts at\n// `$from`, then moves forward as content is placed, and is finally\n// reconciled with `$to`.\n//\n// - `unplaced` is a slice that represents the content that hasn't\n// been placed yet.\n//\n// - `placed` is a fragment of placed content. Its open-start value\n// is implicit in `$from`, and its open-end value in `frontier`.\nvar Fitter = function Fitter($from, $to, slice) {\n this.$to = $to;\n this.$from = $from;\n this.unplaced = slice;\n\n this.frontier = [];\n for (var i = 0; i <= $from.depth; i++) {\n var node = $from.node(i);\n this.frontier.push({\n type: node.type,\n match: node.contentMatchAt($from.indexAfter(i))\n });\n }\n\n this.placed = Fragment.empty;\n for (var i$1 = $from.depth; i$1 > 0; i$1--)\n { this.placed = Fragment.from($from.node(i$1).copy(this.placed)); }\n};\n\nvar prototypeAccessors$1 = { depth: { configurable: true } };\n\nprototypeAccessors$1.depth.get = function () { return this.frontier.length - 1 };\n\nFitter.prototype.fit = function fit () {\n // As long as there's unplaced content, try to place some of it.\n // If that fails, either increase the open score of the unplaced\n // slice, or drop nodes from it, and then try again.\n while (this.unplaced.size) {\n var fit = this.findFittable();\n if (fit) { this.placeNodes(fit); }\n else { this.openMore() || this.dropNode(); }\n }\n // When there's inline content directly after the frontier _and_\n // directly after `this.$to`, we must generate a `ReplaceAround`\n // step that pulls that content into the node after the frontier.\n // That means the fitting must be done to the end of the textblock\n // node after `this.$to`, not `this.$to` itself.\n var moveInline = this.mustMoveInline(), placedSize = this.placed.size - this.depth - this.$from.depth;\n var $from = this.$from, $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));\n if (!$to) { return null }\n\n // If closing to `$to` succeeded, create a step\n var content = this.placed, openStart = $from.depth, openEnd = $to.depth;\n while (openStart && openEnd && content.childCount == 1) { // Normalize by dropping open parent nodes\n content = content.firstChild.content;\n openStart--; openEnd--;\n }\n var slice = new Slice(content, openStart, openEnd);\n if (moveInline > -1)\n { return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize) }\n if (slice.size || $from.pos != this.$to.pos) // Don't generate no-op steps\n { return new ReplaceStep($from.pos, $to.pos, slice) }\n};\n\n// Find a position on the start spine of `this.unplaced` that has\n// content that can be moved somewhere on the frontier. Returns two\n// depths, one for the slice and one for the frontier.\nFitter.prototype.findFittable = function findFittable () {\n // Only try wrapping nodes (pass 2) after finding a place without\n // wrapping failed.\n for (var pass = 1; pass <= 2; pass++) {\n for (var sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {\n var fragment = (void 0), parent = (void 0);\n if (sliceDepth) {\n parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;\n fragment = parent.content;\n } else {\n fragment = this.unplaced.content;\n }\n var first = fragment.firstChild;\n for (var frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {\n var ref = this.frontier[frontierDepth];\n var type = ref.type;\n var match = ref.match;\n var wrap = (void 0), inject = (void 0);\n // In pass 1, if the next node matches, or there is no next\n // node but the parents look compatible, we've found a\n // place.\n if (pass == 1 && (first ? match.matchType(first.type) || (inject = match.fillBefore(Fragment.from(first), false))\n : type.compatibleContent(parent.type)))\n { return {sliceDepth: sliceDepth, frontierDepth: frontierDepth, parent: parent, inject: inject} }\n // In pass 2, look for a set of wrapping nodes that make\n // `first` fit here.\n else if (pass == 2 && first && (wrap = match.findWrapping(first.type)))\n { return {sliceDepth: sliceDepth, frontierDepth: frontierDepth, parent: parent, wrap: wrap} }\n // Don't continue looking further up if the parent node\n // would fit here.\n if (parent && match.matchType(parent.type)) { break }\n }\n }\n }\n};\n\nFitter.prototype.openMore = function openMore () {\n var ref = this.unplaced;\n var content = ref.content;\n var openStart = ref.openStart;\n var openEnd = ref.openEnd;\n var inner = contentAt(content, openStart);\n if (!inner.childCount || inner.firstChild.isLeaf) { return false }\n this.unplaced = new Slice(content, openStart + 1,\n Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));\n return true\n};\n\nFitter.prototype.dropNode = function dropNode () {\n var ref = this.unplaced;\n var content = ref.content;\n var openStart = ref.openStart;\n var openEnd = ref.openEnd;\n var inner = contentAt(content, openStart);\n if (inner.childCount <= 1 && openStart > 0) {\n var openAtEnd = content.size - openStart <= openStart + inner.size;\n this.unplaced = new Slice(dropFromFragment(content, openStart - 1, 1), openStart - 1,\n openAtEnd ? openStart - 1 : openEnd);\n } else {\n this.unplaced = new Slice(dropFromFragment(content, openStart, 1), openStart, openEnd);\n }\n};\n\n// : ({sliceDepth: number, frontierDepth: number, parent: ?Node, wrap: ?[NodeType], inject: ?Fragment})\n// Move content from the unplaced slice at `sliceDepth` to the\n// frontier node at `frontierDepth`. Close that frontier node when\n// applicable.\nFitter.prototype.placeNodes = function placeNodes (ref) {\n var sliceDepth = ref.sliceDepth;\n var frontierDepth = ref.frontierDepth;\n var parent = ref.parent;\n var inject = ref.inject;\n var wrap = ref.wrap;\n\n while (this.depth > frontierDepth) { this.closeFrontierNode(); }\n if (wrap) { for (var i = 0; i < wrap.length; i++) { this.openFrontierNode(wrap[i]); } }\n\n var slice = this.unplaced, fragment = parent ? parent.content : slice.content;\n var openStart = slice.openStart - sliceDepth;\n var taken = 0, add = [];\n var ref$1 = this.frontier[frontierDepth];\n var match = ref$1.match;\n var type = ref$1.type;\n if (inject) {\n for (var i$1 = 0; i$1 < inject.childCount; i$1++) { add.push(inject.child(i$1)); }\n match = match.matchFragment(inject);\n }\n // Computes the amount of (end) open nodes at the end of the\n // fragment. When 0, the parent is open, but no more. When\n // negative, nothing is open.\n var openEndCount = (fragment.size + sliceDepth) - (slice.content.size - slice.openEnd);\n // Scan over the fragment, fitting as many child nodes as\n // possible.\n while (taken < fragment.childCount) {\n var next = fragment.child(taken), matches = match.matchType(next.type);\n if (!matches) { break }\n taken++;\n if (taken > 1 || openStart == 0 || next.content.size) { // Drop empty open nodes\n match = matches;\n add.push(closeNodeStart(next.mark(type.allowedMarks(next.marks)), taken == 1 ? openStart : 0,\n taken == fragment.childCount ? openEndCount : -1));\n }\n }\n var toEnd = taken == fragment.childCount;\n if (!toEnd) { openEndCount = -1; }\n\n this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add));\n this.frontier[frontierDepth].match = match;\n\n // If the parent types match, and the entire node was moved, and\n // it's not open, close this frontier node right away.\n if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1)\n { this.closeFrontierNode(); }\n\n // Add new frontier nodes for any open nodes at the end.\n for (var i$2 = 0, cur = fragment; i$2 < openEndCount; i$2++) {\n var node = cur.lastChild;\n this.frontier.push({type: node.type, match: node.contentMatchAt(node.childCount)});\n cur = node.content;\n }\n\n // Update `this.unplaced`. Drop the entire node from which we\n // placed it we got to its end, otherwise just drop the placed\n // nodes.\n this.unplaced = !toEnd ? new Slice(dropFromFragment(slice.content, sliceDepth, taken), slice.openStart, slice.openEnd)\n : sliceDepth == 0 ? Slice.empty\n : new Slice(dropFromFragment(slice.content, sliceDepth - 1, 1),\n sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1);\n};\n\nFitter.prototype.mustMoveInline = function mustMoveInline () {\n if (!this.$to.parent.isTextblock || this.$to.end() == this.$to.pos) { return -1 }\n var top = this.frontier[this.depth], level;\n if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) ||\n (this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth)) { return -1 }\n\n var ref = this.$to;\n var depth = ref.depth;\n var after = this.$to.after(depth);\n while (depth > 1 && after == this.$to.end(--depth)) { ++after; }\n return after\n};\n\nFitter.prototype.findCloseLevel = function findCloseLevel ($to) {\n scan: for (var i = Math.min(this.depth, $to.depth); i >= 0; i--) {\n var ref = this.frontier[i];\n var match = ref.match;\n var type = ref.type;\n var dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));\n var fit = contentAfterFits($to, i, type, match, dropInner);\n if (!fit) { continue }\n for (var d = i - 1; d >= 0; d--) {\n var ref$1 = this.frontier[d];\n var match$1 = ref$1.match;\n var type$1 = ref$1.type;\n var matches = contentAfterFits($to, d, type$1, match$1, true);\n if (!matches || matches.childCount) { continue scan }\n }\n return {depth: i, fit: fit, move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to}\n }\n};\n\nFitter.prototype.close = function close ($to) {\n var close = this.findCloseLevel($to);\n if (!close) { return null }\n\n while (this.depth > close.depth) { this.closeFrontierNode(); }\n if (close.fit.childCount) { this.placed = addToFragment(this.placed, close.depth, close.fit); }\n $to = close.move;\n for (var d = close.depth + 1; d <= $to.depth; d++) {\n var node = $to.node(d), add = node.type.contentMatch.fillBefore(node.content, true, $to.index(d));\n this.openFrontierNode(node.type, node.attrs, add);\n }\n return $to\n};\n\nFitter.prototype.openFrontierNode = function openFrontierNode (type, attrs, content) {\n var top = this.frontier[this.depth];\n top.match = top.match.matchType(type);\n this.placed = addToFragment(this.placed, this.depth, Fragment.from(type.create(attrs, content)));\n this.frontier.push({type: type, match: type.contentMatch});\n};\n\nFitter.prototype.closeFrontierNode = function closeFrontierNode () {\n var open = this.frontier.pop();\n var add = open.match.fillBefore(Fragment.empty, true);\n if (add.childCount) { this.placed = addToFragment(this.placed, this.frontier.length, add); }\n};\n\nObject.defineProperties( Fitter.prototype, prototypeAccessors$1 );\n\nfunction dropFromFragment(fragment, depth, count) {\n if (depth == 0) { return fragment.cutByIndex(count) }\n return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)))\n}\n\nfunction addToFragment(fragment, depth, content) {\n if (depth == 0) { return fragment.append(content) }\n return fragment.replaceChild(fragment.childCount - 1,\n fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content)))\n}\n\nfunction contentAt(fragment, depth) {\n for (var i = 0; i < depth; i++) { fragment = fragment.firstChild.content; }\n return fragment\n}\n\nfunction closeNodeStart(node, openStart, openEnd) {\n if (openStart <= 0) { return node }\n var frag = node.content;\n if (openStart > 1)\n { frag = frag.replaceChild(0, closeNodeStart(frag.firstChild, openStart - 1, frag.childCount == 1 ? openEnd - 1 : 0)); }\n if (openStart > 0) {\n frag = node.type.contentMatch.fillBefore(frag).append(frag);\n if (openEnd <= 0) { frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment.empty, true)); }\n }\n return node.copy(frag)\n}\n\nfunction contentAfterFits($to, depth, type, match, open) {\n var node = $to.node(depth), index = open ? $to.indexAfter(depth) : $to.index(depth);\n if (index == node.childCount && !type.compatibleContent(node.type)) { return null }\n var fit = match.fillBefore(node.content, true, index);\n return fit && !invalidMarks(type, node.content, index) ? fit : null\n}\n\nfunction invalidMarks(type, fragment, start) {\n for (var i = start; i < fragment.childCount; i++)\n { if (!type.allowsMarks(fragment.child(i).marks)) { return true } }\n return false\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 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 (depth < 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(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 Slice(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) ||\n (d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&\n d && $to.start(d - 1) == start - 1))\n { result.push(d); }\n }\n return result\n}\n\nexport { AddMarkStep, MapResult, Mapping, RemoveMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, TransformError, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };\n//# sourceMappingURL=index.es.js.map\n","import { Slice, Fragment, Mark, Node } from 'prosemirror-model';\nimport { ReplaceStep, ReplaceAroundStep, Transform } from 'prosemirror-transform';\n\nvar classesById = Object.create(null);\n\n// ::- Superclass for editor selections. Every selection type should\n// extend this. Should not be instantiated directly.\nvar Selection = function Selection($anchor, $head, ranges) {\n // :: [SelectionRange]\n // The ranges covered by the selection.\n this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];\n // :: ResolvedPos\n // The resolved anchor of the selection (the side that stays in\n // place when the selection is modified).\n this.$anchor = $anchor;\n // :: ResolvedPos\n // The resolved head of the selection (the side that moves when\n // the selection is modified).\n this.$head = $head;\n};\n\nvar prototypeAccessors = { anchor: { configurable: true },head: { configurable: true },from: { configurable: true },to: { configurable: true },$from: { configurable: true },$to: { configurable: true },empty: { configurable: true } };\n\n// :: number\n// The selection's anchor, as an unresolved position.\nprototypeAccessors.anchor.get = function () { return this.$anchor.pos };\n\n// :: number\n// The selection's head.\nprototypeAccessors.head.get = function () { return this.$head.pos };\n\n// :: number\n// The lower bound of the selection's main range.\nprototypeAccessors.from.get = function () { return this.$from.pos };\n\n// :: number\n// The upper bound of the selection's main range.\nprototypeAccessors.to.get = function () { return this.$to.pos };\n\n// :: ResolvedPos\n// The resolved lowerbound of the selection's main range.\nprototypeAccessors.$from.get = function () {\n return this.ranges[0].$from\n};\n\n// :: ResolvedPos\n// The resolved upper bound of the selection's main range.\nprototypeAccessors.$to.get = function () {\n return this.ranges[0].$to\n};\n\n// :: bool\n// Indicates whether the selection contains any content.\nprototypeAccessors.empty.get = function () {\n var ranges = this.ranges;\n for (var i = 0; i < ranges.length; i++)\n { if (ranges[i].$from.pos != ranges[i].$to.pos) { return false } }\n return true\n};\n\n// eq:: (Selection) → bool\n// Test whether the selection is the same as another selection.\n\n// map:: (doc: Node, mapping: Mappable) → Selection\n// Map this selection through a [mappable](#transform.Mappable) thing. `doc`\n// should be the new document to which we are mapping.\n\n// :: () → Slice\n// Get the content of this selection as a slice.\nSelection.prototype.content = function content () {\n return this.$from.node(0).slice(this.from, this.to, true)\n};\n\n// :: (Transaction, ?Slice)\n// Replace the selection with a slice or, if no slice is given,\n// delete the selection. Will append to the given transaction.\nSelection.prototype.replace = function replace (tr, content) {\n if ( content === void 0 ) content = Slice.empty;\n\n // Put the new selection at the position after the inserted\n // content. When that ended in an inline node, search backwards,\n // to get the position after that node. If not, search forward.\n var lastNode = content.content.lastChild, lastParent = null;\n for (var i = 0; i < content.openEnd; i++) {\n lastParent = lastNode;\n lastNode = lastNode.lastChild;\n }\n\n var mapFrom = tr.steps.length, ranges = this.ranges;\n for (var i$1 = 0; i$1 < ranges.length; i$1++) {\n var ref = ranges[i$1];\n var $from = ref.$from;\n var $to = ref.$to;\n var mapping = tr.mapping.slice(mapFrom);\n tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), i$1 ? Slice.empty : content);\n if (i$1 == 0)\n { selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1); }\n }\n};\n\n// :: (Transaction, Node)\n// Replace the selection with the given node, appending the changes\n// to the given transaction.\nSelection.prototype.replaceWith = function replaceWith (tr, node) {\n var mapFrom = tr.steps.length, ranges = this.ranges;\n for (var i = 0; i < ranges.length; i++) {\n var ref = ranges[i];\n var $from = ref.$from;\n var $to = ref.$to;\n var mapping = tr.mapping.slice(mapFrom);\n var from = mapping.map($from.pos), to = mapping.map($to.pos);\n if (i) {\n tr.deleteRange(from, to);\n } else {\n tr.replaceRangeWith(from, to, node);\n selectionToInsertionEnd(tr, mapFrom, node.isInline ? -1 : 1);\n }\n }\n};\n\n// toJSON:: () → Object\n// Convert the selection to a JSON representation. When implementing\n// this for a custom selection class, make sure to give the object a\n// `type` property whose value matches the ID under which you\n// [registered](#state.Selection^jsonID) your class.\n\n// :: (ResolvedPos, number, ?bool) → ?Selection\n// Find a valid cursor or leaf node selection starting at the given\n// position and searching back if `dir` is negative, and forward if\n// positive. When `textOnly` is true, only consider cursor\n// selections. Will return null when no valid selection position is\n// found.\nSelection.findFrom = function findFrom ($pos, dir, textOnly) {\n var inner = $pos.parent.inlineContent ? new TextSelection($pos)\n : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);\n if (inner) { return inner }\n\n for (var depth = $pos.depth - 1; depth >= 0; depth--) {\n var found = dir < 0\n ? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly)\n : findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);\n if (found) { return found }\n }\n};\n\n// :: (ResolvedPos, ?number) → Selection\n// Find a valid cursor or leaf node selection near the given\n// position. Searches forward first by default, but if `bias` is\n// negative, it will search backwards first.\nSelection.near = function near ($pos, bias) {\n if ( bias === void 0 ) bias = 1;\n\n return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0))\n};\n\n// :: (Node) → Selection\n// Find the cursor or leaf node selection closest to the start of\n// the given document. Will return an\n// [`AllSelection`](#state.AllSelection) if no valid position\n// exists.\nSelection.atStart = function atStart (doc) {\n return findSelectionIn(doc, doc, 0, 0, 1) || new AllSelection(doc)\n};\n\n// :: (Node) → Selection\n// Find the cursor or leaf node selection closest to the end of the\n// given document.\nSelection.atEnd = function atEnd (doc) {\n return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1) || new AllSelection(doc)\n};\n\n// :: (Node, Object) → Selection\n// Deserialize the JSON representation of a selection. Must be\n// implemented for custom classes (as a static class method).\nSelection.fromJSON = function fromJSON (doc, json) {\n if (!json || !json.type) { throw new RangeError(\"Invalid input for Selection.fromJSON\") }\n var cls = classesById[json.type];\n if (!cls) { throw new RangeError((\"No selection type \" + (json.type) + \" defined\")) }\n return cls.fromJSON(doc, json)\n};\n\n// :: (string, constructor)\n// To be able to deserialize selections from JSON, custom selection\n// classes must register themselves with an ID string, so that they\n// can be disambiguated. Try to pick something that's unlikely to\n// clash with classes from other modules.\nSelection.jsonID = function jsonID (id, selectionClass) {\n if (id in classesById) { throw new RangeError(\"Duplicate use of selection JSON ID \" + id) }\n classesById[id] = selectionClass;\n selectionClass.prototype.jsonID = id;\n return selectionClass\n};\n\n// :: () → SelectionBookmark\n// Get a [bookmark](#state.SelectionBookmark) for this selection,\n// which is a value that can be mapped without having access to a\n// current document, and later resolved to a real selection for a\n// given document again. (This is used mostly by the history to\n// track and restore old selections.) The default implementation of\n// this method just converts the selection to a text selection and\n// returns the bookmark for that.\nSelection.prototype.getBookmark = function getBookmark () {\n return TextSelection.between(this.$anchor, this.$head).getBookmark()\n};\n\nObject.defineProperties( Selection.prototype, prototypeAccessors );\n\n// :: bool\n// Controls whether, when a selection of this type is active in the\n// browser, the selected range should be visible to the user. Defaults\n// to `true`.\nSelection.prototype.visible = true;\n\n// SelectionBookmark:: interface\n// A lightweight, document-independent representation of a selection.\n// You can define a custom bookmark type for a custom selection class\n// to make the history handle it well.\n//\n// map:: (mapping: Mapping) → SelectionBookmark\n// Map the bookmark through a set of changes.\n//\n// resolve:: (doc: Node) → Selection\n// Resolve the bookmark to a real selection again. This may need to\n// do some error checking and may fall back to a default (usually\n// [`TextSelection.between`](#state.TextSelection^between)) if\n// mapping made the bookmark invalid.\n\n// ::- Represents a selected range in a document.\nvar SelectionRange = function SelectionRange($from, $to) {\n // :: ResolvedPos\n // The lower bound of the range.\n this.$from = $from;\n // :: ResolvedPos\n // The upper bound of the range.\n this.$to = $to;\n};\n\n// ::- A text selection represents a classical editor selection, with\n// a head (the moving side) and anchor (immobile side), both of which\n// point into textblock nodes. It can be empty (a regular cursor\n// position).\nvar TextSelection = /*@__PURE__*/(function (Selection) {\n function TextSelection($anchor, $head) {\n if ( $head === void 0 ) $head = $anchor;\n\n Selection.call(this, $anchor, $head);\n }\n\n if ( Selection ) TextSelection.__proto__ = Selection;\n TextSelection.prototype = Object.create( Selection && Selection.prototype );\n TextSelection.prototype.constructor = TextSelection;\n\n var prototypeAccessors$1 = { $cursor: { configurable: true } };\n\n // :: ?ResolvedPos\n // Returns a resolved position if this is a cursor selection (an\n // empty text selection), and null otherwise.\n prototypeAccessors$1.$cursor.get = function () { return this.$anchor.pos == this.$head.pos ? this.$head : null };\n\n TextSelection.prototype.map = function map (doc, mapping) {\n var $head = doc.resolve(mapping.map(this.head));\n if (!$head.parent.inlineContent) { return Selection.near($head) }\n var $anchor = doc.resolve(mapping.map(this.anchor));\n return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head)\n };\n\n TextSelection.prototype.replace = function replace (tr, content) {\n if ( content === void 0 ) content = Slice.empty;\n\n Selection.prototype.replace.call(this, tr, content);\n if (content == Slice.empty) {\n var marks = this.$from.marksAcross(this.$to);\n if (marks) { tr.ensureMarks(marks); }\n }\n };\n\n TextSelection.prototype.eq = function eq (other) {\n return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head\n };\n\n TextSelection.prototype.getBookmark = function getBookmark () {\n return new TextBookmark(this.anchor, this.head)\n };\n\n TextSelection.prototype.toJSON = function toJSON () {\n return {type: \"text\", anchor: this.anchor, head: this.head}\n };\n\n TextSelection.fromJSON = function fromJSON (doc, json) {\n if (typeof json.anchor != \"number\" || typeof json.head != \"number\")\n { throw new RangeError(\"Invalid input for TextSelection.fromJSON\") }\n return new TextSelection(doc.resolve(json.anchor), doc.resolve(json.head))\n };\n\n // :: (Node, number, ?number) → TextSelection\n // Create a text selection from non-resolved positions.\n TextSelection.create = function create (doc, anchor, head) {\n if ( head === void 0 ) head = anchor;\n\n var $anchor = doc.resolve(anchor);\n return new this($anchor, head == anchor ? $anchor : doc.resolve(head))\n };\n\n // :: (ResolvedPos, ResolvedPos, ?number) → Selection\n // Return a text selection that spans the given positions or, if\n // they aren't text positions, find a text selection near them.\n // `bias` determines whether the method searches forward (default)\n // or backwards (negative number) first. Will fall back to calling\n // [`Selection.near`](#state.Selection^near) when the document\n // doesn't contain a valid text position.\n TextSelection.between = function between ($anchor, $head, bias) {\n var dPos = $anchor.pos - $head.pos;\n if (!bias || dPos) { bias = dPos >= 0 ? 1 : -1; }\n if (!$head.parent.inlineContent) {\n var found = Selection.findFrom($head, bias, true) || Selection.findFrom($head, -bias, true);\n if (found) { $head = found.$head; }\n else { return Selection.near($head, bias) }\n }\n if (!$anchor.parent.inlineContent) {\n if (dPos == 0) {\n $anchor = $head;\n } else {\n $anchor = (Selection.findFrom($anchor, -bias, true) || Selection.findFrom($anchor, bias, true)).$anchor;\n if (($anchor.pos < $head.pos) != (dPos < 0)) { $anchor = $head; }\n }\n }\n return new TextSelection($anchor, $head)\n };\n\n Object.defineProperties( TextSelection.prototype, prototypeAccessors$1 );\n\n return TextSelection;\n}(Selection));\n\nSelection.jsonID(\"text\", TextSelection);\n\nvar TextBookmark = function TextBookmark(anchor, head) {\n this.anchor = anchor;\n this.head = head;\n};\nTextBookmark.prototype.map = function map (mapping) {\n return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head))\n};\nTextBookmark.prototype.resolve = function resolve (doc) {\n return TextSelection.between(doc.resolve(this.anchor), doc.resolve(this.head))\n};\n\n// ::- A node selection is a selection that points at a single node.\n// All nodes marked [selectable](#model.NodeSpec.selectable) can be\n// the target of a node selection. In such a selection, `from` and\n// `to` point directly before and after the selected node, `anchor`\n// equals `from`, and `head` equals `to`..\nvar NodeSelection = /*@__PURE__*/(function (Selection) {\n function NodeSelection($pos) {\n var node = $pos.nodeAfter;\n var $end = $pos.node(0).resolve($pos.pos + node.nodeSize);\n Selection.call(this, $pos, $end);\n // :: Node The selected node.\n this.node = node;\n }\n\n if ( Selection ) NodeSelection.__proto__ = Selection;\n NodeSelection.prototype = Object.create( Selection && Selection.prototype );\n NodeSelection.prototype.constructor = NodeSelection;\n\n NodeSelection.prototype.map = function map (doc, mapping) {\n var ref = mapping.mapResult(this.anchor);\n var deleted = ref.deleted;\n var pos = ref.pos;\n var $pos = doc.resolve(pos);\n if (deleted) { return Selection.near($pos) }\n return new NodeSelection($pos)\n };\n\n NodeSelection.prototype.content = function content () {\n return new Slice(Fragment.from(this.node), 0, 0)\n };\n\n NodeSelection.prototype.eq = function eq (other) {\n return other instanceof NodeSelection && other.anchor == this.anchor\n };\n\n NodeSelection.prototype.toJSON = function toJSON () {\n return {type: \"node\", anchor: this.anchor}\n };\n\n NodeSelection.prototype.getBookmark = function getBookmark () { return new NodeBookmark(this.anchor) };\n\n NodeSelection.fromJSON = function fromJSON (doc, json) {\n if (typeof json.anchor != \"number\")\n { throw new RangeError(\"Invalid input for NodeSelection.fromJSON\") }\n return new NodeSelection(doc.resolve(json.anchor))\n };\n\n // :: (Node, number) → NodeSelection\n // Create a node selection from non-resolved positions.\n NodeSelection.create = function create (doc, from) {\n return new this(doc.resolve(from))\n };\n\n // :: (Node) → bool\n // Determines whether the given node may be selected as a node\n // selection.\n NodeSelection.isSelectable = function isSelectable (node) {\n return !node.isText && node.type.spec.selectable !== false\n };\n\n return NodeSelection;\n}(Selection));\n\nNodeSelection.prototype.visible = false;\n\nSelection.jsonID(\"node\", NodeSelection);\n\nvar NodeBookmark = function NodeBookmark(anchor) {\n this.anchor = anchor;\n};\nNodeBookmark.prototype.map = function map (mapping) {\n var ref = mapping.mapResult(this.anchor);\n var deleted = ref.deleted;\n var pos = ref.pos;\n return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos)\n};\nNodeBookmark.prototype.resolve = function resolve (doc) {\n var $pos = doc.resolve(this.anchor), node = $pos.nodeAfter;\n if (node && NodeSelection.isSelectable(node)) { return new NodeSelection($pos) }\n return Selection.near($pos)\n};\n\n// ::- A selection type that represents selecting the whole document\n// (which can not necessarily be expressed with a text selection, when\n// there are for example leaf block nodes at the start or end of the\n// document).\nvar AllSelection = /*@__PURE__*/(function (Selection) {\n function AllSelection(doc) {\n Selection.call(this, doc.resolve(0), doc.resolve(doc.content.size));\n }\n\n if ( Selection ) AllSelection.__proto__ = Selection;\n AllSelection.prototype = Object.create( Selection && Selection.prototype );\n AllSelection.prototype.constructor = AllSelection;\n\n AllSelection.prototype.replace = function replace (tr, content) {\n if ( content === void 0 ) content = Slice.empty;\n\n if (content == Slice.empty) {\n tr.delete(0, tr.doc.content.size);\n var sel = Selection.atStart(tr.doc);\n if (!sel.eq(tr.selection)) { tr.setSelection(sel); }\n } else {\n Selection.prototype.replace.call(this, tr, content);\n }\n };\n\n AllSelection.prototype.toJSON = function toJSON () { return {type: \"all\"} };\n\n AllSelection.fromJSON = function fromJSON (doc) { return new AllSelection(doc) };\n\n AllSelection.prototype.map = function map (doc) { return new AllSelection(doc) };\n\n AllSelection.prototype.eq = function eq (other) { return other instanceof AllSelection };\n\n AllSelection.prototype.getBookmark = function getBookmark () { return AllBookmark };\n\n return AllSelection;\n}(Selection));\n\nSelection.jsonID(\"all\", AllSelection);\n\nvar AllBookmark = {\n map: function map() { return this },\n resolve: function resolve(doc) { return new AllSelection(doc) }\n};\n\n// FIXME we'll need some awareness of text direction when scanning for selections\n\n// Try to find a selection inside the given node. `pos` points at the\n// position where the search starts. When `text` is true, only return\n// text selections.\nfunction findSelectionIn(doc, node, pos, index, dir, text) {\n if (node.inlineContent) { return TextSelection.create(doc, pos) }\n for (var i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {\n var child = node.child(i);\n if (!child.isAtom) {\n var inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);\n if (inner) { return inner }\n } else if (!text && NodeSelection.isSelectable(child)) {\n return NodeSelection.create(doc, pos - (dir < 0 ? child.nodeSize : 0))\n }\n pos += child.nodeSize * dir;\n }\n}\n\nfunction selectionToInsertionEnd(tr, startLen, bias) {\n var last = tr.steps.length - 1;\n if (last < startLen) { return }\n var step = tr.steps[last];\n if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) { return }\n var map = tr.mapping.maps[last], end;\n map.forEach(function (_from, _to, _newFrom, newTo) { if (end == null) { end = newTo; } });\n tr.setSelection(Selection.near(tr.doc.resolve(end), bias));\n}\n\nvar UPDATED_SEL = 1, UPDATED_MARKS = 2, UPDATED_SCROLL = 4;\n\n// ::- An editor state transaction, which can be applied to a state to\n// create an updated state. Use\n// [`EditorState.tr`](#state.EditorState.tr) to create an instance.\n//\n// Transactions track changes to the document (they are a subclass of\n// [`Transform`](#transform.Transform)), but also other state changes,\n// like selection updates and adjustments of the set of [stored\n// marks](#state.EditorState.storedMarks). In addition, you can store\n// metadata properties in a transaction, which are extra pieces of\n// information that client code or plugins can use to describe what a\n// transacion represents, so that they can update their [own\n// state](#state.StateField) accordingly.\n//\n// The [editor view](#view.EditorView) uses a few metadata properties:\n// it will attach a property `\"pointer\"` with the value `true` to\n// selection transactions directly caused by mouse or touch input, and\n// a `\"uiEvent\"` property of that may be `\"paste\"`, `\"cut\"`, or `\"drop\"`.\nvar Transaction = /*@__PURE__*/(function (Transform) {\n function Transaction(state) {\n Transform.call(this, state.doc);\n // :: number\n // The timestamp associated with this transaction, in the same\n // format as `Date.now()`.\n this.time = Date.now();\n this.curSelection = state.selection;\n // The step count for which the current selection is valid.\n this.curSelectionFor = 0;\n // :: ?[Mark]\n // The stored marks set by this transaction, if any.\n this.storedMarks = state.storedMarks;\n // Bitfield to track which aspects of the state were updated by\n // this transaction.\n this.updated = 0;\n // Object used to store metadata properties for the transaction.\n this.meta = Object.create(null);\n }\n\n if ( Transform ) Transaction.__proto__ = Transform;\n Transaction.prototype = Object.create( Transform && Transform.prototype );\n Transaction.prototype.constructor = Transaction;\n\n var prototypeAccessors = { selection: { configurable: true },selectionSet: { configurable: true },storedMarksSet: { configurable: true },isGeneric: { configurable: true },scrolledIntoView: { configurable: true } };\n\n // :: Selection\n // The transaction's current selection. This defaults to the editor\n // selection [mapped](#state.Selection.map) through the steps in the\n // transaction, but can be overwritten with\n // [`setSelection`](#state.Transaction.setSelection).\n prototypeAccessors.selection.get = function () {\n if (this.curSelectionFor < this.steps.length) {\n this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor));\n this.curSelectionFor = this.steps.length;\n }\n return this.curSelection\n };\n\n // :: (Selection) → Transaction\n // Update the transaction's current selection. Will determine the\n // selection that the editor gets when the transaction is applied.\n Transaction.prototype.setSelection = function setSelection (selection) {\n if (selection.$from.doc != this.doc)\n { throw new RangeError(\"Selection passed to setSelection must point at the current document\") }\n this.curSelection = selection;\n this.curSelectionFor = this.steps.length;\n this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;\n this.storedMarks = null;\n return this\n };\n\n // :: bool\n // Whether the selection was explicitly updated by this transaction.\n prototypeAccessors.selectionSet.get = function () {\n return (this.updated & UPDATED_SEL) > 0\n };\n\n // :: (?[Mark]) → Transaction\n // Set the current stored marks.\n Transaction.prototype.setStoredMarks = function setStoredMarks (marks) {\n this.storedMarks = marks;\n this.updated |= UPDATED_MARKS;\n return this\n };\n\n // :: ([Mark]) → Transaction\n // Make sure the current stored marks or, if that is null, the marks\n // at the selection, match the given set of marks. Does nothing if\n // this is already the case.\n Transaction.prototype.ensureMarks = function ensureMarks (marks) {\n if (!Mark.sameSet(this.storedMarks || this.selection.$from.marks(), marks))\n { this.setStoredMarks(marks); }\n return this\n };\n\n // :: (Mark) → Transaction\n // Add a mark to the set of stored marks.\n Transaction.prototype.addStoredMark = function addStoredMark (mark) {\n return this.ensureMarks(mark.addToSet(this.storedMarks || this.selection.$head.marks()))\n };\n\n // :: (union) → Transaction\n // Remove a mark or mark type from the set of stored marks.\n Transaction.prototype.removeStoredMark = function removeStoredMark (mark) {\n return this.ensureMarks(mark.removeFromSet(this.storedMarks || this.selection.$head.marks()))\n };\n\n // :: bool\n // Whether the stored marks were explicitly set for this transaction.\n prototypeAccessors.storedMarksSet.get = function () {\n return (this.updated & UPDATED_MARKS) > 0\n };\n\n Transaction.prototype.addStep = function addStep (step, doc) {\n Transform.prototype.addStep.call(this, step, doc);\n this.updated = this.updated & ~UPDATED_MARKS;\n this.storedMarks = null;\n };\n\n // :: (number) → Transaction\n // Update the timestamp for the transaction.\n Transaction.prototype.setTime = function setTime (time) {\n this.time = time;\n return this\n };\n\n // :: (Slice) → Transaction\n // Replace the current selection with the given slice.\n Transaction.prototype.replaceSelection = function replaceSelection (slice) {\n this.selection.replace(this, slice);\n return this\n };\n\n // :: (Node, ?bool) → Transaction\n // Replace the selection with the given node. When `inheritMarks` is\n // true and the content is inline, it inherits the marks from the\n // place where it is inserted.\n Transaction.prototype.replaceSelectionWith = function replaceSelectionWith (node, inheritMarks) {\n var selection = this.selection;\n if (inheritMarks !== false)\n { node = node.mark(this.storedMarks || (selection.empty ? selection.$from.marks() : (selection.$from.marksAcross(selection.$to) || Mark.none))); }\n selection.replaceWith(this, node);\n return this\n };\n\n // :: () → Transaction\n // Delete the selection.\n Transaction.prototype.deleteSelection = function deleteSelection () {\n this.selection.replace(this);\n return this\n };\n\n // :: (string, from: ?number, to: ?number) → Transaction\n // Replace the given range, or the selection if no range is given,\n // with a text node containing the given string.\n Transaction.prototype.insertText = function insertText (text, from, to) {\n if ( to === void 0 ) to = from;\n\n var schema = this.doc.type.schema;\n if (from == null) {\n if (!text) { return this.deleteSelection() }\n return this.replaceSelectionWith(schema.text(text), true)\n } else {\n if (!text) { return this.deleteRange(from, to) }\n var marks = this.storedMarks;\n if (!marks) {\n var $from = this.doc.resolve(from);\n marks = to == from ? $from.marks() : $from.marksAcross(this.doc.resolve(to));\n }\n this.replaceRangeWith(from, to, schema.text(text, marks));\n if (!this.selection.empty) { this.setSelection(Selection.near(this.selection.$to)); }\n return this\n }\n };\n\n // :: (union, any) → Transaction\n // Store a metadata property in this transaction, keyed either by\n // name or by plugin.\n Transaction.prototype.setMeta = function setMeta (key, value) {\n this.meta[typeof key == \"string\" ? key : key.key] = value;\n return this\n };\n\n // :: (union) → any\n // Retrieve a metadata property for a given name or plugin.\n Transaction.prototype.getMeta = function getMeta (key) {\n return this.meta[typeof key == \"string\" ? key : key.key]\n };\n\n // :: bool\n // Returns true if this transaction doesn't contain any metadata,\n // and can thus safely be extended.\n prototypeAccessors.isGeneric.get = function () {\n for (var _ in this.meta) { return false }\n return true\n };\n\n // :: () → Transaction\n // Indicate that the editor should scroll the selection into view\n // when updated to the state produced by this transaction.\n Transaction.prototype.scrollIntoView = function scrollIntoView () {\n this.updated |= UPDATED_SCROLL;\n return this\n };\n\n prototypeAccessors.scrolledIntoView.get = function () {\n return (this.updated & UPDATED_SCROLL) > 0\n };\n\n Object.defineProperties( Transaction.prototype, prototypeAccessors );\n\n return Transaction;\n}(Transform));\n\nfunction bind(f, self) {\n return !self || !f ? f : f.bind(self)\n}\n\nvar FieldDesc = function FieldDesc(name, desc, self) {\n this.name = name;\n this.init = bind(desc.init, self);\n this.apply = bind(desc.apply, self);\n};\n\nvar baseFields = [\n new FieldDesc(\"doc\", {\n init: function init(config) { return config.doc || config.schema.topNodeType.createAndFill() },\n apply: function apply(tr) { return tr.doc }\n }),\n\n new FieldDesc(\"selection\", {\n init: function init(config, instance) { return config.selection || Selection.atStart(instance.doc) },\n apply: function apply(tr) { return tr.selection }\n }),\n\n new FieldDesc(\"storedMarks\", {\n init: function init(config) { return config.storedMarks || null },\n apply: function apply(tr, _marks, _old, state) { return state.selection.$cursor ? tr.storedMarks : null }\n }),\n\n new FieldDesc(\"scrollToSelection\", {\n init: function init() { return 0 },\n apply: function apply(tr, prev) { return tr.scrolledIntoView ? prev + 1 : prev }\n })\n];\n\n// Object wrapping the part of a state object that stays the same\n// across transactions. Stored in the state's `config` property.\nvar Configuration = function Configuration(schema, plugins) {\n var this$1 = this;\n\n this.schema = schema;\n this.fields = baseFields.concat();\n this.plugins = [];\n this.pluginsByKey = Object.create(null);\n if (plugins) { plugins.forEach(function (plugin) {\n if (this$1.pluginsByKey[plugin.key])\n { throw new RangeError(\"Adding different instances of a keyed plugin (\" + plugin.key + \")\") }\n this$1.plugins.push(plugin);\n this$1.pluginsByKey[plugin.key] = plugin;\n if (plugin.spec.state)\n { this$1.fields.push(new FieldDesc(plugin.key, plugin.spec.state, plugin)); }\n }); }\n};\n\n// ::- The state of a ProseMirror editor is represented by an object\n// of this type. A state is a persistent data structure—it isn't\n// updated, but rather a new state value is computed from an old one\n// using the [`apply`](#state.EditorState.apply) method.\n//\n// A state holds a number of built-in fields, and plugins can\n// [define](#state.PluginSpec.state) additional fields.\nvar EditorState = function EditorState(config) {\n this.config = config;\n};\n\nvar prototypeAccessors$1 = { schema: { configurable: true },plugins: { configurable: true },tr: { configurable: true } };\n\n// doc:: Node\n// The current document.\n\n// selection:: Selection\n// The selection.\n\n// storedMarks:: ?[Mark]\n// A set of marks to apply to the next input. Will be null when\n// no explicit marks have been set.\n\n// :: Schema\n// The schema of the state's document.\nprototypeAccessors$1.schema.get = function () {\n return this.config.schema\n};\n\n// :: [Plugin]\n// The plugins that are active in this state.\nprototypeAccessors$1.plugins.get = function () {\n return this.config.plugins\n};\n\n// :: (Transaction) → EditorState\n// Apply the given transaction to produce a new state.\nEditorState.prototype.apply = function apply (tr) {\n return this.applyTransaction(tr).state\n};\n\n// : (Transaction) → bool\nEditorState.prototype.filterTransaction = function filterTransaction (tr, ignore) {\n if ( ignore === void 0 ) ignore = -1;\n\n for (var i = 0; i < this.config.plugins.length; i++) { if (i != ignore) {\n var plugin = this.config.plugins[i];\n if (plugin.spec.filterTransaction && !plugin.spec.filterTransaction.call(plugin, tr, this))\n { return false }\n } }\n return true\n};\n\n// :: (Transaction) → {state: EditorState, transactions: [Transaction]}\n// Verbose variant of [`apply`](#state.EditorState.apply) that\n// returns the precise transactions that were applied (which might\n// be influenced by the [transaction\n// hooks](#state.PluginSpec.filterTransaction) of\n// plugins) along with the new state.\nEditorState.prototype.applyTransaction = function applyTransaction (rootTr) {\n if (!this.filterTransaction(rootTr)) { return {state: this, transactions: []} }\n\n var trs = [rootTr], newState = this.applyInner(rootTr), seen = null;\n // This loop repeatedly gives plugins a chance to respond to\n // transactions as new transactions are added, making sure to only\n // pass the transactions the plugin did not see before.\n for (;;) {\n var haveNew = false;\n for (var i = 0; i < this.config.plugins.length; i++) {\n var plugin = this.config.plugins[i];\n if (plugin.spec.appendTransaction) {\n var n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this;\n var tr = n < trs.length &&\n plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState);\n if (tr && newState.filterTransaction(tr, i)) {\n tr.setMeta(\"appendedTransaction\", rootTr);\n if (!seen) {\n seen = [];\n for (var j = 0; j < this.config.plugins.length; j++)\n { seen.push(j < i ? {state: newState, n: trs.length} : {state: this, n: 0}); }\n }\n trs.push(tr);\n newState = newState.applyInner(tr);\n haveNew = true;\n }\n if (seen) { seen[i] = {state: newState, n: trs.length}; }\n }\n }\n if (!haveNew) { return {state: newState, transactions: trs} }\n }\n};\n\n// : (Transaction) → EditorState\nEditorState.prototype.applyInner = function applyInner (tr) {\n if (!tr.before.eq(this.doc)) { throw new RangeError(\"Applying a mismatched transaction\") }\n var newInstance = new EditorState(this.config), fields = this.config.fields;\n for (var i = 0; i < fields.length; i++) {\n var field = fields[i];\n newInstance[field.name] = field.apply(tr, this[field.name], this, newInstance);\n }\n for (var i$1 = 0; i$1 < applyListeners.length; i$1++) { applyListeners[i$1](this, tr, newInstance); }\n return newInstance\n};\n\n// :: Transaction\n// Start a [transaction](#state.Transaction) from this state.\nprototypeAccessors$1.tr.get = function () { return new Transaction(this) };\n\n// :: (Object) → EditorState\n// Create a new state.\n//\n// config::- Configuration options. Must contain `schema` or `doc` (or both).\n//\n// schema:: ?Schema\n// The schema to use (only relevant if no `doc` is specified).\n//\n// doc:: ?Node\n// The starting document.\n//\n// selection:: ?Selection\n// A valid selection in the document.\n//\n// storedMarks:: ?[Mark]\n// The initial set of [stored marks](#state.EditorState.storedMarks).\n//\n// plugins:: ?[Plugin]\n// The plugins that should be active in this state.\nEditorState.create = function create (config) {\n var $config = new Configuration(config.doc ? config.doc.type.schema : config.schema, config.plugins);\n var instance = new EditorState($config);\n for (var i = 0; i < $config.fields.length; i++)\n { instance[$config.fields[i].name] = $config.fields[i].init(config, instance); }\n return instance\n};\n\n// :: (Object) → EditorState\n// Create a new state based on this one, but with an adjusted set of\n// active plugins. State fields that exist in both sets of plugins\n// are kept unchanged. Those that no longer exist are dropped, and\n// those that are new are initialized using their\n// [`init`](#state.StateField.init) method, passing in the new\n// configuration object..\n//\n// config::- configuration options\n//\n// plugins:: [Plugin]\n// New set of active plugins.\nEditorState.prototype.reconfigure = function reconfigure (config) {\n var $config = new Configuration(this.schema, config.plugins);\n var fields = $config.fields, instance = new EditorState($config);\n for (var i = 0; i < fields.length; i++) {\n var name = fields[i].name;\n instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config, instance);\n }\n return instance\n};\n\n// :: (?union, string, number>) → Object\n// Serialize this state to JSON. If you want to serialize the state\n// of plugins, pass an object mapping property names to use in the\n// resulting JSON object to plugin objects. The argument may also be\n// a string or number, in which case it is ignored, to support the\n// way `JSON.stringify` calls `toString` methods.\nEditorState.prototype.toJSON = function toJSON (pluginFields) {\n var result = {doc: this.doc.toJSON(), selection: this.selection.toJSON()};\n if (this.storedMarks) { result.storedMarks = this.storedMarks.map(function (m) { return m.toJSON(); }); }\n if (pluginFields && typeof pluginFields == 'object') { for (var prop in pluginFields) {\n if (prop == \"doc\" || prop == \"selection\")\n { throw new RangeError(\"The JSON fields `doc` and `selection` are reserved\") }\n var plugin = pluginFields[prop], state = plugin.spec.state;\n if (state && state.toJSON) { result[prop] = state.toJSON.call(plugin, this[plugin.key]); }\n } }\n return result\n};\n\n// :: (Object, Object, ?Object) → EditorState\n// Deserialize a JSON representation of a state. `config` should\n// have at least a `schema` field, and should contain array of\n// plugins to initialize the state with. `pluginFields` can be used\n// to deserialize the state of plugins, by associating plugin\n// instances with the property names they use in the JSON object.\n//\n// config::- configuration options\n//\n// schema:: Schema\n// The schema to use.\n//\n// plugins:: ?[Plugin]\n// The set of active plugins.\nEditorState.fromJSON = function fromJSON (config, json, pluginFields) {\n if (!json) { throw new RangeError(\"Invalid input for EditorState.fromJSON\") }\n if (!config.schema) { throw new RangeError(\"Required config field 'schema' missing\") }\n var $config = new Configuration(config.schema, config.plugins);\n var instance = new EditorState($config);\n $config.fields.forEach(function (field) {\n if (field.name == \"doc\") {\n instance.doc = Node.fromJSON(config.schema, json.doc);\n } else if (field.name == \"selection\") {\n instance.selection = Selection.fromJSON(instance.doc, json.selection);\n } else if (field.name == \"storedMarks\") {\n if (json.storedMarks) { instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON); }\n } else {\n if (pluginFields) { for (var prop in pluginFields) {\n var plugin = pluginFields[prop], state = plugin.spec.state;\n if (plugin.key == field.name && state && state.fromJSON &&\n Object.prototype.hasOwnProperty.call(json, prop)) {\n // This field belongs to a plugin mapped to a JSON field, read it from there.\n instance[field.name] = state.fromJSON.call(plugin, config, json[prop], instance);\n return\n }\n } }\n instance[field.name] = field.init(config, instance);\n }\n });\n return instance\n};\n\n// Kludge to allow the view to track mappings between different\n// instances of a state.\n//\n// FIXME this is no longer needed as of prosemirror-view 1.9.0,\n// though due to backwards-compat we should probably keep it around\n// for a while (if only as a no-op)\nEditorState.addApplyListener = function addApplyListener (f) {\n applyListeners.push(f);\n};\nEditorState.removeApplyListener = function removeApplyListener (f) {\n var found = applyListeners.indexOf(f);\n if (found > -1) { applyListeners.splice(found, 1); }\n};\n\nObject.defineProperties( EditorState.prototype, prototypeAccessors$1 );\n\nvar applyListeners = [];\n\n// PluginSpec:: interface\n//\n// This is the type passed to the [`Plugin`](#state.Plugin)\n// constructor. It provides a definition for a plugin.\n//\n// props:: ?EditorProps\n// The [view props](#view.EditorProps) added by this plugin. Props\n// that are functions will be bound to have the plugin instance as\n// their `this` binding.\n//\n// state:: ?StateField\n// Allows a plugin to define a [state field](#state.StateField), an\n// extra slot in the state object in which it can keep its own data.\n//\n// key:: ?PluginKey\n// Can be used to make this a keyed plugin. You can have only one\n// plugin with a given key in a given state, but it is possible to\n// access the plugin's configuration and state through the key,\n// without having access to the plugin instance object.\n//\n// view:: ?(EditorView) → Object\n// When the plugin needs to interact with the editor view, or\n// set something up in the DOM, use this field. The function\n// will be called when the plugin's state is associated with an\n// editor view.\n//\n// return::-\n// Should return an object with the following optional\n// properties:\n//\n// update:: ?(view: EditorView, prevState: EditorState)\n// Called whenever the view's state is updated.\n//\n// destroy:: ?()\n// Called when the view is destroyed or receives a state\n// with different plugins.\n//\n// filterTransaction:: ?(Transaction, EditorState) → bool\n// When present, this will be called before a transaction is\n// applied by the state, allowing the plugin to cancel it (by\n// returning false).\n//\n// appendTransaction:: ?(transactions: [Transaction], oldState: EditorState, newState: EditorState) → ?Transaction\n// Allows the plugin to append another transaction to be applied\n// after the given array of transactions. When another plugin\n// appends a transaction after this was called, it is called again\n// with the new state and new transactions—but only the new\n// transactions, i.e. it won't be passed transactions that it\n// already saw.\n\nfunction bindProps(obj, self, target) {\n for (var prop in obj) {\n var val = obj[prop];\n if (val instanceof Function) { val = val.bind(self); }\n else if (prop == \"handleDOMEvents\") { val = bindProps(val, self, {}); }\n target[prop] = val;\n }\n return target\n}\n\n// ::- Plugins bundle functionality that can be added to an editor.\n// They are part of the [editor state](#state.EditorState) and\n// may influence that state and the view that contains it.\nvar Plugin = function Plugin(spec) {\n // :: EditorProps\n // The [props](#view.EditorProps) exported by this plugin.\n this.props = {};\n if (spec.props) { bindProps(spec.props, this, this.props); }\n // :: Object\n // The plugin's [spec object](#state.PluginSpec).\n this.spec = spec;\n this.key = spec.key ? spec.key.key : createKey(\"plugin\");\n};\n\n// :: (EditorState) → any\n// Extract the plugin's state field from an editor state.\nPlugin.prototype.getState = function getState (state) { return state[this.key] };\n\n// StateField:: interface\n// A plugin spec may provide a state field (under its\n// [`state`](#state.PluginSpec.state) property) of this type, which\n// describes the state it wants to keep. Functions provided here are\n// always called with the plugin instance as their `this` binding.\n//\n// init:: (config: Object, instance: EditorState) → T\n// Initialize the value of the field. `config` will be the object\n// passed to [`EditorState.create`](#state.EditorState^create). Note\n// that `instance` is a half-initialized state instance, and will\n// not have values for plugin fields initialized after this one.\n//\n// apply:: (tr: Transaction, value: T, oldState: EditorState, newState: EditorState) → T\n// Apply the given transaction to this state field, producing a new\n// field value. Note that the `newState` argument is again a partially\n// constructed state does not yet contain the state from plugins\n// coming after this one.\n//\n// toJSON:: ?(value: T) → *\n// Convert this field to JSON. Optional, can be left off to disable\n// JSON serialization for the field.\n//\n// fromJSON:: ?(config: Object, value: *, state: EditorState) → T\n// Deserialize the JSON representation of this field. Note that the\n// `state` argument is again a half-initialized state.\n\nvar keys = Object.create(null);\n\nfunction createKey(name) {\n if (name in keys) { return name + \"$\" + ++keys[name] }\n keys[name] = 0;\n return name + \"$\"\n}\n\n// ::- A key is used to [tag](#state.PluginSpec.key)\n// plugins in a way that makes it possible to find them, given an\n// editor state. Assigning a key does mean only one plugin of that\n// type can be active in a state.\nvar PluginKey = function PluginKey(name) {\nif ( name === void 0 ) name = \"key\";\n this.key = createKey(name); };\n\n// :: (EditorState) → ?Plugin\n// Get the active plugin with this key, if any, from an editor\n// state.\nPluginKey.prototype.get = function get (state) { return state.config.pluginsByKey[this.key] };\n\n// :: (EditorState) → ?any\n// Get the plugin's state from an editor state.\nPluginKey.prototype.getState = function getState (state) { return state[this.key] };\n\nexport { AllSelection, EditorState, NodeSelection, Plugin, PluginKey, Selection, SelectionRange, TextSelection, Transaction };\n//# sourceMappingURL=index.es.js.map\n","import { liftTarget, canJoin, joinPoint, canSplit, ReplaceAroundStep, findWrapping } from 'prosemirror-transform';\nimport { Fragment, Slice } from 'prosemirror-model';\nimport { NodeSelection, Selection, AllSelection, TextSelection } from 'prosemirror-state';\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Delete the selection, if there is one.\nfunction deleteSelection(state, dispatch) {\n if (state.selection.empty) { return false }\n if (dispatch) { dispatch(state.tr.deleteSelection().scrollIntoView()); }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction), ?EditorView) → bool\n// If the selection is empty and at the start of a textblock, try to\n// reduce the distance between that block and the one before it—if\n// there's a block directly before it that can be joined, join them.\n// If not, try to move the selected block closer to the next one in\n// the document structure by lifting it out of its parent or moving it\n// into a parent of the previous block. Will use the view for accurate\n// (bidi-aware) start-of-textblock detection if given.\nfunction joinBackward(state, dispatch, view) {\n var ref = state.selection;\n var $cursor = ref.$cursor;\n if (!$cursor || (view ? !view.endOfTextblock(\"backward\", state)\n : $cursor.parentOffset > 0))\n { return false }\n\n var $cut = findCutBefore($cursor);\n\n // If there is no node before this, try to lift\n if (!$cut) {\n var range = $cursor.blockRange(), target = range && liftTarget(range);\n if (target == null) { return false }\n if (dispatch) { dispatch(state.tr.lift(range, target).scrollIntoView()); }\n return true\n }\n\n var before = $cut.nodeBefore;\n // Apply the joining algorithm\n if (!before.type.spec.isolating && deleteBarrier(state, $cut, dispatch))\n { return true }\n\n // If the node below has no content and the node above is\n // selectable, delete the node below and select the one above.\n if ($cursor.parent.content.size == 0 &&\n (textblockAt(before, \"end\") || NodeSelection.isSelectable(before))) {\n if (dispatch) {\n var tr = state.tr.deleteRange($cursor.before(), $cursor.after());\n tr.setSelection(textblockAt(before, \"end\") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1)\n : NodeSelection.create(tr.doc, $cut.pos - before.nodeSize));\n dispatch(tr.scrollIntoView());\n }\n return true\n }\n\n // If the node before is an atom, delete it\n if (before.isAtom && $cut.depth == $cursor.depth - 1) {\n if (dispatch) { dispatch(state.tr.delete($cut.pos - before.nodeSize, $cut.pos).scrollIntoView()); }\n return true\n }\n\n return false\n}\n\nfunction textblockAt(node, side, only) {\n for (; node; node = (side == \"start\" ? node.firstChild : node.lastChild)) {\n if (node.isTextblock) { return true }\n if (only && node.childCount != 1) { return false }\n }\n return false\n}\n\n// :: (EditorState, ?(tr: Transaction), ?EditorView) → bool\n// When the selection is empty and at the start of a textblock, select\n// the node before that textblock, if possible. This is intended to be\n// bound to keys like backspace, after\n// [`joinBackward`](#commands.joinBackward) or other deleting\n// commands, as a fall-back behavior when the schema doesn't allow\n// deletion at the selected point.\nfunction selectNodeBackward(state, dispatch, view) {\n var ref = state.selection;\n var $head = ref.$head;\n var empty = ref.empty;\n var $cut = $head;\n if (!empty) { return false }\n\n if ($head.parent.isTextblock) {\n if (view ? !view.endOfTextblock(\"backward\", state) : $head.parentOffset > 0) { return false }\n $cut = findCutBefore($head);\n }\n var node = $cut && $cut.nodeBefore;\n if (!node || !NodeSelection.isSelectable(node)) { return false }\n if (dispatch)\n { dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos - node.nodeSize)).scrollIntoView()); }\n return true\n}\n\nfunction findCutBefore($pos) {\n if (!$pos.parent.type.spec.isolating) { for (var i = $pos.depth - 1; i >= 0; i--) {\n if ($pos.index(i) > 0) { return $pos.doc.resolve($pos.before(i + 1)) }\n if ($pos.node(i).type.spec.isolating) { break }\n } }\n return null\n}\n\n// :: (EditorState, ?(tr: Transaction), ?EditorView) → bool\n// If the selection is empty and the cursor is at the end of a\n// textblock, try to reduce or remove the boundary between that block\n// and the one after it, either by joining them or by moving the other\n// block closer to this one in the tree structure. Will use the view\n// for accurate start-of-textblock detection if given.\nfunction joinForward(state, dispatch, view) {\n var ref = state.selection;\n var $cursor = ref.$cursor;\n if (!$cursor || (view ? !view.endOfTextblock(\"forward\", state)\n : $cursor.parentOffset < $cursor.parent.content.size))\n { return false }\n\n var $cut = findCutAfter($cursor);\n\n // If there is no node after this, there's nothing to do\n if (!$cut) { return false }\n\n var after = $cut.nodeAfter;\n // Try the joining algorithm\n if (deleteBarrier(state, $cut, dispatch)) { return true }\n\n // If the node above has no content and the node below is\n // selectable, delete the node above and select the one below.\n if ($cursor.parent.content.size == 0 &&\n (textblockAt(after, \"start\") || NodeSelection.isSelectable(after))) {\n if (dispatch) {\n var tr = state.tr.deleteRange($cursor.before(), $cursor.after());\n tr.setSelection(textblockAt(after, \"start\") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1)\n : NodeSelection.create(tr.doc, tr.mapping.map($cut.pos)));\n dispatch(tr.scrollIntoView());\n }\n return true\n }\n\n // If the next node is an atom, delete it\n if (after.isAtom && $cut.depth == $cursor.depth - 1) {\n if (dispatch) { dispatch(state.tr.delete($cut.pos, $cut.pos + after.nodeSize).scrollIntoView()); }\n return true\n }\n\n return false\n}\n\n// :: (EditorState, ?(tr: Transaction), ?EditorView) → bool\n// When the selection is empty and at the end of a textblock, select\n// the node coming after that textblock, if possible. This is intended\n// to be bound to keys like delete, after\n// [`joinForward`](#commands.joinForward) and similar deleting\n// commands, to provide a fall-back behavior when the schema doesn't\n// allow deletion at the selected point.\nfunction selectNodeForward(state, dispatch, view) {\n var ref = state.selection;\n var $head = ref.$head;\n var empty = ref.empty;\n var $cut = $head;\n if (!empty) { return false }\n if ($head.parent.isTextblock) {\n if (view ? !view.endOfTextblock(\"forward\", state) : $head.parentOffset < $head.parent.content.size)\n { return false }\n $cut = findCutAfter($head);\n }\n var node = $cut && $cut.nodeAfter;\n if (!node || !NodeSelection.isSelectable(node)) { return false }\n if (dispatch)\n { dispatch(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos)).scrollIntoView()); }\n return true\n}\n\nfunction findCutAfter($pos) {\n if (!$pos.parent.type.spec.isolating) { for (var i = $pos.depth - 1; i >= 0; i--) {\n var parent = $pos.node(i);\n if ($pos.index(i) + 1 < parent.childCount) { return $pos.doc.resolve($pos.after(i + 1)) }\n if (parent.type.spec.isolating) { break }\n } }\n return null\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Join the selected block or, if there is a text selection, the\n// closest ancestor block of the selection that can be joined, with\n// the sibling above it.\nfunction joinUp(state, dispatch) {\n var sel = state.selection, nodeSel = sel instanceof NodeSelection, point;\n if (nodeSel) {\n if (sel.node.isTextblock || !canJoin(state.doc, sel.from)) { return false }\n point = sel.from;\n } else {\n point = joinPoint(state.doc, sel.from, -1);\n if (point == null) { return false }\n }\n if (dispatch) {\n var tr = state.tr.join(point);\n if (nodeSel) { tr.setSelection(NodeSelection.create(tr.doc, point - state.doc.resolve(point).nodeBefore.nodeSize)); }\n dispatch(tr.scrollIntoView());\n }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Join the selected block, or the closest ancestor of the selection\n// that can be joined, with the sibling after it.\nfunction joinDown(state, dispatch) {\n var sel = state.selection, point;\n if (sel instanceof NodeSelection) {\n if (sel.node.isTextblock || !canJoin(state.doc, sel.to)) { return false }\n point = sel.to;\n } else {\n point = joinPoint(state.doc, sel.to, 1);\n if (point == null) { return false }\n }\n if (dispatch)\n { dispatch(state.tr.join(point).scrollIntoView()); }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Lift the selected block, or the closest ancestor block of the\n// selection that can be lifted, out of its parent node.\nfunction lift(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n var range = $from.blockRange($to), target = range && liftTarget(range);\n if (target == null) { return false }\n if (dispatch) { dispatch(state.tr.lift(range, target).scrollIntoView()); }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// If the selection is in a node whose type has a truthy\n// [`code`](#model.NodeSpec.code) property in its spec, replace the\n// selection with a newline character.\nfunction newlineInCode(state, dispatch) {\n var ref = state.selection;\n var $head = ref.$head;\n var $anchor = ref.$anchor;\n if (!$head.parent.type.spec.code || !$head.sameParent($anchor)) { return false }\n if (dispatch) { dispatch(state.tr.insertText(\"\\n\").scrollIntoView()); }\n return true\n}\n\nfunction defaultBlockAt(match) {\n for (var i = 0; i < match.edgeCount; i++) {\n var ref = match.edge(i);\n var type = ref.type;\n if (type.isTextblock && !type.hasRequiredAttrs()) { return type }\n }\n return null\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// When the selection is in a node with a truthy\n// [`code`](#model.NodeSpec.code) property in its spec, create a\n// default block after the code block, and move the cursor there.\nfunction exitCode(state, dispatch) {\n var ref = state.selection;\n var $head = ref.$head;\n var $anchor = ref.$anchor;\n if (!$head.parent.type.spec.code || !$head.sameParent($anchor)) { return false }\n var above = $head.node(-1), after = $head.indexAfter(-1), type = defaultBlockAt(above.contentMatchAt(after));\n if (!above.canReplaceWith(after, after, type)) { return false }\n if (dispatch) {\n var pos = $head.after(), tr = state.tr.replaceWith(pos, pos, type.createAndFill());\n tr.setSelection(Selection.near(tr.doc.resolve(pos), 1));\n dispatch(tr.scrollIntoView());\n }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// If a block node is selected, create an empty paragraph before (if\n// it is its parent's first child) or after it.\nfunction createParagraphNear(state, dispatch) {\n var sel = state.selection;\n var $from = sel.$from;\n var $to = sel.$to;\n if (sel instanceof AllSelection || $from.parent.inlineContent || $to.parent.inlineContent) { return false }\n var type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter()));\n if (!type || !type.isTextblock) { return false }\n if (dispatch) {\n var side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;\n var tr = state.tr.insert(side, type.createAndFill());\n tr.setSelection(TextSelection.create(tr.doc, side + 1));\n dispatch(tr.scrollIntoView());\n }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// If the cursor is in an empty textblock that can be lifted, lift the\n// block.\nfunction liftEmptyBlock(state, dispatch) {\n var ref = state.selection;\n var $cursor = ref.$cursor;\n if (!$cursor || $cursor.parent.content.size) { return false }\n if ($cursor.depth > 1 && $cursor.after() != $cursor.end(-1)) {\n var before = $cursor.before();\n if (canSplit(state.doc, before)) {\n if (dispatch) { dispatch(state.tr.split(before).scrollIntoView()); }\n return true\n }\n }\n var range = $cursor.blockRange(), target = range && liftTarget(range);\n if (target == null) { return false }\n if (dispatch) { dispatch(state.tr.lift(range, target).scrollIntoView()); }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Split the parent block of the selection. If the selection is a text\n// selection, also delete its content.\nfunction splitBlock(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {\n if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) { return false }\n if (dispatch) { dispatch(state.tr.split($from.pos).scrollIntoView()); }\n return true\n }\n\n if (!$from.parent.isBlock) { return false }\n\n if (dispatch) {\n var atEnd = $to.parentOffset == $to.parent.content.size;\n var tr = state.tr;\n if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) { tr.deleteSelection(); }\n var deflt = $from.depth == 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));\n var types = atEnd && deflt ? [{type: deflt}] : null;\n var can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);\n if (!types && !can && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt && [{type: deflt}])) {\n types = [{type: deflt}];\n can = true;\n }\n if (can) {\n tr.split(tr.mapping.map($from.pos), 1, types);\n if (!atEnd && !$from.parentOffset && $from.parent.type != deflt) {\n var first = tr.mapping.map($from.before()), $first = tr.doc.resolve(first);\n if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt))\n { tr.setNodeMarkup(tr.mapping.map($from.before()), deflt); }\n }\n }\n dispatch(tr.scrollIntoView());\n }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Acts like [`splitBlock`](#commands.splitBlock), but without\n// resetting the set of active marks at the cursor.\nfunction splitBlockKeepMarks(state, dispatch) {\n return splitBlock(state, dispatch && (function (tr) {\n var marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks());\n if (marks) { tr.ensureMarks(marks); }\n dispatch(tr);\n }))\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Move the selection to the node wrapping the current selection, if\n// any. (Will not select the document node.)\nfunction selectParentNode(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var to = ref.to;\n var pos;\n var same = $from.sharedDepth(to);\n if (same == 0) { return false }\n pos = $from.before(same);\n if (dispatch) { dispatch(state.tr.setSelection(NodeSelection.create(state.doc, pos))); }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// Select the whole document.\nfunction selectAll(state, dispatch) {\n if (dispatch) { dispatch(state.tr.setSelection(new AllSelection(state.doc))); }\n return true\n}\n\nfunction joinMaybeClear(state, $pos, dispatch) {\n var before = $pos.nodeBefore, after = $pos.nodeAfter, index = $pos.index();\n if (!before || !after || !before.type.compatibleContent(after.type)) { return false }\n if (!before.content.size && $pos.parent.canReplace(index - 1, index)) {\n if (dispatch) { dispatch(state.tr.delete($pos.pos - before.nodeSize, $pos.pos).scrollIntoView()); }\n return true\n }\n if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || canJoin(state.doc, $pos.pos)))\n { return false }\n if (dispatch)\n { dispatch(state.tr\n .clearIncompatible($pos.pos, before.type, before.contentMatchAt(before.childCount))\n .join($pos.pos)\n .scrollIntoView()); }\n return true\n}\n\nfunction deleteBarrier(state, $cut, dispatch) {\n var before = $cut.nodeBefore, after = $cut.nodeAfter, conn, match;\n if (before.type.spec.isolating || after.type.spec.isolating) { return false }\n if (joinMaybeClear(state, $cut, dispatch)) { return true }\n\n var canDelAfter = $cut.parent.canReplace($cut.index(), $cut.index() + 1);\n if (canDelAfter &&\n (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) &&\n match.matchType(conn[0] || after.type).validEnd) {\n if (dispatch) {\n var end = $cut.pos + after.nodeSize, wrap = Fragment.empty;\n for (var i = conn.length - 1; i >= 0; i--)\n { wrap = Fragment.from(conn[i].create(null, wrap)); }\n wrap = Fragment.from(before.copy(wrap));\n var tr = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new Slice(wrap, 1, 0), conn.length, true));\n var joinAt = end + 2 * conn.length;\n if (canJoin(tr.doc, joinAt)) { tr.join(joinAt); }\n dispatch(tr.scrollIntoView());\n }\n return true\n }\n\n var selAfter = Selection.findFrom($cut, 1);\n var range = selAfter && selAfter.$from.blockRange(selAfter.$to), target = range && liftTarget(range);\n if (target != null && target >= $cut.depth) {\n if (dispatch) { dispatch(state.tr.lift(range, target).scrollIntoView()); }\n return true\n }\n\n if (canDelAfter && textblockAt(after, \"start\", true) && textblockAt(before, \"end\")) {\n var at = before, wrap$1 = [];\n for (;;) {\n wrap$1.push(at);\n if (at.isTextblock) { break }\n at = at.lastChild;\n }\n var afterText = after, afterDepth = 1;\n for (; !afterText.isTextblock; afterText = afterText.firstChild) { afterDepth++; }\n if (at.canReplace(at.childCount, at.childCount, afterText.content)) {\n if (dispatch) {\n var end$1 = Fragment.empty;\n for (var i$1 = wrap$1.length - 1; i$1 >= 0; i$1--) { end$1 = Fragment.from(wrap$1[i$1].copy(end$1)); }\n var tr$1 = state.tr.step(new ReplaceAroundStep($cut.pos - wrap$1.length, $cut.pos + after.nodeSize,\n $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth,\n new Slice(end$1, wrap$1.length, 0), 0, true));\n dispatch(tr$1.scrollIntoView());\n }\n return true\n }\n }\n\n return false\n}\n\n// Parameterized commands\n\n// :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Wrap the selection in a node of the given type with the given\n// attributes.\nfunction wrapIn(nodeType, attrs) {\n return function(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n var range = $from.blockRange($to), wrapping = range && findWrapping(range, nodeType, attrs);\n if (!wrapping) { return false }\n if (dispatch) { dispatch(state.tr.wrap(range, wrapping).scrollIntoView()); }\n return true\n }\n}\n\n// :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Returns a command that tries to set the selected textblocks to the\n// given node type with the given attributes.\nfunction setBlockType(nodeType, attrs) {\n return function(state, dispatch) {\n var ref = state.selection;\n var from = ref.from;\n var to = ref.to;\n var applicable = false;\n state.doc.nodesBetween(from, to, function (node, pos) {\n if (applicable) { return false }\n if (!node.isTextblock || node.hasMarkup(nodeType, attrs)) { return }\n if (node.type == nodeType) {\n applicable = true;\n } else {\n var $pos = state.doc.resolve(pos), index = $pos.index();\n applicable = $pos.parent.canReplaceWith(index, index + 1, nodeType);\n }\n });\n if (!applicable) { return false }\n if (dispatch) { dispatch(state.tr.setBlockType(from, to, nodeType, attrs).scrollIntoView()); }\n return true\n }\n}\n\nfunction markApplies(doc, ranges, type) {\n var loop = function ( i ) {\n var ref = ranges[i];\n var $from = ref.$from;\n var $to = ref.$to;\n var can = $from.depth == 0 ? doc.type.allowsMarkType(type) : false;\n doc.nodesBetween($from.pos, $to.pos, function (node) {\n if (can) { return false }\n can = node.inlineContent && node.type.allowsMarkType(type);\n });\n if (can) { return { v: true } }\n };\n\n for (var i = 0; i < ranges.length; i++) {\n var returned = loop( i );\n\n if ( returned ) return returned.v;\n }\n return false\n}\n\n// :: (MarkType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Create a command function that toggles the given mark with the\n// given attributes. Will return `false` when the current selection\n// doesn't support that mark. This will remove the mark if any marks\n// of that type exist in the selection, or add it otherwise. If the\n// selection is empty, this applies to the [stored\n// marks](#state.EditorState.storedMarks) instead of a range of the\n// document.\nfunction toggleMark(markType, attrs) {\n return function(state, dispatch) {\n var ref = state.selection;\n var empty = ref.empty;\n var $cursor = ref.$cursor;\n var ranges = ref.ranges;\n if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) { return false }\n if (dispatch) {\n if ($cursor) {\n if (markType.isInSet(state.storedMarks || $cursor.marks()))\n { dispatch(state.tr.removeStoredMark(markType)); }\n else\n { dispatch(state.tr.addStoredMark(markType.create(attrs))); }\n } else {\n var has = false, tr = state.tr;\n for (var i = 0; !has && i < ranges.length; i++) {\n var ref$1 = ranges[i];\n var $from = ref$1.$from;\n var $to = ref$1.$to;\n has = state.doc.rangeHasMark($from.pos, $to.pos, markType);\n }\n for (var i$1 = 0; i$1 < ranges.length; i$1++) {\n var ref$2 = ranges[i$1];\n var $from$1 = ref$2.$from;\n var $to$1 = ref$2.$to;\n if (has) {\n tr.removeMark($from$1.pos, $to$1.pos, markType);\n } else {\n var from = $from$1.pos, to = $to$1.pos, start = $from$1.nodeAfter, end = $to$1.nodeBefore;\n var spaceStart = start && start.isText ? /^\\s*/.exec(start.text)[0].length : 0;\n var spaceEnd = end && end.isText ? /\\s*$/.exec(end.text)[0].length : 0;\n if (from + spaceStart < to) { from += spaceStart; to -= spaceEnd; }\n tr.addMark(from, to, markType.create(attrs));\n }\n }\n dispatch(tr.scrollIntoView());\n }\n }\n return true\n }\n}\n\nfunction wrapDispatchForJoin(dispatch, isJoinable) {\n return function (tr) {\n if (!tr.isGeneric) { return dispatch(tr) }\n\n var ranges = [];\n for (var i = 0; i < tr.mapping.maps.length; i++) {\n var map = tr.mapping.maps[i];\n for (var j = 0; j < ranges.length; j++)\n { ranges[j] = map.map(ranges[j]); }\n map.forEach(function (_s, _e, from, to) { return ranges.push(from, to); });\n }\n\n // Figure out which joinable points exist inside those ranges,\n // by checking all node boundaries in their parent nodes.\n var joinable = [];\n for (var i$1 = 0; i$1 < ranges.length; i$1 += 2) {\n var from = ranges[i$1], to = ranges[i$1 + 1];\n var $from = tr.doc.resolve(from), depth = $from.sharedDepth(to), parent = $from.node(depth);\n for (var index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {\n var after = parent.maybeChild(index);\n if (!after) { break }\n if (index && joinable.indexOf(pos) == -1) {\n var before = parent.child(index - 1);\n if (before.type == after.type && isJoinable(before, after))\n { joinable.push(pos); }\n }\n pos += after.nodeSize;\n }\n }\n // Join the joinable points\n joinable.sort(function (a, b) { return a - b; });\n for (var i$2 = joinable.length - 1; i$2 >= 0; i$2--) {\n if (canJoin(tr.doc, joinable[i$2])) { tr.join(joinable[i$2]); }\n }\n dispatch(tr);\n }\n}\n\n// :: ((state: EditorState, ?(tr: Transaction)) → bool, union<(before: Node, after: Node) → bool, [string]>) → (state: EditorState, ?(tr: Transaction)) → bool\n// Wrap a command so that, when it produces a transform that causes\n// two joinable nodes to end up next to each other, those are joined.\n// Nodes are considered joinable when they are of the same type and\n// when the `isJoinable` predicate returns true for them or, if an\n// array of strings was passed, if their node type name is in that\n// array.\nfunction autoJoin(command, isJoinable) {\n if (Array.isArray(isJoinable)) {\n var types = isJoinable;\n isJoinable = function (node) { return types.indexOf(node.type.name) > -1; };\n }\n return function (state, dispatch, view) { return command(state, dispatch && wrapDispatchForJoin(dispatch, isJoinable), view); }\n}\n\n// :: (...[(EditorState, ?(tr: Transaction), ?EditorView) → bool]) → (EditorState, ?(tr: Transaction), ?EditorView) → bool\n// Combine a number of command functions into a single function (which\n// calls them one by one until one returns true).\nfunction chainCommands() {\n var commands = [], len = arguments.length;\n while ( len-- ) commands[ len ] = arguments[ len ];\n\n return function(state, dispatch, view) {\n for (var i = 0; i < commands.length; i++)\n { if (commands[i](state, dispatch, view)) { return true } }\n return false\n }\n}\n\nvar backspace = chainCommands(deleteSelection, joinBackward, selectNodeBackward);\nvar del = chainCommands(deleteSelection, joinForward, selectNodeForward);\n\n// :: Object\n// A basic keymap containing bindings not specific to any schema.\n// Binds the following keys (when multiple commands are listed, they\n// are chained with [`chainCommands`](#commands.chainCommands)):\n//\n// * **Enter** to `newlineInCode`, `createParagraphNear`, `liftEmptyBlock`, `splitBlock`\n// * **Mod-Enter** to `exitCode`\n// * **Backspace** and **Mod-Backspace** to `deleteSelection`, `joinBackward`, `selectNodeBackward`\n// * **Delete** and **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`\n// * **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`\n// * **Mod-a** to `selectAll`\nvar pcBaseKeymap = {\n \"Enter\": chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),\n \"Mod-Enter\": exitCode,\n \"Backspace\": backspace,\n \"Mod-Backspace\": backspace,\n \"Shift-Backspace\": backspace,\n \"Delete\": del,\n \"Mod-Delete\": del,\n \"Mod-a\": selectAll\n};\n\n// :: Object\n// A copy of `pcBaseKeymap` that also binds **Ctrl-h** like Backspace,\n// **Ctrl-d** like Delete, **Alt-Backspace** like Ctrl-Backspace, and\n// **Ctrl-Alt-Backspace**, **Alt-Delete**, and **Alt-d** like\n// Ctrl-Delete.\nvar macBaseKeymap = {\n \"Ctrl-h\": pcBaseKeymap[\"Backspace\"],\n \"Alt-Backspace\": pcBaseKeymap[\"Mod-Backspace\"],\n \"Ctrl-d\": pcBaseKeymap[\"Delete\"],\n \"Ctrl-Alt-Backspace\": pcBaseKeymap[\"Mod-Delete\"],\n \"Alt-Delete\": pcBaseKeymap[\"Mod-Delete\"],\n \"Alt-d\": pcBaseKeymap[\"Mod-Delete\"]\n};\nfor (var key in pcBaseKeymap) { macBaseKeymap[key] = pcBaseKeymap[key]; }\n\n// declare global: os, navigator\nvar mac = typeof navigator != \"undefined\" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform)\n : typeof os != \"undefined\" ? os.platform() == \"darwin\" : false;\n\n// :: Object\n// Depending on the detected platform, this will hold\n// [`pcBasekeymap`](#commands.pcBaseKeymap) or\n// [`macBaseKeymap`](#commands.macBaseKeymap).\nvar baseKeymap = mac ? macBaseKeymap : pcBaseKeymap;\n\nexport { autoJoin, baseKeymap, chainCommands, createParagraphNear, deleteSelection, exitCode, joinBackward, joinDown, joinForward, joinUp, lift, liftEmptyBlock, macBaseKeymap, newlineInCode, pcBaseKeymap, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, setBlockType, splitBlock, splitBlockKeepMarks, toggleMark, wrapIn };\n//# sourceMappingURL=index.es.js.map\n","import { findWrapping, ReplaceAroundStep, canSplit, liftTarget } from 'prosemirror-transform';\nimport { NodeRange, Fragment, Slice } from 'prosemirror-model';\n\nvar olDOM = [\"ol\", 0], ulDOM = [\"ul\", 0], liDOM = [\"li\", 0];\n\n// :: NodeSpec\n// An ordered list [node spec](#model.NodeSpec). Has a single\n// attribute, `order`, which determines the number at which the list\n// starts counting, and defaults to 1. Represented as an ``\n// element.\nvar orderedList = {\n attrs: {order: {default: 1}},\n parseDOM: [{tag: \"ol\", getAttrs: function getAttrs(dom) {\n return {order: dom.hasAttribute(\"start\") ? +dom.getAttribute(\"start\") : 1}\n }}],\n toDOM: function toDOM(node) {\n return node.attrs.order == 1 ? olDOM : [\"ol\", {start: node.attrs.order}, 0]\n }\n};\n\n// :: NodeSpec\n// A bullet list node spec, represented in the DOM as ``.\nvar bulletList = {\n parseDOM: [{tag: \"ul\"}],\n toDOM: function toDOM() { return ulDOM }\n};\n\n// :: NodeSpec\n// A list item (``) spec.\nvar listItem = {\n parseDOM: [{tag: \"li\"}],\n toDOM: function toDOM() { return liDOM },\n defining: true\n};\n\nfunction add(obj, props) {\n var copy = {};\n for (var prop in obj) { copy[prop] = obj[prop]; }\n for (var prop$1 in props) { copy[prop$1] = props[prop$1]; }\n return copy\n}\n\n// :: (OrderedMap, string, ?string) → OrderedMap\n// Convenience function for adding list-related node types to a map\n// specifying the nodes for a schema. Adds\n// [`orderedList`](#schema-list.orderedList) as `\"ordered_list\"`,\n// [`bulletList`](#schema-list.bulletList) as `\"bullet_list\"`, and\n// [`listItem`](#schema-list.listItem) as `\"list_item\"`.\n//\n// `itemContent` determines the content expression for the list items.\n// If you want the commands defined in this module to apply to your\n// list structure, it should have a shape like `\"paragraph block*\"` or\n// `\"paragraph (ordered_list | bullet_list)*\"`. `listGroup` can be\n// given to assign a group name to the list node types, for example\n// `\"block\"`.\nfunction addListNodes(nodes, itemContent, listGroup) {\n return nodes.append({\n ordered_list: add(orderedList, {content: \"list_item+\", group: listGroup}),\n bullet_list: add(bulletList, {content: \"list_item+\", group: listGroup}),\n list_item: add(listItem, {content: itemContent})\n })\n}\n\n// :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Returns a command function that wraps the selection in a list with\n// the given type an attributes. If `dispatch` is null, only return a\n// value to indicate whether this is possible, but don't actually\n// perform the change.\nfunction wrapInList(listType, attrs) {\n return function(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n var range = $from.blockRange($to), doJoin = false, outerRange = range;\n if (!range) { return false }\n // This is at the top of an existing list item\n if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex == 0) {\n // Don't do anything if this is the top of the list\n if ($from.index(range.depth - 1) == 0) { return false }\n var $insert = state.doc.resolve(range.start - 2);\n outerRange = new NodeRange($insert, $insert, range.depth);\n if (range.endIndex < range.parent.childCount)\n { range = new NodeRange($from, state.doc.resolve($to.end(range.depth)), range.depth); }\n doJoin = true;\n }\n var wrap = findWrapping(outerRange, listType, attrs, range);\n if (!wrap) { return false }\n if (dispatch) { dispatch(doWrapInList(state.tr, range, wrap, doJoin, listType).scrollIntoView()); }\n return true\n }\n}\n\nfunction doWrapInList(tr, range, wrappers, joinBefore, listType) {\n var content = Fragment.empty;\n for (var i = wrappers.length - 1; i >= 0; i--)\n { content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content)); }\n\n tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end,\n new Slice(content, 0, 0), wrappers.length, true));\n\n var found = 0;\n for (var i$1 = 0; i$1 < wrappers.length; i$1++) { if (wrappers[i$1].type == listType) { found = i$1 + 1; } }\n var splitDepth = wrappers.length - found;\n\n var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0), parent = range.parent;\n for (var i$2 = range.startIndex, e = range.endIndex, first = true; i$2 < e; i$2++, first = false) {\n if (!first && canSplit(tr.doc, splitPos, splitDepth)) {\n tr.split(splitPos, splitDepth);\n splitPos += 2 * splitDepth;\n }\n splitPos += parent.child(i$2).nodeSize;\n }\n return tr\n}\n\n// :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Build a command that splits a non-empty textblock at the top level\n// of a list item by also splitting that list item.\nfunction splitListItem(itemType) {\n return function(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n var node = ref.node;\n if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) { return false }\n var grandParent = $from.node(-1);\n if (grandParent.type != itemType) { return false }\n if ($from.parent.content.size == 0 && $from.node(-1).childCount == $from.indexAfter(-1)) {\n // In an empty block. If this is a nested list, the wrapping\n // list item should be split. Otherwise, bail out and let next\n // command handle lifting.\n if ($from.depth == 2 || $from.node(-3).type != itemType ||\n $from.index(-2) != $from.node(-2).childCount - 1) { return false }\n if (dispatch) {\n var wrap = Fragment.empty;\n var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;\n // Build a fragment containing empty versions of the structure\n // from the outer list item to the parent node of the cursor\n for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--)\n { wrap = Fragment.from($from.node(d).copy(wrap)); }\n var depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1\n : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;\n // Add a second list item with an empty default start node\n wrap = wrap.append(Fragment.from(itemType.createAndFill()));\n var start = $from.before($from.depth - (depthBefore - 1));\n var tr$1 = state.tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0));\n var sel = -1;\n tr$1.doc.nodesBetween(start, tr$1.doc.content.size, function (node, pos) {\n if (sel > -1) { return false }\n if (node.isTextblock && node.content.size == 0) { sel = pos + 1; }\n });\n if (sel > -1) { tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve(sel))); }\n dispatch(tr$1.scrollIntoView());\n }\n return true\n }\n var nextType = $to.pos == $from.end() ? grandParent.contentMatchAt(0).defaultType : null;\n var tr = state.tr.delete($from.pos, $to.pos);\n var types = nextType && [null, {type: nextType}];\n if (!canSplit(tr.doc, $from.pos, 2, types)) { return false }\n if (dispatch) { dispatch(tr.split($from.pos, 2, types).scrollIntoView()); }\n return true\n }\n}\n\n// :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Create a command to lift the list item around the selection up into\n// a wrapping list.\nfunction liftListItem(itemType) {\n return function(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n var range = $from.blockRange($to, function (node) { return node.childCount && node.firstChild.type == itemType; });\n if (!range) { return false }\n if (!dispatch) { return true }\n if ($from.node(range.depth - 1).type == itemType) // Inside a parent list\n { return liftToOuterList(state, dispatch, itemType, range) }\n else // Outer list node\n { return liftOutOfList(state, dispatch, range) }\n }\n}\n\nfunction liftToOuterList(state, dispatch, itemType, range) {\n var tr = state.tr, end = range.end, endOfList = range.$to.end(range.depth);\n if (end < endOfList) {\n // There are siblings after the lifted items, which must become\n // children of the last item\n tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList,\n new Slice(Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));\n range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);\n }\n dispatch(tr.lift(range, liftTarget(range)).scrollIntoView());\n return true\n}\n\nfunction liftOutOfList(state, dispatch, range) {\n var tr = state.tr, list = range.parent;\n // Merge the list items into a single big item\n for (var pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {\n pos -= list.child(i).nodeSize;\n tr.delete(pos - 1, pos + 1);\n }\n var $start = tr.doc.resolve(range.start), item = $start.nodeAfter;\n if (tr.mapping.map(range.end) != range.start + $start.nodeAfter.nodeSize) { return false }\n var atStart = range.startIndex == 0, atEnd = range.endIndex == list.childCount;\n var parent = $start.node(-1), indexBefore = $start.index(-1);\n if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1,\n item.content.append(atEnd ? Fragment.empty : Fragment.from(list))))\n { return false }\n var start = $start.pos, end = start + item.nodeSize;\n // Strip off the surrounding list. At the sides where we're not at\n // the end of the list, the existing list is closed. At sides where\n // this is the end, it is overwritten to its end.\n tr.step(new ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1,\n new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty)))\n .append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))),\n atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));\n dispatch(tr.scrollIntoView());\n return true\n}\n\n// :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool\n// Create a command to sink the list item around the selection down\n// into an inner list.\nfunction sinkListItem(itemType) {\n return function(state, dispatch) {\n var ref = state.selection;\n var $from = ref.$from;\n var $to = ref.$to;\n var range = $from.blockRange($to, function (node) { return node.childCount && node.firstChild.type == itemType; });\n if (!range) { return false }\n var startIndex = range.startIndex;\n if (startIndex == 0) { return false }\n var parent = range.parent, nodeBefore = parent.child(startIndex - 1);\n if (nodeBefore.type != itemType) { return false }\n\n if (dispatch) {\n var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;\n var inner = Fragment.from(nestedBefore ? itemType.create() : null);\n var slice = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))),\n nestedBefore ? 3 : 1, 0);\n var before = range.start, after = range.end;\n dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after,\n before, after, slice, 1, true))\n .scrollIntoView());\n }\n return true\n }\n}\n\nexport { addListNodes, bulletList, liftListItem, listItem, orderedList, sinkListItem, splitListItem, wrapInList };\n//# sourceMappingURL=index.es.js.map\n","import { TextSelection, NodeSelection, Selection, AllSelection } from 'prosemirror-state';\nimport { DOMSerializer, Fragment, Mark, DOMParser, Slice } from 'prosemirror-model';\nimport { dropPoint } from 'prosemirror-transform';\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 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 // Is true for both iOS and iPadOS for convenience\n result.safari = !ie && /Apple Computer/.test(navigator.vendor);\n result.ios = result.safari && (/Mobile\\/\\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2);\n result.mac = result.ios || /Mac/.test(navigator.platform);\n result.android = /Android \\d/.test(navigator.userAgent);\n result.webkit = \"webkitFontSmoothing\" in document.documentElement.style;\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.assignedSlot || node.parentNode;\n return parent && parent.nodeType == 11 ? parent.host : parent\n};\n\nvar reusedRange = null;\n\n// Note that this will always return the same range, because DOM range\n// objects are every expensive, and keep slowing down subsequent DOM\n// updates, for some reason.\nvar textRange = function(node, from, to) {\n var range = reusedRange || (reusedRange = 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(doc) {\n return {left: 0, right: doc.documentElement.clientWidth,\n top: 0, bottom: doc.documentElement.clientHeight}\n}\n\nfunction getSide(value, side) {\n return typeof value == \"number\" ? value : value[side]\n}\n\nfunction clientRect(node) {\n var rect = node.getBoundingClientRect();\n // Adjust for elements with style \"transform: scale()\"\n var scaleX = (rect.width / node.offsetWidth) || 1;\n var scaleY = (rect.height / node.offsetHeight) || 1;\n // Make sure scrollbar width isn't included in the rectangle\n return {left: rect.left, right: rect.left + node.clientWidth * scaleX,\n top: rect.top, bottom: rect.top + node.clientHeight * scaleY}\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;\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(doc) : clientRect(parent);\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 doc.defaultView.scrollBy(moveX, moveY);\n } else {\n var startX = parent.scrollLeft, startY = parent.scrollTop;\n if (moveY) { parent.scrollTop += moveY; }\n if (moveX) { parent.scrollLeft += moveX; }\n var dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;\n rect = {left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY};\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 doc = view.dom.ownerDocument, node, offset;\n if (doc.caretPositionFromPoint) {\n try { // Firefox throws for this call in hard-to-predict circumstances (#994)\n var pos$1 = doc.caretPositionFromPoint(coords.left, coords.top);\n if (pos$1) { ((assign = pos$1, node = assign.offsetNode, offset = assign.offset)); }\n } catch (_) {}\n }\n if (!node && doc.caretRangeFromPoint) {\n var range = doc.caretRangeFromPoint(coords.left, coords.top);\n if (range) { ((assign$1 = range, node = assign$1.startContainer, offset = assign$1.startOffset)); }\n }\n\n var elt = (view.root.elementFromPoint ? view.root : doc).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 // Safari's caretRangeFromPoint returns nonsense when on a draggable element\n if (result.safari) {\n for (var p = elt; node && p; p = parentNode(p))\n { if (p.draggable) { node = offset = 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\nvar BIDI = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/;\n\n// : (EditorView, number, 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, side) {\n var ref = view.docView.domFromPos(pos, side < 0 ? -1 : 1);\n var node = ref.node;\n var offset = ref.offset;\n\n var supportEmptyRange = result.webkit || result.gecko;\n if (node.nodeType == 3) {\n // These browsers support querying empty text ranges. Prefer that in\n // bidi context or when at the end of a node.\n if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {\n var rect = singleRect(textRange(node, offset, offset), side);\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 (rectBefore.top == rect.top) {\n var rectAfter = singleRect(textRange(node, offset, offset + 1), -1);\n if (rectAfter.top != rect.top)\n { return flattenV(rectAfter, rectAfter.left < rectBefore.left) }\n }\n }\n return rect\n } else {\n var from = offset, to = offset, takeSide = side < 0 ? 1 : -1;\n if (side < 0 && !offset) { to++; takeSide = -1; }\n else if (side >= 0 && offset == node.nodeValue.length) { from--; takeSide = 1; }\n else if (side < 0) { from--; }\n else { to ++; }\n return flattenV(singleRect(textRange(node, from, to), takeSide), takeSide < 0)\n }\n }\n\n // Return a horizontal line in block context\n if (!view.state.doc.resolve(pos).parent.inlineContent) {\n if (offset && (side < 0 || offset == nodeSize(node))) {\n var before = node.childNodes[offset - 1];\n if (before.nodeType == 1) { return flattenH(before.getBoundingClientRect(), false) }\n }\n if (offset < nodeSize(node)) {\n var after = node.childNodes[offset];\n if (after.nodeType == 1) { return flattenH(after.getBoundingClientRect(), true) }\n }\n return flattenH(node.getBoundingClientRect(), side >= 0)\n }\n\n // Inline, not in text node (this is not Bidi-safe)\n if (offset && (side < 0 || offset == nodeSize(node))) {\n var before$1 = node.childNodes[offset - 1];\n var target = before$1.nodeType == 3 ? textRange(before$1, nodeSize(before$1) - (supportEmptyRange ? 0 : 1))\n // BR nodes tend to only return the rectangle before them.\n // Only use them if they are the last element in their parent\n : before$1.nodeType == 1 && (before$1.nodeName != \"BR\" || !before$1.nextSibling) ? before$1 : null;\n if (target) { return flattenV(singleRect(target, 1), false) }\n }\n if (offset < nodeSize(node)) {\n var after$1 = node.childNodes[offset];\n while (after$1.pmViewDesc && after$1.pmViewDesc.ignoreForCoords) { after$1 = after$1.nextSibling; }\n var target$1 = !after$1 ? null : after$1.nodeType == 3 ? textRange(after$1, 0, (supportEmptyRange ? 0 : 1))\n : after$1.nodeType == 1 ? after$1 : null;\n if (target$1) { return flattenV(singleRect(target$1, -1), true) }\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, -side), side >= 0)\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) { 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.$from : sel.$to;\n return withFlushedState(view, state, function () {\n var ref = view.docView.domFromPos($pos.pos, dir == \"up\" ? -1 : 1);\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, 1);\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 + 1 &&\n (dir == \"up\" ? coords.top - box.top > (box.bottom - coords.top) * 2\n : box.bottom - coords.bottom > (coords.bottom - box.top) * 2))\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 = view.root.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// Mark views only support `dom` and `contentDOM`, and don't support\n// any of the node view methods.\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], innerDecorations: DecorationSource) → 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), an array\n// of active decorations around the node (which are automatically\n// drawn, and the node view may ignore if it isn't interested in\n// them), and a [decoration source](#view.DecorationSource) that\n// represents any decorations that apply to the content of the node\n// (which again may be ignored). It should return true if it was\n// able to update to that node, and false otherwise. If the node\n// view has a `contentDOM` property (or no `dom` property), updating\n// its child nodes will be handled by 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. (Not available for marks.)\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 = { size: { configurable: true },border: { configurable: true },posBefore: { configurable: true },posAtStart: { configurable: true },posAfter: { configurable: true },posAtEnd: { configurable: true },contentLost: { configurable: true },domAtom: { configurable: true },ignoreForCoords: { 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 (_nodeName) { 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 (dom == this.dom && this.contentDOM) {\n atEnd = offset > domIndex(this.contentDOM);\n } else 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 &&\n !(desc.nodeDOM.nodeType == 1 ? desc.nodeDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode) : desc.nodeDOM == dom))\n { first = false; }\n else\n { 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 = scan.parentNode) {\n var desc = this.getDesc(scan);\n if (desc) { return desc.localPosFromDOM(dom, offset, bias) }\n }\n return -1\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, number) → {node: dom.Node, offset: number}\nViewDesc.prototype.domFromPos = function domFromPos (pos, side) {\n if (!this.contentDOM) { return {node: this.dom, offset: 0} }\n // First find the position in the child array\n var i = 0, offset = 0;\n for (var curPos = 0; i < this.children.length; i++) {\n var child = this.children[i], end = curPos + child.size;\n if (end > pos || child instanceof TrailingHackViewDesc) { offset = pos - curPos; break }\n curPos = end;\n }\n // If this points into the middle of a child, call through\n if (offset) { return this.children[i].domFromPos(offset - this.children[i].border, side) }\n // Go back if there were any zero-length widgets with side >= 0 before this point\n for (var prev = (void 0); i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.widget.type.side >= 0; i--) {}\n // Scan towards the first useable node\n if (side <= 0) {\n var prev$1, enter = true;\n for (;; i--, enter = false) {\n prev$1 = i ? this.children[i - 1] : null;\n if (!prev$1 || prev$1.dom.parentNode == this.contentDOM) { break }\n }\n if (prev$1 && side && enter && !prev$1.border && !prev$1.domAtom) { return prev$1.domFromPos(prev$1.size, side) }\n return {node: this.contentDOM, offset: prev$1 ? domIndex(prev$1.dom) + 1 : 0}\n } else {\n var next, enter$1 = true;\n for (;; i++, enter$1 = false) {\n next = i < this.children.length ? this.children[i] : null;\n if (!next || next.dom.parentNode == this.contentDOM) { break }\n }\n if (next && enter$1 && !next.border && !next.domAtom) { return next.domFromPos(0, side) }\n return {node: this.contentDOM, offset: next ? domIndex(next.dom) : this.contentDOM.childNodes.length}\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 && (end > to || i == this.children.length - 1)) {\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, 0);\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, anchor ? -1 : 1);\n var headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1);\n var domSel = root.getSelection();\n\n var brKludge = false;\n // On Firefox, using Selection.collapse to put the cursor after a\n // BR node for some reason doesn't always work (#1073). On Safari,\n // the cursor sometimes inexplicable visually lags behind its\n // reported position in such situations (#1092).\n if ((result.gecko || result.safari) && anchor == head) {\n var node = anchorDOM.node;\n var offset$1 = anchorDOM.offset;\n if (node.nodeType == 3) {\n brKludge = offset$1 && node.nodeValue[offset$1 - 1] == \"\\n\";\n // Issue #1128\n if (brKludge && offset$1 == node.nodeValue.length) {\n for (var scan = node, after = (void 0); scan; scan = scan.parentNode) {\n if (after = scan.nextSibling) {\n if (after.nodeName == \"BR\")\n { anchorDOM = headDOM = {node: after.parentNode, offset: domIndex(after) + 1}; }\n break\n }\n var desc = scan.pmViewDesc;\n if (desc && desc.node && desc.node.isBlock) { break }\n }\n }\n } else {\n var prev = node.childNodes[offset$1 - 1];\n brKludge = prev && (prev.nodeName == \"BR\" || prev.contentEditable == \"false\");\n }\n }\n // Firefox can act strangely when the selection is in front of an\n // uneditable node. See #1163 and https://bugzilla.mozilla.org/show_bug.cgi?id=1709536\n if (result.gecko && domSel.focusNode && domSel.focusNode != headDOM.node && domSel.focusNode.nodeType == 1) {\n var after$1 = domSel.focusNode.childNodes[domSel.focusOffset];\n if (after$1 && after$1.contentEditable == \"false\") { force = true; }\n }\n\n if (!(force || brKludge && result.safari) &&\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 var domSelExtended = false;\n if ((domSel.extend || anchor == head) && !brKludge) {\n domSel.collapse(anchorDOM.node, anchorDOM.offset);\n try {\n if (anchor != head) { domSel.extend(headDOM.node, headDOM.offset); }\n domSelExtended = true;\n } catch (err) {\n // In some cases with Chrome the selection is empty after calling\n // collapse, even when it should be valid. This appears to be a bug, but\n // it is difficult to isolate. If this happens fallback to the old path\n // without using extend.\n if (!(err instanceof DOMException)) { throw err }\n // declare global: DOMException\n }\n }\n if (!domSelExtended) {\n if (anchor > head) { var tmp = anchorDOM; anchorDOM = headDOM; headDOM = tmp; }\n var range = document.createRange();\n range.setEnd(headDOM.node, headDOM.offset);\n range.setStart(anchorDOM.node, anchorDOM.offset);\n domSel.removeAllRanges();\n domSel.addRange(range);\n }\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 = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM ? CONTENT_DIRTY : NODE_DIRTY;\n }\n }\n offset = end;\n }\n this.dirty = CONTENT_DIRTY;\n};\n\nViewDesc.prototype.markParentsDirty = function markParentsDirty () {\n var level = 1;\n for (var node = this.parent; node; node = node.parent, level++) {\n var dirty = level == 1 ? CONTENT_DIRTY : CHILD_DIRTY;\n if (node.dirty < dirty) { node.dirty = dirty; }\n }\n};\n\nprototypeAccessors.domAtom.get = function () { return false };\n\nprototypeAccessors.ignoreForCoords.get = function () { return false };\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 = { domAtom: { configurable: true } };\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 WidgetViewDesc.prototype.destroy = function destroy () {\n this.widget.type.destroy(this.dom);\n ViewDesc.prototype.destroy.call(this);\n };\n\n prototypeAccessors$1.domAtom.get = function () { return true };\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 = 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 },domAtom: { 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 finicky\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, innerDeco);\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 = 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 ? 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 = view.composing && this.localCompositionInfo(view, pos);\n var localComposition = composition && composition.pos > -1 ? composition : null;\n var compositionInChild = composition && composition.pos < 0;\n var updater = new ViewTreeUpdater(this, localComposition && localComposition.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 ? 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 // Try several strategies for drawing this node\n var compIndex;\n if (updater.findNodeMatch(child, outerDeco, innerDeco, i)) ; else if (compositionInChild && view.state.selection.from > off &&\n view.state.selection.to < off + child.nodeSize &&\n (compIndex = updater.findIndexWithChild(composition.node)) > -1 &&\n updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view)) ; else if (updater.updateNextNode(child, outerDeco, innerDeco, view, i)) ; else {\n // Add it as a new view\n updater.addNode(child, outerDeco, innerDeco, view, off);\n }\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 (localComposition) { this.protectLocalComposition(view, localComposition); }\n renderDescs(this.contentDOM, this.children, view);\n if (result.ios) { iosHacks(this.dom); }\n }\n };\n\n NodeViewDesc.prototype.localCompositionInfo = function localCompositionInfo (view, pos) {\n // Only do something if both the selection and a focused text node\n // are inside of this node\n var ref = view.state.selection;\n var from = ref.from;\n var to = ref.to;\n if (!(view.state.selection instanceof 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 if (this.node.inlineContent) {\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 return textPos < 0 ? null : {node: textNode, pos: textPos, text: text}\n } else {\n return {node: textNode, pos: -1}\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;\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], DecorationSource, 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.removeAttribute(\"draggable\"); }\n };\n\n prototypeAccessors$3.domAtom.get = function () { return this.node.isAtom };\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 var prototypeAccessors$4 = { domAtom: { configurable: true } };\n\n TextViewDesc.prototype.parseRule = function parseRule () {\n var skip = this.nodeDOM.parentNode;\n while (skip && skip != this.dom && !skip.pmIsDeco) { skip = skip.parentNode; }\n return {skip: skip || true}\n };\n\n TextViewDesc.prototype.update = function update (node, outerDeco, _, view) {\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 if (view.trackWrites == this.nodeDOM) { view.trackWrites = null; }\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 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 TextViewDesc.prototype.markDirty = function markDirty (from, to) {\n NodeViewDesc.prototype.markDirty.call(this, from, to);\n if (this.dom != this.nodeDOM && (from == 0 || to == this.nodeDOM.nodeValue.length))\n { this.dirty = NODE_DIRTY; }\n };\n\n prototypeAccessors$4.domAtom.get = function () { return false };\n\n Object.defineProperties( TextViewDesc.prototype, prototypeAccessors$4 );\n\n return TextViewDesc;\n}(NodeViewDesc));\n\n// A dummy desc used to tag trailing BR or IMG nodes created to work\n// around contentEditable terribleness.\nvar TrailingHackViewDesc = /*@__PURE__*/(function (ViewDesc) {\n function TrailingHackViewDesc () {\n ViewDesc.apply(this, arguments);\n }\n\n if ( ViewDesc ) TrailingHackViewDesc.__proto__ = ViewDesc;\n TrailingHackViewDesc.prototype = Object.create( ViewDesc && ViewDesc.prototype );\n TrailingHackViewDesc.prototype.constructor = TrailingHackViewDesc;\n\n var prototypeAccessors$5 = { domAtom: { configurable: true },ignoreForCoords: { configurable: true } };\n\n TrailingHackViewDesc.prototype.parseRule = function parseRule () { return {ignore: true} };\n TrailingHackViewDesc.prototype.matchesHack = function matchesHack (nodeName) { return this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName };\n prototypeAccessors$5.domAtom.get = function () { return true };\n prototypeAccessors$5.ignoreForCoords.get = function () { return this.dom.nodeName == \"IMG\" };\n\n Object.defineProperties( TrailingHackViewDesc.prototype, prototypeAccessors$5 );\n\n return TrailingHackViewDesc;\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, innerDeco);\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, view) {\n var dom = parentDOM.firstChild, written = false;\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); written = true; }\n dom = dom.nextSibling;\n } else {\n written = true;\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, view);\n dom = pos ? pos.nextSibling : parentDOM.firstChild;\n }\n }\n while (dom) { dom = rm(dom); written = true; }\n if (written && view.trackWrites == parentDOM) { view.trackWrites = null; }\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;\n if (!attrs) { continue }\n if (attrs.nodeName)\n { result.push(top = 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(top = new OuterDecoLevel(node.isInline ? \"span\" : \"div\")); }\n if (name == \"class\") { top.class = (top.class ? top.class + \" \" : \"\") + val; }\n else if (name == \"style\") { top.style = (top.style ? top.style + \";\" : \"\") + val; }\n else if (name != \"nodeName\") { top[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.pmIsDeco = true;\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(\" \").filter(Boolean) : nothing;\n var curList = cur.class ? cur.class.split(\" \").filter(Boolean) : 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 if (dom.classList.length == 0)\n { dom.removeAttribute(\"class\"); }\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 this.preMatch = preMatch(top.node.content, top);\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], DecorationSource) → 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, targetDesc;\n if (index >= this.preMatch.index &&\n (targetDesc = this.preMatch.matches[index - this.preMatch.index]).parent == this.top &&\n targetDesc.matchesNode(node, outerDeco, innerDeco)) {\n found = this.top.children.indexOf(targetDesc, this.index);\n } else {\n for (var i = this.index, e = Math.min(this.top.children.length, i + 5); i < e; i++) {\n var child = this.top.children[i];\n if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {\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\nViewTreeUpdater.prototype.updateNodeAt = function updateNodeAt (node, outerDeco, innerDeco, index, view) {\n var child = this.top.children[index];\n if (!child.update(node, outerDeco, innerDeco, view)) { return false }\n this.destroyBetween(this.index, index);\n this.index = index + 1;\n return true\n};\n\nViewTreeUpdater.prototype.findIndexWithChild = function findIndexWithChild (domNode) {\n for (;;) {\n var parent = domNode.parentNode;\n if (!parent) { return -1 }\n if (parent == this.top.contentDOM) {\n var desc = domNode.pmViewDesc;\n if (desc) { for (var i = this.index; i < this.top.children.length; i++) {\n if (this.top.children[i] == desc) { return i }\n } }\n return -1\n }\n domNode = parent;\n }\n};\n\n// : (Node, [Decoration], DecorationSource, 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 for (var i = this.index; i < this.top.children.length; i++) {\n var next = this.top.children[i];\n if (next instanceof NodeViewDesc) {\n var preMatch = this.preMatch.matched.get(next);\n if (preMatch != null && preMatch != 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 this.destroyBetween(this.index, i);\n if (next.dom != nextDOM) { this.changed = true; }\n this.index++;\n return true\n }\n break\n }\n }\n return false\n};\n\n// : (Node, [Decoration], DecorationSource, 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 var next = this.index < this.top.children.length ? this.top.children[this.index] : null;\n if (next && next.matchesWidget(widget) && (widget == next.widget || !next.widget.type.toDOM.parentNode)) {\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 // Avoid bugs in Safari's cursor drawing (#1165) and Chrome's mouse selection (#1152)\n if ((result.safari || result.chrome) && lastChild && lastChild.dom.contentEditable == \"false\")\n { this.addHackNode(\"IMG\"); }\n this.addHackNode(\"BR\");\n }\n};\n\nViewTreeUpdater.prototype.addHackNode = function addHackNode (nodeName) {\n if (this.index < this.top.children.length && this.top.children[this.index].matchesHack(nodeName)) {\n this.index++;\n } else {\n var dom = document.createElement(nodeName);\n if (nodeName == \"IMG\") { dom.className = \"ProseMirror-separator\"; }\n if (nodeName == \"BR\") { dom.className = \"ProseMirror-trailingBreak\"; }\n this.top.children.splice(this.index++, 0, new TrailingHackViewDesc(this.top, nothing, dom, null));\n this.changed = true;\n }\n};\n\n// : (Fragment, [ViewDesc]) → {index: number, matched: Map, matches: 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 those\n// for other nodes. Returns the fragment index of the first node that\n// is part of the sequence of matched nodes at the end of the\n// fragment.\nfunction preMatch(frag, parentDesc) {\n var curDesc = parentDesc, descI = curDesc.children.length;\n var fI = frag.childCount, matched = new Map, matches = [];\n outer: while (fI > 0) {\n var desc = (void 0);\n for (;;) {\n if (descI) {\n var next = curDesc.children[descI - 1];\n if (next instanceof MarkViewDesc) {\n curDesc = next;\n descI = next.children.length;\n } else {\n desc = next;\n descI--;\n break\n }\n } else if (curDesc == parentDesc) {\n break outer\n } else {\n // FIXME\n descI = curDesc.parent.children.indexOf(curDesc);\n curDesc = curDesc.parent;\n }\n }\n var node = desc.node;\n if (!node) { continue }\n if (node != frag.child(fI - 1)) { break }\n --fI;\n matched.set(desc, fI);\n matches.push(desc);\n }\n return {index: fI, matched: matched, matches: matches.reverse()}\n}\n\nfunction compareSide(a, b) { return a.type.side - b.type.side }\n\n// : (ViewDesc, DecorationSource, (Decoration, number), (Node, [Decoration], DecorationSource, 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 && locals[decoIndex].to > offset)\n { 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 var outerDeco = !active.length ? nothing\n : child$1.isInline && !child$1.isLeaf ? active.filter(function (d) { return !d.inline; })\n : active.slice();\n onNode(child$1, outerDeco, 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 selectionFromDOM(view, origin) {\n var domSel = view.root.getSelection(), doc = view.state.doc;\n if (!domSel.focusNode) { return null }\n var nearestDesc = view.docView.nearestDesc(domSel.focusNode), inWidget = nearestDesc && nearestDesc.size == 0;\n var head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);\n if (head < 0) { return null }\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 && 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 NodeSelection(head == pos ? $head : doc.resolve(pos));\n }\n } else {\n var anchor = view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);\n if (anchor < 0) { return null }\n $anchor = doc.resolve(anchor);\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 editorOwnsSelection(view) {\n return view.editable ? view.hasFocus() :\n hasSelection(view) && document.activeElement && document.activeElement.contains(view.dom)\n}\n\nfunction selectionToDOM(view, force) {\n var sel = view.state.selection;\n syncNodeSelection(view, sel);\n\n if (!editorOwnsSelection(view)) { return }\n\n if (!force && view.mouseDown && view.mouseDown.allowDefault) {\n view.mouseDown.delayedSelectionSync = true;\n view.domObserver.setCurSelection();\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 if (brokenSelectBetweenUneditable && !(sel instanceof 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 {\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, 0);\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 setTimeout(function () {\n if (!editorOwnsSelection(view) || view.state.selection.visible)\n { view.dom.classList.remove(\"ProseMirror-hideselection\"); }\n }, 20);\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 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 || 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, 0);\n var domSel = view.root.getSelection();\n return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset)\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 && 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 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 NodeSelection)) { return apply(view, next) }\n return false\n } else if (!(result.mac && mods.indexOf(\"m\") > -1)) {\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 (NodeSelection.isSelectable(node)) {\n return apply(view, new 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 TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)))\n } else {\n return false\n }\n }\n } else if (sel instanceof NodeSelection && sel.node.isInline) {\n return apply(view, new 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 var state = view.state;\n // If no state update ends up happening, reset the selection.\n setTimeout(function () {\n if (view.state == state) { selectionToDOM(view); }\n }, 50);\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 TextSelection && !sel.empty || mods.indexOf(\"s\") > -1) { return false }\n if (result.mac && mods.indexOf(\"m\") > -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 NodeSelection))\n { return apply(view, next) }\n }\n if (!$from.parent.inlineContent) {\n var side = dir < 0 ? $from : $to;\n var beyond = sel instanceof AllSelection ? Selection.near(side, dir) : Selection.findFrom(side, dir);\n return beyond ? apply(view, beyond) : false\n }\n return false\n}\n\nfunction stopNativeHorizontalDelete(view, dir) {\n if (!(view.state.selection instanceof 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 / #1090 / https://bugs.chromium.org/p/chromium/issues/detail?id=903821\n// In which Safari (and at some point in the past, Chrome) does really\n// wrong things when the down arrow is pressed when the cursor is\n// directly at the start of a textblock and has an uneditable node\n// after it\nfunction safariDownArrowBug(view) {\n if (!result.safari || 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 || code == 27) { // Enter, 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 safariDownArrowBug(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\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.nodeName == \"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\") || 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 (newSel && !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 // Chrome sometimes leaves the cursor before the inserted text when\n // composing after a cursor wrapper. This moves it forward.\n if (result.chrome && view.cursorWrapper && parse.sel && parse.sel.anchor == view.cursorWrapper.deco.from) {\n var text = view.cursorWrapper.deco.type.toDOM.nextSibling;\n var size = text && text.nodeValue ? text.nodeValue.length : 1;\n parse.sel = {anchor: parse.sel.anchor + size, head: parse.sel.anchor + size};\n }\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 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 if ((result.ios && view.lastIOSEnter > Date.now() - 225 || result.android) &&\n addedNodes.some(function (n) { return n.nodeName == \"DIV\" || n.nodeName == \"P\"; }) &&\n view.someProp(\"handleKeyDown\", function (f) { return f(view, keyEvent(13, \"Enter\")); })) {\n view.lastIOSEnter = 0;\n return\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 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 inlineChange = $from.sameParent($to) && $from.parent.inlineContent;\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() - 225 &&\n (!inlineChange || addedNodes.some(function (n) { return n.nodeName == \"DIV\" || n.nodeName == \"P\"; }))) ||\n (!inlineChange && $from.pos < parse.doc.content.size &&\n (nextSel = 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 // Chrome Android will occasionally, during composition, delete the\n // entire composition and then immediately insert it again. This is\n // used to detect that situation.\n if (result.chrome && result.android && change.toB == change.from)\n { view.lastAndroidDelete = Date.now(); }\n\n // This tries to detect Android virtual keyboard\n // enter-and-pick-suggestion action. That sometimes (see issue\n // #1059) first fires a DOM mutation, before moving the selection to\n // the newly created block. And then, because ProseMirror cleans up\n // the DOM selection, it gives up moving the selection entirely,\n // leaving the cursor in the wrong place. When that happens, we drop\n // the new paragraph from the initial change, and fire a simulated\n // enter key afterwards.\n if (result.android && !inlineChange && $from.start() != $to.start() && $to.parentOffset == 0 && $from.depth == $to.depth &&\n parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA) {\n change.endB -= 2;\n $to = parse.doc.resolveNoCache(change.endB - parse.from);\n setTimeout(function () {\n view.someProp(\"handleKeyDown\", function (f) { return f(view, keyEvent(13, \"Enter\")); });\n }, 20);\n }\n\n var chFrom = change.start, chTo = change.endA;\n\n var tr, storedMarks, markChange, $from1;\n if (inlineChange) {\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$1 = $from.parent.textBetween($from.parentOffset, $to.parentOffset);\n if (view.someProp(\"handleTextInput\", function (f) { return f(view, chFrom, chTo, text$1); })) { return }\n tr = view.state.tr.insertText(text$1, 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 &&\n (change.start != change.endB || view.lastAndroidDelete < Date.now() - 100) &&\n (sel$2.head == chFrom || sel$2.head == tr.mapping.map(chTo) - 1) ||\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 (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.attrs != node.type.defaultAttrs ? node.attrs : null);\n content = node.content;\n }\n\n var serializer = view.someProp(\"clipboardSerializer\") || 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 if (needsWrap[i] != \"tbody\") {\n openStart++;\n openEnd++;\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 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, inCode || plainText); });\n if (inCode) { return text ? new Slice(Fragment.from(view.state.schema.text(text.replace(/\\r\\n?/g, \"\\n\"))), 0, 0) : Slice.empty }\n var parsed = view.someProp(\"clipboardTextParser\", function (f) { return f(text, $context, plainText); });\n if (parsed) {\n slice = parsed;\n } else {\n var marks = $context.marks();\n var ref = view.state;\n var schema = ref.schema;\n var serializer = DOMSerializer.fromSchema(schema);\n dom = document.createElement(\"div\");\n text.split(/(?:\\r\\n?|\\n)+/).forEach(function (block) {\n var p = dom.appendChild(document.createElement(\"p\"));\n if (block) { p.appendChild(serializer.serializeNode(schema.text(block, marks))); }\n });\n }\n } else {\n view.someProp(\"transformPastedHTML\", function (f) { html = f(html); });\n dom = readHTML(html);\n if (result.webkit) { restoreReplacedSpaces(dom); }\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\") || DOMParser.fromSchema(view.state.schema);\n slice = parser.parseSlice(dom, {\n preserveWhitespace: !!(asText || sliceData),\n context: $context,\n ruleFromNode: function ruleFromNode(dom) {\n if (dom.nodeName == \"BR\" && !dom.nextSibling &&\n dom.parentNode && !inlineParents.test(dom.parentNode.nodeName)) { return {ignore: true} }\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 slice = Slice.maxOpen(normalizeSiblings(slice.content, $context), true);\n if (slice.openStart || slice.openEnd) {\n var openStart = 0, openEnd = 0;\n for (var node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating;\n openStart++, node = node.firstChild) {}\n for (var node$1 = slice.content.lastChild; openEnd < slice.openEnd && !node$1.type.spec.isolating;\n openEnd++, node$1 = node$1.lastChild) {}\n slice = closeSlice(slice, openStart, openEnd);\n }\n }\n\n view.someProp(\"transformPasted\", function (f) { slice = f(slice); });\n return slice\n}\n\nvar inlineParents = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;\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: 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, 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(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(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(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 Slice(closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd); }\n if (openEnd < slice.openEnd)\n { slice = new 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;\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 elt.innerHTML = html;\n if (wrap) { for (var i = 0; i < wrap.length; i++) { elt = elt.querySelector(wrap[i]) || elt; } }\n return elt\n}\n\n// Webkit browsers do some hard-to-predict replacement of regular\n// spaces with non-breaking spaces when putting content on the\n// clipboard. This tries to convert such non-breaking spaces (which\n// will be wrapped in a plain span on Chrome, a span with class\n// Apple-converted-space on Safari) back to regular spaces.\nfunction restoreReplacedSpaces(dom) {\n var nodes = dom.querySelectorAll(result.chrome ? \"span:not([class]):not([style])\" : \"span.Apple-converted-space\");\n for (var i = 0; i < nodes.length; i++) {\n var node = nodes[i];\n if (node.childNodes.length == 1 && node.textContent == \"\\u00a0\" && node.parentNode)\n { node.parentNode.replaceChild(dom.ownerDocument.createTextNode(\" \"), node); }\n }\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 = Fragment.from(type.create(array[i + 1], content));\n openStart++; openEnd++;\n }\n return new 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 = -1;\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 < 0)\n { this.flushingSoon = window.setTimeout(function () { this$1.flushingSoon = -1; this$1.flush(); }, 20); }\n};\n\nDOMObserver.prototype.forceFlush = function forceFlush () {\n if (this.flushingSoon > -1) {\n window.clearTimeout(this.flushingSoon);\n this.flushingSoon = -1;\n this.flush();\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 > -1) { 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) { 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 this.currentSelection.set(sel);\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 for (var i = 0; i < mut.addedNodes.length; i++) { added.push(mut.addedNodes[i]); }\n if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))\n { return {from: desc.posBefore, to: desc.posAfter} }\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$1 = 0; i$1 < mut.addedNodes.length; i$1++) {\n var ref = mut.addedNodes[i$1];\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 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 view.lastIOSEnterFallbackTimeout = null;\n view.lastAndroidDelete = 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 clearTimeout(view.lastIOSEnterFallbackTimeout);\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 if (event.keyCode != 229) { view.domObserver.forceFlush(); }\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 var now = Date.now();\n view.lastIOSEnter = now;\n view.lastIOSEnterFallbackTimeout = setTimeout(function () {\n if (view.lastIOSEnter == now) {\n view.someProp(\"handleKeyDown\", function (f) { return f(view, keyEvent(13, \"Enter\")); });\n view.lastIOSEnter = 0;\n }\n }, 200);\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};\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 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 && NodeSelection.isSelectable(node)) {\n updateSelection(view, new 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 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 (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, 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, event)\n}\n\nfunction defaultTripleClick(view, inside, event) {\n if (event.button != 0) { return false }\n var doc = view.state.doc;\n if (inside == -1) {\n if (doc.inlineContent) {\n updateSelection(view, 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, TextSelection.create(doc, nodePos + 1, nodePos + 1 + node.content.size), \"pointer\"); }\n else if (NodeSelection.isSelectable(node))\n { updateSelection(view, 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 if (view.mouseDown) { view.mouseDown.done(); }\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\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 this.delayedSelectionSync = false;\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 var ref = view.state;\n var selection = ref.selection;\n if (event.button == 0 &&\n targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||\n selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)\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 () {\n if (this$1.view.mouseDown == this$1) { this$1.target.setAttribute(\"contentEditable\", \"false\"); }\n }, 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 var this$1 = this;\n\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.removeAttribute(\"draggable\"); }\n if (this.mightDrag.setUneditable) { this.target.removeAttribute(\"contentEditable\"); }\n this.view.domObserver.start();\n }\n if (this.delayedSelectionSync) { setTimeout(function () { return selectionToDOM(this$1.view); }); }\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 (event.button == 0 &&\n (this.flushed ||\n // Safari ignores clicks on draggable elements\n (result.safari && this.mightDrag && !this.mightDrag.node.isAtom) ||\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 TextSelection) &&\n Math.min(Math.abs(pos.pos - this.view.state.selection.from),\n Math.abs(pos.pos - this.view.state.selection.to)) <= 2))) {\n updateSelection(this.view, 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 if (event.buttons == 0) { this.done(); }\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 ||\n (!$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 clearComposition(view) {\n if (view.composing) {\n view.composing = false;\n view.compositionEndedAt = timestampFromCustomEvent();\n }\n while (view.compositionNodes.length > 0) { view.compositionNodes.pop().markParentsDirty(); }\n}\n\nfunction timestampFromCustomEvent() {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"event\", true, true);\n return event.timeStamp\n}\n\nfunction endComposition(view, forceUpdate) {\n view.domObserver.forceFlush();\n clearComposition(view);\n if (forceUpdate || view.docView.dirty) {\n var sel = selectionFromDOM(view);\n if (sel && !sel.eq(view.state.selection)) { view.dispatch(view.state.tr.setSelection(sel)); }\n else { 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 if (!view.dom.parentNode) { return }\n var wrap = view.dom.parentNode.appendChild(document.createElement(\"div\"));\n wrap.appendChild(dom);\n wrap.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n var sel = getSelection(), range = document.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 if (wrap.parentNode) { wrap.parentNode.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 if (!view.dom.parentNode) { return }\n var plainText = view.shiftKey || view.state.selection.$from.parent.type.spec.code;\n var target = view.dom.parentNode.appendChild(document.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 if (target.parentNode) { target.parentNode.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 || Slice.empty); })) { return true }\n if (!slice) { return false }\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 return true\n}\n\neditHandlers.paste = function (view, e) {\n var data = brokenClipboardAPI ? null : e.clipboardData;\n if (data && doPaste(view, data.getData(\"text/plain\"), data.getData(\"text/html\"), e)) { e.preventDefault(); }\n else { capturePaste(view, e); }\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 NodeSelection ? sel.to - 1: sel.to)) ; else if (mouseDown && mouseDown.mightDrag) {\n view.dispatch(view.state.tr.setSelection(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)\n { view.dispatch(view.state.tr.setSelection(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 // See https://github.com/ProseMirror/prosemirror/issues/1156\n e.dataTransfer.effectAllowed = \"copyMove\";\n if (!brokenClipboardAPI) { e.dataTransfer.setData(\"text/plain\", text); }\n view.dragging = new Dragging(slice, !e[dragCopyModifier]);\n};\n\nhandlers.dragend = function (view) {\n var dragging = view.dragging;\n window.setTimeout(function () {\n if (view.dragging == dragging) { view.dragging = null; }\n }, 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 if (slice) {\n view.someProp(\"transformPasted\", function (f) { slice = f(slice); });\n } else {\n slice = parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? \"Text\" : \"text/plain\"),\n brokenClipboardAPI ? null : e.dataTransfer.getData(\"text/html\"), false, $mouse);\n }\n var move = dragging && !e[dragCopyModifier];\n if (view.someProp(\"handleDrop\", function (f) { return f(view, e, slice || Slice.empty, move); })) {\n e.preventDefault();\n return\n }\n if (!slice) { return }\n\n e.preventDefault();\n var insertPos = slice ? 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 (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 && NodeSelection.isSelectable(slice.content.firstChild) &&\n $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild)) {\n tr.setSelection(new NodeSelection($pos));\n } else {\n var end = tr.mapping.map(insertPos);\n tr.mapping.maps[tr.mapping.maps.length - 1].forEach(function (_from, _to, _newFrom, newTo) { return end = newTo; });\n tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end)));\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 }, 20);\n }\n};\n\nhandlers.blur = function (view, e) {\n if (view.focused) {\n view.domObserver.stop();\n view.dom.classList.remove(\"ProseMirror-focused\");\n view.domObserver.start();\n if (e.relatedTarget && view.dom.contains(e.relatedTarget))\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\nWidgetType.prototype.destroy = function destroy (node) {\n if (this.spec.destroy) { this.spec.destroy(node); }\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 var child;\n return offset == span.from && !(child = node.child(index)).isText && offset + child.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 },inline: { 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, offset) {\n if ( offset === void 0 ) offset = 0;\n\n return this.type.eq(other.type) && this.from + offset == other.from && this.to + offset == 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.\n//\n// destroy:: ?(node: dom.Node)\n// Called when the widget decoration is removed as a result of\n// mapping\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\nprototypeAccessors$1.inline.get = function () { return this.type instanceof InlineType };\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// :: class extends DecorationSource\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 for (var i = 0; i < local.length; i++) { if (!local[i].type.valid(doc, local[i])) { local.splice(i--, 1); } }\n\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].eq(span$1, offset)) {\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\n// DecorationSource:: interface\n// An object that can [provide](#view.EditorProps.decorations)\n// decorations. Implemented by [`DecorationSet`](#view.DecorationSet),\n// and passed to [node views](#view.EditorProps.nodeViews).\n//\n// map:: (Mapping, Node) → DecorationSource\n// Map the set of decorations in response to a change in the\n// document.\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.map = function map (mapping, doc) {\n var mappedDecos = this.members.map(\n function (member) { return member.map(mapping, doc, noSpec); }\n );\n return DecorationGroup.from(mappedDecos)\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 (newStart >= offset && (dSize = (newEnd - newStart) - (oldEnd - oldStart))) {\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(oldChildren[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, oldChildren[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 subtracted 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.directPlugins = props.plugins || [];\n this.directPlugins.forEach(checkStateComponent);\n\n this.dispatch = this.dispatch.bind(this);\n\n this._root = null;\n this.focused = false;\n // Kludge used to work around a Chrome bug\n this.trackWrites = null;\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.prevDirectPlugins = [];\n this.pluginViews = [];\n this.updatePluginViews();\n};\n\nvar prototypeAccessors$2 = { props: { configurable: true },root: { configurable: true },isDestroyed: { 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 if (props.plugins) {\n props.plugins.forEach(checkStateComponent);\n this.directPlugins = props.plugins;\n }\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, updateSel = false;\n // When stored marks are added, stop composition, so that they can\n // be displayed.\n if (state.storedMarks && this.composing) {\n clearComposition(this);\n updateSel = true;\n }\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 if (updateDoc || !state.selection.eq(prev.selection)) { updateSel = true; }\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, #1035).\n var forceSelUpdate = updateDoc && (result.ie || result.chrome) && !this.composing &&\n !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);\n if (updateDoc) {\n // If the node that the selection points into is written to,\n // Chrome sometimes starts misreporting the selection, so this\n // tracks that and forces a selection reset when our update\n // did write to the node.\n var chromeKludge = result.chrome ? (this.trackWrites = this.root.getSelection().focusNode) : null;\n if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {\n this.docView.updateOuterDeco([]);\n this.docView.destroy();\n this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);\n }\n if (chromeKludge && !this.trackWrites) { forceSelUpdate = true; }\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 NodeSelection)\n { scrollRectIntoView(this, this.docView.domAfterPos(state.selection.from).getBoundingClientRect(), startDOM); }\n else\n { scrollRectIntoView(this, this.coordsAtPos(state.selection.head, 1), 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 || this.directPlugins != this.prevDirectPlugins) {\n this.prevDirectPlugins = this.directPlugins;\n this.destroyPluginViews();\n for (var i = 0; i < this.directPlugins.length; i++) {\n var plugin = this.directPlugins[i];\n if (plugin.spec.view) { this.pluginViews.push(plugin.spec.view(this)); }\n }\n for (var i$1 = 0; i$1 < this.state.plugins.length; i$1++) {\n var plugin$1 = this.state.plugins[i$1];\n if (plugin$1.spec.view) { this.pluginViews.push(plugin$1.spec.view(this)); }\n }\n } else {\n for (var i$2 = 0; i$2 < this.pluginViews.length; i$2++) {\n var pluginView = this.pluginViews[i$2];\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 given to the view, then from plugins in\n// the state (in order), and calls `f` every time a non-undefined\n// value is found. When `f` returns a truthy value, that is\n// immediately returned. When `f` isn't provided, it is treated as\n// the identity function (the prop value is returned 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 for (var i = 0; i < this.directPlugins.length; i++) {\n var prop$1 = this.directPlugins[i].props[propName];\n if (prop$1 != null && (value = f ? f(prop$1) : prop$1)) { return value }\n }\n var plugins = this.state.plugins;\n if (plugins) { for (var i$1 = 0; i$1 < plugins.length; i$1++) {\n var prop$2 = plugins[i$1].props[propName];\n if (prop$2 != null && (value = f ? f(prop$2) : prop$2)) { 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, number) → {left: number, right: number, top: number, bottom: number}\n// Returns the viewport rectangle at a given document position.\n// `left` and `right` will be the same number, as this returns a\n// flat cursor-ish rectangle. If the position is between two things\n// that aren't directly adjacent, `side` determines which element is\n// used. When < 0, the element before the position is used,\n// otherwise the element after.\nEditorView.prototype.coordsAtPos = function coordsAtPos$1 (pos, side) {\n if ( side === void 0 ) side = 1;\n\n return coordsAtPos(this, pos, side)\n};\n\n// :: (number, number) → {node: dom.Node, offset: number}\n// Find the DOM position that corresponds to the given document\n// position. When `side` is negative, find the position as close as\n// possible to the content before the position. When positive,\n// prefer positions close to the content after the position. When\n// zero, prefer as shallow a position as possible.\n//\n// Note that you should **not** mutate the editor's internal DOM,\n// only inspect it (and even that is usually not necessary).\nEditorView.prototype.domAtPos = function domAtPos (pos, side) {\n if ( side === void 0 ) side = 0;\n\n return this.docView.domFromPos(pos, side)\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// :: boolean\n// This is true when the view has been\n// [destroyed](#view.EditorView.destroy) (and thus should not be\n// used anymore).\nprototypeAccessors$2.isDestroyed.get = function () {\n return 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 attrs.translate = \"no\";\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 if (attr == \"style\") {\n attrs.style = (attrs.style ? attrs.style + \";\" : \"\") + value[attr];\n }\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 if (view.markCursor) {\n var dom = document.createElement(\"img\");\n dom.className = \"ProseMirror-separator\";\n dom.setAttribute(\"mark-placeholder\", \"true\");\n view.cursorWrapper = {dom: dom, deco: Decoration.widget(view.state.selection.head, dom, {raw: true, marks: view.markCursor})};\n } else {\n view.cursorWrapper = null;\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.start(depth) != sel2.$anchor.start(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\nfunction checkStateComponent(plugin) {\n if (plugin.spec.state || plugin.spec.filterTransaction || plugin.spec.appendTransaction)\n { throw new RangeError(\"Plugins passed directly to the view must not have a state component\") }\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.ClipboardEvent, 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, plain: bool) → string\n// Transform pasted plain text. The `plain` flag will be true when\n// the text is pasted as plain text.\n//\n// clipboardTextParser:: ?(text: string, $context: ResolvedPos, plain: bool) → 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// The `plain` flag will be true when the text is pasted as plain text.\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], innerDecorations: DecorationSource) → 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// `innerDecorations` holds the decorations for the node's content.\n// You can safely ignore this if your view has no content or a\n// `contentDOM` property, since the editor will draw the decorations\n// on the content. But if you, for example, want to create a nested\n// editor with the content, it may make sense to provide it with the\n// inner decorations.\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) → ?DecorationSource\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// plugins:: [Plugin]\n// A set of plugins to use in the view, applying their [plugin\n// view](#state.PluginSpec.view) and\n// [props](#state.PluginSpec.props). Passing plugins with a state\n// component (a [state field](#state.PluginSpec.state) field or a\n// [transaction](#state.PluginSpec.filterTransaction) filter or\n// appender) will result in an error, since such plugins must be\n// present in the state to work.\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\nexport { Decoration, DecorationSet, EditorView, endComposition as __endComposition, parseFromClipboard as __parseFromClipboard, serializeForClipboard as __serializeForClipboard };\n//# sourceMappingURL=index.es.js.map\n","export var 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}\n\nexport var 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}\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\nexport 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) ||\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","import { keyName, base } from 'w3c-keyname';\nimport { Plugin } from 'prosemirror-state';\n\n// declare global: navigator\n\nvar mac = typeof navigator != \"undefined\" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : false;\n\nfunction normalizeKeyName(name) {\n var parts = name.split(/-(?!$)/), result = parts[parts.length - 1];\n if (result == \"Space\") { result = \" \"; }\n var alt, ctrl, shift, meta;\n for (var i = 0; i < parts.length - 1; i++) {\n var mod = parts[i];\n if (/^(cmd|meta|m)$/i.test(mod)) { meta = true; }\n else if (/^a(lt)?$/i.test(mod)) { alt = true; }\n else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }\n else if (/^s(hift)?$/i.test(mod)) { shift = true; }\n else if (/^mod$/i.test(mod)) { if (mac) { meta = true; } else { ctrl = true; } }\n else { throw new Error(\"Unrecognized modifier name: \" + mod) }\n }\n if (alt) { result = \"Alt-\" + result; }\n if (ctrl) { result = \"Ctrl-\" + result; }\n if (meta) { result = \"Meta-\" + result; }\n if (shift) { result = \"Shift-\" + result; }\n return result\n}\n\nfunction normalize(map) {\n var copy = Object.create(null);\n for (var prop in map) { copy[normalizeKeyName(prop)] = map[prop]; }\n return copy\n}\n\nfunction modifiers(name, event, shift) {\n if (event.altKey) { name = \"Alt-\" + name; }\n if (event.ctrlKey) { name = \"Ctrl-\" + name; }\n if (event.metaKey) { name = \"Meta-\" + name; }\n if (shift !== false && event.shiftKey) { name = \"Shift-\" + name; }\n return name\n}\n\n// :: (Object) → Plugin\n// Create a keymap plugin for the given set of bindings.\n//\n// Bindings should map key names to [command](#commands)-style\n// functions, which will be called with `(EditorState, dispatch,\n// EditorView)` arguments, and should return true when they've handled\n// the key. Note that the view argument isn't part of the command\n// protocol, but can be used as an escape hatch if a binding needs to\n// directly interact with the UI.\n//\n// Key names may be strings like `\"Shift-Ctrl-Enter\"`—a key\n// identifier prefixed with zero or more modifiers. Key identifiers\n// are based on the strings that can appear in\n// [`KeyEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).\n// Use lowercase letters to refer to letter keys (or uppercase letters\n// if you want shift to be held). You may use `\"Space\"` as an alias\n// for the `\" \"` name.\n//\n// Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or\n// `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or\n// `Meta-`) are recognized. For characters that are created by holding\n// shift, the `Shift-` prefix is implied, and should not be added\n// explicitly.\n//\n// You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on\n// other platforms.\n//\n// You can add multiple keymap plugins to an editor. The order in\n// which they appear determines their precedence (the ones early in\n// the array get to dispatch first).\nfunction keymap(bindings) {\n return new Plugin({props: {handleKeyDown: keydownHandler(bindings)}})\n}\n\n// :: (Object) → (view: EditorView, event: dom.Event) → bool\n// Given a set of bindings (using the same format as\n// [`keymap`](#keymap.keymap)), return a [keydown\n// handler](#view.EditorProps.handleKeyDown) that handles them.\nfunction keydownHandler(bindings) {\n var map = normalize(bindings);\n return function(view, event) {\n var name = keyName(event), isChar = name.length == 1 && name != \" \", baseName;\n var direct = map[modifiers(name, event, !isChar)];\n if (direct && direct(view.state, view.dispatch, view)) { return true }\n if (isChar && (event.shiftKey || event.altKey || event.metaKey || name.charCodeAt(0) > 127) &&\n (baseName = base[event.keyCode]) && baseName != name) {\n // Try falling back to the keyCode when there's a modifier\n // active or the character produced isn't ASCII, and our table\n // produces a different name from the the keyCode. See #668,\n // #1060\n var fromCode = map[modifiers(baseName, event, true)];\n if (fromCode && fromCode(view.state, view.dispatch, view)) { return true }\n } else if (isChar && event.shiftKey) {\n // Otherwise, if shift is active, also try the binding with the\n // Shift- prefix enabled. See #997\n var withShift = map[modifiers(name, event, true)];\n if (withShift && withShift(view.state, view.dispatch, view)) { return true }\n }\n return false\n }\n}\n\nexport { keydownHandler, keymap };\n//# sourceMappingURL=index.es.js.map\n","import { Plugin, PluginKey, TextSelection, Selection, NodeSelection, EditorState } from 'prosemirror-state';\nimport { liftTarget, ReplaceStep, ReplaceAroundStep, canSplit, canJoin, findWrapping, Transform } from 'prosemirror-transform';\nimport { createParagraphNear as createParagraphNear$2, deleteSelection as deleteSelection$2, exitCode as exitCode$2, joinBackward as joinBackward$2, joinForward as joinForward$2, lift as lift$2, liftEmptyBlock as liftEmptyBlock$2, newlineInCode as newlineInCode$2, selectNodeBackward as selectNodeBackward$2, selectNodeForward as selectNodeForward$2, selectParentNode as selectParentNode$2, setBlockType, wrapIn as wrapIn$2 } from 'prosemirror-commands';\nimport { Fragment, DOMParser, Slice, DOMSerializer, Schema, Node as Node$1 } from 'prosemirror-model';\nimport { liftListItem as liftListItem$2, sinkListItem as sinkListItem$2, wrapInList as wrapInList$2 } from 'prosemirror-schema-list';\nimport { EditorView } from 'prosemirror-view';\nimport { keymap } from 'prosemirror-keymap';\n\n// see: https://github.com/mesqueeb/is-what/blob/88d6e4ca92fb2baab6003c54e02eedf4e729e5ab/src/index.ts\r\nfunction getType(value) {\r\n return Object.prototype.toString.call(value).slice(8, -1);\r\n}\r\nfunction isPlainObject(value) {\r\n if (getType(value) !== 'Object') {\r\n return false;\r\n }\r\n return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;\r\n}\n\nfunction mergeDeep(target, source) {\r\n const output = { ...target };\r\n if (isPlainObject(target) && isPlainObject(source)) {\r\n Object.keys(source).forEach(key => {\r\n if (isPlainObject(source[key])) {\r\n if (!(key in target)) {\r\n Object.assign(output, { [key]: source[key] });\r\n }\r\n else {\r\n output[key] = mergeDeep(target[key], source[key]);\r\n }\r\n }\r\n else {\r\n Object.assign(output, { [key]: source[key] });\r\n }\r\n });\r\n }\r\n return output;\r\n}\n\nfunction isFunction(value) {\r\n return typeof value === 'function';\r\n}\n\n/**\r\n * Optionally calls `value` as a function.\r\n * Otherwise it is returned directly.\r\n * @param value Function or any value.\r\n * @param context Optional context to bind to function.\r\n * @param props Optional props to pass to function.\r\n */\r\nfunction callOrReturn(value, context = undefined, ...props) {\r\n if (isFunction(value)) {\r\n if (context) {\r\n return value.bind(context)(...props);\r\n }\r\n return value(...props);\r\n }\r\n return value;\r\n}\n\nfunction getExtensionField(extension, field, context) {\r\n if (extension.config[field] === undefined && extension.parent) {\r\n return getExtensionField(extension.parent, field, context);\r\n }\r\n if (typeof extension.config[field] === 'function') {\r\n const value = extension.config[field].bind({\r\n ...context,\r\n parent: extension.parent\r\n ? getExtensionField(extension.parent, field, context)\r\n : null,\r\n });\r\n return value;\r\n }\r\n return extension.config[field];\r\n}\n\nclass Extension {\r\n constructor(config = {}) {\r\n this.type = 'extension';\r\n this.name = 'extension';\r\n this.parent = null;\r\n this.child = null;\r\n this.config = {\r\n name: this.name,\r\n defaultOptions: {},\r\n };\r\n this.config = {\r\n ...this.config,\r\n ...config,\r\n };\r\n this.name = this.config.name;\r\n if (config.defaultOptions) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${this.name}\".`);\r\n }\r\n // TODO: remove `addOptions` fallback\r\n this.options = this.config.defaultOptions;\r\n if (this.config.addOptions) {\r\n this.options = callOrReturn(getExtensionField(this, 'addOptions', {\r\n name: this.name,\r\n }));\r\n }\r\n this.storage = callOrReturn(getExtensionField(this, 'addStorage', {\r\n name: this.name,\r\n options: this.options,\r\n })) || {};\r\n }\r\n static create(config = {}) {\r\n return new Extension(config);\r\n }\r\n configure(options = {}) {\r\n // return a new instance so we can use the same extension\r\n // with different calls of `configure`\r\n const extension = this.extend();\r\n extension.options = mergeDeep(this.options, options);\r\n extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {\r\n name: extension.name,\r\n options: extension.options,\r\n }));\r\n return extension;\r\n }\r\n extend(extendedConfig = {}) {\r\n const extension = new Extension(extendedConfig);\r\n extension.parent = this;\r\n this.child = extension;\r\n extension.name = extendedConfig.name\r\n ? extendedConfig.name\r\n : extension.parent.name;\r\n if (extendedConfig.defaultOptions) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${extension.name}\".`);\r\n }\r\n extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {\r\n name: extension.name,\r\n }));\r\n extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {\r\n name: extension.name,\r\n options: extension.options,\r\n }));\r\n return extension;\r\n }\r\n}\n\nfunction getTextBetween(startNode, range, options) {\r\n const { from, to } = range;\r\n const { blockSeparator = '\\n\\n', textSerializers = {}, } = options || {};\r\n let text = '';\r\n let separated = true;\r\n startNode.nodesBetween(from, to, (node, pos, parent, index) => {\r\n var _a;\r\n const textSerializer = textSerializers === null || textSerializers === void 0 ? void 0 : textSerializers[node.type.name];\r\n if (textSerializer) {\r\n if (node.isBlock && !separated) {\r\n text += blockSeparator;\r\n separated = true;\r\n }\r\n text += textSerializer({\r\n node,\r\n pos,\r\n parent,\r\n index,\r\n });\r\n }\r\n else if (node.isText) {\r\n text += (_a = node === null || node === void 0 ? void 0 : node.text) === null || _a === void 0 ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos);\r\n separated = false;\r\n }\r\n else if (node.isBlock && !separated) {\r\n text += blockSeparator;\r\n separated = true;\r\n }\r\n });\r\n return text;\r\n}\n\nfunction getTextSeralizersFromSchema(schema) {\r\n return Object.fromEntries(Object\r\n .entries(schema.nodes)\r\n .filter(([, node]) => node.spec.toText)\r\n .map(([name, node]) => [name, node.spec.toText]));\r\n}\n\nconst ClipboardTextSerializer = Extension.create({\r\n name: 'clipboardTextSerializer',\r\n addProseMirrorPlugins() {\r\n return [\r\n new Plugin({\r\n key: new PluginKey('clipboardTextSerializer'),\r\n props: {\r\n clipboardTextSerializer: () => {\r\n const { editor } = this;\r\n const { state, schema } = editor;\r\n const { doc, selection } = state;\r\n const { ranges } = selection;\r\n const from = Math.min(...ranges.map(range => range.$from.pos));\r\n const to = Math.max(...ranges.map(range => range.$to.pos));\r\n const textSerializers = getTextSeralizersFromSchema(schema);\r\n const range = { from, to };\r\n return getTextBetween(doc, range, {\r\n textSerializers,\r\n });\r\n },\r\n },\r\n }),\r\n ];\r\n },\r\n});\n\nconst blur = () => ({ editor, view }) => {\r\n requestAnimationFrame(() => {\r\n if (!editor.isDestroyed) {\r\n view.dom.blur();\r\n }\r\n });\r\n return true;\r\n};\n\nvar blur$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n blur: blur\n});\n\nconst clearContent = (emitUpdate = false) => ({ commands }) => {\r\n return commands.setContent('', emitUpdate);\r\n};\n\nvar clearContent$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n clearContent: clearContent\n});\n\nconst clearNodes = () => ({ state, tr, dispatch }) => {\r\n const { selection } = tr;\r\n const { ranges } = selection;\r\n ranges.forEach(range => {\r\n state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {\r\n if (node.type.isText) {\r\n return;\r\n }\r\n const $fromPos = tr.doc.resolve(tr.mapping.map(pos));\r\n const $toPos = tr.doc.resolve(tr.mapping.map(pos + node.nodeSize));\r\n const nodeRange = $fromPos.blockRange($toPos);\r\n if (!nodeRange) {\r\n return;\r\n }\r\n const targetLiftDepth = liftTarget(nodeRange);\r\n if (node.type.isTextblock && dispatch) {\r\n const { defaultType } = $fromPos.parent.contentMatchAt($fromPos.index());\r\n tr.setNodeMarkup(nodeRange.start, defaultType);\r\n }\r\n if ((targetLiftDepth || targetLiftDepth === 0) && dispatch) {\r\n tr.lift(nodeRange, targetLiftDepth);\r\n }\r\n });\r\n });\r\n return true;\r\n};\n\nvar clearNodes$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n clearNodes: clearNodes\n});\n\nconst command = fn => props => {\r\n return fn(props);\r\n};\n\nvar command$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n command: command\n});\n\nconst createParagraphNear = () => ({ state, dispatch }) => {\r\n return createParagraphNear$2(state, dispatch);\r\n};\n\nvar createParagraphNear$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n createParagraphNear: createParagraphNear\n});\n\nfunction getNodeType(nameOrType, schema) {\r\n if (typeof nameOrType === 'string') {\r\n if (!schema.nodes[nameOrType]) {\r\n throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);\r\n }\r\n return schema.nodes[nameOrType];\r\n }\r\n return nameOrType;\r\n}\n\nconst deleteNode = typeOrName => ({ tr, state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n const $pos = tr.selection.$anchor;\r\n for (let depth = $pos.depth; depth > 0; depth -= 1) {\r\n const node = $pos.node(depth);\r\n if (node.type === type) {\r\n if (dispatch) {\r\n const from = $pos.before(depth);\r\n const to = $pos.after(depth);\r\n tr.delete(from, to).scrollIntoView();\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\n\nvar deleteNode$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n deleteNode: deleteNode\n});\n\nconst deleteRange = range => ({ tr, dispatch }) => {\r\n const { from, to } = range;\r\n if (dispatch) {\r\n tr.delete(from, to);\r\n }\r\n return true;\r\n};\n\nvar deleteRange$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n deleteRange: deleteRange\n});\n\nconst deleteSelection = () => ({ state, dispatch }) => {\r\n return deleteSelection$2(state, dispatch);\r\n};\n\nvar deleteSelection$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n deleteSelection: deleteSelection\n});\n\nconst enter = () => ({ commands }) => {\r\n return commands.keyboardShortcut('Enter');\r\n};\n\nvar enter$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n enter: enter\n});\n\nconst exitCode = () => ({ state, dispatch }) => {\r\n return exitCode$2(state, dispatch);\r\n};\n\nvar exitCode$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n exitCode: exitCode\n});\n\nfunction getMarkType(nameOrType, schema) {\r\n if (typeof nameOrType === 'string') {\r\n if (!schema.marks[nameOrType]) {\r\n throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`);\r\n }\r\n return schema.marks[nameOrType];\r\n }\r\n return nameOrType;\r\n}\n\nfunction isRegExp(value) {\r\n return Object.prototype.toString.call(value) === '[object RegExp]';\r\n}\n\n/**\r\n * Check if object1 includes object2\r\n * @param object1 Object\r\n * @param object2 Object\r\n */\r\nfunction objectIncludes(object1, object2, options = { strict: true }) {\r\n const keys = Object.keys(object2);\r\n if (!keys.length) {\r\n return true;\r\n }\r\n return keys.every(key => {\r\n if (options.strict) {\r\n return object2[key] === object1[key];\r\n }\r\n if (isRegExp(object2[key])) {\r\n return object2[key].test(object1[key]);\r\n }\r\n return object2[key] === object1[key];\r\n });\r\n}\n\nfunction findMarkInSet(marks, type, attributes = {}) {\r\n return marks.find(item => {\r\n return item.type === type && objectIncludes(item.attrs, attributes);\r\n });\r\n}\r\nfunction isMarkInSet(marks, type, attributes = {}) {\r\n return !!findMarkInSet(marks, type, attributes);\r\n}\r\nfunction getMarkRange($pos, type, attributes = {}) {\r\n if (!$pos || !type) {\r\n return;\r\n }\r\n const start = $pos.parent.childAfter($pos.parentOffset);\r\n if (!start.node) {\r\n return;\r\n }\r\n const mark = findMarkInSet(start.node.marks, type, attributes);\r\n if (!mark) {\r\n return;\r\n }\r\n let startIndex = $pos.index();\r\n let startPos = $pos.start() + start.offset;\r\n let endIndex = startIndex + 1;\r\n let endPos = startPos + start.node.nodeSize;\r\n findMarkInSet(start.node.marks, type, attributes);\r\n while (startIndex > 0 && mark.isInSet($pos.parent.child(startIndex - 1).marks)) {\r\n startIndex -= 1;\r\n startPos -= $pos.parent.child(startIndex).nodeSize;\r\n }\r\n while (endIndex < $pos.parent.childCount\r\n && isMarkInSet($pos.parent.child(endIndex).marks, type, attributes)) {\r\n endPos += $pos.parent.child(endIndex).nodeSize;\r\n endIndex += 1;\r\n }\r\n return {\r\n from: startPos,\r\n to: endPos,\r\n };\r\n}\n\nconst extendMarkRange = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {\r\n const type = getMarkType(typeOrName, state.schema);\r\n const { doc, selection } = tr;\r\n const { $from, from, to } = selection;\r\n if (dispatch) {\r\n const range = getMarkRange($from, type, attributes);\r\n if (range && range.from <= from && range.to >= to) {\r\n const newSelection = TextSelection.create(doc, range.from, range.to);\r\n tr.setSelection(newSelection);\r\n }\r\n }\r\n return true;\r\n};\n\nvar extendMarkRange$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n extendMarkRange: extendMarkRange\n});\n\nconst first = commands => props => {\r\n const items = typeof commands === 'function'\r\n ? commands(props)\r\n : commands;\r\n for (let i = 0; i < items.length; i += 1) {\r\n if (items[i](props)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\n\nvar first$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n first: first\n});\n\nfunction isClass(value) {\r\n var _a;\r\n if (((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.toString().substring(0, 5)) !== 'class') {\r\n return false;\r\n }\r\n return true;\r\n}\n\nfunction isObject(value) {\r\n return (value\r\n && typeof value === 'object'\r\n && !Array.isArray(value)\r\n && !isClass(value));\r\n}\n\nfunction isTextSelection(value) {\r\n return isObject(value) && value instanceof TextSelection;\r\n}\n\nfunction isiOS() {\r\n return [\r\n 'iPad Simulator',\r\n 'iPhone Simulator',\r\n 'iPod Simulator',\r\n 'iPad',\r\n 'iPhone',\r\n 'iPod',\r\n ].includes(navigator.platform)\r\n // iPad on iOS 13 detection\r\n || (navigator.userAgent.includes('Mac') && 'ontouchend' in document);\r\n}\n\nfunction minMax(value = 0, min = 0, max = 0) {\r\n return Math.min(Math.max(value, min), max);\r\n}\n\nfunction resolveFocusPosition(doc, position = null) {\r\n if (!position) {\r\n return null;\r\n }\r\n if (position === 'start' || position === true) {\r\n return Selection.atStart(doc);\r\n }\r\n if (position === 'end') {\r\n return Selection.atEnd(doc);\r\n }\r\n if (position === 'all') {\r\n return TextSelection.create(doc, 0, doc.content.size);\r\n }\r\n // Check if `position` is in bounds of the doc if `position` is a number.\r\n const minPos = Selection.atStart(doc).from;\r\n const maxPos = Selection.atEnd(doc).to;\r\n const resolvedFrom = minMax(position, minPos, maxPos);\r\n const resolvedEnd = minMax(position, minPos, maxPos);\r\n return TextSelection.create(doc, resolvedFrom, resolvedEnd);\r\n}\n\nconst focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {\r\n options = {\r\n scrollIntoView: true,\r\n ...options,\r\n };\r\n const delayedFocus = () => {\r\n // focus within `requestAnimationFrame` breaks focus on iOS\r\n // so we have to call this\r\n if (isiOS()) {\r\n view.dom.focus();\r\n }\r\n // For React we have to focus asynchronously. Otherwise wild things happen.\r\n // see: https://github.com/ueberdosis/tiptap/issues/1520\r\n requestAnimationFrame(() => {\r\n if (!editor.isDestroyed) {\r\n view.focus();\r\n if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {\r\n editor.commands.scrollIntoView();\r\n }\r\n }\r\n });\r\n };\r\n if ((view.hasFocus() && position === null) || position === false) {\r\n return true;\r\n }\r\n // we don’t try to resolve a NodeSelection or CellSelection\r\n if (dispatch && position === null && !isTextSelection(editor.state.selection)) {\r\n delayedFocus();\r\n return true;\r\n }\r\n const selection = resolveFocusPosition(editor.state.doc, position) || editor.state.selection;\r\n const isSameSelection = editor.state.selection.eq(selection);\r\n if (dispatch) {\r\n if (!isSameSelection) {\r\n tr.setSelection(selection);\r\n }\r\n // `tr.setSelection` resets the stored marks\r\n // so we’ll restore them if the selection is the same as before\r\n if (isSameSelection && tr.storedMarks) {\r\n tr.setStoredMarks(tr.storedMarks);\r\n }\r\n delayedFocus();\r\n }\r\n return true;\r\n};\n\nvar focus$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n focus: focus\n});\n\nconst forEach = (items, fn) => props => {\r\n return items.every((item, index) => fn(item, { ...props, index }));\r\n};\n\nvar forEach$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n forEach: forEach\n});\n\nconst insertContent = (value, options) => ({ tr, commands }) => {\r\n return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options);\r\n};\n\nvar insertContent$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n insertContent: insertContent\n});\n\nfunction elementFromString(value) {\r\n // add a wrapper to preserve leading and trailing whitespace\r\n const wrappedValue = `${value}`;\r\n return new window.DOMParser().parseFromString(wrappedValue, 'text/html').body;\r\n}\n\nfunction createNodeFromContent(content, schema, options) {\r\n options = {\r\n slice: true,\r\n parseOptions: {},\r\n ...options,\r\n };\r\n if (typeof content === 'object' && content !== null) {\r\n try {\r\n if (Array.isArray(content)) {\r\n return Fragment.fromArray(content.map(item => schema.nodeFromJSON(item)));\r\n }\r\n return schema.nodeFromJSON(content);\r\n }\r\n catch (error) {\r\n console.warn('[tiptap warn]: Invalid content.', 'Passed value:', content, 'Error:', error);\r\n return createNodeFromContent('', schema, options);\r\n }\r\n }\r\n if (typeof content === 'string') {\r\n const parser = DOMParser.fromSchema(schema);\r\n return options.slice\r\n ? parser.parseSlice(elementFromString(content), options.parseOptions).content\r\n : parser.parse(elementFromString(content), options.parseOptions);\r\n }\r\n return createNodeFromContent('', schema, options);\r\n}\n\n// source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466\r\nfunction selectionToInsertionEnd(tr, startLen, bias) {\r\n const last = tr.steps.length - 1;\r\n if (last < startLen) {\r\n return;\r\n }\r\n const step = tr.steps[last];\r\n if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {\r\n return;\r\n }\r\n const map = tr.mapping.maps[last];\r\n let end = 0;\r\n map.forEach((_from, _to, _newFrom, newTo) => {\r\n if (end === 0) {\r\n end = newTo;\r\n }\r\n });\r\n tr.setSelection(Selection.near(tr.doc.resolve(end), bias));\r\n}\n\nconst isFragment = (nodeOrFragment) => {\r\n return nodeOrFragment.toString().startsWith('<');\r\n};\r\nconst insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) => {\r\n if (dispatch) {\r\n options = {\r\n parseOptions: {},\r\n updateSelection: true,\r\n ...options,\r\n };\r\n const content = createNodeFromContent(value, editor.schema, {\r\n parseOptions: {\r\n preserveWhitespace: 'full',\r\n ...options.parseOptions,\r\n },\r\n });\r\n // don’t dispatch an empty fragment because this can lead to strange errors\r\n if (content.toString() === '<>') {\r\n return true;\r\n }\r\n let { from, to } = typeof position === 'number'\r\n ? { from: position, to: position }\r\n : position;\r\n let isOnlyBlockContent = true;\r\n const nodes = isFragment(content)\r\n ? content\r\n : [content];\r\n nodes.forEach(node => {\r\n isOnlyBlockContent = isOnlyBlockContent\r\n ? node.isBlock\r\n : false;\r\n });\r\n // check if we can replace the wrapping node by\r\n // the newly inserted content\r\n // example:\r\n // replace an empty paragraph by an inserted image\r\n // instead of inserting the image below the paragraph\r\n if (from === to && isOnlyBlockContent) {\r\n const { parent } = tr.doc.resolve(from);\r\n const isEmptyTextBlock = parent.isTextblock\r\n && !parent.type.spec.code\r\n && !parent.childCount;\r\n if (isEmptyTextBlock) {\r\n from -= 1;\r\n to += 1;\r\n }\r\n }\r\n tr.replaceWith(from, to, content);\r\n // set cursor at end of inserted content\r\n if (options.updateSelection) {\r\n selectionToInsertionEnd(tr, tr.steps.length - 1, -1);\r\n }\r\n }\r\n return true;\r\n};\n\nvar insertContentAt$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n insertContentAt: insertContentAt\n});\n\nconst joinBackward = () => ({ state, dispatch }) => {\r\n return joinBackward$2(state, dispatch);\r\n};\n\nvar joinBackward$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n joinBackward: joinBackward\n});\n\nconst joinForward = () => ({ state, dispatch }) => {\r\n return joinForward$2(state, dispatch);\r\n};\n\nvar joinForward$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n joinForward: joinForward\n});\n\nconst mac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false;\r\nfunction normalizeKeyName(name) {\r\n const parts = name.split(/-(?!$)/);\r\n let result = parts[parts.length - 1];\r\n if (result === 'Space') {\r\n result = ' ';\r\n }\r\n let alt;\r\n let ctrl;\r\n let shift;\r\n let meta;\r\n for (let i = 0; i < parts.length - 1; i += 1) {\r\n const mod = parts[i];\r\n if (/^(cmd|meta|m)$/i.test(mod)) {\r\n meta = true;\r\n }\r\n else if (/^a(lt)?$/i.test(mod)) {\r\n alt = true;\r\n }\r\n else if (/^(c|ctrl|control)$/i.test(mod)) {\r\n ctrl = true;\r\n }\r\n else if (/^s(hift)?$/i.test(mod)) {\r\n shift = true;\r\n }\r\n else if (/^mod$/i.test(mod)) {\r\n if (mac) {\r\n meta = true;\r\n }\r\n else {\r\n ctrl = true;\r\n }\r\n }\r\n else {\r\n throw new Error(`Unrecognized modifier name: ${mod}`);\r\n }\r\n }\r\n if (alt) {\r\n result = `Alt-${result}`;\r\n }\r\n if (ctrl) {\r\n result = `Ctrl-${result}`;\r\n }\r\n if (meta) {\r\n result = `Meta-${result}`;\r\n }\r\n if (shift) {\r\n result = `Shift-${result}`;\r\n }\r\n return result;\r\n}\r\nconst keyboardShortcut = name => ({ editor, view, tr, dispatch, }) => {\r\n const keys = normalizeKeyName(name).split(/-(?!$)/);\r\n const key = keys.find(item => !['Alt', 'Ctrl', 'Meta', 'Shift'].includes(item));\r\n const event = new KeyboardEvent('keydown', {\r\n key: key === 'Space'\r\n ? ' '\r\n : key,\r\n altKey: keys.includes('Alt'),\r\n ctrlKey: keys.includes('Ctrl'),\r\n metaKey: keys.includes('Meta'),\r\n shiftKey: keys.includes('Shift'),\r\n bubbles: true,\r\n cancelable: true,\r\n });\r\n const capturedTransaction = editor.captureTransaction(() => {\r\n view.someProp('handleKeyDown', f => f(view, event));\r\n });\r\n capturedTransaction === null || capturedTransaction === void 0 ? void 0 : capturedTransaction.steps.forEach(step => {\r\n const newStep = step.map(tr.mapping);\r\n if (newStep && dispatch) {\r\n tr.maybeStep(newStep);\r\n }\r\n });\r\n return true;\r\n};\n\nvar keyboardShortcut$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n keyboardShortcut: keyboardShortcut\n});\n\nfunction isNodeActive(state, typeOrName, attributes = {}) {\r\n const { from, to, empty } = state.selection;\r\n const type = typeOrName\r\n ? getNodeType(typeOrName, state.schema)\r\n : null;\r\n const nodeRanges = [];\r\n state.doc.nodesBetween(from, to, (node, pos) => {\r\n if (node.isText) {\r\n return;\r\n }\r\n const relativeFrom = Math.max(from, pos);\r\n const relativeTo = Math.min(to, pos + node.nodeSize);\r\n nodeRanges.push({\r\n node,\r\n from: relativeFrom,\r\n to: relativeTo,\r\n });\r\n });\r\n const selectionRange = to - from;\r\n const matchedNodeRanges = nodeRanges\r\n .filter(nodeRange => {\r\n if (!type) {\r\n return true;\r\n }\r\n return type.name === nodeRange.node.type.name;\r\n })\r\n .filter(nodeRange => objectIncludes(nodeRange.node.attrs, attributes, { strict: false }));\r\n if (empty) {\r\n return !!matchedNodeRanges.length;\r\n }\r\n const range = matchedNodeRanges\r\n .reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0);\r\n return range >= selectionRange;\r\n}\n\nconst lift = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n const isActive = isNodeActive(state, type, attributes);\r\n if (!isActive) {\r\n return false;\r\n }\r\n return lift$2(state, dispatch);\r\n};\n\nvar lift$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n lift: lift\n});\n\nconst liftEmptyBlock = () => ({ state, dispatch }) => {\r\n return liftEmptyBlock$2(state, dispatch);\r\n};\n\nvar liftEmptyBlock$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n liftEmptyBlock: liftEmptyBlock\n});\n\nconst liftListItem = typeOrName => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n return liftListItem$2(type)(state, dispatch);\r\n};\n\nvar liftListItem$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n liftListItem: liftListItem\n});\n\nconst newlineInCode = () => ({ state, dispatch }) => {\r\n return newlineInCode$2(state, dispatch);\r\n};\n\nvar newlineInCode$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n newlineInCode: newlineInCode\n});\n\nfunction getSchemaTypeNameByName(name, schema) {\r\n if (schema.nodes[name]) {\r\n return 'node';\r\n }\r\n if (schema.marks[name]) {\r\n return 'mark';\r\n }\r\n return null;\r\n}\n\n/**\r\n * Remove a property or an array of properties from an object\r\n * @param obj Object\r\n * @param key Key to remove\r\n */\r\nfunction deleteProps(obj, propOrProps) {\r\n const props = typeof propOrProps === 'string'\r\n ? [propOrProps]\r\n : propOrProps;\r\n return Object\r\n .keys(obj)\r\n .reduce((newObj, prop) => {\r\n if (!props.includes(prop)) {\r\n newObj[prop] = obj[prop];\r\n }\r\n return newObj;\r\n }, {});\r\n}\n\nconst resetAttributes = (typeOrName, attributes) => ({ tr, state, dispatch }) => {\r\n let nodeType = null;\r\n let markType = null;\r\n const schemaType = getSchemaTypeNameByName(typeof typeOrName === 'string'\r\n ? typeOrName\r\n : typeOrName.name, state.schema);\r\n if (!schemaType) {\r\n return false;\r\n }\r\n if (schemaType === 'node') {\r\n nodeType = getNodeType(typeOrName, state.schema);\r\n }\r\n if (schemaType === 'mark') {\r\n markType = getMarkType(typeOrName, state.schema);\r\n }\r\n if (dispatch) {\r\n tr.selection.ranges.forEach(range => {\r\n state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {\r\n if (nodeType && nodeType === node.type) {\r\n tr.setNodeMarkup(pos, undefined, deleteProps(node.attrs, attributes));\r\n }\r\n if (markType && node.marks.length) {\r\n node.marks.forEach(mark => {\r\n if (markType === mark.type) {\r\n tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)));\r\n }\r\n });\r\n }\r\n });\r\n });\r\n }\r\n return true;\r\n};\n\nvar resetAttributes$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n resetAttributes: resetAttributes\n});\n\nconst scrollIntoView = () => ({ tr, dispatch }) => {\r\n if (dispatch) {\r\n tr.scrollIntoView();\r\n }\r\n return true;\r\n};\n\nvar scrollIntoView$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n scrollIntoView: scrollIntoView\n});\n\nconst selectAll = () => ({ tr, commands }) => {\r\n return commands.setTextSelection({\r\n from: 0,\r\n to: tr.doc.content.size,\r\n });\r\n};\n\nvar selectAll$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n selectAll: selectAll\n});\n\nconst selectNodeBackward = () => ({ state, dispatch }) => {\r\n return selectNodeBackward$2(state, dispatch);\r\n};\n\nvar selectNodeBackward$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n selectNodeBackward: selectNodeBackward\n});\n\nconst selectNodeForward = () => ({ state, dispatch }) => {\r\n return selectNodeForward$2(state, dispatch);\r\n};\n\nvar selectNodeForward$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n selectNodeForward: selectNodeForward\n});\n\nconst selectParentNode = () => ({ state, dispatch }) => {\r\n return selectParentNode$2(state, dispatch);\r\n};\n\nvar selectParentNode$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n selectParentNode: selectParentNode\n});\n\nfunction createDocument(content, schema, parseOptions = {}) {\r\n return createNodeFromContent(content, schema, { slice: false, parseOptions });\r\n}\n\nconst setContent = (content, emitUpdate = false, parseOptions = {}) => ({ tr, editor, dispatch }) => {\r\n const { doc } = tr;\r\n const document = createDocument(content, editor.schema, parseOptions);\r\n const selection = TextSelection.create(doc, 0, doc.content.size);\r\n if (dispatch) {\r\n tr.setSelection(selection)\r\n .replaceSelectionWith(document, false)\r\n .setMeta('preventUpdate', !emitUpdate);\r\n }\r\n return true;\r\n};\n\nvar setContent$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n setContent: setContent\n});\n\nfunction getMarkAttributes(state, typeOrName) {\r\n const type = getMarkType(typeOrName, state.schema);\r\n const { from, to, empty } = state.selection;\r\n const marks = [];\r\n if (empty) {\r\n if (state.storedMarks) {\r\n marks.push(...state.storedMarks);\r\n }\r\n marks.push(...state.selection.$head.marks());\r\n }\r\n else {\r\n state.doc.nodesBetween(from, to, node => {\r\n marks.push(...node.marks);\r\n });\r\n }\r\n const mark = marks.find(markItem => markItem.type.name === type.name);\r\n if (!mark) {\r\n return {};\r\n }\r\n return { ...mark.attrs };\r\n}\n\nconst setMark = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {\r\n const { selection } = tr;\r\n const { empty, ranges } = selection;\r\n const type = getMarkType(typeOrName, state.schema);\r\n if (dispatch) {\r\n if (empty) {\r\n const oldAttributes = getMarkAttributes(state, type);\r\n tr.addStoredMark(type.create({\r\n ...oldAttributes,\r\n ...attributes,\r\n }));\r\n }\r\n else {\r\n ranges.forEach(range => {\r\n const from = range.$from.pos;\r\n const to = range.$to.pos;\r\n state.doc.nodesBetween(from, to, (node, pos) => {\r\n const trimmedFrom = Math.max(pos, from);\r\n const trimmedTo = Math.min(pos + node.nodeSize, to);\r\n const someHasMark = node.marks.find(mark => mark.type === type);\r\n // if there is already a mark of this type\r\n // we know that we have to merge its attributes\r\n // otherwise we add a fresh new mark\r\n if (someHasMark) {\r\n node.marks.forEach(mark => {\r\n if (type === mark.type) {\r\n tr.addMark(trimmedFrom, trimmedTo, type.create({\r\n ...mark.attrs,\r\n ...attributes,\r\n }));\r\n }\r\n });\r\n }\r\n else {\r\n tr.addMark(trimmedFrom, trimmedTo, type.create(attributes));\r\n }\r\n });\r\n });\r\n }\r\n }\r\n return true;\r\n};\n\nvar setMark$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n setMark: setMark\n});\n\nconst setMeta = (key, value) => ({ tr }) => {\r\n tr.setMeta(key, value);\r\n return true;\r\n};\n\nvar setMeta$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n setMeta: setMeta\n});\n\nconst setNode = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n return setBlockType(type, attributes)(state, dispatch);\r\n};\n\nvar setNode$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n setNode: setNode\n});\n\nconst setNodeSelection = position => ({ tr, dispatch }) => {\r\n if (dispatch) {\r\n const { doc } = tr;\r\n const minPos = Selection.atStart(doc).from;\r\n const maxPos = Selection.atEnd(doc).to;\r\n const resolvedPos = minMax(position, minPos, maxPos);\r\n const selection = NodeSelection.create(doc, resolvedPos);\r\n tr.setSelection(selection);\r\n }\r\n return true;\r\n};\n\nvar setNodeSelection$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n setNodeSelection: setNodeSelection\n});\n\nconst setTextSelection = position => ({ tr, dispatch }) => {\r\n if (dispatch) {\r\n const { doc } = tr;\r\n const { from, to } = typeof position === 'number'\r\n ? { from: position, to: position }\r\n : position;\r\n const minPos = Selection.atStart(doc).from;\r\n const maxPos = Selection.atEnd(doc).to;\r\n const resolvedFrom = minMax(from, minPos, maxPos);\r\n const resolvedEnd = minMax(to, minPos, maxPos);\r\n const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd);\r\n tr.setSelection(selection);\r\n }\r\n return true;\r\n};\n\nvar setTextSelection$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n setTextSelection: setTextSelection\n});\n\nconst sinkListItem = typeOrName => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n return sinkListItem$2(type)(state, dispatch);\r\n};\n\nvar sinkListItem$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n sinkListItem: sinkListItem\n});\n\nfunction getSplittedAttributes(extensionAttributes, typeName, attributes) {\r\n return Object.fromEntries(Object\r\n .entries(attributes)\r\n .filter(([name]) => {\r\n const extensionAttribute = extensionAttributes.find(item => {\r\n return item.type === typeName && item.name === name;\r\n });\r\n if (!extensionAttribute) {\r\n return false;\r\n }\r\n return extensionAttribute.attribute.keepOnSplit;\r\n }));\r\n}\n\nfunction defaultBlockAt$1(match) {\r\n for (let i = 0; i < match.edgeCount; i += 1) {\r\n const { type } = match.edge(i);\r\n if (type.isTextblock && !type.hasRequiredAttrs()) {\r\n return type;\r\n }\r\n }\r\n return null;\r\n}\r\nfunction ensureMarks(state, splittableMarks) {\r\n const marks = state.storedMarks\r\n || (state.selection.$to.parentOffset && state.selection.$from.marks());\r\n if (marks) {\r\n const filteredMarks = marks.filter(mark => splittableMarks === null || splittableMarks === void 0 ? void 0 : splittableMarks.includes(mark.type.name));\r\n state.tr.ensureMarks(filteredMarks);\r\n }\r\n}\r\nconst splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor, }) => {\r\n const { selection, doc } = tr;\r\n const { $from, $to } = selection;\r\n const extensionAttributes = editor.extensionManager.attributes;\r\n const newAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);\r\n if (selection instanceof NodeSelection && selection.node.isBlock) {\r\n if (!$from.parentOffset || !canSplit(doc, $from.pos)) {\r\n return false;\r\n }\r\n if (dispatch) {\r\n if (keepMarks) {\r\n ensureMarks(state, editor.extensionManager.splittableMarks);\r\n }\r\n tr.split($from.pos).scrollIntoView();\r\n }\r\n return true;\r\n }\r\n if (!$from.parent.isBlock) {\r\n return false;\r\n }\r\n if (dispatch) {\r\n const atEnd = $to.parentOffset === $to.parent.content.size;\r\n if (selection instanceof TextSelection) {\r\n tr.deleteSelection();\r\n }\r\n const deflt = $from.depth === 0\r\n ? undefined\r\n : defaultBlockAt$1($from.node(-1).contentMatchAt($from.indexAfter(-1)));\r\n let types = atEnd && deflt\r\n ? [{\r\n type: deflt,\r\n attrs: newAttributes,\r\n }]\r\n : undefined;\r\n let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);\r\n if (!types\r\n && !can\r\n && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)) {\r\n can = true;\r\n types = deflt\r\n ? [{\r\n type: deflt,\r\n attrs: newAttributes,\r\n }]\r\n : undefined;\r\n }\r\n if (can) {\r\n tr.split(tr.mapping.map($from.pos), 1, types);\r\n if (deflt\r\n && !atEnd\r\n && !$from.parentOffset\r\n && $from.parent.type !== deflt) {\r\n const first = tr.mapping.map($from.before());\r\n const $first = tr.doc.resolve(first);\r\n if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) {\r\n tr.setNodeMarkup(tr.mapping.map($from.before()), deflt);\r\n }\r\n }\r\n }\r\n if (keepMarks) {\r\n ensureMarks(state, editor.extensionManager.splittableMarks);\r\n }\r\n tr.scrollIntoView();\r\n }\r\n return true;\r\n};\n\nvar splitBlock$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n splitBlock: splitBlock\n});\n\nconst splitListItem = typeOrName => ({ tr, state, dispatch, editor, }) => {\r\n var _a;\r\n const type = getNodeType(typeOrName, state.schema);\r\n const { $from, $to } = state.selection;\r\n // @ts-ignore\r\n // eslint-disable-next-line\r\n const node = state.selection.node;\r\n if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) {\r\n return false;\r\n }\r\n const grandParent = $from.node(-1);\r\n if (grandParent.type !== type) {\r\n return false;\r\n }\r\n const extensionAttributes = editor.extensionManager.attributes;\r\n if ($from.parent.content.size === 0 && $from.node(-1).childCount === $from.indexAfter(-1)) {\r\n // In an empty block. If this is a nested list, the wrapping\r\n // list item should be split. Otherwise, bail out and let next\r\n // command handle lifting.\r\n if ($from.depth === 2\r\n || $from.node(-3).type !== type\r\n || $from.index(-2) !== $from.node(-2).childCount - 1) {\r\n return false;\r\n }\r\n if (dispatch) {\r\n let wrap = Fragment.empty;\r\n // eslint-disable-next-line\r\n const depthBefore = $from.index(-1)\r\n ? 1\r\n : $from.index(-2)\r\n ? 2\r\n : 3;\r\n // Build a fragment containing empty versions of the structure\r\n // from the outer list item to the parent node of the cursor\r\n for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {\r\n wrap = Fragment.from($from.node(d).copy(wrap));\r\n }\r\n // eslint-disable-next-line\r\n const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount\r\n ? 1\r\n : $from.indexAfter(-2) < $from.node(-3).childCount\r\n ? 2\r\n : 3;\r\n // Add a second list item with an empty default start node\r\n const newNextTypeAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);\r\n const nextType = ((_a = type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.createAndFill(newNextTypeAttributes)) || undefined;\r\n wrap = wrap.append(Fragment.from(type.createAndFill(null, nextType) || undefined));\r\n const start = $from.before($from.depth - (depthBefore - 1));\r\n tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0));\r\n let sel = -1;\r\n tr.doc.nodesBetween(start, tr.doc.content.size, (n, pos) => {\r\n if (sel > -1) {\r\n return false;\r\n }\r\n if (n.isTextblock && n.content.size === 0) {\r\n sel = pos + 1;\r\n }\r\n });\r\n if (sel > -1) {\r\n tr.setSelection(TextSelection.near(tr.doc.resolve(sel)));\r\n }\r\n tr.scrollIntoView();\r\n }\r\n return true;\r\n }\r\n const nextType = $to.pos === $from.end()\r\n ? grandParent.contentMatchAt(0).defaultType\r\n : null;\r\n const newTypeAttributes = getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs);\r\n const newNextTypeAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);\r\n tr.delete($from.pos, $to.pos);\r\n const types = nextType\r\n ? [{ type, attrs: newTypeAttributes }, { type: nextType, attrs: newNextTypeAttributes }]\r\n : [{ type, attrs: newTypeAttributes }];\r\n if (!canSplit(tr.doc, $from.pos, 2)) {\r\n return false;\r\n }\r\n if (dispatch) {\r\n tr.split($from.pos, 2, types).scrollIntoView();\r\n }\r\n return true;\r\n};\n\nvar splitListItem$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n splitListItem: splitListItem\n});\n\nfunction findParentNodeClosestToPos($pos, predicate) {\r\n for (let i = $pos.depth; i > 0; i -= 1) {\r\n const node = $pos.node(i);\r\n if (predicate(node)) {\r\n return {\r\n pos: i > 0 ? $pos.before(i) : 0,\r\n start: $pos.start(i),\r\n depth: i,\r\n node,\r\n };\r\n }\r\n }\r\n}\n\nfunction findParentNode(predicate) {\r\n return (selection) => findParentNodeClosestToPos(selection.$from, predicate);\r\n}\n\nfunction splitExtensions(extensions) {\r\n const baseExtensions = extensions.filter(extension => extension.type === 'extension');\r\n const nodeExtensions = extensions.filter(extension => extension.type === 'node');\r\n const markExtensions = extensions.filter(extension => extension.type === 'mark');\r\n return {\r\n baseExtensions,\r\n nodeExtensions,\r\n markExtensions,\r\n };\r\n}\n\nfunction isList(name, extensions) {\r\n const { nodeExtensions } = splitExtensions(extensions);\r\n const extension = nodeExtensions.find(item => item.name === name);\r\n if (!extension) {\r\n return false;\r\n }\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n const group = callOrReturn(getExtensionField(extension, 'group', context));\r\n if (typeof group !== 'string') {\r\n return false;\r\n }\r\n return group.split(' ').includes('list');\r\n}\n\nconst joinListBackwards = (tr, listType) => {\r\n const list = findParentNode(node => node.type === listType)(tr.selection);\r\n if (!list) {\r\n return true;\r\n }\r\n const before = tr.doc.resolve(Math.max(0, list.pos - 1)).before(list.depth);\r\n const nodeBefore = tr.doc.nodeAt(before);\r\n const canJoinBackwards = list.node.type === (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type)\r\n && canJoin(tr.doc, list.pos);\r\n if (!canJoinBackwards) {\r\n return true;\r\n }\r\n tr.join(list.pos);\r\n return true;\r\n};\r\nconst joinListForwards = (tr, listType) => {\r\n const list = findParentNode(node => node.type === listType)(tr.selection);\r\n if (!list) {\r\n return true;\r\n }\r\n const after = tr.doc.resolve(list.start).after(list.depth);\r\n const nodeAfter = tr.doc.nodeAt(after);\r\n const canJoinForwards = list.node.type === (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.type)\r\n && canJoin(tr.doc, after);\r\n if (!canJoinForwards) {\r\n return true;\r\n }\r\n tr.join(after);\r\n return true;\r\n};\r\nconst toggleList = (listTypeOrName, itemTypeOrName) => ({ editor, tr, state, dispatch, chain, commands, can, }) => {\r\n const { extensions } = editor.extensionManager;\r\n const listType = getNodeType(listTypeOrName, state.schema);\r\n const itemType = getNodeType(itemTypeOrName, state.schema);\r\n const { selection } = state;\r\n const { $from, $to } = selection;\r\n const range = $from.blockRange($to);\r\n if (!range) {\r\n return false;\r\n }\r\n const parentList = findParentNode(node => isList(node.type.name, extensions))(selection);\r\n if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {\r\n // remove list\r\n if (parentList.node.type === listType) {\r\n return commands.liftListItem(itemType);\r\n }\r\n // change list type\r\n if (isList(parentList.node.type.name, extensions)\r\n && listType.validContent(parentList.node.content)\r\n && dispatch) {\r\n return chain()\r\n .command(() => {\r\n tr.setNodeMarkup(parentList.pos, listType);\r\n return true;\r\n })\r\n .command(() => joinListBackwards(tr, listType))\r\n .command(() => joinListForwards(tr, listType))\r\n .run();\r\n }\r\n }\r\n return chain()\r\n // try to convert node to default node if needed\r\n .command(() => {\r\n const canWrapInList = can().wrapInList(listType);\r\n if (canWrapInList) {\r\n return true;\r\n }\r\n return commands.clearNodes();\r\n })\r\n .wrapInList(listType)\r\n .command(() => joinListBackwards(tr, listType))\r\n .command(() => joinListForwards(tr, listType))\r\n .run();\r\n};\n\nvar toggleList$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n toggleList: toggleList\n});\n\nfunction isMarkActive(state, typeOrName, attributes = {}) {\r\n const { empty, ranges } = state.selection;\r\n const type = typeOrName\r\n ? getMarkType(typeOrName, state.schema)\r\n : null;\r\n if (empty) {\r\n return !!(state.storedMarks || state.selection.$from.marks())\r\n .filter(mark => {\r\n if (!type) {\r\n return true;\r\n }\r\n return type.name === mark.type.name;\r\n })\r\n .find(mark => objectIncludes(mark.attrs, attributes, { strict: false }));\r\n }\r\n let selectionRange = 0;\r\n const markRanges = [];\r\n ranges.forEach(({ $from, $to }) => {\r\n const from = $from.pos;\r\n const to = $to.pos;\r\n state.doc.nodesBetween(from, to, (node, pos) => {\r\n if (!node.isText && !node.marks.length) {\r\n return;\r\n }\r\n const relativeFrom = Math.max(from, pos);\r\n const relativeTo = Math.min(to, pos + node.nodeSize);\r\n const range = relativeTo - relativeFrom;\r\n selectionRange += range;\r\n markRanges.push(...node.marks.map(mark => ({\r\n mark,\r\n from: relativeFrom,\r\n to: relativeTo,\r\n })));\r\n });\r\n });\r\n if (selectionRange === 0) {\r\n return false;\r\n }\r\n // calculate range of matched mark\r\n const matchedRange = markRanges\r\n .filter(markRange => {\r\n if (!type) {\r\n return true;\r\n }\r\n return type.name === markRange.mark.type.name;\r\n })\r\n .filter(markRange => objectIncludes(markRange.mark.attrs, attributes, { strict: false }))\r\n .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0);\r\n // calculate range of marks that excludes the searched mark\r\n // for example `code` doesn’t allow any other marks\r\n const excludedRange = markRanges\r\n .filter(markRange => {\r\n if (!type) {\r\n return true;\r\n }\r\n return markRange.mark.type !== type\r\n && markRange.mark.type.excludes(type);\r\n })\r\n .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0);\r\n // we only include the result of `excludedRange`\r\n // if there is a match at all\r\n const range = matchedRange > 0\r\n ? matchedRange + excludedRange\r\n : matchedRange;\r\n return range >= selectionRange;\r\n}\n\nconst toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state, commands }) => {\r\n const { extendEmptyMarkRange = false } = options;\r\n const type = getMarkType(typeOrName, state.schema);\r\n const isActive = isMarkActive(state, type, attributes);\r\n if (isActive) {\r\n return commands.unsetMark(type, { extendEmptyMarkRange });\r\n }\r\n return commands.setMark(type, attributes);\r\n};\n\nvar toggleMark$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n toggleMark: toggleMark\n});\n\nconst toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state, commands }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n const toggleType = getNodeType(toggleTypeOrName, state.schema);\r\n const isActive = isNodeActive(state, type, attributes);\r\n if (isActive) {\r\n return commands.setNode(toggleType);\r\n }\r\n return commands.setNode(type, attributes);\r\n};\n\nvar toggleNode$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n toggleNode: toggleNode\n});\n\nconst toggleWrap = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n const isActive = isNodeActive(state, type, attributes);\r\n if (isActive) {\r\n return lift$2(state, dispatch);\r\n }\r\n return wrapIn$2(type, attributes)(state, dispatch);\r\n};\n\nvar toggleWrap$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n toggleWrap: toggleWrap\n});\n\nconst undoInputRule = () => ({ state, dispatch }) => {\r\n const plugins = state.plugins;\r\n for (let i = 0; i < plugins.length; i += 1) {\r\n const plugin = plugins[i];\r\n let undoable;\r\n // @ts-ignore\r\n // eslint-disable-next-line\r\n if (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {\r\n if (dispatch) {\r\n const tr = state.tr;\r\n const toUndo = undoable.transform;\r\n for (let j = toUndo.steps.length - 1; j >= 0; j -= 1) {\r\n tr.step(toUndo.steps[j].invert(toUndo.docs[j]));\r\n }\r\n if (undoable.text) {\r\n const marks = tr.doc.resolve(undoable.from).marks();\r\n tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks));\r\n }\r\n else {\r\n tr.delete(undoable.from, undoable.to);\r\n }\r\n }\r\n return true;\r\n }\r\n }\r\n return false;\r\n};\n\nvar undoInputRule$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n undoInputRule: undoInputRule\n});\n\nconst unsetAllMarks = () => ({ tr, dispatch }) => {\r\n const { selection } = tr;\r\n const { empty, ranges } = selection;\r\n if (empty) {\r\n return true;\r\n }\r\n if (dispatch) {\r\n ranges.forEach(range => {\r\n tr.removeMark(range.$from.pos, range.$to.pos);\r\n });\r\n }\r\n return true;\r\n};\n\nvar unsetAllMarks$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n unsetAllMarks: unsetAllMarks\n});\n\nconst unsetMark = (typeOrName, options = {}) => ({ tr, state, dispatch }) => {\r\n var _a;\r\n const { extendEmptyMarkRange = false } = options;\r\n const { selection } = tr;\r\n const type = getMarkType(typeOrName, state.schema);\r\n const { $from, empty, ranges } = selection;\r\n if (!dispatch) {\r\n return true;\r\n }\r\n if (empty && extendEmptyMarkRange) {\r\n let { from, to } = selection;\r\n const attrs = (_a = $from.marks().find(mark => mark.type === type)) === null || _a === void 0 ? void 0 : _a.attrs;\r\n const range = getMarkRange($from, type, attrs);\r\n if (range) {\r\n from = range.from;\r\n to = range.to;\r\n }\r\n tr.removeMark(from, to, type);\r\n }\r\n else {\r\n ranges.forEach(range => {\r\n tr.removeMark(range.$from.pos, range.$to.pos, type);\r\n });\r\n }\r\n tr.removeStoredMark(type);\r\n return true;\r\n};\n\nvar unsetMark$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n unsetMark: unsetMark\n});\n\nconst updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {\r\n let nodeType = null;\r\n let markType = null;\r\n const schemaType = getSchemaTypeNameByName(typeof typeOrName === 'string'\r\n ? typeOrName\r\n : typeOrName.name, state.schema);\r\n if (!schemaType) {\r\n return false;\r\n }\r\n if (schemaType === 'node') {\r\n nodeType = getNodeType(typeOrName, state.schema);\r\n }\r\n if (schemaType === 'mark') {\r\n markType = getMarkType(typeOrName, state.schema);\r\n }\r\n if (dispatch) {\r\n tr.selection.ranges.forEach(range => {\r\n const from = range.$from.pos;\r\n const to = range.$to.pos;\r\n state.doc.nodesBetween(from, to, (node, pos) => {\r\n if (nodeType && nodeType === node.type) {\r\n tr.setNodeMarkup(pos, undefined, {\r\n ...node.attrs,\r\n ...attributes,\r\n });\r\n }\r\n if (markType && node.marks.length) {\r\n node.marks.forEach(mark => {\r\n if (markType === mark.type) {\r\n const trimmedFrom = Math.max(pos, from);\r\n const trimmedTo = Math.min(pos + node.nodeSize, to);\r\n tr.addMark(trimmedFrom, trimmedTo, markType.create({\r\n ...mark.attrs,\r\n ...attributes,\r\n }));\r\n }\r\n });\r\n }\r\n });\r\n });\r\n }\r\n return true;\r\n};\n\nvar updateAttributes$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n updateAttributes: updateAttributes\n});\n\nconst wrapIn = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n const isActive = isNodeActive(state, type, attributes);\r\n if (isActive) {\r\n return false;\r\n }\r\n return wrapIn$2(type, attributes)(state, dispatch);\r\n};\n\nvar wrapIn$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n wrapIn: wrapIn\n});\n\nconst wrapInList = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\r\n const type = getNodeType(typeOrName, state.schema);\r\n return wrapInList$2(type, attributes)(state, dispatch);\r\n};\n\nvar wrapInList$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n wrapInList: wrapInList\n});\n\nconst Commands = Extension.create({\r\n name: 'commands',\r\n addCommands() {\r\n return {\r\n ...blur$1,\r\n ...clearContent$1,\r\n ...clearNodes$1,\r\n ...command$1,\r\n ...createParagraphNear$1,\r\n ...deleteNode$1,\r\n ...deleteRange$1,\r\n ...deleteSelection$1,\r\n ...enter$1,\r\n ...exitCode$1,\r\n ...extendMarkRange$1,\r\n ...first$1,\r\n ...focus$1,\r\n ...forEach$1,\r\n ...insertContent$1,\r\n ...insertContentAt$1,\r\n ...joinBackward$1,\r\n ...joinForward$1,\r\n ...keyboardShortcut$1,\r\n ...lift$1,\r\n ...liftEmptyBlock$1,\r\n ...liftListItem$1,\r\n ...newlineInCode$1,\r\n ...resetAttributes$1,\r\n ...scrollIntoView$1,\r\n ...selectAll$1,\r\n ...selectNodeBackward$1,\r\n ...selectNodeForward$1,\r\n ...selectParentNode$1,\r\n ...setContent$1,\r\n ...setMark$1,\r\n ...setMeta$1,\r\n ...setNode$1,\r\n ...setNodeSelection$1,\r\n ...setTextSelection$1,\r\n ...sinkListItem$1,\r\n ...splitBlock$1,\r\n ...splitListItem$1,\r\n ...toggleList$1,\r\n ...toggleMark$1,\r\n ...toggleNode$1,\r\n ...toggleWrap$1,\r\n ...undoInputRule$1,\r\n ...unsetAllMarks$1,\r\n ...unsetMark$1,\r\n ...updateAttributes$1,\r\n ...wrapIn$1,\r\n ...wrapInList$1,\r\n };\r\n },\r\n});\n\nconst Editable = Extension.create({\r\n name: 'editable',\r\n addProseMirrorPlugins() {\r\n return [\r\n new Plugin({\r\n key: new PluginKey('editable'),\r\n props: {\r\n editable: () => this.editor.options.editable,\r\n },\r\n }),\r\n ];\r\n },\r\n});\n\nconst FocusEvents = Extension.create({\r\n name: 'focusEvents',\r\n addProseMirrorPlugins() {\r\n const { editor } = this;\r\n return [\r\n new Plugin({\r\n key: new PluginKey('focusEvents'),\r\n props: {\r\n handleDOMEvents: {\r\n focus: (view, event) => {\r\n editor.isFocused = true;\r\n const transaction = editor.state.tr\r\n .setMeta('focus', { event })\r\n .setMeta('addToHistory', false);\r\n view.dispatch(transaction);\r\n return false;\r\n },\r\n blur: (view, event) => {\r\n editor.isFocused = false;\r\n const transaction = editor.state.tr\r\n .setMeta('blur', { event })\r\n .setMeta('addToHistory', false);\r\n view.dispatch(transaction);\r\n return false;\r\n },\r\n },\r\n },\r\n }),\r\n ];\r\n },\r\n});\n\nconst Keymap = Extension.create({\r\n name: 'keymap',\r\n addKeyboardShortcuts() {\r\n const handleBackspace = () => this.editor.commands.first(({ commands }) => [\r\n () => commands.undoInputRule(),\r\n () => commands.deleteSelection(),\r\n () => commands.joinBackward(),\r\n () => commands.selectNodeBackward(),\r\n ]);\r\n const handleDelete = () => this.editor.commands.first(({ commands }) => [\r\n () => commands.deleteSelection(),\r\n () => commands.joinForward(),\r\n () => commands.selectNodeForward(),\r\n ]);\r\n return {\r\n Enter: () => this.editor.commands.first(({ commands }) => [\r\n () => commands.newlineInCode(),\r\n () => commands.createParagraphNear(),\r\n () => commands.liftEmptyBlock(),\r\n () => commands.splitBlock(),\r\n ]),\r\n 'Mod-Enter': () => this.editor.commands.exitCode(),\r\n Backspace: handleBackspace,\r\n 'Mod-Backspace': handleBackspace,\r\n 'Shift-Backspace': handleBackspace,\r\n Delete: handleDelete,\r\n 'Mod-Delete': handleDelete,\r\n 'Mod-a': () => this.editor.commands.selectAll(),\r\n };\r\n },\r\n});\n\nconst Tabindex = Extension.create({\r\n name: 'tabindex',\r\n addProseMirrorPlugins() {\r\n return [\r\n new Plugin({\r\n key: new PluginKey('tabindex'),\r\n props: {\r\n attributes: {\r\n tabindex: '0',\r\n },\r\n },\r\n }),\r\n ];\r\n },\r\n});\n\nvar extensions = /*#__PURE__*/Object.freeze({\n __proto__: null,\n ClipboardTextSerializer: ClipboardTextSerializer,\n Commands: Commands,\n Editable: Editable,\n FocusEvents: FocusEvents,\n Keymap: Keymap,\n Tabindex: Tabindex\n});\n\nfunction getNodeAttributes(state, typeOrName) {\r\n const type = getNodeType(typeOrName, state.schema);\r\n const { from, to } = state.selection;\r\n const nodes = [];\r\n state.doc.nodesBetween(from, to, node => {\r\n nodes.push(node);\r\n });\r\n const node = nodes\r\n .reverse()\r\n .find(nodeItem => nodeItem.type.name === type.name);\r\n if (!node) {\r\n return {};\r\n }\r\n return { ...node.attrs };\r\n}\n\nfunction getAttributes(state, typeOrName) {\r\n const schemaType = getSchemaTypeNameByName(typeof typeOrName === 'string'\r\n ? typeOrName\r\n : typeOrName.name, state.schema);\r\n if (schemaType === 'node') {\r\n return getNodeAttributes(state, typeOrName);\r\n }\r\n if (schemaType === 'mark') {\r\n return getMarkAttributes(state, typeOrName);\r\n }\r\n return {};\r\n}\n\nfunction isActive(state, name, attributes = {}) {\r\n if (!name) {\r\n return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes);\r\n }\r\n const schemaType = getSchemaTypeNameByName(name, state.schema);\r\n if (schemaType === 'node') {\r\n return isNodeActive(state, name, attributes);\r\n }\r\n if (schemaType === 'mark') {\r\n return isMarkActive(state, name, attributes);\r\n }\r\n return false;\r\n}\n\nfunction getHTMLFromFragment(fragment, schema) {\r\n const documentFragment = DOMSerializer\r\n .fromSchema(schema)\r\n .serializeFragment(fragment);\r\n const temporaryDocument = document.implementation.createHTMLDocument();\r\n const container = temporaryDocument.createElement('div');\r\n container.appendChild(documentFragment);\r\n return container.innerHTML;\r\n}\n\nfunction getText(node, options) {\r\n const range = {\r\n from: 0,\r\n to: node.content.size,\r\n };\r\n return getTextBetween(node, range, options);\r\n}\n\nfunction isNodeEmpty(node) {\r\n var _a;\r\n const defaultContent = (_a = node.type.createAndFill()) === null || _a === void 0 ? void 0 : _a.toJSON();\r\n const content = node.toJSON();\r\n return JSON.stringify(defaultContent) === JSON.stringify(content);\r\n}\n\nfunction createStyleTag(style) {\r\n const tipTapStyleTag = document.querySelector('style[data-tiptap-style]');\r\n if (tipTapStyleTag !== null) {\r\n return tipTapStyleTag;\r\n }\r\n const styleNode = document.createElement('style');\r\n styleNode.setAttribute('data-tiptap-style', '');\r\n styleNode.innerHTML = style;\r\n document.getElementsByTagName('head')[0].appendChild(styleNode);\r\n return styleNode;\r\n}\n\nfunction createChainableState(config) {\r\n const { state, transaction } = config;\r\n let { selection } = transaction;\r\n let { doc } = transaction;\r\n let { storedMarks } = transaction;\r\n return {\r\n ...state,\r\n schema: state.schema,\r\n plugins: state.plugins,\r\n apply: state.apply.bind(state),\r\n applyTransaction: state.applyTransaction.bind(state),\r\n reconfigure: state.reconfigure.bind(state),\r\n toJSON: state.toJSON.bind(state),\r\n get storedMarks() {\r\n return storedMarks;\r\n },\r\n get selection() {\r\n return selection;\r\n },\r\n get doc() {\r\n return doc;\r\n },\r\n get tr() {\r\n selection = transaction.selection;\r\n doc = transaction.doc;\r\n storedMarks = transaction.storedMarks;\r\n return transaction;\r\n },\r\n };\r\n}\n\nclass CommandManager {\r\n constructor(props) {\r\n this.editor = props.editor;\r\n this.rawCommands = this.editor.extensionManager.commands;\r\n this.customState = props.state;\r\n }\r\n get hasCustomState() {\r\n return !!this.customState;\r\n }\r\n get state() {\r\n return this.customState || this.editor.state;\r\n }\r\n get commands() {\r\n const { rawCommands, editor, state } = this;\r\n const { view } = editor;\r\n const { tr } = state;\r\n const props = this.buildProps(tr);\r\n return Object.fromEntries(Object\r\n .entries(rawCommands)\r\n .map(([name, command]) => {\r\n const method = (...args) => {\r\n const callback = command(...args)(props);\r\n if (!tr.getMeta('preventDispatch') && !this.hasCustomState) {\r\n view.dispatch(tr);\r\n }\r\n return callback;\r\n };\r\n return [name, method];\r\n }));\r\n }\r\n get chain() {\r\n return () => this.createChain();\r\n }\r\n get can() {\r\n return () => this.createCan();\r\n }\r\n createChain(startTr, shouldDispatch = true) {\r\n const { rawCommands, editor, state } = this;\r\n const { view } = editor;\r\n const callbacks = [];\r\n const hasStartTransaction = !!startTr;\r\n const tr = startTr || state.tr;\r\n const run = () => {\r\n if (!hasStartTransaction\r\n && shouldDispatch\r\n && !tr.getMeta('preventDispatch')\r\n && !this.hasCustomState) {\r\n view.dispatch(tr);\r\n }\r\n return callbacks.every(callback => callback === true);\r\n };\r\n const chain = {\r\n ...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {\r\n const chainedCommand = (...args) => {\r\n const props = this.buildProps(tr, shouldDispatch);\r\n const callback = command(...args)(props);\r\n callbacks.push(callback);\r\n return chain;\r\n };\r\n return [name, chainedCommand];\r\n })),\r\n run,\r\n };\r\n return chain;\r\n }\r\n createCan(startTr) {\r\n const { rawCommands, state } = this;\r\n const dispatch = undefined;\r\n const tr = startTr || state.tr;\r\n const props = this.buildProps(tr, dispatch);\r\n const formattedCommands = Object.fromEntries(Object\r\n .entries(rawCommands)\r\n .map(([name, command]) => {\r\n return [name, (...args) => command(...args)({ ...props, dispatch })];\r\n }));\r\n return {\r\n ...formattedCommands,\r\n chain: () => this.createChain(tr, dispatch),\r\n };\r\n }\r\n buildProps(tr, shouldDispatch = true) {\r\n const { rawCommands, editor, state } = this;\r\n const { view } = editor;\r\n if (state.storedMarks) {\r\n tr.setStoredMarks(state.storedMarks);\r\n }\r\n const props = {\r\n tr,\r\n editor,\r\n view,\r\n state: createChainableState({\r\n state,\r\n transaction: tr,\r\n }),\r\n dispatch: shouldDispatch\r\n ? () => undefined\r\n : undefined,\r\n chain: () => this.createChain(tr),\r\n can: () => this.createCan(tr),\r\n get commands() {\r\n return Object.fromEntries(Object\r\n .entries(rawCommands)\r\n .map(([name, command]) => {\r\n return [name, (...args) => command(...args)(props)];\r\n }));\r\n },\r\n };\r\n return props;\r\n }\r\n}\n\nclass InputRule {\r\n constructor(config) {\r\n this.find = config.find;\r\n this.handler = config.handler;\r\n }\r\n}\r\nconst inputRuleMatcherHandler = (text, find) => {\r\n if (isRegExp(find)) {\r\n return find.exec(text);\r\n }\r\n const inputRuleMatch = find(text);\r\n if (!inputRuleMatch) {\r\n return null;\r\n }\r\n const result = [];\r\n result.push(inputRuleMatch.text);\r\n result.index = inputRuleMatch.index;\r\n result.input = text;\r\n result.data = inputRuleMatch.data;\r\n if (inputRuleMatch.replaceWith) {\r\n if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {\r\n console.warn('[tiptap warn]: \"inputRuleMatch.replaceWith\" must be part of \"inputRuleMatch.text\".');\r\n }\r\n result.push(inputRuleMatch.replaceWith);\r\n }\r\n return result;\r\n};\r\nfunction run$1(config) {\r\n var _a;\r\n const { editor, from, to, text, rules, plugin, } = config;\r\n const { view } = editor;\r\n if (view.composing) {\r\n return false;\r\n }\r\n const $from = view.state.doc.resolve(from);\r\n if (\r\n // check for code node\r\n $from.parent.type.spec.code\r\n // check for code mark\r\n || !!((_a = ($from.nodeBefore || $from.nodeAfter)) === null || _a === void 0 ? void 0 : _a.marks.find(mark => mark.type.spec.code))) {\r\n return false;\r\n }\r\n let matched = false;\r\n const maxMatch = 500;\r\n const textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - maxMatch), $from.parentOffset, undefined, '\\ufffc') + text;\r\n rules.forEach(rule => {\r\n if (matched) {\r\n return;\r\n }\r\n const match = inputRuleMatcherHandler(textBefore, rule.find);\r\n if (!match) {\r\n return;\r\n }\r\n const tr = view.state.tr;\r\n const state = createChainableState({\r\n state: view.state,\r\n transaction: tr,\r\n });\r\n const range = {\r\n from: from - (match[0].length - text.length),\r\n to,\r\n };\r\n const { commands, chain, can } = new CommandManager({\r\n editor,\r\n state,\r\n });\r\n rule.handler({\r\n state,\r\n range,\r\n match,\r\n commands,\r\n chain,\r\n can,\r\n });\r\n // stop if there are no changes\r\n if (!tr.steps.length) {\r\n return;\r\n }\r\n // store transform as meta data\r\n // so we can undo input rules within the `undoInputRules` command\r\n tr.setMeta(plugin, {\r\n transform: tr,\r\n from,\r\n to,\r\n text,\r\n });\r\n view.dispatch(tr);\r\n matched = true;\r\n });\r\n return matched;\r\n}\r\n/**\r\n * Create an input rules plugin. When enabled, it will cause text\r\n * input that matches any of the given rules to trigger the rule’s\r\n * action.\r\n */\r\nfunction inputRulesPlugin(props) {\r\n const { editor, rules } = props;\r\n const plugin = new Plugin({\r\n state: {\r\n init() {\r\n return null;\r\n },\r\n apply(tr, prev) {\r\n const stored = tr.getMeta(this);\r\n if (stored) {\r\n return stored;\r\n }\r\n return tr.selectionSet || tr.docChanged\r\n ? null\r\n : prev;\r\n },\r\n },\r\n props: {\r\n handleTextInput(view, from, to, text) {\r\n return run$1({\r\n editor,\r\n from,\r\n to,\r\n text,\r\n rules,\r\n plugin,\r\n });\r\n },\r\n handleDOMEvents: {\r\n compositionend: view => {\r\n setTimeout(() => {\r\n const { $cursor } = view.state.selection;\r\n if ($cursor) {\r\n run$1({\r\n editor,\r\n from: $cursor.pos,\r\n to: $cursor.pos,\r\n text: '',\r\n rules,\r\n plugin,\r\n });\r\n }\r\n });\r\n return false;\r\n },\r\n },\r\n // add support for input rules to trigger on enter\r\n // this is useful for example for code blocks\r\n handleKeyDown(view, event) {\r\n if (event.key !== 'Enter') {\r\n return false;\r\n }\r\n const { $cursor } = view.state.selection;\r\n if ($cursor) {\r\n return run$1({\r\n editor,\r\n from: $cursor.pos,\r\n to: $cursor.pos,\r\n text: '\\n',\r\n rules,\r\n plugin,\r\n });\r\n }\r\n return false;\r\n },\r\n },\r\n // @ts-ignore\r\n isInputRules: true,\r\n });\r\n return plugin;\r\n}\n\nfunction isNumber(value) {\r\n return typeof value === 'number';\r\n}\n\nclass PasteRule {\r\n constructor(config) {\r\n this.find = config.find;\r\n this.handler = config.handler;\r\n }\r\n}\r\nconst pasteRuleMatcherHandler = (text, find) => {\r\n if (isRegExp(find)) {\r\n return [...text.matchAll(find)];\r\n }\r\n const matches = find(text);\r\n if (!matches) {\r\n return [];\r\n }\r\n return matches.map(pasteRuleMatch => {\r\n const result = [];\r\n result.push(pasteRuleMatch.text);\r\n result.index = pasteRuleMatch.index;\r\n result.input = text;\r\n result.data = pasteRuleMatch.data;\r\n if (pasteRuleMatch.replaceWith) {\r\n if (!pasteRuleMatch.text.includes(pasteRuleMatch.replaceWith)) {\r\n console.warn('[tiptap warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\".');\r\n }\r\n result.push(pasteRuleMatch.replaceWith);\r\n }\r\n return result;\r\n });\r\n};\r\nfunction run(config) {\r\n const { editor, state, from, to, rules, } = config;\r\n const { commands, chain, can } = new CommandManager({\r\n editor,\r\n state,\r\n });\r\n state.doc.nodesBetween(from, to, (node, pos) => {\r\n if (!node.isTextblock || node.type.spec.code) {\r\n return;\r\n }\r\n const resolvedFrom = Math.max(from, pos);\r\n const resolvedTo = Math.min(to, pos + node.content.size);\r\n const textToMatch = node.textBetween(resolvedFrom - pos, resolvedTo - pos, undefined, '\\ufffc');\r\n rules.forEach(rule => {\r\n const matches = pasteRuleMatcherHandler(textToMatch, rule.find);\r\n matches.forEach(match => {\r\n if (match.index === undefined) {\r\n return;\r\n }\r\n const start = resolvedFrom + match.index + 1;\r\n const end = start + match[0].length;\r\n const range = {\r\n from: state.tr.mapping.map(start),\r\n to: state.tr.mapping.map(end),\r\n };\r\n rule.handler({\r\n state,\r\n range,\r\n match,\r\n commands,\r\n chain,\r\n can,\r\n });\r\n });\r\n });\r\n });\r\n}\r\n/**\r\n * Create an paste rules plugin. When enabled, it will cause pasted\r\n * text that matches any of the given rules to trigger the rule’s\r\n * action.\r\n */\r\nfunction pasteRulesPlugin(props) {\r\n const { editor, rules } = props;\r\n let isProseMirrorHTML = false;\r\n const plugin = new Plugin({\r\n props: {\r\n handlePaste: (view, event) => {\r\n var _a;\r\n const html = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text/html');\r\n isProseMirrorHTML = !!(html === null || html === void 0 ? void 0 : html.includes('data-pm-slice'));\r\n return false;\r\n },\r\n },\r\n appendTransaction: (transactions, oldState, state) => {\r\n const transaction = transactions[0];\r\n // stop if there is not a paste event\r\n if (!transaction.getMeta('paste') || isProseMirrorHTML) {\r\n return;\r\n }\r\n // stop if there is no changed range\r\n const { doc, before } = transaction;\r\n const from = before.content.findDiffStart(doc.content);\r\n const to = before.content.findDiffEnd(doc.content);\r\n if (!isNumber(from) || !to || from === to.b) {\r\n return;\r\n }\r\n // build a chainable state\r\n // so we can use a single transaction for all paste rules\r\n const tr = state.tr;\r\n const chainableState = createChainableState({\r\n state,\r\n transaction: tr,\r\n });\r\n run({\r\n editor,\r\n state: chainableState,\r\n from: Math.max(from - 1, 0),\r\n to: to.b,\r\n rules,\r\n plugin,\r\n });\r\n // stop if there are no changes\r\n if (!tr.steps.length) {\r\n return;\r\n }\r\n return tr;\r\n },\r\n // @ts-ignore\r\n isPasteRules: true,\r\n });\r\n return plugin;\r\n}\n\n/**\r\n * Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.\r\n * @param extensions List of extensions\r\n */\r\nfunction getAttributesFromExtensions(extensions) {\r\n const extensionAttributes = [];\r\n const { nodeExtensions, markExtensions } = splitExtensions(extensions);\r\n const nodeAndMarkExtensions = [...nodeExtensions, ...markExtensions];\r\n const defaultAttribute = {\r\n default: null,\r\n rendered: true,\r\n renderHTML: null,\r\n parseHTML: null,\r\n keepOnSplit: true,\r\n };\r\n extensions.forEach(extension => {\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n const addGlobalAttributes = getExtensionField(extension, 'addGlobalAttributes', context);\r\n if (!addGlobalAttributes) {\r\n return;\r\n }\r\n // TODO: remove `as GlobalAttributes`\r\n const globalAttributes = addGlobalAttributes();\r\n globalAttributes.forEach(globalAttribute => {\r\n globalAttribute.types.forEach(type => {\r\n Object\r\n .entries(globalAttribute.attributes)\r\n .forEach(([name, attribute]) => {\r\n extensionAttributes.push({\r\n type,\r\n name,\r\n attribute: {\r\n ...defaultAttribute,\r\n ...attribute,\r\n },\r\n });\r\n });\r\n });\r\n });\r\n });\r\n nodeAndMarkExtensions.forEach(extension => {\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n const addAttributes = getExtensionField(extension, 'addAttributes', context);\r\n if (!addAttributes) {\r\n return;\r\n }\r\n // TODO: remove `as Attributes`\r\n const attributes = addAttributes();\r\n Object\r\n .entries(attributes)\r\n .forEach(([name, attribute]) => {\r\n extensionAttributes.push({\r\n type: extension.name,\r\n name,\r\n attribute: {\r\n ...defaultAttribute,\r\n ...attribute,\r\n },\r\n });\r\n });\r\n });\r\n return extensionAttributes;\r\n}\n\nfunction mergeAttributes(...objects) {\r\n return objects\r\n .filter(item => !!item)\r\n .reduce((items, item) => {\r\n const mergedAttributes = { ...items };\r\n Object.entries(item).forEach(([key, value]) => {\r\n const exists = mergedAttributes[key];\r\n if (!exists) {\r\n mergedAttributes[key] = value;\r\n return;\r\n }\r\n if (key === 'class') {\r\n mergedAttributes[key] = [mergedAttributes[key], value].join(' ');\r\n }\r\n else if (key === 'style') {\r\n mergedAttributes[key] = [mergedAttributes[key], value].join('; ');\r\n }\r\n else {\r\n mergedAttributes[key] = value;\r\n }\r\n });\r\n return mergedAttributes;\r\n }, {});\r\n}\n\nfunction getRenderedAttributes(nodeOrMark, extensionAttributes) {\r\n return extensionAttributes\r\n .filter(item => item.attribute.rendered)\r\n .map(item => {\r\n if (!item.attribute.renderHTML) {\r\n return {\r\n [item.name]: nodeOrMark.attrs[item.name],\r\n };\r\n }\r\n return item.attribute.renderHTML(nodeOrMark.attrs) || {};\r\n })\r\n .reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {});\r\n}\n\nfunction isEmptyObject(value = {}) {\r\n return Object.keys(value).length === 0 && value.constructor === Object;\r\n}\n\nfunction fromString(value) {\r\n if (typeof value !== 'string') {\r\n return value;\r\n }\r\n if (value.match(/^[+-]?(?:\\d*\\.)?\\d+$/)) {\r\n return Number(value);\r\n }\r\n if (value === 'true') {\r\n return true;\r\n }\r\n if (value === 'false') {\r\n return false;\r\n }\r\n return value;\r\n}\n\n/**\r\n * This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).\r\n * Cancels when `getAttrs` returned `false`.\r\n * @param parseRule ProseMirror ParseRule\r\n * @param extensionAttributes List of attributes to inject\r\n */\r\nfunction injectExtensionAttributesToParseRule(parseRule, extensionAttributes) {\r\n if (parseRule.style) {\r\n return parseRule;\r\n }\r\n return {\r\n ...parseRule,\r\n getAttrs: node => {\r\n const oldAttributes = parseRule.getAttrs\r\n ? parseRule.getAttrs(node)\r\n : parseRule.attrs;\r\n if (oldAttributes === false) {\r\n return false;\r\n }\r\n const newAttributes = extensionAttributes\r\n .filter(item => item.attribute.rendered)\r\n .reduce((items, item) => {\r\n const value = item.attribute.parseHTML\r\n ? item.attribute.parseHTML(node)\r\n : fromString(node.getAttribute(item.name));\r\n if (isObject(value)) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"parseHTML\" for your attribute \"${item.name}\" returns an object but should return the value itself. If this is expected you can ignore this message. This warning will be removed in one of the next releases. Further information: https://github.com/ueberdosis/tiptap/issues/1863`);\r\n }\r\n if (value === null || value === undefined) {\r\n return items;\r\n }\r\n return {\r\n ...items,\r\n [item.name]: value,\r\n };\r\n }, {});\r\n return { ...oldAttributes, ...newAttributes };\r\n },\r\n };\r\n}\n\nfunction cleanUpSchemaItem(data) {\r\n return Object.fromEntries(Object.entries(data).filter(([key, value]) => {\r\n if (key === 'attrs' && isEmptyObject(value)) {\r\n return false;\r\n }\r\n return value !== null && value !== undefined;\r\n }));\r\n}\r\nfunction getSchemaByResolvedExtensions(extensions) {\r\n var _a;\r\n const allAttributes = getAttributesFromExtensions(extensions);\r\n const { nodeExtensions, markExtensions } = splitExtensions(extensions);\r\n const topNode = (_a = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))) === null || _a === void 0 ? void 0 : _a.name;\r\n const nodes = Object.fromEntries(nodeExtensions.map(extension => {\r\n const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name);\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n const extraNodeFields = extensions.reduce((fields, e) => {\r\n const extendNodeSchema = getExtensionField(e, 'extendNodeSchema', context);\r\n return {\r\n ...fields,\r\n ...(extendNodeSchema ? extendNodeSchema(extension) : {}),\r\n };\r\n }, {});\r\n const schema = cleanUpSchemaItem({\r\n ...extraNodeFields,\r\n content: callOrReturn(getExtensionField(extension, 'content', context)),\r\n marks: callOrReturn(getExtensionField(extension, 'marks', context)),\r\n group: callOrReturn(getExtensionField(extension, 'group', context)),\r\n inline: callOrReturn(getExtensionField(extension, 'inline', context)),\r\n atom: callOrReturn(getExtensionField(extension, 'atom', context)),\r\n selectable: callOrReturn(getExtensionField(extension, 'selectable', context)),\r\n draggable: callOrReturn(getExtensionField(extension, 'draggable', context)),\r\n code: callOrReturn(getExtensionField(extension, 'code', context)),\r\n defining: callOrReturn(getExtensionField(extension, 'defining', context)),\r\n isolating: callOrReturn(getExtensionField(extension, 'isolating', context)),\r\n attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => {\r\n var _a;\r\n return [extensionAttribute.name, { default: (_a = extensionAttribute === null || extensionAttribute === void 0 ? void 0 : extensionAttribute.attribute) === null || _a === void 0 ? void 0 : _a.default }];\r\n })),\r\n });\r\n const parseHTML = callOrReturn(getExtensionField(extension, 'parseHTML', context));\r\n if (parseHTML) {\r\n schema.parseDOM = parseHTML\r\n .map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes));\r\n }\r\n const renderHTML = getExtensionField(extension, 'renderHTML', context);\r\n if (renderHTML) {\r\n schema.toDOM = node => renderHTML({\r\n node,\r\n HTMLAttributes: getRenderedAttributes(node, extensionAttributes),\r\n });\r\n }\r\n const renderText = getExtensionField(extension, 'renderText', context);\r\n if (renderText) {\r\n schema.toText = renderText;\r\n }\r\n return [extension.name, schema];\r\n }));\r\n const marks = Object.fromEntries(markExtensions.map(extension => {\r\n const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name);\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n const extraMarkFields = extensions.reduce((fields, e) => {\r\n const extendMarkSchema = getExtensionField(e, 'extendMarkSchema', context);\r\n return {\r\n ...fields,\r\n ...(extendMarkSchema ? extendMarkSchema(extension) : {}),\r\n };\r\n }, {});\r\n const schema = cleanUpSchemaItem({\r\n ...extraMarkFields,\r\n inclusive: callOrReturn(getExtensionField(extension, 'inclusive', context)),\r\n excludes: callOrReturn(getExtensionField(extension, 'excludes', context)),\r\n group: callOrReturn(getExtensionField(extension, 'group', context)),\r\n spanning: callOrReturn(getExtensionField(extension, 'spanning', context)),\r\n code: callOrReturn(getExtensionField(extension, 'code', context)),\r\n attrs: Object.fromEntries(extensionAttributes.map(extensionAttribute => {\r\n var _a;\r\n return [extensionAttribute.name, { default: (_a = extensionAttribute === null || extensionAttribute === void 0 ? void 0 : extensionAttribute.attribute) === null || _a === void 0 ? void 0 : _a.default }];\r\n })),\r\n });\r\n const parseHTML = callOrReturn(getExtensionField(extension, 'parseHTML', context));\r\n if (parseHTML) {\r\n schema.parseDOM = parseHTML\r\n .map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes));\r\n }\r\n const renderHTML = getExtensionField(extension, 'renderHTML', context);\r\n if (renderHTML) {\r\n schema.toDOM = mark => renderHTML({\r\n mark,\r\n HTMLAttributes: getRenderedAttributes(mark, extensionAttributes),\r\n });\r\n }\r\n return [extension.name, schema];\r\n }));\r\n return new Schema({\r\n topNode,\r\n nodes,\r\n marks,\r\n });\r\n}\n\nfunction getSchemaTypeByName(name, schema) {\r\n return schema.nodes[name] || schema.marks[name] || null;\r\n}\n\nfunction isExtensionRulesEnabled(extension, enabled) {\r\n if (Array.isArray(enabled)) {\r\n return enabled.some(enabledExtension => {\r\n const name = typeof enabledExtension === 'string'\r\n ? enabledExtension\r\n : enabledExtension.name;\r\n return name === extension.name;\r\n });\r\n }\r\n return enabled;\r\n}\n\nfunction findDuplicates(items) {\r\n const filtered = items.filter((el, index) => items.indexOf(el) !== index);\r\n return [...new Set(filtered)];\r\n}\n\nclass ExtensionManager {\r\n constructor(extensions, editor) {\r\n this.splittableMarks = [];\r\n this.editor = editor;\r\n this.extensions = ExtensionManager.resolve(extensions);\r\n this.schema = getSchemaByResolvedExtensions(this.extensions);\r\n this.extensions.forEach(extension => {\r\n var _a;\r\n // store extension storage in editor\r\n this.editor.extensionStorage[extension.name] = extension.storage;\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n editor: this.editor,\r\n type: getSchemaTypeByName(extension.name, this.schema),\r\n };\r\n if (extension.type === 'mark') {\r\n const keepOnSplit = (_a = callOrReturn(getExtensionField(extension, 'keepOnSplit', context))) !== null && _a !== void 0 ? _a : true;\r\n if (keepOnSplit) {\r\n this.splittableMarks.push(extension.name);\r\n }\r\n }\r\n const onBeforeCreate = getExtensionField(extension, 'onBeforeCreate', context);\r\n if (onBeforeCreate) {\r\n this.editor.on('beforeCreate', onBeforeCreate);\r\n }\r\n const onCreate = getExtensionField(extension, 'onCreate', context);\r\n if (onCreate) {\r\n this.editor.on('create', onCreate);\r\n }\r\n const onUpdate = getExtensionField(extension, 'onUpdate', context);\r\n if (onUpdate) {\r\n this.editor.on('update', onUpdate);\r\n }\r\n const onSelectionUpdate = getExtensionField(extension, 'onSelectionUpdate', context);\r\n if (onSelectionUpdate) {\r\n this.editor.on('selectionUpdate', onSelectionUpdate);\r\n }\r\n const onTransaction = getExtensionField(extension, 'onTransaction', context);\r\n if (onTransaction) {\r\n this.editor.on('transaction', onTransaction);\r\n }\r\n const onFocus = getExtensionField(extension, 'onFocus', context);\r\n if (onFocus) {\r\n this.editor.on('focus', onFocus);\r\n }\r\n const onBlur = getExtensionField(extension, 'onBlur', context);\r\n if (onBlur) {\r\n this.editor.on('blur', onBlur);\r\n }\r\n const onDestroy = getExtensionField(extension, 'onDestroy', context);\r\n if (onDestroy) {\r\n this.editor.on('destroy', onDestroy);\r\n }\r\n });\r\n }\r\n static resolve(extensions) {\r\n const resolvedExtensions = ExtensionManager.sort(ExtensionManager.flatten(extensions));\r\n const duplicatedNames = findDuplicates(resolvedExtensions.map(extension => extension.name));\r\n if (duplicatedNames.length) {\r\n console.warn(`[tiptap warn]: Duplicate extension names found: [${duplicatedNames.map(item => `'${item}'`).join(', ')}]. This can lead to issues.`);\r\n }\r\n return resolvedExtensions;\r\n }\r\n static flatten(extensions) {\r\n return extensions\r\n .map(extension => {\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n const addExtensions = getExtensionField(extension, 'addExtensions', context);\r\n if (addExtensions) {\r\n return [\r\n extension,\r\n ...this.flatten(addExtensions()),\r\n ];\r\n }\r\n return extension;\r\n })\r\n // `Infinity` will break TypeScript so we set a number that is probably high enough\r\n .flat(10);\r\n }\r\n static sort(extensions) {\r\n const defaultPriority = 100;\r\n return extensions.sort((a, b) => {\r\n const priorityA = getExtensionField(a, 'priority') || defaultPriority;\r\n const priorityB = getExtensionField(b, 'priority') || defaultPriority;\r\n if (priorityA > priorityB) {\r\n return -1;\r\n }\r\n if (priorityA < priorityB) {\r\n return 1;\r\n }\r\n return 0;\r\n });\r\n }\r\n get commands() {\r\n return this.extensions.reduce((commands, extension) => {\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n editor: this.editor,\r\n type: getSchemaTypeByName(extension.name, this.schema),\r\n };\r\n const addCommands = getExtensionField(extension, 'addCommands', context);\r\n if (!addCommands) {\r\n return commands;\r\n }\r\n return {\r\n ...commands,\r\n ...addCommands(),\r\n };\r\n }, {});\r\n }\r\n get plugins() {\r\n const { editor } = this;\r\n // With ProseMirror, first plugins within an array are executed first.\r\n // In tiptap, we provide the ability to override plugins,\r\n // so it feels more natural to run plugins at the end of an array first.\r\n // That’s why we have to reverse the `extensions` array and sort again\r\n // based on the `priority` option.\r\n const extensions = ExtensionManager.sort([...this.extensions].reverse());\r\n const inputRules = [];\r\n const pasteRules = [];\r\n const allPlugins = extensions\r\n .map(extension => {\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n editor,\r\n type: getSchemaTypeByName(extension.name, this.schema),\r\n };\r\n const plugins = [];\r\n const addKeyboardShortcuts = getExtensionField(extension, 'addKeyboardShortcuts', context);\r\n if (addKeyboardShortcuts) {\r\n const bindings = Object.fromEntries(Object\r\n .entries(addKeyboardShortcuts())\r\n .map(([shortcut, method]) => {\r\n return [shortcut, () => method({ editor })];\r\n }));\r\n const keyMapPlugin = keymap(bindings);\r\n plugins.push(keyMapPlugin);\r\n }\r\n const addInputRules = getExtensionField(extension, 'addInputRules', context);\r\n if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {\r\n inputRules.push(...addInputRules());\r\n }\r\n const addPasteRules = getExtensionField(extension, 'addPasteRules', context);\r\n if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {\r\n pasteRules.push(...addPasteRules());\r\n }\r\n const addProseMirrorPlugins = getExtensionField(extension, 'addProseMirrorPlugins', context);\r\n if (addProseMirrorPlugins) {\r\n const proseMirrorPlugins = addProseMirrorPlugins();\r\n plugins.push(...proseMirrorPlugins);\r\n }\r\n return plugins;\r\n })\r\n .flat();\r\n return [\r\n inputRulesPlugin({\r\n editor,\r\n rules: inputRules,\r\n }),\r\n pasteRulesPlugin({\r\n editor,\r\n rules: pasteRules,\r\n }),\r\n ...allPlugins,\r\n ];\r\n }\r\n get attributes() {\r\n return getAttributesFromExtensions(this.extensions);\r\n }\r\n get nodeViews() {\r\n const { editor } = this;\r\n const { nodeExtensions } = splitExtensions(this.extensions);\r\n return Object.fromEntries(nodeExtensions\r\n .filter(extension => !!getExtensionField(extension, 'addNodeView'))\r\n .map(extension => {\r\n const extensionAttributes = this.attributes.filter(attribute => attribute.type === extension.name);\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n editor,\r\n type: getNodeType(extension.name, this.schema),\r\n };\r\n const addNodeView = getExtensionField(extension, 'addNodeView', context);\r\n if (!addNodeView) {\r\n return [];\r\n }\r\n const nodeview = (node, view, getPos, decorations) => {\r\n const HTMLAttributes = getRenderedAttributes(node, extensionAttributes);\r\n return addNodeView()({\r\n editor,\r\n node,\r\n getPos,\r\n decorations,\r\n HTMLAttributes,\r\n extension,\r\n });\r\n };\r\n return [extension.name, nodeview];\r\n }));\r\n }\r\n}\n\nclass EventEmitter {\r\n constructor() {\r\n this.callbacks = {};\r\n }\r\n on(event, fn) {\r\n if (!this.callbacks[event]) {\r\n this.callbacks[event] = [];\r\n }\r\n this.callbacks[event].push(fn);\r\n return this;\r\n }\r\n emit(event, ...args) {\r\n const callbacks = this.callbacks[event];\r\n if (callbacks) {\r\n callbacks.forEach(callback => callback.apply(this, args));\r\n }\r\n return this;\r\n }\r\n off(event, fn) {\r\n const callbacks = this.callbacks[event];\r\n if (callbacks) {\r\n if (fn) {\r\n this.callbacks[event] = callbacks.filter(callback => callback !== fn);\r\n }\r\n else {\r\n delete this.callbacks[event];\r\n }\r\n }\r\n return this;\r\n }\r\n removeAllListeners() {\r\n this.callbacks = {};\r\n }\r\n}\n\nconst style = `.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}`;\n\nclass Editor extends EventEmitter {\r\n constructor(options = {}) {\r\n super();\r\n this.isFocused = false;\r\n this.extensionStorage = {};\r\n this.options = {\r\n element: document.createElement('div'),\r\n content: '',\r\n injectCSS: true,\r\n extensions: [],\r\n autofocus: false,\r\n editable: true,\r\n editorProps: {},\r\n parseOptions: {},\r\n enableInputRules: true,\r\n enablePasteRules: true,\r\n enableCoreExtensions: true,\r\n onBeforeCreate: () => null,\r\n onCreate: () => null,\r\n onUpdate: () => null,\r\n onSelectionUpdate: () => null,\r\n onTransaction: () => null,\r\n onFocus: () => null,\r\n onBlur: () => null,\r\n onDestroy: () => null,\r\n };\r\n this.isCapturingTransaction = false;\r\n this.capturedTransaction = null;\r\n this.setOptions(options);\r\n this.createExtensionManager();\r\n this.createCommandManager();\r\n this.createSchema();\r\n this.on('beforeCreate', this.options.onBeforeCreate);\r\n this.emit('beforeCreate', { editor: this });\r\n this.createView();\r\n this.injectCSS();\r\n this.on('create', this.options.onCreate);\r\n this.on('update', this.options.onUpdate);\r\n this.on('selectionUpdate', this.options.onSelectionUpdate);\r\n this.on('transaction', this.options.onTransaction);\r\n this.on('focus', this.options.onFocus);\r\n this.on('blur', this.options.onBlur);\r\n this.on('destroy', this.options.onDestroy);\r\n window.setTimeout(() => {\r\n if (this.isDestroyed) {\r\n return;\r\n }\r\n this.commands.focus(this.options.autofocus);\r\n this.emit('create', { editor: this });\r\n }, 0);\r\n }\r\n /**\r\n * Returns the editor storage.\r\n */\r\n get storage() {\r\n return this.extensionStorage;\r\n }\r\n /**\r\n * An object of all registered commands.\r\n */\r\n get commands() {\r\n return this.commandManager.commands;\r\n }\r\n /**\r\n * Create a command chain to call multiple commands at once.\r\n */\r\n chain() {\r\n return this.commandManager.chain();\r\n }\r\n /**\r\n * Check if a command or a command chain can be executed. Without executing it.\r\n */\r\n can() {\r\n return this.commandManager.can();\r\n }\r\n /**\r\n * Inject CSS styles.\r\n */\r\n injectCSS() {\r\n if (this.options.injectCSS && document) {\r\n this.css = createStyleTag(style);\r\n }\r\n }\r\n /**\r\n * Update editor options.\r\n *\r\n * @param options A list of options\r\n */\r\n setOptions(options = {}) {\r\n this.options = {\r\n ...this.options,\r\n ...options,\r\n };\r\n if (!this.view || !this.state || this.isDestroyed) {\r\n return;\r\n }\r\n if (this.options.editorProps) {\r\n this.view.setProps(this.options.editorProps);\r\n }\r\n this.view.updateState(this.state);\r\n }\r\n /**\r\n * Update editable state of the editor.\r\n */\r\n setEditable(editable) {\r\n this.setOptions({ editable });\r\n }\r\n /**\r\n * Returns whether the editor is editable.\r\n */\r\n get isEditable() {\r\n // since plugins are applied after creating the view\r\n // `editable` is always `true` for one tick.\r\n // that’s why we also have to check for `options.editable`\r\n return this.options.editable\r\n && this.view\r\n && this.view.editable;\r\n }\r\n /**\r\n * Returns the editor state.\r\n */\r\n get state() {\r\n return this.view.state;\r\n }\r\n /**\r\n * Register a ProseMirror plugin.\r\n *\r\n * @param plugin A ProseMirror plugin\r\n * @param handlePlugins Control how to merge the plugin into the existing plugins.\r\n */\r\n registerPlugin(plugin, handlePlugins) {\r\n const plugins = isFunction(handlePlugins)\r\n ? handlePlugins(plugin, this.state.plugins)\r\n : [...this.state.plugins, plugin];\r\n const state = this.state.reconfigure({ plugins });\r\n this.view.updateState(state);\r\n }\r\n /**\r\n * Unregister a ProseMirror plugin.\r\n *\r\n * @param nameOrPluginKey The plugins name\r\n */\r\n unregisterPlugin(nameOrPluginKey) {\r\n if (this.isDestroyed) {\r\n return;\r\n }\r\n const name = typeof nameOrPluginKey === 'string'\r\n ? `${nameOrPluginKey}$`\r\n // @ts-ignore\r\n : nameOrPluginKey.key;\r\n const state = this.state.reconfigure({\r\n // @ts-ignore\r\n plugins: this.state.plugins.filter(plugin => !plugin.key.startsWith(name)),\r\n });\r\n this.view.updateState(state);\r\n }\r\n /**\r\n * Creates an extension manager.\r\n */\r\n createExtensionManager() {\r\n const coreExtensions = this.options.enableCoreExtensions\r\n ? Object.values(extensions)\r\n : [];\r\n const allExtensions = [...coreExtensions, ...this.options.extensions].filter(extension => {\r\n return ['extension', 'node', 'mark'].includes(extension === null || extension === void 0 ? void 0 : extension.type);\r\n });\r\n this.extensionManager = new ExtensionManager(allExtensions, this);\r\n }\r\n /**\r\n * Creates an command manager.\r\n */\r\n createCommandManager() {\r\n this.commandManager = new CommandManager({\r\n editor: this,\r\n });\r\n }\r\n /**\r\n * Creates a ProseMirror schema.\r\n */\r\n createSchema() {\r\n this.schema = this.extensionManager.schema;\r\n }\r\n /**\r\n * Creates a ProseMirror view.\r\n */\r\n createView() {\r\n const doc = createDocument(this.options.content, this.schema, this.options.parseOptions);\r\n const selection = resolveFocusPosition(doc, this.options.autofocus);\r\n this.view = new EditorView(this.options.element, {\r\n ...this.options.editorProps,\r\n dispatchTransaction: this.dispatchTransaction.bind(this),\r\n state: EditorState.create({\r\n doc,\r\n selection,\r\n }),\r\n });\r\n // `editor.view` is not yet available at this time.\r\n // Therefore we will add all plugins and node views directly afterwards.\r\n const newState = this.state.reconfigure({\r\n plugins: this.extensionManager.plugins,\r\n });\r\n this.view.updateState(newState);\r\n this.createNodeViews();\r\n // Let’s store the editor instance in the DOM element.\r\n // So we’ll have access to it for tests.\r\n const dom = this.view.dom;\r\n dom.editor = this;\r\n }\r\n /**\r\n * Creates all node views.\r\n */\r\n createNodeViews() {\r\n this.view.setProps({\r\n nodeViews: this.extensionManager.nodeViews,\r\n });\r\n }\r\n captureTransaction(fn) {\r\n this.isCapturingTransaction = true;\r\n fn();\r\n this.isCapturingTransaction = false;\r\n const tr = this.capturedTransaction;\r\n this.capturedTransaction = null;\r\n return tr;\r\n }\r\n /**\r\n * The callback over which to send transactions (state updates) produced by the view.\r\n *\r\n * @param transaction An editor state transaction\r\n */\r\n dispatchTransaction(transaction) {\r\n if (this.isCapturingTransaction) {\r\n if (!this.capturedTransaction) {\r\n this.capturedTransaction = transaction;\r\n return;\r\n }\r\n transaction.steps.forEach(step => { var _a; return (_a = this.capturedTransaction) === null || _a === void 0 ? void 0 : _a.step(step); });\r\n return;\r\n }\r\n const state = this.state.apply(transaction);\r\n const selectionHasChanged = !this.state.selection.eq(state.selection);\r\n this.view.updateState(state);\r\n this.emit('transaction', {\r\n editor: this,\r\n transaction,\r\n });\r\n if (selectionHasChanged) {\r\n this.emit('selectionUpdate', {\r\n editor: this,\r\n transaction,\r\n });\r\n }\r\n const focus = transaction.getMeta('focus');\r\n const blur = transaction.getMeta('blur');\r\n if (focus) {\r\n this.emit('focus', {\r\n editor: this,\r\n event: focus.event,\r\n transaction,\r\n });\r\n }\r\n if (blur) {\r\n this.emit('blur', {\r\n editor: this,\r\n event: blur.event,\r\n transaction,\r\n });\r\n }\r\n if (!transaction.docChanged || transaction.getMeta('preventUpdate')) {\r\n return;\r\n }\r\n this.emit('update', {\r\n editor: this,\r\n transaction,\r\n });\r\n }\r\n /**\r\n * Get attributes of the currently selected node or mark.\r\n */\r\n getAttributes(nameOrType) {\r\n return getAttributes(this.state, nameOrType);\r\n }\r\n isActive(nameOrAttributes, attributesOrUndefined) {\r\n const name = typeof nameOrAttributes === 'string'\r\n ? nameOrAttributes\r\n : null;\r\n const attributes = typeof nameOrAttributes === 'string'\r\n ? attributesOrUndefined\r\n : nameOrAttributes;\r\n return isActive(this.state, name, attributes);\r\n }\r\n /**\r\n * Get the document as JSON.\r\n */\r\n getJSON() {\r\n return this.state.doc.toJSON();\r\n }\r\n /**\r\n * Get the document as HTML.\r\n */\r\n getHTML() {\r\n return getHTMLFromFragment(this.state.doc.content, this.schema);\r\n }\r\n /**\r\n * Get the document as text.\r\n */\r\n getText(options) {\r\n const { blockSeparator = '\\n\\n', textSerializers = {}, } = options || {};\r\n return getText(this.state.doc, {\r\n blockSeparator,\r\n textSerializers: {\r\n ...textSerializers,\r\n ...getTextSeralizersFromSchema(this.schema),\r\n },\r\n });\r\n }\r\n /**\r\n * Check if there is no content.\r\n */\r\n get isEmpty() {\r\n return isNodeEmpty(this.state.doc);\r\n }\r\n /**\r\n * Get the number of characters for the current document.\r\n *\r\n * @deprecated\r\n */\r\n getCharacterCount() {\r\n console.warn('[tiptap warn]: \"editor.getCharacterCount()\" is deprecated. Please use \"editor.storage.characterCount.characters()\" instead.');\r\n return this.state.doc.content.size - 2;\r\n }\r\n /**\r\n * Destroy the editor.\r\n */\r\n destroy() {\r\n this.emit('destroy');\r\n if (this.view) {\r\n this.view.destroy();\r\n }\r\n this.removeAllListeners();\r\n }\r\n /**\r\n * Check if the editor is already destroyed.\r\n */\r\n get isDestroyed() {\r\n var _a;\r\n // @ts-ignore\r\n return !((_a = this.view) === null || _a === void 0 ? void 0 : _a.docView);\r\n }\r\n}\n\nclass Node {\r\n constructor(config = {}) {\r\n this.type = 'node';\r\n this.name = 'node';\r\n this.parent = null;\r\n this.child = null;\r\n this.config = {\r\n name: this.name,\r\n defaultOptions: {},\r\n };\r\n this.config = {\r\n ...this.config,\r\n ...config,\r\n };\r\n this.name = this.config.name;\r\n if (config.defaultOptions) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${this.name}\".`);\r\n }\r\n // TODO: remove `addOptions` fallback\r\n this.options = this.config.defaultOptions;\r\n if (this.config.addOptions) {\r\n this.options = callOrReturn(getExtensionField(this, 'addOptions', {\r\n name: this.name,\r\n }));\r\n }\r\n this.storage = callOrReturn(getExtensionField(this, 'addStorage', {\r\n name: this.name,\r\n options: this.options,\r\n })) || {};\r\n }\r\n static create(config = {}) {\r\n return new Node(config);\r\n }\r\n configure(options = {}) {\r\n // return a new instance so we can use the same extension\r\n // with different calls of `configure`\r\n const extension = this.extend();\r\n extension.options = mergeDeep(this.options, options);\r\n extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {\r\n name: extension.name,\r\n options: extension.options,\r\n }));\r\n return extension;\r\n }\r\n extend(extendedConfig = {}) {\r\n const extension = new Node(extendedConfig);\r\n extension.parent = this;\r\n this.child = extension;\r\n extension.name = extendedConfig.name\r\n ? extendedConfig.name\r\n : extension.parent.name;\r\n if (extendedConfig.defaultOptions) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${extension.name}\".`);\r\n }\r\n extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {\r\n name: extension.name,\r\n }));\r\n extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {\r\n name: extension.name,\r\n options: extension.options,\r\n }));\r\n return extension;\r\n }\r\n}\n\nclass Mark {\r\n constructor(config = {}) {\r\n this.type = 'mark';\r\n this.name = 'mark';\r\n this.parent = null;\r\n this.child = null;\r\n this.config = {\r\n name: this.name,\r\n defaultOptions: {},\r\n };\r\n this.config = {\r\n ...this.config,\r\n ...config,\r\n };\r\n this.name = this.config.name;\r\n if (config.defaultOptions) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${this.name}\".`);\r\n }\r\n // TODO: remove `addOptions` fallback\r\n this.options = this.config.defaultOptions;\r\n if (this.config.addOptions) {\r\n this.options = callOrReturn(getExtensionField(this, 'addOptions', {\r\n name: this.name,\r\n }));\r\n }\r\n this.storage = callOrReturn(getExtensionField(this, 'addStorage', {\r\n name: this.name,\r\n options: this.options,\r\n })) || {};\r\n }\r\n static create(config = {}) {\r\n return new Mark(config);\r\n }\r\n configure(options = {}) {\r\n // return a new instance so we can use the same extension\r\n // with different calls of `configure`\r\n const extension = this.extend();\r\n extension.options = mergeDeep(this.options, options);\r\n extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {\r\n name: extension.name,\r\n options: extension.options,\r\n }));\r\n return extension;\r\n }\r\n extend(extendedConfig = {}) {\r\n const extension = new Mark(extendedConfig);\r\n extension.parent = this;\r\n this.child = extension;\r\n extension.name = extendedConfig.name\r\n ? extendedConfig.name\r\n : extension.parent.name;\r\n if (extendedConfig.defaultOptions) {\r\n console.warn(`[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${extension.name}\".`);\r\n }\r\n extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {\r\n name: extension.name,\r\n }));\r\n extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {\r\n name: extension.name,\r\n options: extension.options,\r\n }));\r\n return extension;\r\n }\r\n}\n\nclass NodeView {\r\n constructor(component, props, options) {\r\n this.isDragging = false;\r\n this.component = component;\r\n this.editor = props.editor;\r\n this.options = {\r\n stopEvent: null,\r\n ignoreMutation: null,\r\n ...options,\r\n };\r\n this.extension = props.extension;\r\n this.node = props.node;\r\n this.decorations = props.decorations;\r\n this.getPos = props.getPos;\r\n this.mount();\r\n }\r\n mount() {\r\n // eslint-disable-next-line\r\n return;\r\n }\r\n get dom() {\r\n return null;\r\n }\r\n get contentDOM() {\r\n return null;\r\n }\r\n onDragStart(event) {\r\n var _a, _b, _c;\r\n const { view } = this.editor;\r\n const target = event.target;\r\n // get the drag handle element\r\n // `closest` is not available for text nodes so we may have to use its parent\r\n const dragHandle = target.nodeType === 3\r\n ? (_a = target.parentElement) === null || _a === void 0 ? void 0 : _a.closest('[data-drag-handle]')\r\n : target.closest('[data-drag-handle]');\r\n if (!this.dom\r\n || ((_b = this.contentDOM) === null || _b === void 0 ? void 0 : _b.contains(target))\r\n || !dragHandle) {\r\n return;\r\n }\r\n let x = 0;\r\n let y = 0;\r\n // calculate offset for drag element if we use a different drag handle element\r\n if (this.dom !== dragHandle) {\r\n const domBox = this.dom.getBoundingClientRect();\r\n const handleBox = dragHandle.getBoundingClientRect();\r\n x = handleBox.x - domBox.x + event.offsetX;\r\n y = handleBox.y - domBox.y + event.offsetY;\r\n }\r\n (_c = event.dataTransfer) === null || _c === void 0 ? void 0 : _c.setDragImage(this.dom, x, y);\r\n // we need to tell ProseMirror that we want to move the whole node\r\n // so we create a NodeSelection\r\n const selection = NodeSelection.create(view.state.doc, this.getPos());\r\n const transaction = view.state.tr.setSelection(selection);\r\n view.dispatch(transaction);\r\n }\r\n stopEvent(event) {\r\n var _a;\r\n if (!this.dom) {\r\n return false;\r\n }\r\n if (typeof this.options.stopEvent === 'function') {\r\n return this.options.stopEvent({ event });\r\n }\r\n const target = event.target;\r\n const isInElement = this.dom.contains(target) && !((_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.contains(target));\r\n // any event from child nodes should be handled by ProseMirror\r\n if (!isInElement) {\r\n return false;\r\n }\r\n const isDropEvent = event.type === 'drop';\r\n const isInput = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName)\r\n || target.isContentEditable;\r\n // any input event within node views should be ignored by ProseMirror\r\n if (isInput && !isDropEvent) {\r\n return true;\r\n }\r\n const { isEditable } = this.editor;\r\n const { isDragging } = this;\r\n const isDraggable = !!this.node.type.spec.draggable;\r\n const isSelectable = NodeSelection.isSelectable(this.node);\r\n const isCopyEvent = event.type === 'copy';\r\n const isPasteEvent = event.type === 'paste';\r\n const isCutEvent = event.type === 'cut';\r\n const isClickEvent = event.type === 'mousedown';\r\n const isDragEvent = event.type.startsWith('drag');\r\n // ProseMirror tries to drag selectable nodes\r\n // even if `draggable` is set to `false`\r\n // this fix prevents that\r\n if (!isDraggable && isSelectable && isDragEvent) {\r\n event.preventDefault();\r\n }\r\n if (isDraggable && isDragEvent && !isDragging) {\r\n event.preventDefault();\r\n return false;\r\n }\r\n // we have to store that dragging started\r\n if (isDraggable && isEditable && !isDragging && isClickEvent) {\r\n const dragHandle = target.closest('[data-drag-handle]');\r\n const isValidDragHandle = dragHandle\r\n && (this.dom === dragHandle || (this.dom.contains(dragHandle)));\r\n if (isValidDragHandle) {\r\n this.isDragging = true;\r\n document.addEventListener('dragend', () => {\r\n this.isDragging = false;\r\n }, { once: true });\r\n document.addEventListener('mouseup', () => {\r\n this.isDragging = false;\r\n }, { once: true });\r\n }\r\n }\r\n // these events are handled by prosemirror\r\n if (isDragging\r\n || isDropEvent\r\n || isCopyEvent\r\n || isPasteEvent\r\n || isCutEvent\r\n || (isClickEvent && isSelectable)) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n ignoreMutation(mutation) {\r\n if (!this.dom || !this.contentDOM) {\r\n return true;\r\n }\r\n if (typeof this.options.ignoreMutation === 'function') {\r\n return this.options.ignoreMutation({ mutation });\r\n }\r\n // a leaf/atom node is like a black box for ProseMirror\r\n // and should be fully handled by the node view\r\n if (this.node.isLeaf || this.node.isAtom) {\r\n return true;\r\n }\r\n // ProseMirror should handle any selections\r\n if (mutation.type === 'selection') {\r\n return false;\r\n }\r\n // try to prevent a bug on iOS that will break node views on enter\r\n // this is because ProseMirror can’t preventDispatch on enter\r\n // this will lead to a re-render of the node view on enter\r\n // see: https://github.com/ueberdosis/tiptap/issues/1214\r\n if (this.dom.contains(mutation.target)\r\n && mutation.type === 'childList'\r\n && isiOS()\r\n && this.editor.isFocused) {\r\n const changedNodes = [\r\n ...Array.from(mutation.addedNodes),\r\n ...Array.from(mutation.removedNodes),\r\n ];\r\n // we’ll check if every changed node is contentEditable\r\n // to make sure it’s probably mutated by ProseMirror\r\n if (changedNodes.every(node => node.isContentEditable)) {\r\n return false;\r\n }\r\n }\r\n // we will allow mutation contentDOM with attributes\r\n // so we can for example adding classes within our node view\r\n if (this.contentDOM === mutation.target && mutation.type === 'attributes') {\r\n return true;\r\n }\r\n // ProseMirror should handle any changes within contentDOM\r\n if (this.contentDOM.contains(mutation.target)) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n updateAttributes(attributes) {\r\n this.editor.commands.command(({ tr }) => {\r\n const pos = this.getPos();\r\n tr.setNodeMarkup(pos, undefined, {\r\n ...this.node.attrs,\r\n ...attributes,\r\n });\r\n return true;\r\n });\r\n }\r\n deleteNode() {\r\n const from = this.getPos();\r\n const to = from + this.node.nodeSize;\r\n this.editor.commands.deleteRange({ from, to });\r\n }\r\n}\n\nclass Tracker {\r\n constructor(transaction) {\r\n this.transaction = transaction;\r\n this.currentStep = this.transaction.steps.length;\r\n }\r\n map(position) {\r\n let deleted = false;\r\n const mappedPosition = this.transaction.steps\r\n .slice(this.currentStep)\r\n .reduce((newPosition, step) => {\r\n const mapResult = step\r\n .getMap()\r\n .mapResult(newPosition);\r\n if (mapResult.deleted) {\r\n deleted = true;\r\n }\r\n return mapResult.pos;\r\n }, position);\r\n return {\r\n position: mappedPosition,\r\n deleted,\r\n };\r\n }\r\n}\n\n/**\r\n * Build an input rule that adds a node when the\r\n * matched text is typed into it.\r\n */\r\nfunction nodeInputRule(config) {\r\n return new InputRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n const attributes = callOrReturn(config.getAttributes, undefined, match) || {};\r\n const { tr } = state;\r\n const start = range.from;\r\n let end = range.to;\r\n if (match[1]) {\r\n const offset = match[0].lastIndexOf(match[1]);\r\n let matchStart = start + offset;\r\n if (matchStart > end) {\r\n matchStart = end;\r\n }\r\n else {\r\n end = matchStart + match[1].length;\r\n }\r\n // insert last typed character\r\n const lastChar = match[0][match[0].length - 1];\r\n tr.insertText(lastChar, start + match[0].length - 1);\r\n // insert node from input rule\r\n tr.replaceWith(matchStart, end, config.type.create(attributes));\r\n }\r\n else if (match[0]) {\r\n tr.replaceWith(start, end, config.type.create(attributes));\r\n }\r\n },\r\n });\r\n}\n\nfunction getMarksBetween(from, to, doc) {\r\n const marks = [];\r\n // get all inclusive marks on empty selection\r\n if (from === to) {\r\n doc\r\n .resolve(from)\r\n .marks()\r\n .forEach(mark => {\r\n const $pos = doc.resolve(from - 1);\r\n const range = getMarkRange($pos, mark.type);\r\n if (!range) {\r\n return;\r\n }\r\n marks.push({\r\n mark,\r\n ...range,\r\n });\r\n });\r\n }\r\n else {\r\n doc.nodesBetween(from, to, (node, pos) => {\r\n marks.push(...node.marks.map(mark => ({\r\n from: pos,\r\n to: pos + node.nodeSize,\r\n mark,\r\n })));\r\n });\r\n }\r\n return marks;\r\n}\n\n/**\r\n * Build an input rule that adds a mark when the\r\n * matched text is typed into it.\r\n */\r\nfunction markInputRule(config) {\r\n return new InputRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n const attributes = callOrReturn(config.getAttributes, undefined, match);\r\n if (attributes === false || attributes === null) {\r\n return;\r\n }\r\n const { tr } = state;\r\n const captureGroup = match[match.length - 1];\r\n const fullMatch = match[0];\r\n let markEnd = range.to;\r\n if (captureGroup) {\r\n const startSpaces = fullMatch.search(/\\S/);\r\n const textStart = range.from + fullMatch.indexOf(captureGroup);\r\n const textEnd = textStart + captureGroup.length;\r\n const excludedMarks = getMarksBetween(range.from, range.to, state.doc)\r\n .filter(item => {\r\n // @ts-ignore\r\n const excluded = item.mark.type.excluded;\r\n return excluded.find(type => type === config.type && type !== item.mark.type);\r\n })\r\n .filter(item => item.to > textStart);\r\n if (excludedMarks.length) {\r\n return null;\r\n }\r\n if (textEnd < range.to) {\r\n tr.delete(textEnd, range.to);\r\n }\r\n if (textStart > range.from) {\r\n tr.delete(range.from + startSpaces, textStart);\r\n }\r\n markEnd = range.from + startSpaces + captureGroup.length;\r\n tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));\r\n tr.removeStoredMark(config.type);\r\n }\r\n },\r\n });\r\n}\n\n/**\r\n * Build an input rule that changes the type of a textblock when the\r\n * matched text is typed into it. When using a regular expresion you’ll\r\n * probably want the regexp to start with `^`, so that the pattern can\r\n * only occur at the start of a textblock.\r\n */\r\nfunction textblockTypeInputRule(config) {\r\n return new InputRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n const $start = state.doc.resolve(range.from);\r\n const attributes = callOrReturn(config.getAttributes, undefined, match) || {};\r\n if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), config.type)) {\r\n return null;\r\n }\r\n state.tr\r\n .delete(range.from, range.to)\r\n .setBlockType(range.from, range.from, config.type, attributes);\r\n },\r\n });\r\n}\n\n/**\r\n * Build an input rule that replaces text when the\r\n * matched text is typed into it.\r\n */\r\nfunction textInputRule(config) {\r\n return new InputRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n let insert = config.replace;\r\n let start = range.from;\r\n const end = range.to;\r\n if (match[1]) {\r\n const offset = match[0].lastIndexOf(match[1]);\r\n insert += match[0].slice(offset + match[1].length);\r\n start += offset;\r\n const cutOff = start - end;\r\n if (cutOff > 0) {\r\n insert = match[0].slice(offset - cutOff, offset) + insert;\r\n start = end;\r\n }\r\n }\r\n state.tr.insertText(insert, start, end);\r\n },\r\n });\r\n}\n\n/**\r\n * Build an input rule for automatically wrapping a textblock when a\r\n * given string is typed. When using a regular expresion you’ll\r\n * probably want the regexp to start with `^`, so that the pattern can\r\n * only occur at the start of a textblock.\r\n *\r\n * `type` is the type of node to wrap in.\r\n *\r\n * By default, if there’s a node with the same type above the newly\r\n * wrapped node, the rule will try to join those\r\n * two nodes. You can pass a join predicate, which takes a regular\r\n * expression match and the node before the wrapped node, and can\r\n * return a boolean to indicate whether a join should happen.\r\n */\r\nfunction wrappingInputRule(config) {\r\n return new InputRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n const attributes = callOrReturn(config.getAttributes, undefined, match) || {};\r\n const tr = state.tr.delete(range.from, range.to);\r\n const $start = tr.doc.resolve(range.from);\r\n const blockRange = $start.blockRange();\r\n const wrapping = blockRange && findWrapping(blockRange, config.type, attributes);\r\n if (!wrapping) {\r\n return null;\r\n }\r\n tr.wrap(blockRange, wrapping);\r\n const before = tr.doc.resolve(range.from - 1).nodeBefore;\r\n if (before\r\n && before.type === config.type\r\n && canJoin(tr.doc, range.from - 1)\r\n && (!config.joinPredicate || config.joinPredicate(match, before))) {\r\n tr.join(range.from - 1);\r\n }\r\n },\r\n });\r\n}\n\n/**\r\n * Build an paste rule that adds a mark when the\r\n * matched text is pasted into it.\r\n */\r\nfunction markPasteRule(config) {\r\n return new PasteRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n const attributes = callOrReturn(config.getAttributes, undefined, match);\r\n if (attributes === false || attributes === null) {\r\n return;\r\n }\r\n const { tr } = state;\r\n const captureGroup = match[match.length - 1];\r\n const fullMatch = match[0];\r\n let markEnd = range.to;\r\n if (captureGroup) {\r\n const startSpaces = fullMatch.search(/\\S/);\r\n const textStart = range.from + fullMatch.indexOf(captureGroup);\r\n const textEnd = textStart + captureGroup.length;\r\n const excludedMarks = getMarksBetween(range.from, range.to, state.doc)\r\n .filter(item => {\r\n // @ts-ignore\r\n const excluded = item.mark.type.excluded;\r\n return excluded.find(type => type === config.type && type !== item.mark.type);\r\n })\r\n .filter(item => item.to > textStart);\r\n if (excludedMarks.length) {\r\n return null;\r\n }\r\n if (textEnd < range.to) {\r\n tr.delete(textEnd, range.to);\r\n }\r\n if (textStart > range.from) {\r\n tr.delete(range.from + startSpaces, textStart);\r\n }\r\n markEnd = range.from + startSpaces + captureGroup.length;\r\n tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));\r\n tr.removeStoredMark(config.type);\r\n }\r\n },\r\n });\r\n}\n\n/**\r\n * Build an paste rule that replaces text when the\r\n * matched text is pasted into it.\r\n */\r\nfunction textPasteRule(config) {\r\n return new PasteRule({\r\n find: config.find,\r\n handler: ({ state, range, match }) => {\r\n let insert = config.replace;\r\n let start = range.from;\r\n const end = range.to;\r\n if (match[1]) {\r\n const offset = match[0].lastIndexOf(match[1]);\r\n insert += match[0].slice(offset + match[1].length);\r\n start += offset;\r\n const cutOff = start - end;\r\n if (cutOff > 0) {\r\n insert = match[0].slice(offset - cutOff, offset) + insert;\r\n start = end;\r\n }\r\n }\r\n state.tr.insertText(insert, start, end);\r\n },\r\n });\r\n}\n\n/**\r\n * Returns a new `Transform` based on all steps of the passed transactions.\r\n */\r\nfunction combineTransactionSteps(oldDoc, transactions) {\r\n const transform = new Transform(oldDoc);\r\n transactions.forEach(transaction => {\r\n transaction.steps.forEach(step => {\r\n transform.step(step);\r\n });\r\n });\r\n return transform;\r\n}\n\nfunction defaultBlockAt(match) {\r\n for (let i = 0; i < match.edgeCount; i += 1) {\r\n const { type } = match.edge(i);\r\n if (type.isTextblock && !type.hasRequiredAttrs()) {\r\n return type;\r\n }\r\n }\r\n return null;\r\n}\n\nfunction findChildren(node, predicate) {\r\n const nodesWithPos = [];\r\n node.descendants((child, pos) => {\r\n if (predicate(child)) {\r\n nodesWithPos.push({\r\n node: child,\r\n pos,\r\n });\r\n }\r\n });\r\n return nodesWithPos;\r\n}\n\n/**\r\n * Same as `findChildren` but searches only within a `range`.\r\n */\r\nfunction findChildrenInRange(node, range, predicate) {\r\n const nodesWithPos = [];\r\n // if (range.from === range.to) {\r\n // const nodeAt = node.nodeAt(range.from)\r\n // if (nodeAt) {\r\n // nodesWithPos.push({\r\n // node: nodeAt,\r\n // pos: range.from,\r\n // })\r\n // }\r\n // }\r\n node.nodesBetween(range.from, range.to, (child, pos) => {\r\n if (predicate(child)) {\r\n nodesWithPos.push({\r\n node: child,\r\n pos,\r\n });\r\n }\r\n });\r\n return nodesWithPos;\r\n}\n\nfunction getSchema(extensions) {\r\n const resolvedExtensions = ExtensionManager.resolve(extensions);\r\n return getSchemaByResolvedExtensions(resolvedExtensions);\r\n}\n\nfunction generateHTML(doc, extensions) {\r\n const schema = getSchema(extensions);\r\n const contentNode = Node$1.fromJSON(schema, doc);\r\n return getHTMLFromFragment(contentNode.content, schema);\r\n}\n\nfunction generateJSON(html, extensions) {\r\n const schema = getSchema(extensions);\r\n const dom = elementFromString(html);\r\n return DOMParser.fromSchema(schema)\r\n .parse(dom)\r\n .toJSON();\r\n}\n\nfunction generateText(doc, extensions, options) {\r\n const { blockSeparator = '\\n\\n', textSerializers = {}, } = options || {};\r\n const schema = getSchema(extensions);\r\n const contentNode = Node$1.fromJSON(schema, doc);\r\n return getText(contentNode, {\r\n blockSeparator,\r\n textSerializers: {\r\n ...textSerializers,\r\n ...getTextSeralizersFromSchema(schema),\r\n },\r\n });\r\n}\n\n/**\r\n * Removes duplicated values within an array.\r\n * Supports numbers, strings and objects.\r\n */\r\nfunction removeDuplicates(array, by = JSON.stringify) {\r\n const seen = {};\r\n return array.filter(item => {\r\n const key = by(item);\r\n return Object.prototype.hasOwnProperty.call(seen, key)\r\n ? false\r\n : (seen[key] = true);\r\n });\r\n}\n\n/**\r\n * Removes duplicated ranges and ranges that are\r\n * fully captured by other ranges.\r\n */\r\nfunction simplifyChangedRanges(changes) {\r\n const uniqueChanges = removeDuplicates(changes);\r\n return uniqueChanges.length === 1\r\n ? uniqueChanges\r\n : uniqueChanges.filter((change, index) => {\r\n const rest = uniqueChanges.filter((_, i) => i !== index);\r\n return !rest.some(otherChange => {\r\n return change.oldRange.from >= otherChange.oldRange.from\r\n && change.oldRange.to <= otherChange.oldRange.to\r\n && change.newRange.from >= otherChange.newRange.from\r\n && change.newRange.to <= otherChange.newRange.to;\r\n });\r\n });\r\n}\r\n/**\r\n * Returns a list of changed ranges\r\n * based on the first and last state of all steps.\r\n */\r\nfunction getChangedRanges(transform) {\r\n const { mapping, steps } = transform;\r\n const changes = [];\r\n mapping.maps.forEach((stepMap, index) => {\r\n const ranges = [];\r\n // This accounts for step changes where no range was actually altered\r\n // e.g. when setting a mark, node attribute, etc.\r\n // @ts-ignore\r\n if (!stepMap.ranges.length) {\r\n const { from, to } = steps[index];\r\n if (from === undefined || to === undefined) {\r\n return;\r\n }\r\n ranges.push({ from, to });\r\n }\r\n else {\r\n stepMap.forEach((from, to) => {\r\n ranges.push({ from, to });\r\n });\r\n }\r\n ranges.forEach(({ from, to }) => {\r\n const newStart = mapping.slice(index).map(from, -1);\r\n const newEnd = mapping.slice(index).map(to);\r\n const oldStart = mapping.invert().map(newStart, -1);\r\n const oldEnd = mapping.invert().map(newEnd);\r\n changes.push({\r\n oldRange: {\r\n from: oldStart,\r\n to: oldEnd,\r\n },\r\n newRange: {\r\n from: newStart,\r\n to: newEnd,\r\n },\r\n });\r\n });\r\n });\r\n return simplifyChangedRanges(changes);\r\n}\n\nfunction getDebugJSON(node, startOffset = 0) {\r\n const isTopNode = node.type === node.type.schema.topNodeType;\r\n const increment = isTopNode ? 0 : 1;\r\n const from = startOffset; // + offset\r\n const to = from + node.nodeSize;\r\n const marks = node.marks.map(mark => ({\r\n type: mark.type.name,\r\n attrs: { ...mark.attrs },\r\n }));\r\n const attrs = { ...node.attrs };\r\n const output = {\r\n type: node.type.name,\r\n from,\r\n to,\r\n };\r\n if (Object.keys(attrs).length) {\r\n output.attrs = attrs;\r\n }\r\n if (marks.length) {\r\n output.marks = marks;\r\n }\r\n if (node.content.childCount) {\r\n output.content = [];\r\n node.forEach((child, offset) => {\r\n var _a;\r\n (_a = output.content) === null || _a === void 0 ? void 0 : _a.push(getDebugJSON(child, startOffset + offset + increment));\r\n });\r\n }\r\n if (node.text) {\r\n output.text = node.text;\r\n }\r\n return output;\r\n}\n\nfunction isNodeSelection(value) {\r\n return isObject(value) && value instanceof NodeSelection;\r\n}\n\nfunction posToDOMRect(view, from, to) {\r\n const minPos = 0;\r\n const maxPos = view.state.doc.content.size;\r\n const resolvedFrom = minMax(from, minPos, maxPos);\r\n const resolvedEnd = minMax(to, minPos, maxPos);\r\n const start = view.coordsAtPos(resolvedFrom);\r\n const end = view.coordsAtPos(resolvedEnd, -1);\r\n const top = Math.min(start.top, end.top);\r\n const bottom = Math.max(start.bottom, end.bottom);\r\n const left = Math.min(start.left, end.left);\r\n const right = Math.max(start.right, end.right);\r\n const width = right - left;\r\n const height = bottom - top;\r\n const x = left;\r\n const y = top;\r\n const data = {\r\n top,\r\n bottom,\r\n left,\r\n right,\r\n width,\r\n height,\r\n x,\r\n y,\r\n };\r\n return {\r\n ...data,\r\n toJSON: () => data,\r\n };\r\n}\n\nexport { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, defaultBlockAt, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, inputRulesPlugin, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, pasteRulesPlugin, posToDOMRect, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };\n//# sourceMappingURL=tiptap-core.esm.js.map\n","import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';\n\nconst inputRegex = /^\\s*>\\s$/;\r\nconst Blockquote = Node.create({\r\n name: 'blockquote',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n content: 'block+',\r\n group: 'block',\r\n defining: true,\r\n parseHTML() {\r\n return [\r\n { tag: 'blockquote' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['blockquote', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setBlockquote: () => ({ commands }) => {\r\n return commands.wrapIn(this.name);\r\n },\r\n toggleBlockquote: () => ({ commands }) => {\r\n return commands.toggleWrap(this.name);\r\n },\r\n unsetBlockquote: () => ({ commands }) => {\r\n return commands.lift(this.name);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Shift-b': () => this.editor.commands.toggleBlockquote(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n wrappingInputRule({\r\n find: inputRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { Blockquote, Blockquote as default, inputRegex };\n//# sourceMappingURL=tiptap-extension-blockquote.esm.js.map\n","import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';\n\nconst starInputRegex = /(?:^|\\s)((?:\\*\\*)((?:[^*]+))(?:\\*\\*))$/;\r\nconst starPasteRegex = /(?:^|\\s)((?:\\*\\*)((?:[^*]+))(?:\\*\\*))/g;\r\nconst underscoreInputRegex = /(?:^|\\s)((?:__)((?:[^__]+))(?:__))$/;\r\nconst underscorePasteRegex = /(?:^|\\s)((?:__)((?:[^__]+))(?:__))/g;\r\nconst Bold = Mark.create({\r\n name: 'bold',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n parseHTML() {\r\n return [\r\n {\r\n tag: 'strong',\r\n },\r\n {\r\n tag: 'b',\r\n getAttrs: node => node.style.fontWeight !== 'normal' && null,\r\n },\r\n {\r\n style: 'font-weight',\r\n getAttrs: value => /^(bold(er)?|[5-9]\\d{2,})$/.test(value) && null,\r\n },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['strong', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setBold: () => ({ commands }) => {\r\n return commands.setMark(this.name);\r\n },\r\n toggleBold: () => ({ commands }) => {\r\n return commands.toggleMark(this.name);\r\n },\r\n unsetBold: () => ({ commands }) => {\r\n return commands.unsetMark(this.name);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-b': () => this.editor.commands.toggleBold(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n markInputRule({\r\n find: starInputRegex,\r\n type: this.type,\r\n }),\r\n markInputRule({\r\n find: underscoreInputRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n addPasteRules() {\r\n return [\r\n markPasteRule({\r\n find: starPasteRegex,\r\n type: this.type,\r\n }),\r\n markPasteRule({\r\n find: underscorePasteRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { Bold, Bold as default, starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex };\n//# sourceMappingURL=tiptap-extension-bold.esm.js.map\n","import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';\n\nconst inputRegex = /^\\s*([-+*])\\s$/;\r\nconst BulletList = Node.create({\r\n name: 'bulletList',\r\n addOptions() {\r\n return {\r\n itemTypeName: 'listItem',\r\n HTMLAttributes: {},\r\n };\r\n },\r\n group: 'block list',\r\n content() {\r\n return `${this.options.itemTypeName}+`;\r\n },\r\n parseHTML() {\r\n return [\r\n { tag: 'ul' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n toggleBulletList: () => ({ commands }) => {\r\n return commands.toggleList(this.name, this.options.itemTypeName);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Shift-8': () => this.editor.commands.toggleBulletList(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n wrappingInputRule({\r\n find: inputRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { BulletList, BulletList as default, inputRegex };\n//# sourceMappingURL=tiptap-extension-bullet-list.esm.js.map\n","import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';\n\nconst inputRegex = /(?:^|\\s)((?:`)((?:[^`]+))(?:`))$/;\r\nconst pasteRegex = /(?:^|\\s)((?:`)((?:[^`]+))(?:`))/g;\r\nconst Code = Mark.create({\r\n name: 'code',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n excludes: '_',\r\n code: true,\r\n parseHTML() {\r\n return [\r\n { tag: 'code' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['code', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setCode: () => ({ commands }) => {\r\n return commands.setMark(this.name);\r\n },\r\n toggleCode: () => ({ commands }) => {\r\n return commands.toggleMark(this.name);\r\n },\r\n unsetCode: () => ({ commands }) => {\r\n return commands.unsetMark(this.name);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-e': () => this.editor.commands.toggleCode(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n markInputRule({\r\n find: inputRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n addPasteRules() {\r\n return [\r\n markPasteRule({\r\n find: pasteRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { Code, Code as default, inputRegex, pasteRegex };\n//# sourceMappingURL=tiptap-extension-code.esm.js.map\n","import { Node, textblockTypeInputRule } from '@tiptap/core';\nimport { Plugin, PluginKey, TextSelection } from 'prosemirror-state';\n\nconst backtickInputRegex = /^```(?[a-z]*)?[\\s\\n]$/;\r\nconst tildeInputRegex = /^~~~(?[a-z]*)?[\\s\\n]$/;\r\nconst CodeBlock = Node.create({\r\n name: 'codeBlock',\r\n addOptions() {\r\n return {\r\n languageClassPrefix: 'language-',\r\n HTMLAttributes: {},\r\n };\r\n },\r\n content: 'text*',\r\n marks: '',\r\n group: 'block',\r\n code: true,\r\n defining: true,\r\n addAttributes() {\r\n return {\r\n language: {\r\n default: null,\r\n parseHTML: element => {\r\n var _a;\r\n const { languageClassPrefix } = this.options;\r\n const classNames = [...((_a = element.firstElementChild) === null || _a === void 0 ? void 0 : _a.classList) || []];\r\n const languages = classNames\r\n .filter(className => className.startsWith(languageClassPrefix))\r\n .map(className => className.replace(languageClassPrefix, ''));\r\n const language = languages[0];\r\n if (!language) {\r\n return null;\r\n }\r\n return language;\r\n },\r\n renderHTML: attributes => {\r\n if (!attributes.language) {\r\n return null;\r\n }\r\n return {\r\n class: this.options.languageClassPrefix + attributes.language,\r\n };\r\n },\r\n },\r\n };\r\n },\r\n parseHTML() {\r\n return [\r\n {\r\n tag: 'pre',\r\n preserveWhitespace: 'full',\r\n },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['pre', this.options.HTMLAttributes, ['code', HTMLAttributes, 0]];\r\n },\r\n addCommands() {\r\n return {\r\n setCodeBlock: attributes => ({ commands }) => {\r\n return commands.setNode(this.name, attributes);\r\n },\r\n toggleCodeBlock: attributes => ({ commands }) => {\r\n return commands.toggleNode(this.name, 'paragraph', attributes);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Alt-c': () => this.editor.commands.toggleCodeBlock(),\r\n // remove code block when at start of document or code block is empty\r\n Backspace: () => {\r\n const { empty, $anchor } = this.editor.state.selection;\r\n const isAtStart = $anchor.pos === 1;\r\n if (!empty || $anchor.parent.type.name !== this.name) {\r\n return false;\r\n }\r\n if (isAtStart || !$anchor.parent.textContent.length) {\r\n return this.editor.commands.clearNodes();\r\n }\r\n return false;\r\n },\r\n // escape node on triple enter\r\n Enter: ({ editor }) => {\r\n const { state } = editor;\r\n const { selection } = state;\r\n const { $from, empty } = selection;\r\n if (!empty || $from.parent.type !== this.type) {\r\n return false;\r\n }\r\n const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;\r\n const endsWithDoubleNewline = $from.parent.textContent.endsWith('\\n\\n');\r\n if (!isAtEnd || !endsWithDoubleNewline) {\r\n return false;\r\n }\r\n return editor\r\n .chain()\r\n .command(({ tr }) => {\r\n tr.delete($from.pos - 2, $from.pos);\r\n return true;\r\n })\r\n .exitCode()\r\n .run();\r\n },\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n textblockTypeInputRule({\r\n find: backtickInputRegex,\r\n type: this.type,\r\n getAttributes: ({ groups }) => groups,\r\n }),\r\n textblockTypeInputRule({\r\n find: tildeInputRegex,\r\n type: this.type,\r\n getAttributes: ({ groups }) => groups,\r\n }),\r\n ];\r\n },\r\n addProseMirrorPlugins() {\r\n return [\r\n // this plugin creates a code block for pasted content from VS Code\r\n // we can also detect the copied code language\r\n new Plugin({\r\n key: new PluginKey('codeBlockVSCodeHandler'),\r\n props: {\r\n handlePaste: (view, event) => {\r\n if (!event.clipboardData) {\r\n return false;\r\n }\r\n // don’t create a new code block within code blocks\r\n if (this.editor.isActive(this.type.name)) {\r\n return false;\r\n }\r\n const text = event.clipboardData.getData('text/plain');\r\n const vscode = event.clipboardData.getData('vscode-editor-data');\r\n const vscodeData = vscode\r\n ? JSON.parse(vscode)\r\n : undefined;\r\n const language = vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;\r\n if (!text || !language) {\r\n return false;\r\n }\r\n const { tr } = view.state;\r\n // create an empty code block\r\n tr.replaceSelectionWith(this.type.create({ language }));\r\n // put cursor inside the newly created code block\r\n tr.setSelection(TextSelection.near(tr.doc.resolve(Math.max(0, tr.selection.from - 2))));\r\n // add text to code block\r\n // strip carriage return chars from text pasted as code\r\n // see: https://github.com/ProseMirror/prosemirror-view/commit/a50a6bcceb4ce52ac8fcc6162488d8875613aacd\r\n tr.insertText(text.replace(/\\r\\n?/g, '\\n'));\r\n // store meta information\r\n // this is useful for other plugins that depends on the paste event\r\n // like the paste rule plugin\r\n tr.setMeta('paste', true);\r\n view.dispatch(tr);\r\n return true;\r\n },\r\n },\r\n }),\r\n ];\r\n },\r\n});\n\nexport { CodeBlock, backtickInputRegex, CodeBlock as default, tildeInputRegex };\n//# sourceMappingURL=tiptap-extension-code-block.esm.js.map\n","import { Node } from '@tiptap/core';\n\nconst Document = Node.create({\r\n name: 'doc',\r\n topNode: true,\r\n content: 'block+',\r\n});\n\nexport { Document, Document as default };\n//# sourceMappingURL=tiptap-extension-document.esm.js.map\n","import { Plugin } from 'prosemirror-state';\nimport { dropPoint } from 'prosemirror-transform';\n\n// :: (options: ?Object) → Plugin\n// Create a plugin that, when added to a ProseMirror instance,\n// causes a decoration to show up at the drop position when something\n// is dragged over the editor.\n//\n// Nodes may add a `disableDropCursor` property to their spec to\n// control the showing of a drop cursor inside them. This may be a\n// boolean or a function, which will be called with a view and a\n// position, and should return a boolean.\n//\n// options::- These options are supported:\n//\n// color:: ?string\n// The color of the cursor. Defaults to `black`.\n//\n// width:: ?number\n// The precise width of the cursor in pixels. Defaults to 1.\n//\n// class:: ?string\n// A CSS class name to add to the cursor element.\nfunction dropCursor(options) {\n if ( options === void 0 ) options = {};\n\n return new Plugin({\n view: function view(editorView) { return new DropCursorView(editorView, options) }\n })\n}\n\nvar DropCursorView = function DropCursorView(editorView, options) {\n var this$1 = this;\n\n this.editorView = editorView;\n this.width = options.width || 1;\n this.color = options.color || \"black\";\n this.class = options.class;\n this.cursorPos = null;\n this.element = null;\n this.timeout = null;\n\n this.handlers = [\"dragover\", \"dragend\", \"drop\", \"dragleave\"].map(function (name) {\n var handler = function (e) { return this$1[name](e); };\n editorView.dom.addEventListener(name, handler);\n return {name: name, handler: handler}\n });\n};\n\nDropCursorView.prototype.destroy = function destroy () {\n var this$1 = this;\n\n this.handlers.forEach(function (ref) {\n var name = ref.name;\n var handler = ref.handler;\n\n return this$1.editorView.dom.removeEventListener(name, handler);\n });\n};\n\nDropCursorView.prototype.update = function update (editorView, prevState) {\n if (this.cursorPos != null && prevState.doc != editorView.state.doc) {\n if (this.cursorPos > editorView.state.doc.content.size) { this.setCursor(null); }\n else { this.updateOverlay(); }\n }\n};\n\nDropCursorView.prototype.setCursor = function setCursor (pos) {\n if (pos == this.cursorPos) { return }\n this.cursorPos = pos;\n if (pos == null) {\n this.element.parentNode.removeChild(this.element);\n this.element = null;\n } else {\n this.updateOverlay();\n }\n};\n\nDropCursorView.prototype.updateOverlay = function updateOverlay () {\n var $pos = this.editorView.state.doc.resolve(this.cursorPos), rect;\n if (!$pos.parent.inlineContent) {\n var before = $pos.nodeBefore, after = $pos.nodeAfter;\n if (before || after) {\n var nodeRect = this.editorView.nodeDOM(this.cursorPos - (before ?before.nodeSize : 0)).getBoundingClientRect();\n var top = before ? nodeRect.bottom : nodeRect.top;\n if (before && after)\n { top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2; }\n rect = {left: nodeRect.left, right: nodeRect.right, top: top - this.width / 2, bottom: top + this.width / 2};\n }\n }\n if (!rect) {\n var coords = this.editorView.coordsAtPos(this.cursorPos);\n rect = {left: coords.left - this.width / 2, right: coords.left + this.width / 2, top: coords.top, bottom: coords.bottom};\n }\n\n var parent = this.editorView.dom.offsetParent;\n if (!this.element) {\n this.element = parent.appendChild(document.createElement(\"div\"));\n if (this.class) { this.element.className = this.class; }\n this.element.style.cssText = \"position: absolute; z-index: 50; pointer-events: none; background-color: \" + this.color;\n }\n var parentLeft, parentTop;\n if (!parent || parent == document.body && getComputedStyle(parent).position == \"static\") {\n parentLeft = -pageXOffset;\n parentTop = -pageYOffset;\n } else {\n var rect$1 = parent.getBoundingClientRect();\n parentLeft = rect$1.left - parent.scrollLeft;\n parentTop = rect$1.top - parent.scrollTop;\n }\n this.element.style.left = (rect.left - parentLeft) + \"px\";\n this.element.style.top = (rect.top - parentTop) + \"px\";\n this.element.style.width = (rect.right - rect.left) + \"px\";\n this.element.style.height = (rect.bottom - rect.top) + \"px\";\n};\n\nDropCursorView.prototype.scheduleRemoval = function scheduleRemoval (timeout) {\n var this$1 = this;\n\n clearTimeout(this.timeout);\n this.timeout = setTimeout(function () { return this$1.setCursor(null); }, timeout);\n};\n\nDropCursorView.prototype.dragover = function dragover (event) {\n if (!this.editorView.editable) { return }\n var pos = this.editorView.posAtCoords({left: event.clientX, top: event.clientY});\n\n var node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);\n var disableDropCursor = node && node.type.spec.disableDropCursor;\n var disabled = typeof disableDropCursor == \"function\" ? disableDropCursor(this.editorView, pos) : disableDropCursor;\n\n if (pos && !disabled) {\n var target = pos.pos;\n if (this.editorView.dragging && this.editorView.dragging.slice) {\n target = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);\n if (target == null) { return this.setCursor(null) }\n }\n this.setCursor(target);\n this.scheduleRemoval(5000);\n }\n};\n\nDropCursorView.prototype.dragend = function dragend () {\n this.scheduleRemoval(20);\n};\n\nDropCursorView.prototype.drop = function drop () {\n this.scheduleRemoval(20);\n};\n\nDropCursorView.prototype.dragleave = function dragleave (event) {\n if (event.target == this.editorView.dom || !this.editorView.dom.contains(event.relatedTarget))\n { this.setCursor(null); }\n};\n\nexport { dropCursor };\n//# sourceMappingURL=index.es.js.map\n","import { Extension } from '@tiptap/core';\nimport { dropCursor } from 'prosemirror-dropcursor';\n\nconst Dropcursor = Extension.create({\r\n name: 'dropCursor',\r\n addOptions() {\r\n return {\r\n color: 'currentColor',\r\n width: 1,\r\n class: null,\r\n };\r\n },\r\n addProseMirrorPlugins() {\r\n return [\r\n dropCursor(this.options),\r\n ];\r\n },\r\n});\n\nexport { Dropcursor, Dropcursor as default };\n//# sourceMappingURL=tiptap-extension-dropcursor.esm.js.map\n","import { keydownHandler } from 'prosemirror-keymap';\nimport { NodeSelection, Selection, Plugin, TextSelection } from 'prosemirror-state';\nimport { DecorationSet, Decoration } from 'prosemirror-view';\nimport { Slice } from 'prosemirror-model';\n\n// ::- Gap cursor selections are represented using this class. Its\n// `$anchor` and `$head` properties both point at the cursor position.\nvar GapCursor = /*@__PURE__*/(function (Selection) {\n function GapCursor($pos) {\n Selection.call(this, $pos, $pos);\n }\n\n if ( Selection ) GapCursor.__proto__ = Selection;\n GapCursor.prototype = Object.create( Selection && Selection.prototype );\n GapCursor.prototype.constructor = GapCursor;\n\n GapCursor.prototype.map = function map (doc, mapping) {\n var $pos = doc.resolve(mapping.map(this.head));\n return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos)\n };\n\n GapCursor.prototype.content = function content () { return Slice.empty };\n\n GapCursor.prototype.eq = function eq (other) {\n return other instanceof GapCursor && other.head == this.head\n };\n\n GapCursor.prototype.toJSON = function toJSON () {\n return {type: \"gapcursor\", pos: this.head}\n };\n\n GapCursor.fromJSON = function fromJSON (doc, json) {\n if (typeof json.pos != \"number\") { throw new RangeError(\"Invalid input for GapCursor.fromJSON\") }\n return new GapCursor(doc.resolve(json.pos))\n };\n\n GapCursor.prototype.getBookmark = function getBookmark () { return new GapBookmark(this.anchor) };\n\n GapCursor.valid = function valid ($pos) {\n var parent = $pos.parent;\n if (parent.isTextblock || !closedBefore($pos) || !closedAfter($pos)) { return false }\n var override = parent.type.spec.allowGapCursor;\n if (override != null) { return override }\n var deflt = parent.contentMatchAt($pos.index()).defaultType;\n return deflt && deflt.isTextblock\n };\n\n GapCursor.findFrom = function findFrom ($pos, dir, mustMove) {\n search: for (;;) {\n if (!mustMove && GapCursor.valid($pos)) { return $pos }\n var pos = $pos.pos, next = null;\n // Scan up from this position\n for (var d = $pos.depth;; d--) {\n var parent = $pos.node(d);\n if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {\n next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);\n break\n } else if (d == 0) {\n return null\n }\n pos += dir;\n var $cur = $pos.doc.resolve(pos);\n if (GapCursor.valid($cur)) { return $cur }\n }\n\n // And then down into the next node\n for (;;) {\n var inside = dir > 0 ? next.firstChild : next.lastChild;\n if (!inside) {\n if (next.isAtom && !next.isText && !NodeSelection.isSelectable(next)) {\n $pos = $pos.doc.resolve(pos + next.nodeSize * dir);\n mustMove = false;\n continue search\n }\n break\n }\n next = inside;\n pos += dir;\n var $cur$1 = $pos.doc.resolve(pos);\n if (GapCursor.valid($cur$1)) { return $cur$1 }\n }\n\n return null\n }\n };\n\n return GapCursor;\n}(Selection));\n\nGapCursor.prototype.visible = false;\n\nSelection.jsonID(\"gapcursor\", GapCursor);\n\nvar GapBookmark = function GapBookmark(pos) {\n this.pos = pos;\n};\nGapBookmark.prototype.map = function map (mapping) {\n return new GapBookmark(mapping.map(this.pos))\n};\nGapBookmark.prototype.resolve = function resolve (doc) {\n var $pos = doc.resolve(this.pos);\n return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos)\n};\n\nfunction closedBefore($pos) {\n for (var d = $pos.depth; d >= 0; d--) {\n var index = $pos.index(d);\n // At the start of this parent, look at next one\n if (index == 0) { continue }\n // See if the node before (or its first ancestor) is closed\n for (var before = $pos.node(d).child(index - 1);; before = before.lastChild) {\n if ((before.childCount == 0 && !before.inlineContent) || before.isAtom || before.type.spec.isolating) { return true }\n if (before.inlineContent) { return false }\n }\n }\n // Hit start of document\n return true\n}\n\nfunction closedAfter($pos) {\n for (var d = $pos.depth; d >= 0; d--) {\n var index = $pos.indexAfter(d), parent = $pos.node(d);\n if (index == parent.childCount) { continue }\n for (var after = parent.child(index);; after = after.firstChild) {\n if ((after.childCount == 0 && !after.inlineContent) || after.isAtom || after.type.spec.isolating) { return true }\n if (after.inlineContent) { return false }\n }\n }\n return true\n}\n\n// :: () → Plugin\n// Create a gap cursor plugin. When enabled, this will capture clicks\n// near and arrow-key-motion past places that don't have a normally\n// selectable position nearby, and create a gap cursor selection for\n// them. The cursor is drawn as an element with class\n// `ProseMirror-gapcursor`. You can either include\n// `style/gapcursor.css` from the package's directory or add your own\n// styles to make it visible.\nvar gapCursor = function() {\n return new Plugin({\n props: {\n decorations: drawGapCursor,\n\n createSelectionBetween: function createSelectionBetween(_view, $anchor, $head) {\n if ($anchor.pos == $head.pos && GapCursor.valid($head)) { return new GapCursor($head) }\n },\n\n handleClick: handleClick,\n handleKeyDown: handleKeyDown\n }\n })\n};\n\nvar handleKeyDown = keydownHandler({\n \"ArrowLeft\": arrow(\"horiz\", -1),\n \"ArrowRight\": arrow(\"horiz\", 1),\n \"ArrowUp\": arrow(\"vert\", -1),\n \"ArrowDown\": arrow(\"vert\", 1)\n});\n\nfunction arrow(axis, dir) {\n var dirStr = axis == \"vert\" ? (dir > 0 ? \"down\" : \"up\") : (dir > 0 ? \"right\" : \"left\");\n return function(state, dispatch, view) {\n var sel = state.selection;\n var $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;\n if (sel instanceof TextSelection) {\n if (!view.endOfTextblock(dirStr) || $start.depth == 0) { return false }\n mustMove = false;\n $start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());\n }\n var $found = GapCursor.findFrom($start, dir, mustMove);\n if (!$found) { return false }\n if (dispatch) { dispatch(state.tr.setSelection(new GapCursor($found))); }\n return true\n }\n}\n\nfunction handleClick(view, pos, event) {\n if (!view.editable) { return false }\n var $pos = view.state.doc.resolve(pos);\n if (!GapCursor.valid($pos)) { return false }\n var ref = view.posAtCoords({left: event.clientX, top: event.clientY});\n var inside = ref.inside;\n if (inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(inside))) { return false }\n view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));\n return true\n}\n\nfunction drawGapCursor(state) {\n if (!(state.selection instanceof GapCursor)) { return null }\n var node = document.createElement(\"div\");\n node.className = \"ProseMirror-gapcursor\";\n return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node, {key: \"gapcursor\"})])\n}\n\nexport { GapCursor, gapCursor };\n//# sourceMappingURL=index.es.js.map\n","import { Extension, callOrReturn, getExtensionField } from '@tiptap/core';\nimport { gapCursor } from 'prosemirror-gapcursor';\n\nconst Gapcursor = Extension.create({\r\n name: 'gapCursor',\r\n addProseMirrorPlugins() {\r\n return [\r\n gapCursor(),\r\n ];\r\n },\r\n extendNodeSchema(extension) {\r\n var _a;\r\n const context = {\r\n name: extension.name,\r\n options: extension.options,\r\n storage: extension.storage,\r\n };\r\n return {\r\n allowGapCursor: (_a = callOrReturn(getExtensionField(extension, 'allowGapCursor', context))) !== null && _a !== void 0 ? _a : null,\r\n };\r\n },\r\n});\n\nexport { Gapcursor, Gapcursor as default };\n//# sourceMappingURL=tiptap-extension-gapcursor.esm.js.map\n","import { Node, mergeAttributes } from '@tiptap/core';\n\nconst HardBreak = Node.create({\r\n name: 'hardBreak',\r\n addOptions() {\r\n return {\r\n keepMarks: true,\r\n HTMLAttributes: {},\r\n };\r\n },\r\n inline: true,\r\n group: 'inline',\r\n selectable: false,\r\n parseHTML() {\r\n return [\r\n { tag: 'br' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['br', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];\r\n },\r\n renderText() {\r\n return '\\n';\r\n },\r\n addCommands() {\r\n return {\r\n setHardBreak: () => ({ commands, chain, state, editor, }) => {\r\n return commands.first([\r\n () => commands.exitCode(),\r\n () => commands.command(() => {\r\n const { selection, storedMarks } = state;\r\n if (selection.$from.parent.type.spec.isolating) {\r\n return false;\r\n }\r\n const { keepMarks } = this.options;\r\n const { splittableMarks } = editor.extensionManager;\r\n const marks = storedMarks\r\n || (selection.$to.parentOffset && selection.$from.marks());\r\n return chain()\r\n .insertContent({ type: this.name })\r\n .command(({ tr, dispatch }) => {\r\n if (dispatch && marks && keepMarks) {\r\n const filteredMarks = marks\r\n .filter(mark => splittableMarks.includes(mark.type.name));\r\n tr.ensureMarks(filteredMarks);\r\n }\r\n return true;\r\n })\r\n .run();\r\n }),\r\n ]);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Enter': () => this.editor.commands.setHardBreak(),\r\n 'Shift-Enter': () => this.editor.commands.setHardBreak(),\r\n };\r\n },\r\n});\n\nexport { HardBreak, HardBreak as default };\n//# sourceMappingURL=tiptap-extension-hard-break.esm.js.map\n","import { Node, mergeAttributes, textblockTypeInputRule } from '@tiptap/core';\n\nconst Heading = Node.create({\r\n name: 'heading',\r\n addOptions() {\r\n return {\r\n levels: [1, 2, 3, 4, 5, 6],\r\n HTMLAttributes: {},\r\n };\r\n },\r\n content: 'inline*',\r\n group: 'block',\r\n defining: true,\r\n addAttributes() {\r\n return {\r\n level: {\r\n default: 1,\r\n rendered: false,\r\n },\r\n };\r\n },\r\n parseHTML() {\r\n return this.options.levels\r\n .map((level) => ({\r\n tag: `h${level}`,\r\n attrs: { level },\r\n }));\r\n },\r\n renderHTML({ node, HTMLAttributes }) {\r\n const hasLevel = this.options.levels.includes(node.attrs.level);\r\n const level = hasLevel\r\n ? node.attrs.level\r\n : this.options.levels[0];\r\n return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setHeading: attributes => ({ commands }) => {\r\n if (!this.options.levels.includes(attributes.level)) {\r\n return false;\r\n }\r\n return commands.setNode(this.name, attributes);\r\n },\r\n toggleHeading: attributes => ({ commands }) => {\r\n if (!this.options.levels.includes(attributes.level)) {\r\n return false;\r\n }\r\n return commands.toggleNode(this.name, 'paragraph', attributes);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return this.options.levels.reduce((items, level) => ({\r\n ...items,\r\n ...{\r\n [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level }),\r\n },\r\n }), {});\r\n },\r\n addInputRules() {\r\n return this.options.levels.map(level => {\r\n return textblockTypeInputRule({\r\n find: new RegExp(`^(#{1,${level}})\\\\s$`),\r\n type: this.type,\r\n getAttributes: {\r\n level,\r\n },\r\n });\r\n });\r\n },\r\n});\n\nexport { Heading, Heading as default };\n//# sourceMappingURL=tiptap-extension-heading.esm.js.map\n","var 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\nexport default ropeSequence;\n","import RopeSequence from 'rope-sequence';\nimport { Mapping } from 'prosemirror-transform';\nimport { PluginKey, Plugin } from 'prosemirror-state';\n\n// ProseMirror's history isn't simply a way to roll back to a previous\n// state, because ProseMirror supports applying changes without adding\n// them to the history (for example during collaboration).\n//\n// To this end, each 'Branch' (one for the undo history and one for\n// the redo history) keeps an array of 'Items', which can optionally\n// hold a step (an actual undoable change), and always hold a position\n// map (which is needed to move changes below them to apply to the\n// current document).\n//\n// An item that has both a step and a selection bookmark is the start\n// of an 'event' — a group of changes that will be undone or redone at\n// once. (It stores only the bookmark, since that way we don't have to\n// provide a document until the selection is actually applied, which\n// is useful when compressing.)\n\n// Used to schedule history compression\nvar max_empty_items = 500;\n\nvar Branch = function Branch(items, eventCount) {\n this.items = items;\n this.eventCount = eventCount;\n};\n\n// : (EditorState, bool) → ?{transform: Transform, selection: ?SelectionBookmark, remaining: Branch}\n// Pop the latest event off the branch's history and apply it\n// to a document transform.\nBranch.prototype.popEvent = function popEvent (state, preserveItems) {\n var this$1 = this;\n\n if (this.eventCount == 0) { return null }\n\n var end = this.items.length;\n for (;; end--) {\n var next = this.items.get(end - 1);\n if (next.selection) { --end; break }\n }\n\n var remap, mapFrom;\n if (preserveItems) {\n remap = this.remapping(end, this.items.length);\n mapFrom = remap.maps.length;\n }\n var transform = state.tr;\n var selection, remaining;\n var addAfter = [], addBefore = [];\n\n this.items.forEach(function (item, i) {\n if (!item.step) {\n if (!remap) {\n remap = this$1.remapping(end, i + 1);\n mapFrom = remap.maps.length;\n }\n mapFrom--;\n addBefore.push(item);\n return\n }\n\n if (remap) {\n addBefore.push(new Item(item.map));\n var step = item.step.map(remap.slice(mapFrom)), map;\n\n if (step && transform.maybeStep(step).doc) {\n map = transform.mapping.maps[transform.mapping.maps.length - 1];\n addAfter.push(new Item(map, null, null, addAfter.length + addBefore.length));\n }\n mapFrom--;\n if (map) { remap.appendMap(map, mapFrom); }\n } else {\n transform.maybeStep(item.step);\n }\n\n if (item.selection) {\n selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;\n remaining = new Branch(this$1.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this$1.eventCount - 1);\n return false\n }\n }, this.items.length, 0);\n\n return {remaining: remaining, transform: transform, selection: selection}\n};\n\n// : (Transform, ?SelectionBookmark, Object) → Branch\n// Create a new branch with the given transform added.\nBranch.prototype.addTransform = function addTransform (transform, selection, histOptions, preserveItems) {\n var newItems = [], eventCount = this.eventCount;\n var oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;\n\n for (var i = 0; i < transform.steps.length; i++) {\n var step = transform.steps[i].invert(transform.docs[i]);\n var item = new Item(transform.mapping.maps[i], step, selection), merged = (void 0);\n if (merged = lastItem && lastItem.merge(item)) {\n item = merged;\n if (i) { newItems.pop(); }\n else { oldItems = oldItems.slice(0, oldItems.length - 1); }\n }\n newItems.push(item);\n if (selection) {\n eventCount++;\n selection = null;\n }\n if (!preserveItems) { lastItem = item; }\n }\n var overflow = eventCount - histOptions.depth;\n if (overflow > DEPTH_OVERFLOW) {\n oldItems = cutOffEvents(oldItems, overflow);\n eventCount -= overflow;\n }\n return new Branch(oldItems.append(newItems), eventCount)\n};\n\nBranch.prototype.remapping = function remapping (from, to) {\n var maps = new Mapping;\n this.items.forEach(function (item, i) {\n var mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from\n ? maps.maps.length - item.mirrorOffset : null;\n maps.appendMap(item.map, mirrorPos);\n }, from, to);\n return maps\n};\n\nBranch.prototype.addMaps = function addMaps (array) {\n if (this.eventCount == 0) { return this }\n return new Branch(this.items.append(array.map(function (map) { return new Item(map); })), this.eventCount)\n};\n\n// : (Transform, number)\n// When the collab module receives remote changes, the history has\n// to know about those, so that it can adjust the steps that were\n// rebased on top of the remote changes, and include the position\n// maps for the remote changes in its array of items.\nBranch.prototype.rebased = function rebased (rebasedTransform, rebasedCount) {\n if (!this.eventCount) { return this }\n\n var rebasedItems = [], start = Math.max(0, this.items.length - rebasedCount);\n\n var mapping = rebasedTransform.mapping;\n var newUntil = rebasedTransform.steps.length;\n var eventCount = this.eventCount;\n this.items.forEach(function (item) { if (item.selection) { eventCount--; } }, start);\n\n var iRebased = rebasedCount;\n this.items.forEach(function (item) {\n var pos = mapping.getMirror(--iRebased);\n if (pos == null) { return }\n newUntil = Math.min(newUntil, pos);\n var map = mapping.maps[pos];\n if (item.step) {\n var step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);\n var selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));\n if (selection) { eventCount++; }\n rebasedItems.push(new Item(map, step, selection));\n } else {\n rebasedItems.push(new Item(map));\n }\n }, start);\n\n var newMaps = [];\n for (var i = rebasedCount; i < newUntil; i++)\n { newMaps.push(new Item(mapping.maps[i])); }\n var items = this.items.slice(0, start).append(newMaps).append(rebasedItems);\n var branch = new Branch(items, eventCount);\n\n if (branch.emptyItemCount() > max_empty_items)\n { branch = branch.compress(this.items.length - rebasedItems.length); }\n return branch\n};\n\nBranch.prototype.emptyItemCount = function emptyItemCount () {\n var count = 0;\n this.items.forEach(function (item) { if (!item.step) { count++; } });\n return count\n};\n\n// Compressing a branch means rewriting it to push the air (map-only\n// items) out. During collaboration, these naturally accumulate\n// because each remote change adds one. The `upto` argument is used\n// to ensure that only the items below a given level are compressed,\n// because `rebased` relies on a clean, untouched set of items in\n// order to associate old items with rebased steps.\nBranch.prototype.compress = function compress (upto) {\n if ( upto === void 0 ) upto = this.items.length;\n\n var remap = this.remapping(0, upto), mapFrom = remap.maps.length;\n var items = [], events = 0;\n this.items.forEach(function (item, i) {\n if (i >= upto) {\n items.push(item);\n if (item.selection) { events++; }\n } else if (item.step) {\n var step = item.step.map(remap.slice(mapFrom)), map = step && step.getMap();\n mapFrom--;\n if (map) { remap.appendMap(map, mapFrom); }\n if (step) {\n var selection = item.selection && item.selection.map(remap.slice(mapFrom));\n if (selection) { events++; }\n var newItem = new Item(map.invert(), step, selection), merged, last = items.length - 1;\n if (merged = items.length && items[last].merge(newItem))\n { items[last] = merged; }\n else\n { items.push(newItem); }\n }\n } else if (item.map) {\n mapFrom--;\n }\n }, this.items.length, 0);\n return new Branch(RopeSequence.from(items.reverse()), events)\n};\n\nBranch.empty = new Branch(RopeSequence.empty, 0);\n\nfunction cutOffEvents(items, n) {\n var cutPoint;\n items.forEach(function (item, i) {\n if (item.selection && (n-- == 0)) {\n cutPoint = i;\n return false\n }\n });\n return items.slice(cutPoint)\n}\n\nvar Item = function Item(map, step, selection, mirrorOffset) {\n // The (forward) step map for this item.\n this.map = map;\n // The inverted step\n this.step = step;\n // If this is non-null, this item is the start of a group, and\n // this selection is the starting selection for the group (the one\n // that was active before the first step was applied)\n this.selection = selection;\n // If this item is the inverse of a previous mapping on the stack,\n // this points at the inverse's offset\n this.mirrorOffset = mirrorOffset;\n};\n\nItem.prototype.merge = function merge (other) {\n if (this.step && other.step && !other.selection) {\n var step = other.step.merge(this.step);\n if (step) { return new Item(step.getMap().invert(), step, this.selection) }\n }\n};\n\n// The value of the state field that tracks undo/redo history for that\n// state. Will be stored in the plugin state when the history plugin\n// is active.\nvar HistoryState = function HistoryState(done, undone, prevRanges, prevTime) {\n this.done = done;\n this.undone = undone;\n this.prevRanges = prevRanges;\n this.prevTime = prevTime;\n};\n\nvar DEPTH_OVERFLOW = 20;\n\n// : (HistoryState, EditorState, Transaction, Object)\n// Record a transformation in undo history.\nfunction applyTransaction(history, state, tr, options) {\n var historyTr = tr.getMeta(historyKey), rebased;\n if (historyTr) { return historyTr.historyState }\n\n if (tr.getMeta(closeHistoryKey)) { history = new HistoryState(history.done, history.undone, null, 0); }\n\n var appended = tr.getMeta(\"appendedTransaction\");\n\n if (tr.steps.length == 0) {\n return history\n } else if (appended && appended.getMeta(historyKey)) {\n if (appended.getMeta(historyKey).redo)\n { return new HistoryState(history.done.addTransform(tr, null, options, mustPreserveItems(state)),\n history.undone, rangesFor(tr.mapping.maps[tr.steps.length - 1]), history.prevTime) }\n else\n { return new HistoryState(history.done, history.undone.addTransform(tr, null, options, mustPreserveItems(state)),\n null, history.prevTime) }\n } else if (tr.getMeta(\"addToHistory\") !== false && !(appended && appended.getMeta(\"addToHistory\") === false)) {\n // Group transforms that occur in quick succession into one event.\n var newGroup = history.prevTime == 0 || !appended && (history.prevTime < (tr.time || 0) - options.newGroupDelay ||\n !isAdjacentTo(tr, history.prevRanges));\n var prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps[tr.steps.length - 1]);\n return new HistoryState(history.done.addTransform(tr, newGroup ? state.selection.getBookmark() : null,\n options, mustPreserveItems(state)),\n Branch.empty, prevRanges, tr.time)\n } else if (rebased = tr.getMeta(\"rebased\")) {\n // Used by the collab module to tell the history that some of its\n // content has been rebased.\n return new HistoryState(history.done.rebased(tr, rebased),\n history.undone.rebased(tr, rebased),\n mapRanges(history.prevRanges, tr.mapping), history.prevTime)\n } else {\n return new HistoryState(history.done.addMaps(tr.mapping.maps),\n history.undone.addMaps(tr.mapping.maps),\n mapRanges(history.prevRanges, tr.mapping), history.prevTime)\n }\n}\n\nfunction isAdjacentTo(transform, prevRanges) {\n if (!prevRanges) { return false }\n if (!transform.docChanged) { return true }\n var adjacent = false;\n transform.mapping.maps[0].forEach(function (start, end) {\n for (var i = 0; i < prevRanges.length; i += 2)\n { if (start <= prevRanges[i + 1] && end >= prevRanges[i])\n { adjacent = true; } }\n });\n return adjacent\n}\n\nfunction rangesFor(map) {\n var result = [];\n map.forEach(function (_from, _to, from, to) { return result.push(from, to); });\n return result\n}\n\nfunction mapRanges(ranges, mapping) {\n if (!ranges) { return null }\n var result = [];\n for (var i = 0; i < ranges.length; i += 2) {\n var from = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);\n if (from <= to) { result.push(from, to); }\n }\n return result\n}\n\n// : (HistoryState, EditorState, (tr: Transaction), bool)\n// Apply the latest event from one branch to the document and shift the event\n// onto the other branch.\nfunction histTransaction(history, state, dispatch, redo) {\n var preserveItems = mustPreserveItems(state), histOptions = historyKey.get(state).spec.config;\n var pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);\n if (!pop) { return }\n\n var selection = pop.selection.resolve(pop.transform.doc);\n var added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(),\n histOptions, preserveItems);\n\n var newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0);\n dispatch(pop.transform.setSelection(selection).setMeta(historyKey, {redo: redo, historyState: newHist}).scrollIntoView());\n}\n\nvar cachedPreserveItems = false, cachedPreserveItemsPlugins = null;\n// Check whether any plugin in the given state has a\n// `historyPreserveItems` property in its spec, in which case we must\n// preserve steps exactly as they came in, so that they can be\n// rebased.\nfunction mustPreserveItems(state) {\n var plugins = state.plugins;\n if (cachedPreserveItemsPlugins != plugins) {\n cachedPreserveItems = false;\n cachedPreserveItemsPlugins = plugins;\n for (var i = 0; i < plugins.length; i++) { if (plugins[i].spec.historyPreserveItems) {\n cachedPreserveItems = true;\n break\n } }\n }\n return cachedPreserveItems\n}\n\n// :: (Transaction) → Transaction\n// Set a flag on the given transaction that will prevent further steps\n// from being appended to an existing history event (so that they\n// require a separate undo command to undo).\nfunction closeHistory(tr) {\n return tr.setMeta(closeHistoryKey, true)\n}\n\nvar historyKey = new PluginKey(\"history\");\nvar closeHistoryKey = new PluginKey(\"closeHistory\");\n\n// :: (?Object) → Plugin\n// Returns a plugin that enables the undo history for an editor. The\n// plugin will track undo and redo stacks, which can be used with the\n// [`undo`](#history.undo) and [`redo`](#history.redo) commands.\n//\n// You can set an `\"addToHistory\"` [metadata\n// property](#state.Transaction.setMeta) of `false` on a transaction\n// to prevent it from being rolled back by undo.\n//\n// config::-\n// Supports the following configuration options:\n//\n// depth:: ?number\n// The amount of history events that are collected before the\n// oldest events are discarded. Defaults to 100.\n//\n// newGroupDelay:: ?number\n// The delay between changes after which a new group should be\n// started. Defaults to 500 (milliseconds). Note that when changes\n// aren't adjacent, a new group is always started.\nfunction history(config) {\n config = {depth: config && config.depth || 100,\n newGroupDelay: config && config.newGroupDelay || 500};\n return new Plugin({\n key: historyKey,\n\n state: {\n init: function init() {\n return new HistoryState(Branch.empty, Branch.empty, null, 0)\n },\n apply: function apply(tr, hist, state) {\n return applyTransaction(hist, state, tr, config)\n }\n },\n\n config: config,\n\n props: {\n handleDOMEvents: {\n beforeinput: function beforeinput(view, e) {\n var handled = e.inputType == \"historyUndo\" ? undo(view.state, view.dispatch) :\n e.inputType == \"historyRedo\" ? redo(view.state, view.dispatch) : false;\n if (handled) { e.preventDefault(); }\n return handled\n }\n }\n }\n })\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// A command function that undoes the last change, if any.\nfunction undo(state, dispatch) {\n var hist = historyKey.getState(state);\n if (!hist || hist.done.eventCount == 0) { return false }\n if (dispatch) { histTransaction(hist, state, dispatch, false); }\n return true\n}\n\n// :: (EditorState, ?(tr: Transaction)) → bool\n// A command function that redoes the last undone change, if any.\nfunction redo(state, dispatch) {\n var hist = historyKey.getState(state);\n if (!hist || hist.undone.eventCount == 0) { return false }\n if (dispatch) { histTransaction(hist, state, dispatch, true); }\n return true\n}\n\n// :: (EditorState) → number\n// The amount of undoable events available in a given state.\nfunction undoDepth(state) {\n var hist = historyKey.getState(state);\n return hist ? hist.done.eventCount : 0\n}\n\n// :: (EditorState) → number\n// The amount of redoable events available in a given editor state.\nfunction redoDepth(state) {\n var hist = historyKey.getState(state);\n return hist ? hist.undone.eventCount : 0\n}\n\nexport { HistoryState, closeHistory, history, redo, redoDepth, undo, undoDepth };\n//# sourceMappingURL=index.es.js.map\n","import { Extension } from '@tiptap/core';\nimport { undo, redo, history } from 'prosemirror-history';\n\nconst History = Extension.create({\r\n name: 'history',\r\n addOptions() {\r\n return {\r\n depth: 100,\r\n newGroupDelay: 500,\r\n };\r\n },\r\n addCommands() {\r\n return {\r\n undo: () => ({ state, dispatch }) => {\r\n return undo(state, dispatch);\r\n },\r\n redo: () => ({ state, dispatch }) => {\r\n return redo(state, dispatch);\r\n },\r\n };\r\n },\r\n addProseMirrorPlugins() {\r\n return [\r\n history(this.options),\r\n ];\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-z': () => this.editor.commands.undo(),\r\n 'Mod-y': () => this.editor.commands.redo(),\r\n 'Shift-Mod-z': () => this.editor.commands.redo(),\r\n // Russian keyboard layouts\r\n 'Mod-я': () => this.editor.commands.undo(),\r\n 'Shift-Mod-я': () => this.editor.commands.redo(),\r\n };\r\n },\r\n});\n\nexport { History, History as default };\n//# sourceMappingURL=tiptap-extension-history.esm.js.map\n","import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';\nimport { TextSelection } from 'prosemirror-state';\n\nconst HorizontalRule = Node.create({\r\n name: 'horizontalRule',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n group: 'block',\r\n parseHTML() {\r\n return [\r\n { tag: 'hr' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['hr', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];\r\n },\r\n addCommands() {\r\n return {\r\n setHorizontalRule: () => ({ chain }) => {\r\n return chain()\r\n .insertContent({ type: this.name })\r\n // set cursor after horizontal rule\r\n .command(({ tr, dispatch }) => {\r\n var _a;\r\n if (dispatch) {\r\n const { parent, pos } = tr.selection.$from;\r\n const posAfter = pos + 1;\r\n const nodeAfter = tr.doc.nodeAt(posAfter);\r\n if (nodeAfter) {\r\n tr.setSelection(TextSelection.create(tr.doc, posAfter));\r\n }\r\n else {\r\n // add node after horizontal rule if it’s the end of the document\r\n const node = (_a = parent.type.contentMatch.defaultType) === null || _a === void 0 ? void 0 : _a.create();\r\n if (node) {\r\n tr.insert(posAfter, node);\r\n tr.setSelection(TextSelection.create(tr.doc, posAfter));\r\n }\r\n }\r\n tr.scrollIntoView();\r\n }\r\n return true;\r\n })\r\n .run();\r\n },\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n nodeInputRule({\r\n find: /^(?:---|—-|___\\s|\\*\\*\\*\\s)$/,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { HorizontalRule, HorizontalRule as default };\n//# sourceMappingURL=tiptap-extension-horizontal-rule.esm.js.map\n","import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';\n\nconst starInputRegex = /(?:^|\\s)((?:\\*)((?:[^*]+))(?:\\*))$/;\r\nconst starPasteRegex = /(?:^|\\s)((?:\\*)((?:[^*]+))(?:\\*))/g;\r\nconst underscoreInputRegex = /(?:^|\\s)((?:_)((?:[^_]+))(?:_))$/;\r\nconst underscorePasteRegex = /(?:^|\\s)((?:_)((?:[^_]+))(?:_))/g;\r\nconst Italic = Mark.create({\r\n name: 'italic',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n parseHTML() {\r\n return [\r\n {\r\n tag: 'em',\r\n },\r\n {\r\n tag: 'i',\r\n getAttrs: node => node.style.fontStyle !== 'normal' && null,\r\n },\r\n {\r\n style: 'font-style=italic',\r\n },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['em', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setItalic: () => ({ commands }) => {\r\n return commands.setMark(this.name);\r\n },\r\n toggleItalic: () => ({ commands }) => {\r\n return commands.toggleMark(this.name);\r\n },\r\n unsetItalic: () => ({ commands }) => {\r\n return commands.unsetMark(this.name);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-i': () => this.editor.commands.toggleItalic(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n markInputRule({\r\n find: starInputRegex,\r\n type: this.type,\r\n }),\r\n markInputRule({\r\n find: underscoreInputRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n addPasteRules() {\r\n return [\r\n markPasteRule({\r\n find: starPasteRegex,\r\n type: this.type,\r\n }),\r\n markPasteRule({\r\n find: underscorePasteRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { Italic, Italic as default, starInputRegex, starPasteRegex, underscoreInputRegex, underscorePasteRegex };\n//# sourceMappingURL=tiptap-extension-italic.esm.js.map\n","import { Node, mergeAttributes } from '@tiptap/core';\n\nconst ListItem = Node.create({\r\n name: 'listItem',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n content: 'paragraph block*',\r\n defining: true,\r\n parseHTML() {\r\n return [\r\n {\r\n tag: 'li',\r\n },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['li', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n Enter: () => this.editor.commands.splitListItem(this.name),\r\n Tab: () => this.editor.commands.sinkListItem(this.name),\r\n 'Shift-Tab': () => this.editor.commands.liftListItem(this.name),\r\n };\r\n },\r\n});\n\nexport { ListItem, ListItem as default };\n//# sourceMappingURL=tiptap-extension-list-item.esm.js.map\n","import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core';\n\nconst inputRegex = /^(\\d+)\\.\\s$/;\r\nconst OrderedList = Node.create({\r\n name: 'orderedList',\r\n addOptions() {\r\n return {\r\n itemTypeName: 'listItem',\r\n HTMLAttributes: {},\r\n };\r\n },\r\n group: 'block list',\r\n content() {\r\n return `${this.options.itemTypeName}+`;\r\n },\r\n addAttributes() {\r\n return {\r\n start: {\r\n default: 1,\r\n parseHTML: element => {\r\n return element.hasAttribute('start')\r\n ? parseInt(element.getAttribute('start') || '', 10)\r\n : 1;\r\n },\r\n },\r\n };\r\n },\r\n parseHTML() {\r\n return [\r\n {\r\n tag: 'ol',\r\n },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n const { start, ...attributesWithoutStart } = HTMLAttributes;\r\n return start === 1\r\n ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]\r\n : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n toggleOrderedList: () => ({ commands }) => {\r\n return commands.toggleList(this.name, this.options.itemTypeName);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Shift-7': () => this.editor.commands.toggleOrderedList(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n wrappingInputRule({\r\n find: inputRegex,\r\n type: this.type,\r\n getAttributes: match => ({ start: +match[1] }),\r\n joinPredicate: (match, node) => node.childCount + node.attrs.start === +match[1],\r\n }),\r\n ];\r\n },\r\n});\n\nexport { OrderedList, OrderedList as default, inputRegex };\n//# sourceMappingURL=tiptap-extension-ordered-list.esm.js.map\n","import { Node, mergeAttributes } from '@tiptap/core';\n\nconst Paragraph = Node.create({\r\n name: 'paragraph',\r\n priority: 1000,\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n group: 'block',\r\n content: 'inline*',\r\n parseHTML() {\r\n return [\r\n { tag: 'p' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['p', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setParagraph: () => ({ commands }) => {\r\n return commands.setNode(this.name);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Alt-0': () => this.editor.commands.setParagraph(),\r\n };\r\n },\r\n});\n\nexport { Paragraph, Paragraph as default };\n//# sourceMappingURL=tiptap-extension-paragraph.esm.js.map\n","import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';\n\nconst inputRegex = /(?:^|\\s)((?:~~)((?:[^~]+))(?:~~))$/;\r\nconst pasteRegex = /(?:^|\\s)((?:~~)((?:[^~]+))(?:~~))/g;\r\nconst Strike = Mark.create({\r\n name: 'strike',\r\n addOptions() {\r\n return {\r\n HTMLAttributes: {},\r\n };\r\n },\r\n parseHTML() {\r\n return [\r\n {\r\n tag: 's',\r\n },\r\n {\r\n tag: 'del',\r\n },\r\n {\r\n tag: 'strike',\r\n },\r\n {\r\n style: 'text-decoration',\r\n consuming: false,\r\n getAttrs: style => (style.includes('line-through') ? {} : false),\r\n },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return ['s', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];\r\n },\r\n addCommands() {\r\n return {\r\n setStrike: () => ({ commands }) => {\r\n return commands.setMark(this.name);\r\n },\r\n toggleStrike: () => ({ commands }) => {\r\n return commands.toggleMark(this.name);\r\n },\r\n unsetStrike: () => ({ commands }) => {\r\n return commands.unsetMark(this.name);\r\n },\r\n };\r\n },\r\n addKeyboardShortcuts() {\r\n return {\r\n 'Mod-Shift-x': () => this.editor.commands.toggleStrike(),\r\n };\r\n },\r\n addInputRules() {\r\n return [\r\n markInputRule({\r\n find: inputRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n addPasteRules() {\r\n return [\r\n markPasteRule({\r\n find: pasteRegex,\r\n type: this.type,\r\n }),\r\n ];\r\n },\r\n});\n\nexport { Strike, Strike as default, inputRegex, pasteRegex };\n//# sourceMappingURL=tiptap-extension-strike.esm.js.map\n","import { Node } from '@tiptap/core';\n\nconst Text = Node.create({\r\n name: 'text',\r\n group: 'inline',\r\n});\n\nexport { Text, Text as default };\n//# sourceMappingURL=tiptap-extension-text.esm.js.map\n","import { Extension } from '@tiptap/core';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Code from '@tiptap/extension-code';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport Dropcursor from '@tiptap/extension-dropcursor';\nimport Gapcursor from '@tiptap/extension-gapcursor';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Heading from '@tiptap/extension-heading';\nimport History from '@tiptap/extension-history';\nimport HorizontalRule from '@tiptap/extension-horizontal-rule';\nimport Italic from '@tiptap/extension-italic';\nimport ListItem from '@tiptap/extension-list-item';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Strike from '@tiptap/extension-strike';\nimport Text from '@tiptap/extension-text';\n\nconst StarterKit = Extension.create({\r\n name: 'starterKit',\r\n addExtensions() {\r\n var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;\r\n const extensions = [];\r\n if (this.options.blockquote !== false) {\r\n extensions.push(Blockquote.configure((_a = this.options) === null || _a === void 0 ? void 0 : _a.blockquote));\r\n }\r\n if (this.options.bold !== false) {\r\n extensions.push(Bold.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.bold));\r\n }\r\n if (this.options.bulletList !== false) {\r\n extensions.push(BulletList.configure((_c = this.options) === null || _c === void 0 ? void 0 : _c.bulletList));\r\n }\r\n if (this.options.code !== false) {\r\n extensions.push(Code.configure((_d = this.options) === null || _d === void 0 ? void 0 : _d.code));\r\n }\r\n if (this.options.codeBlock !== false) {\r\n extensions.push(CodeBlock.configure((_e = this.options) === null || _e === void 0 ? void 0 : _e.codeBlock));\r\n }\r\n if (this.options.document !== false) {\r\n extensions.push(Document.configure((_f = this.options) === null || _f === void 0 ? void 0 : _f.document));\r\n }\r\n if (this.options.dropcursor !== false) {\r\n extensions.push(Dropcursor.configure((_g = this.options) === null || _g === void 0 ? void 0 : _g.dropcursor));\r\n }\r\n if (this.options.gapcursor !== false) {\r\n extensions.push(Gapcursor.configure((_h = this.options) === null || _h === void 0 ? void 0 : _h.gapcursor));\r\n }\r\n if (this.options.hardBreak !== false) {\r\n extensions.push(HardBreak.configure((_j = this.options) === null || _j === void 0 ? void 0 : _j.hardBreak));\r\n }\r\n if (this.options.heading !== false) {\r\n extensions.push(Heading.configure((_k = this.options) === null || _k === void 0 ? void 0 : _k.heading));\r\n }\r\n if (this.options.history !== false) {\r\n extensions.push(History.configure((_l = this.options) === null || _l === void 0 ? void 0 : _l.history));\r\n }\r\n if (this.options.horizontalRule !== false) {\r\n extensions.push(HorizontalRule.configure((_m = this.options) === null || _m === void 0 ? void 0 : _m.horizontalRule));\r\n }\r\n if (this.options.italic !== false) {\r\n extensions.push(Italic.configure((_o = this.options) === null || _o === void 0 ? void 0 : _o.italic));\r\n }\r\n if (this.options.listItem !== false) {\r\n extensions.push(ListItem.configure((_p = this.options) === null || _p === void 0 ? void 0 : _p.listItem));\r\n }\r\n if (this.options.orderedList !== false) {\r\n extensions.push(OrderedList.configure((_q = this.options) === null || _q === void 0 ? void 0 : _q.orderedList));\r\n }\r\n if (this.options.paragraph !== false) {\r\n extensions.push(Paragraph.configure((_r = this.options) === null || _r === void 0 ? void 0 : _r.paragraph));\r\n }\r\n if (this.options.strike !== false) {\r\n extensions.push(Strike.configure((_s = this.options) === null || _s === void 0 ? void 0 : _s.strike));\r\n }\r\n if (this.options.text !== false) {\r\n extensions.push(Text.configure((_t = this.options) === null || _t === void 0 ? void 0 : _t.text));\r\n }\r\n return extensions;\r\n },\r\n});\n\nexport { StarterKit as default };\n//# sourceMappingURL=tiptap-starter-kit.esm.js.map\n","/**\n * Finite State Machine generation utilities\n */\n\n/**\n * Define a basic state machine state. j is the list of character transitions,\n * jr is the list of regex-match transitions, jd is the default state to\n * transition to t is the accepting token type, if any. If this is the terminal\n * state, then it does not emit a token.\n * @param {string|class} token to emit\n */\nfunction State(token) {\n this.j = {}; // IMPLEMENTATION 1\n // this.j = []; // IMPLEMENTATION 2\n\n this.jr = [];\n this.jd = null;\n this.t = token;\n}\n/**\n * Take the transition from this state to the next one on the given input.\n * If this state does not exist deterministically, will create it.\n *\n * @param {string} input character or token to transition on\n * @param {string|class} [token] token or multi-token to emit when reaching\n * this state\n */\n\nState.prototype = {\n /**\n * @param {State} state\n */\n accepts: function accepts() {\n return !!this.t;\n },\n\n /**\n * Short for \"take transition\", this is a method for building/working with\n * state machines.\n *\n * If a state already exists for the given input, returns it.\n *\n * If a token is specified, that state will emit that token when reached by\n * the linkify engine.\n *\n * If no state exists, it will be initialized with some default transitions\n * that resemble existing default transitions.\n *\n * If a state is given for the second argument, that state will be\n * transitioned to on the given input regardless of what that input\n * previously did.\n *\n * @param {string} input character or token to transition on\n * @param {Token|State} tokenOrState transition to a matching state\n * @returns State taken after the given input\n */\n tt: function tt(input, tokenOrState) {\n if (tokenOrState && tokenOrState.j) {\n // State, default a basic transition\n this.j[input] = tokenOrState;\n return tokenOrState;\n } // See if there's a direct state transition (not regex or default)\n\n\n var token = tokenOrState;\n var nextState = this.j[input];\n\n if (nextState) {\n if (token) {\n nextState.t = token;\n } // overrwites previous token\n\n\n return nextState;\n } // Create a new state for this input\n\n\n nextState = makeState(); // Take the transition using the usual default mechanisms\n\n var templateState = takeT(this, input);\n\n if (templateState) {\n // Some default state transition, make a prime state based on this one\n Object.assign(nextState.j, templateState.j);\n nextState.jr.append(templateState.jr);\n nextState.jr = templateState.jd;\n nextState.t = token || templateState.t;\n } else {\n nextState.t = token;\n }\n\n this.j[input] = nextState;\n return nextState;\n }\n};\n/**\n * Utility function to create state without using new keyword (reduced file size\n * when minified)\n */\n\nvar makeState = function makeState() {\n return new State();\n};\n/**\n * Similar to previous except it is an accepting state that emits a token\n * @param {Token} token\n */\n\nvar makeAcceptingState = function makeAcceptingState(token) {\n return new State(token);\n};\n/**\n * Create a transition from startState to nextState via the given character\n * @param {State} startState transition from thie starting state\n * @param {Token} input via this input character or other concrete token type\n * @param {State} nextState to this next state\n */\n\nvar makeT = function makeT(startState, input, nextState) {\n // IMPLEMENTATION 1: Add to object (fast)\n if (!startState.j[input]) {\n startState.j[input] = nextState;\n } // IMPLEMENTATION 2: Add to array (slower)\n // startState.j.push([input, nextState]);\n\n};\n/**\n *\n * @param {State} startState stransition from this starting state\n * @param {RegExp} regex Regular expression to match on input\n * @param {State} nextState transition to this next state if there's are regex match\n */\n\nvar makeRegexT = function makeRegexT(startState, regex, nextState) {\n startState.jr.push([regex, nextState]);\n};\n/**\n * Follow the transition from the given character to the next state\n * @param {State} state\n * @param {Token} input character or other concrete token type to transition\n * @returns {?State} the next state, if any\n */\n\nvar takeT = function takeT(state, input) {\n // IMPLEMENTATION 1: Object key lookup (faster)\n var nextState = state.j[input];\n\n if (nextState) {\n return nextState;\n } // IMPLEMENTATION 2: List lookup (slower)\n // Loop through all the state transitions and see if there's a match\n // for (let i = 0; i < state.j.length; i++) {\n //\tconst val = state.j[i][0];\n //\tconst nextState = state.j[i][1];\n // \tif (input === val) { return nextState; }\n // }\n\n\n for (var i = 0; i < state.jr.length; i++) {\n var regex = state.jr[i][0];\n var _nextState = state.jr[i][1];\n\n if (regex.test(input)) {\n return _nextState;\n }\n } // Nowhere left to jump! Return default, if any\n\n\n return state.jd;\n};\n/**\n * Similar to makeT, but takes a list of characters that all transition to the\n * same nextState startState\n * @param {State} startState\n * @param {Array} chars\n * @param {State} nextState\n */\n\nvar makeMultiT = function makeMultiT(startState, chars, nextState) {\n for (var i = 0; i < chars.length; i++) {\n makeT(startState, chars[i], nextState);\n }\n};\n/**\n * Set up a list of multiple transitions at once. transitions is a list of\n * tuples, where the first element is the transitions character and the second\n * is the state to transition to\n * @param {State} startState\n * @param {Array} transitions\n */\n\nvar makeBatchT = function makeBatchT(startState, transitions) {\n for (var i = 0; i < transitions.length; i++) {\n var input = transitions[i][0];\n var nextState = transitions[i][1];\n makeT(startState, input, nextState);\n }\n};\n/**\n * For state machines that transition on characters only; given a non-empty\n * target string, generates states (if required) for each consecutive substring\n * of characters starting from the beginning of the string. The final state will\n * have a special value, as specified in options. All other \"in between\"\n * substrings will have a default end state.\n *\n * This turns the state machine into a Trie-like data structure (rather than a\n * intelligently-designed DFA).\n * @param {State} state\n * @param {string} str\n * @param {Token} endStateFactory\n * @param {Token} defaultStateFactory\n */\n\nvar makeChainT = function makeChainT(state, str, endState, defaultStateFactory) {\n var i = 0,\n len = str.length,\n nextState; // Find the next state without a jump to the next character\n\n while (i < len && (nextState = state.j[str[i]])) {\n state = nextState;\n i++;\n }\n\n if (i >= len) {\n return [];\n } // no new tokens were added\n\n\n while (i < len - 1) {\n nextState = defaultStateFactory();\n makeT(state, str[i], nextState);\n state = nextState;\n i++;\n }\n\n makeT(state, str[len - 1], endState);\n};\n\n/******************************************************************************\n\tText Tokens\n\tTokens composed of strings\n******************************************************************************/\n// A valid web domain token\nvar DOMAIN = 'DOMAIN';\nvar LOCALHOST = 'LOCALHOST'; // special case of domain\n// Valid top-level domain (see tlds.js)\n\nvar TLD = 'TLD'; // Any sequence of digits 0-9\n\nvar NUM = 'NUM'; // A web URL protocol. Supported types include\n// - `http:`\n// - `https:`\n// - `ftp:`\n// - `ftps:`\n// - user-defined custom protocols\n\nvar PROTOCOL = 'PROTOCOL'; // Start of the email URI protocol\n\nvar MAILTO = 'MAILTO'; // mailto:\n// Any number of consecutive whitespace characters that are not newline\n\nvar WS = 'WS'; // New line (unix style)\n\nvar NL = 'NL'; // \\n\n// Opening/closing bracket classes\n\nvar OPENBRACE = 'OPENBRACE'; // {\n\nvar OPENBRACKET = 'OPENBRACKET'; // [\n\nvar OPENANGLEBRACKET = 'OPENANGLEBRACKET'; // <\n\nvar OPENPAREN = 'OPENPAREN'; // (\n\nvar CLOSEBRACE = 'CLOSEBRACE'; // }\n\nvar CLOSEBRACKET = 'CLOSEBRACKET'; // ]\n\nvar CLOSEANGLEBRACKET = 'CLOSEANGLEBRACKET'; // >\n\nvar CLOSEPAREN = 'CLOSEPAREN'; // )\n// Various symbols\n\nvar AMPERSAND = 'AMPERSAND'; // &\n\nvar APOSTROPHE = 'APOSTROPHE'; // '\n\nvar ASTERISK = 'ASTERISK'; // *\n\nvar AT = 'AT'; // @\n\nvar BACKSLASH = 'BACKSLASH'; // \\\n\nvar BACKTICK = 'BACKTICK'; // `\n\nvar CARET = 'CARET'; // ^\n\nvar COLON = 'COLON'; // :\n\nvar COMMA = 'COMMA'; // ,\n\nvar DOLLAR = 'DOLLAR'; // $\n\nvar DOT = 'DOT'; // .\n\nvar EQUALS = 'EQUALS'; // =\n\nvar EXCLAMATION = 'EXCLAMATION'; // !\n\nvar HYPHEN = 'HYPHEN'; // -\n\nvar PERCENT = 'PERCENT'; // %\n\nvar PIPE = 'PIPE'; // |\n\nvar PLUS = 'PLUS'; // +\n\nvar POUND = 'POUND'; // #\n\nvar QUERY = 'QUERY'; // ?\n\nvar QUOTE = 'QUOTE'; // \"\n\nvar SEMI = 'SEMI'; // ;\n\nvar SLASH = 'SLASH'; // /\n\nvar TILDE = 'TILDE'; // ~\n\nvar UNDERSCORE = 'UNDERSCORE'; // _\n// Default token - anything that is not one of the above\n\nvar SYM = 'SYM';\n\nvar text = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tDOMAIN: DOMAIN,\n\tLOCALHOST: LOCALHOST,\n\tTLD: TLD,\n\tNUM: NUM,\n\tPROTOCOL: PROTOCOL,\n\tMAILTO: MAILTO,\n\tWS: WS,\n\tNL: NL,\n\tOPENBRACE: OPENBRACE,\n\tOPENBRACKET: OPENBRACKET,\n\tOPENANGLEBRACKET: OPENANGLEBRACKET,\n\tOPENPAREN: OPENPAREN,\n\tCLOSEBRACE: CLOSEBRACE,\n\tCLOSEBRACKET: CLOSEBRACKET,\n\tCLOSEANGLEBRACKET: CLOSEANGLEBRACKET,\n\tCLOSEPAREN: CLOSEPAREN,\n\tAMPERSAND: AMPERSAND,\n\tAPOSTROPHE: APOSTROPHE,\n\tASTERISK: ASTERISK,\n\tAT: AT,\n\tBACKSLASH: BACKSLASH,\n\tBACKTICK: BACKTICK,\n\tCARET: CARET,\n\tCOLON: COLON,\n\tCOMMA: COMMA,\n\tDOLLAR: DOLLAR,\n\tDOT: DOT,\n\tEQUALS: EQUALS,\n\tEXCLAMATION: EXCLAMATION,\n\tHYPHEN: HYPHEN,\n\tPERCENT: PERCENT,\n\tPIPE: PIPE,\n\tPLUS: PLUS,\n\tPOUND: POUND,\n\tQUERY: QUERY,\n\tQUOTE: QUOTE,\n\tSEMI: SEMI,\n\tSLASH: SLASH,\n\tTILDE: TILDE,\n\tUNDERSCORE: UNDERSCORE,\n\tSYM: SYM\n});\n\n// NOTE: punycode versions of IDNs are not included here because these will not\n// be as commonly used without the http prefix anyway and linkify will already\n// force-encode those.\n// To be updated with the values in this list\n// http://data.iana.org/TLD/tlds-alpha-by-domain.txt\n// Version 2021022800, Last Updated Sun Feb 28 07:07:01 2021 UTC\nvar tlds = 'aaa \\\naarp \\\nabarth \\\nabb \\\nabbott \\\nabbvie \\\nabc \\\nable \\\nabogado \\\nabudhabi \\\nac \\\nacademy \\\naccenture \\\naccountant \\\naccountants \\\naco \\\nactor \\\nad \\\nadac \\\nads \\\nadult \\\nae \\\naeg \\\naero \\\naetna \\\naf \\\nafamilycompany \\\nafl \\\nafrica \\\nag \\\nagakhan \\\nagency \\\nai \\\naig \\\nairbus \\\nairforce \\\nairtel \\\nakdn \\\nal \\\nalfaromeo \\\nalibaba \\\nalipay \\\nallfinanz \\\nallstate \\\nally \\\nalsace \\\nalstom \\\nam \\\namazon \\\namericanexpress \\\namericanfamily \\\namex \\\namfam \\\namica \\\namsterdam \\\nanalytics \\\nandroid \\\nanquan \\\nanz \\\nao \\\naol \\\napartments \\\napp \\\napple \\\naq \\\naquarelle \\\nar \\\narab \\\naramco \\\narchi \\\narmy \\\narpa \\\nart \\\narte \\\nas \\\nasda \\\nasia \\\nassociates \\\nat \\\nathleta \\\nattorney \\\nau \\\nauction \\\naudi \\\naudible \\\naudio \\\nauspost \\\nauthor \\\nauto \\\nautos \\\navianca \\\naw \\\naws \\\nax \\\naxa \\\naz \\\nazure \\\nba \\\nbaby \\\nbaidu \\\nbanamex \\\nbananarepublic \\\nband \\\nbank \\\nbar \\\nbarcelona \\\nbarclaycard \\\nbarclays \\\nbarefoot \\\nbargains \\\nbaseball \\\nbasketball \\\nbauhaus \\\nbayern \\\nbb \\\nbbc \\\nbbt \\\nbbva \\\nbcg \\\nbcn \\\nbd \\\nbe \\\nbeats \\\nbeauty \\\nbeer \\\nbentley \\\nberlin \\\nbest \\\nbestbuy \\\nbet \\\nbf \\\nbg \\\nbh \\\nbharti \\\nbi \\\nbible \\\nbid \\\nbike \\\nbing \\\nbingo \\\nbio \\\nbiz \\\nbj \\\nblack \\\nblackfriday \\\nblockbuster \\\nblog \\\nbloomberg \\\nblue \\\nbm \\\nbms \\\nbmw \\\nbn \\\nbnpparibas \\\nbo \\\nboats \\\nboehringer \\\nbofa \\\nbom \\\nbond \\\nboo \\\nbook \\\nbooking \\\nbosch \\\nbostik \\\nboston \\\nbot \\\nboutique \\\nbox \\\nbr \\\nbradesco \\\nbridgestone \\\nbroadway \\\nbroker \\\nbrother \\\nbrussels \\\nbs \\\nbt \\\nbudapest \\\nbugatti \\\nbuild \\\nbuilders \\\nbusiness \\\nbuy \\\nbuzz \\\nbv \\\nbw \\\nby \\\nbz \\\nbzh \\\nca \\\ncab \\\ncafe \\\ncal \\\ncall \\\ncalvinklein \\\ncam \\\ncamera \\\ncamp \\\ncancerresearch \\\ncanon \\\ncapetown \\\ncapital \\\ncapitalone \\\ncar \\\ncaravan \\\ncards \\\ncare \\\ncareer \\\ncareers \\\ncars \\\ncasa \\\ncase \\\ncash \\\ncasino \\\ncat \\\ncatering \\\ncatholic \\\ncba \\\ncbn \\\ncbre \\\ncbs \\\ncc \\\ncd \\\ncenter \\\nceo \\\ncern \\\ncf \\\ncfa \\\ncfd \\\ncg \\\nch \\\nchanel \\\nchannel \\\ncharity \\\nchase \\\nchat \\\ncheap \\\nchintai \\\nchristmas \\\nchrome \\\nchurch \\\nci \\\ncipriani \\\ncircle \\\ncisco \\\ncitadel \\\nciti \\\ncitic \\\ncity \\\ncityeats \\\nck \\\ncl \\\nclaims \\\ncleaning \\\nclick \\\nclinic \\\nclinique \\\nclothing \\\ncloud \\\nclub \\\nclubmed \\\ncm \\\ncn \\\nco \\\ncoach \\\ncodes \\\ncoffee \\\ncollege \\\ncologne \\\ncom \\\ncomcast \\\ncommbank \\\ncommunity \\\ncompany \\\ncompare \\\ncomputer \\\ncomsec \\\ncondos \\\nconstruction \\\nconsulting \\\ncontact \\\ncontractors \\\ncooking \\\ncookingchannel \\\ncool \\\ncoop \\\ncorsica \\\ncountry \\\ncoupon \\\ncoupons \\\ncourses \\\ncpa \\\ncr \\\ncredit \\\ncreditcard \\\ncreditunion \\\ncricket \\\ncrown \\\ncrs \\\ncruise \\\ncruises \\\ncsc \\\ncu \\\ncuisinella \\\ncv \\\ncw \\\ncx \\\ncy \\\ncymru \\\ncyou \\\ncz \\\ndabur \\\ndad \\\ndance \\\ndata \\\ndate \\\ndating \\\ndatsun \\\nday \\\ndclk \\\ndds \\\nde \\\ndeal \\\ndealer \\\ndeals \\\ndegree \\\ndelivery \\\ndell \\\ndeloitte \\\ndelta \\\ndemocrat \\\ndental \\\ndentist \\\ndesi \\\ndesign \\\ndev \\\ndhl \\\ndiamonds \\\ndiet \\\ndigital \\\ndirect \\\ndirectory \\\ndiscount \\\ndiscover \\\ndish \\\ndiy \\\ndj \\\ndk \\\ndm \\\ndnp \\\ndo \\\ndocs \\\ndoctor \\\ndog \\\ndomains \\\ndot \\\ndownload \\\ndrive \\\ndtv \\\ndubai \\\nduck \\\ndunlop \\\ndupont \\\ndurban \\\ndvag \\\ndvr \\\ndz \\\nearth \\\neat \\\nec \\\neco \\\nedeka \\\nedu \\\neducation \\\nee \\\neg \\\nemail \\\nemerck \\\nenergy \\\nengineer \\\nengineering \\\nenterprises \\\nepson \\\nequipment \\\ner \\\nericsson \\\nerni \\\nes \\\nesq \\\nestate \\\net \\\netisalat \\\neu \\\neurovision \\\neus \\\nevents \\\nexchange \\\nexpert \\\nexposed \\\nexpress \\\nextraspace \\\nfage \\\nfail \\\nfairwinds \\\nfaith \\\nfamily \\\nfan \\\nfans \\\nfarm \\\nfarmers \\\nfashion \\\nfast \\\nfedex \\\nfeedback \\\nferrari \\\nferrero \\\nfi \\\nfiat \\\nfidelity \\\nfido \\\nfilm \\\nfinal \\\nfinance \\\nfinancial \\\nfire \\\nfirestone \\\nfirmdale \\\nfish \\\nfishing \\\nfit \\\nfitness \\\nfj \\\nfk \\\nflickr \\\nflights \\\nflir \\\nflorist \\\nflowers \\\nfly \\\nfm \\\nfo \\\nfoo \\\nfood \\\nfoodnetwork \\\nfootball \\\nford \\\nforex \\\nforsale \\\nforum \\\nfoundation \\\nfox \\\nfr \\\nfree \\\nfresenius \\\nfrl \\\nfrogans \\\nfrontdoor \\\nfrontier \\\nftr \\\nfujitsu \\\nfujixerox \\\nfun \\\nfund \\\nfurniture \\\nfutbol \\\nfyi \\\nga \\\ngal \\\ngallery \\\ngallo \\\ngallup \\\ngame \\\ngames \\\ngap \\\ngarden \\\ngay \\\ngb \\\ngbiz \\\ngd \\\ngdn \\\nge \\\ngea \\\ngent \\\ngenting \\\ngeorge \\\ngf \\\ngg \\\nggee \\\ngh \\\ngi \\\ngift \\\ngifts \\\ngives \\\ngiving \\\ngl \\\nglade \\\nglass \\\ngle \\\nglobal \\\nglobo \\\ngm \\\ngmail \\\ngmbh \\\ngmo \\\ngmx \\\ngn \\\ngodaddy \\\ngold \\\ngoldpoint \\\ngolf \\\ngoo \\\ngoodyear \\\ngoog \\\ngoogle \\\ngop \\\ngot \\\ngov \\\ngp \\\ngq \\\ngr \\\ngrainger \\\ngraphics \\\ngratis \\\ngreen \\\ngripe \\\ngrocery \\\ngroup \\\ngs \\\ngt \\\ngu \\\nguardian \\\ngucci \\\nguge \\\nguide \\\nguitars \\\nguru \\\ngw \\\ngy \\\nhair \\\nhamburg \\\nhangout \\\nhaus \\\nhbo \\\nhdfc \\\nhdfcbank \\\nhealth \\\nhealthcare \\\nhelp \\\nhelsinki \\\nhere \\\nhermes \\\nhgtv \\\nhiphop \\\nhisamitsu \\\nhitachi \\\nhiv \\\nhk \\\nhkt \\\nhm \\\nhn \\\nhockey \\\nholdings \\\nholiday \\\nhomedepot \\\nhomegoods \\\nhomes \\\nhomesense \\\nhonda \\\nhorse \\\nhospital \\\nhost \\\nhosting \\\nhot \\\nhoteles \\\nhotels \\\nhotmail \\\nhouse \\\nhow \\\nhr \\\nhsbc \\\nht \\\nhu \\\nhughes \\\nhyatt \\\nhyundai \\\nibm \\\nicbc \\\nice \\\nicu \\\nid \\\nie \\\nieee \\\nifm \\\nikano \\\nil \\\nim \\\nimamat \\\nimdb \\\nimmo \\\nimmobilien \\\nin \\\ninc \\\nindustries \\\ninfiniti \\\ninfo \\\ning \\\nink \\\ninstitute \\\ninsurance \\\ninsure \\\nint \\\ninternational \\\nintuit \\\ninvestments \\\nio \\\nipiranga \\\niq \\\nir \\\nirish \\\nis \\\nismaili \\\nist \\\nistanbul \\\nit \\\nitau \\\nitv \\\niveco \\\njaguar \\\njava \\\njcb \\\nje \\\njeep \\\njetzt \\\njewelry \\\njio \\\njll \\\njm \\\njmp \\\njnj \\\njo \\\njobs \\\njoburg \\\njot \\\njoy \\\njp \\\njpmorgan \\\njprs \\\njuegos \\\njuniper \\\nkaufen \\\nkddi \\\nke \\\nkerryhotels \\\nkerrylogistics \\\nkerryproperties \\\nkfh \\\nkg \\\nkh \\\nki \\\nkia \\\nkim \\\nkinder \\\nkindle \\\nkitchen \\\nkiwi \\\nkm \\\nkn \\\nkoeln \\\nkomatsu \\\nkosher \\\nkp \\\nkpmg \\\nkpn \\\nkr \\\nkrd \\\nkred \\\nkuokgroup \\\nkw \\\nky \\\nkyoto \\\nkz \\\nla \\\nlacaixa \\\nlamborghini \\\nlamer \\\nlancaster \\\nlancia \\\nland \\\nlandrover \\\nlanxess \\\nlasalle \\\nlat \\\nlatino \\\nlatrobe \\\nlaw \\\nlawyer \\\nlb \\\nlc \\\nlds \\\nlease \\\nleclerc \\\nlefrak \\\nlegal \\\nlego \\\nlexus \\\nlgbt \\\nli \\\nlidl \\\nlife \\\nlifeinsurance \\\nlifestyle \\\nlighting \\\nlike \\\nlilly \\\nlimited \\\nlimo \\\nlincoln \\\nlinde \\\nlink \\\nlipsy \\\nlive \\\nliving \\\nlixil \\\nlk \\\nllc \\\nllp \\\nloan \\\nloans \\\nlocker \\\nlocus \\\nloft \\\nlol \\\nlondon \\\nlotte \\\nlotto \\\nlove \\\nlpl \\\nlplfinancial \\\nlr \\\nls \\\nlt \\\nltd \\\nltda \\\nlu \\\nlundbeck \\\nluxe \\\nluxury \\\nlv \\\nly \\\nma \\\nmacys \\\nmadrid \\\nmaif \\\nmaison \\\nmakeup \\\nman \\\nmanagement \\\nmango \\\nmap \\\nmarket \\\nmarketing \\\nmarkets \\\nmarriott \\\nmarshalls \\\nmaserati \\\nmattel \\\nmba \\\nmc \\\nmckinsey \\\nmd \\\nme \\\nmed \\\nmedia \\\nmeet \\\nmelbourne \\\nmeme \\\nmemorial \\\nmen \\\nmenu \\\nmerckmsd \\\nmg \\\nmh \\\nmiami \\\nmicrosoft \\\nmil \\\nmini \\\nmint \\\nmit \\\nmitsubishi \\\nmk \\\nml \\\nmlb \\\nmls \\\nmm \\\nmma \\\nmn \\\nmo \\\nmobi \\\nmobile \\\nmoda \\\nmoe \\\nmoi \\\nmom \\\nmonash \\\nmoney \\\nmonster \\\nmormon \\\nmortgage \\\nmoscow \\\nmoto \\\nmotorcycles \\\nmov \\\nmovie \\\nmp \\\nmq \\\nmr \\\nms \\\nmsd \\\nmt \\\nmtn \\\nmtr \\\nmu \\\nmuseum \\\nmutual \\\nmv \\\nmw \\\nmx \\\nmy \\\nmz \\\nna \\\nnab \\\nnagoya \\\nname \\\nnationwide \\\nnatura \\\nnavy \\\nnba \\\nnc \\\nne \\\nnec \\\nnet \\\nnetbank \\\nnetflix \\\nnetwork \\\nneustar \\\nnew \\\nnews \\\nnext \\\nnextdirect \\\nnexus \\\nnf \\\nnfl \\\nng \\\nngo \\\nnhk \\\nni \\\nnico \\\nnike \\\nnikon \\\nninja \\\nnissan \\\nnissay \\\nnl \\\nno \\\nnokia \\\nnorthwesternmutual \\\nnorton \\\nnow \\\nnowruz \\\nnowtv \\\nnp \\\nnr \\\nnra \\\nnrw \\\nntt \\\nnu \\\nnyc \\\nnz \\\nobi \\\nobserver \\\noff \\\noffice \\\nokinawa \\\nolayan \\\nolayangroup \\\noldnavy \\\nollo \\\nom \\\nomega \\\none \\\nong \\\nonl \\\nonline \\\nonyourside \\\nooo \\\nopen \\\noracle \\\norange \\\norg \\\norganic \\\norigins \\\nosaka \\\notsuka \\\nott \\\novh \\\npa \\\npage \\\npanasonic \\\nparis \\\npars \\\npartners \\\nparts \\\nparty \\\npassagens \\\npay \\\npccw \\\npe \\\npet \\\npf \\\npfizer \\\npg \\\nph \\\npharmacy \\\nphd \\\nphilips \\\nphone \\\nphoto \\\nphotography \\\nphotos \\\nphysio \\\npics \\\npictet \\\npictures \\\npid \\\npin \\\nping \\\npink \\\npioneer \\\npizza \\\npk \\\npl \\\nplace \\\nplay \\\nplaystation \\\nplumbing \\\nplus \\\npm \\\npn \\\npnc \\\npohl \\\npoker \\\npolitie \\\nporn \\\npost \\\npr \\\npramerica \\\npraxi \\\npress \\\nprime \\\npro \\\nprod \\\nproductions \\\nprof \\\nprogressive \\\npromo \\\nproperties \\\nproperty \\\nprotection \\\npru \\\nprudential \\\nps \\\npt \\\npub \\\npw \\\npwc \\\npy \\\nqa \\\nqpon \\\nquebec \\\nquest \\\nqvc \\\nracing \\\nradio \\\nraid \\\nre \\\nread \\\nrealestate \\\nrealtor \\\nrealty \\\nrecipes \\\nred \\\nredstone \\\nredumbrella \\\nrehab \\\nreise \\\nreisen \\\nreit \\\nreliance \\\nren \\\nrent \\\nrentals \\\nrepair \\\nreport \\\nrepublican \\\nrest \\\nrestaurant \\\nreview \\\nreviews \\\nrexroth \\\nrich \\\nrichardli \\\nricoh \\\nril \\\nrio \\\nrip \\\nrmit \\\nro \\\nrocher \\\nrocks \\\nrodeo \\\nrogers \\\nroom \\\nrs \\\nrsvp \\\nru \\\nrugby \\\nruhr \\\nrun \\\nrw \\\nrwe \\\nryukyu \\\nsa \\\nsaarland \\\nsafe \\\nsafety \\\nsakura \\\nsale \\\nsalon \\\nsamsclub \\\nsamsung \\\nsandvik \\\nsandvikcoromant \\\nsanofi \\\nsap \\\nsarl \\\nsas \\\nsave \\\nsaxo \\\nsb \\\nsbi \\\nsbs \\\nsc \\\nsca \\\nscb \\\nschaeffler \\\nschmidt \\\nscholarships \\\nschool \\\nschule \\\nschwarz \\\nscience \\\nscjohnson \\\nscot \\\nsd \\\nse \\\nsearch \\\nseat \\\nsecure \\\nsecurity \\\nseek \\\nselect \\\nsener \\\nservices \\\nses \\\nseven \\\nsew \\\nsex \\\nsexy \\\nsfr \\\nsg \\\nsh \\\nshangrila \\\nsharp \\\nshaw \\\nshell \\\nshia \\\nshiksha \\\nshoes \\\nshop \\\nshopping \\\nshouji \\\nshow \\\nshowtime \\\nsi \\\nsilk \\\nsina \\\nsingles \\\nsite \\\nsj \\\nsk \\\nski \\\nskin \\\nsky \\\nskype \\\nsl \\\nsling \\\nsm \\\nsmart \\\nsmile \\\nsn \\\nsncf \\\nso \\\nsoccer \\\nsocial \\\nsoftbank \\\nsoftware \\\nsohu \\\nsolar \\\nsolutions \\\nsong \\\nsony \\\nsoy \\\nspa \\\nspace \\\nsport \\\nspot \\\nspreadbetting \\\nsr \\\nsrl \\\nss \\\nst \\\nstada \\\nstaples \\\nstar \\\nstatebank \\\nstatefarm \\\nstc \\\nstcgroup \\\nstockholm \\\nstorage \\\nstore \\\nstream \\\nstudio \\\nstudy \\\nstyle \\\nsu \\\nsucks \\\nsupplies \\\nsupply \\\nsupport \\\nsurf \\\nsurgery \\\nsuzuki \\\nsv \\\nswatch \\\nswiftcover \\\nswiss \\\nsx \\\nsy \\\nsydney \\\nsystems \\\nsz \\\ntab \\\ntaipei \\\ntalk \\\ntaobao \\\ntarget \\\ntatamotors \\\ntatar \\\ntattoo \\\ntax \\\ntaxi \\\ntc \\\ntci \\\ntd \\\ntdk \\\nteam \\\ntech \\\ntechnology \\\ntel \\\ntemasek \\\ntennis \\\nteva \\\ntf \\\ntg \\\nth \\\nthd \\\ntheater \\\ntheatre \\\ntiaa \\\ntickets \\\ntienda \\\ntiffany \\\ntips \\\ntires \\\ntirol \\\ntj \\\ntjmaxx \\\ntjx \\\ntk \\\ntkmaxx \\\ntl \\\ntm \\\ntmall \\\ntn \\\nto \\\ntoday \\\ntokyo \\\ntools \\\ntop \\\ntoray \\\ntoshiba \\\ntotal \\\ntours \\\ntown \\\ntoyota \\\ntoys \\\ntr \\\ntrade \\\ntrading \\\ntraining \\\ntravel \\\ntravelchannel \\\ntravelers \\\ntravelersinsurance \\\ntrust \\\ntrv \\\ntt \\\ntube \\\ntui \\\ntunes \\\ntushu \\\ntv \\\ntvs \\\ntw \\\ntz \\\nua \\\nubank \\\nubs \\\nug \\\nuk \\\nunicom \\\nuniversity \\\nuno \\\nuol \\\nups \\\nus \\\nuy \\\nuz \\\nva \\\nvacations \\\nvana \\\nvanguard \\\nvc \\\nve \\\nvegas \\\nventures \\\nverisign \\\nversicherung \\\nvet \\\nvg \\\nvi \\\nviajes \\\nvideo \\\nvig \\\nviking \\\nvillas \\\nvin \\\nvip \\\nvirgin \\\nvisa \\\nvision \\\nviva \\\nvivo \\\nvlaanderen \\\nvn \\\nvodka \\\nvolkswagen \\\nvolvo \\\nvote \\\nvoting \\\nvoto \\\nvoyage \\\nvu \\\nvuelos \\\nwales \\\nwalmart \\\nwalter \\\nwang \\\nwanggou \\\nwatch \\\nwatches \\\nweather \\\nweatherchannel \\\nwebcam \\\nweber \\\nwebsite \\\nwed \\\nwedding \\\nweibo \\\nweir \\\nwf \\\nwhoswho \\\nwien \\\nwiki \\\nwilliamhill \\\nwin \\\nwindows \\\nwine \\\nwinners \\\nwme \\\nwolterskluwer \\\nwoodside \\\nwork \\\nworks \\\nworld \\\nwow \\\nws \\\nwtc \\\nwtf \\\nxbox \\\nxerox \\\nxfinity \\\nxihuan \\\nxin \\\nxxx \\\nxyz \\\nyachts \\\nyahoo \\\nyamaxun \\\nyandex \\\nye \\\nyodobashi \\\nyoga \\\nyokohama \\\nyou \\\nyoutube \\\nyt \\\nyun \\\nza \\\nzappos \\\nzara \\\nzero \\\nzip \\\nzm \\\nzone \\\nzuerich \\\nzw \\\nvermögensberater-ctb \\\nvermögensberatung-pwb \\\nελ \\\nευ \\\nбг \\\nбел \\\nдети \\\nею \\\nкатолик \\\nком \\\nқаз \\\nмкд \\\nмон \\\nмосква \\\nонлайн \\\nорг \\\nрус \\\nрф \\\nсайт \\\nсрб \\\nукр \\\nგე \\\nհայ \\\nישראל \\\nקום \\\nابوظبي \\\nاتصالات \\\nارامكو \\\nالاردن \\\nالبحرين \\\nالجزائر \\\nالسعودية \\\nالعليان \\\nالمغرب \\\nامارات \\\nایران \\\nبارت \\\nبازار \\\nبھارت \\\nبيتك \\\nپاکستان \\\nڀارت \\\nتونس \\\nسودان \\\nسورية \\\nشبكة \\\nعراق \\\nعرب \\\nعمان \\\nفلسطين \\\nقطر \\\nكاثوليك \\\nكوم \\\nمصر \\\nمليسيا \\\nموريتانيا \\\nموقع \\\nهمراه \\\nकॉम \\\nनेट \\\nभारत \\\nभारतम् \\\nभारोत \\\nसंगठन \\\nবাংলা \\\nভারত \\\nভাৰত \\\nਭਾਰਤ \\\nભારત \\\nଭାରତ \\\nஇந்தியா \\\nஇலங்கை \\\nசிங்கப்பூர் \\\nభారత్ \\\nಭಾರತ \\\nഭാരതം \\\nලංකා \\\nคอม \\\nไทย \\\nລາວ \\\n닷넷 \\\n닷컴 \\\n삼성 \\\n한국 \\\nアマゾン \\\nグーグル \\\nクラウド \\\nコム \\\nストア \\\nセール \\\nファッション \\\nポイント \\\nみんな \\\n世界 \\\n中信 \\\n中国 \\\n中國 \\\n中文网 \\\n亚马逊 \\\n企业 \\\n佛山 \\\n信息 \\\n健康 \\\n八卦 \\\n公司 \\\n公益 \\\n台湾 \\\n台灣 \\\n商城 \\\n商店 \\\n商标 \\\n嘉里 \\\n嘉里大酒店 \\\n在线 \\\n大众汽车 \\\n大拿 \\\n天主教 \\\n娱乐 \\\n家電 \\\n广东 \\\n微博 \\\n慈善 \\\n我爱你 \\\n手机 \\\n招聘 \\\n政务 \\\n政府 \\\n新加坡 \\\n新闻 \\\n时尚 \\\n書籍 \\\n机构 \\\n淡马锡 \\\n游戏 \\\n澳門 \\\n点看 \\\n移动 \\\n组织机构 \\\n网址 \\\n网店 \\\n网站 \\\n网络 \\\n联通 \\\n诺基亚 \\\n谷歌 \\\n购物 \\\n通販 \\\n集团 \\\n電訊盈科 \\\n飞利浦 \\\n食品 \\\n餐厅 \\\n香格里拉 \\\n香港'.split(' ');\n\n/**\n\tThe scanner provides an interface that takes a string of text as input, and\n\toutputs an array of tokens instances that can be used for easy URL parsing.\n\n\t@module linkify\n\t@submodule scanner\n\t@main scanner\n*/\n\nvar LETTER = /(?:[A-Za-z\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05D0-\\u05EA\\u05EF-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086A\\u0870-\\u0887\\u0889-\\u088E\\u08A0-\\u08C9\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\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32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E86-\\u0E8A\\u0E8C-\\u0EA3\\u0EA5\\u0EA7-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16F1-\\u16F8\\u1700-\\u1711\\u171F-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1878\\u1880-\\u1884\\u1887-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4C\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1C80-\\u1C88\\u1C90-\\u1CBA\\u1CBD-\\u1CBF\\u1CE9-\\u1CEC\\u1CEE-\\u1CF3\\u1CF5\\u1CF6\\u1CFA\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312F\\u3131-\\u318E\\u31A0-\\u31BF\\u31F0-\\u31FF\\u3400-\\u4DBF\\u4E00-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7CA\\uA7D0\\uA7D1\\uA7D3\\uA7D5-\\uA7D9\\uA7F2-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA8F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\uDF0F\\uDF10\\uDF13-\\uDF28\\uDF2A-\\uDF30\\uDF32\\uDF33\\uDF35-\\uDF39\\uDF3D\\uDF50\\uDF5D-\\uDF61]|\\uD805[\\uDC00-\\uDC34\\uDC47-\\uDC4A\\uDC5F-\\uDC61\\uDC80-\\uDCAF\\uDCC4\\uDCC5\\uDCC7\\uDD80-\\uDDAE\\uDDD8-\\uDDDB\\uDE00-\\uDE2F\\uDE44\\uDE80-\\uDEAA\\uDEB8\\uDF00-\\uDF1A\\uDF40-\\uDF46]|\\uD806[\\uDC00-\\uDC2B\\uDCA0-\\uDCDF\\uDCFF-\\uDD06\\uDD09\\uDD0C-\\uDD13\\uDD15\\uDD16\\uDD18-\\uDD2F\\uDD3F\\uDD41\\uDDA0-\\uDDA7\\uDDAA-\\uDDD0\\uDDE1\\uDDE3\\uDE00\\uDE0B-\\uDE32\\uDE3A\\uDE50\\uDE5C-\\uDE89\\uDE9D\\uDEB0-\\uDEF8]|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC2E\\uDC40\\uDC72-\\uDC8F\\uDD00-\\uDD06\\uDD08\\uDD09\\uDD0B-\\uDD30\\uDD46\\uDD60-\\uDD65\\uDD67\\uDD68\\uDD6A-\\uDD89\\uDD98\\uDEE0-\\uDEF2\\uDFB0]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC80-\\uDD43]|\\uD80B[\\uDF90-\\uDFF0]|[\\uD80C\\uD81C-\\uD820\\uD822\\uD840-\\uD868\\uD86A-\\uD86C\\uD86F-\\uD872\\uD874-\\uD879\\uD880-\\uD883][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2E]|\\uD811[\\uDC00-\\uDE46]|\\uD81A[\\uDC00-\\uDE38\\uDE40-\\uDE5E\\uDE70-\\uDEBE\\uDED0-\\uDEED\\uDF00-\\uDF2F\\uDF40-\\uDF43\\uDF63-\\uDF77\\uDF7D-\\uDF8F]|\\uD81B[\\uDE40-\\uDE7F\\uDF00-\\uDF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-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDEDF\\uDF00-\\uDFFF]|\\uD86D[\\uDC00-\\uDF38\\uDF40-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEA1\\uDEB0-\\uDFFF]|\\uD87A[\\uDC00-\\uDFE0]|\\uD87E[\\uDC00-\\uDE1D]|\\uD884[\\uDC00-\\uDF4A])/; // Any Unicode character with letter data type\n\nvar EMOJI = /(?:[#\\*0-9\\xA9\\xAE\\u203C\\u2049\\u2122\\u2139\\u2194-\\u2199\\u21A9\\u21AA\\u231A\\u231B\\u2328\\u23CF\\u23E9-\\u23F3\\u23F8-\\u23FA\\u24C2\\u25AA\\u25AB\\u25B6\\u25C0\\u25FB-\\u25FE\\u2600-\\u2604\\u260E\\u2611\\u2614\\u2615\\u2618\\u261D\\u2620\\u2622\\u2623\\u2626\\u262A\\u262E\\u262F\\u2638-\\u263A\\u2640\\u2642\\u2648-\\u2653\\u265F\\u2660\\u2663\\u2665\\u2666\\u2668\\u267B\\u267E\\u267F\\u2692-\\u2697\\u2699\\u269B\\u269C\\u26A0\\u26A1\\u26A7\\u26AA\\u26AB\\u26B0\\u26B1\\u26BD\\u26BE\\u26C4\\u26C5\\u26C8\\u26CE\\u26CF\\u26D1\\u26D3\\u26D4\\u26E9\\u26EA\\u26F0-\\u26F5\\u26F7-\\u26FA\\u26FD\\u2702\\u2705\\u2708-\\u270D\\u270F\\u2712\\u2714\\u2716\\u271D\\u2721\\u2728\\u2733\\u2734\\u2744\\u2747\\u274C\\u274E\\u2753-\\u2755\\u2757\\u2763\\u2764\\u2795-\\u2797\\u27A1\\u27B0\\u27BF\\u2934\\u2935\\u2B05-\\u2B07\\u2B1B\\u2B1C\\u2B50\\u2B55\\u3030\\u303D\\u3297\\u3299]|\\uD83C[\\uDC04\\uDCCF\\uDD70\\uDD71\\uDD7E\\uDD7F\\uDD8E\\uDD91-\\uDD9A\\uDDE6-\\uDDFF\\uDE01\\uDE02\\uDE1A\\uDE2F\\uDE32-\\uDE3A\\uDE50\\uDE51\\uDF00-\\uDF21\\uDF24-\\uDF93\\uDF96\\uDF97\\uDF99-\\uDF9B\\uDF9E-\\uDFF0\\uDFF3-\\uDFF5\\uDFF7-\\uDFFF]|\\uD83D[\\uDC00-\\uDCFD\\uDCFF-\\uDD3D\\uDD49-\\uDD4E\\uDD50-\\uDD67\\uDD6F\\uDD70\\uDD73-\\uDD7A\\uDD87\\uDD8A-\\uDD8D\\uDD90\\uDD95\\uDD96\\uDDA4\\uDDA5\\uDDA8\\uDDB1\\uDDB2\\uDDBC\\uDDC2-\\uDDC4\\uDDD1-\\uDDD3\\uDDDC-\\uDDDE\\uDDE1\\uDDE3\\uDDE8\\uDDEF\\uDDF3\\uDDFA-\\uDE4F\\uDE80-\\uDEC5\\uDECB-\\uDED2\\uDED5-\\uDED7\\uDEDD-\\uDEE5\\uDEE9\\uDEEB\\uDEEC\\uDEF0\\uDEF3-\\uDEFC\\uDFE0-\\uDFEB\\uDFF0]|\\uD83E[\\uDD0C-\\uDD3A\\uDD3C-\\uDD45\\uDD47-\\uDDFF\\uDE70-\\uDE74\\uDE78-\\uDE7C\\uDE80-\\uDE86\\uDE90-\\uDEAC\\uDEB0-\\uDEBA\\uDEC0-\\uDEC5\\uDED0-\\uDED9\\uDEE0-\\uDEE7\\uDEF0-\\uDEF6])/; // Any Unicode emoji character\n\nvar EMOJI_VARIATION = /\\uFE0F/; // Variation selector, follows heart and others\n\nvar DIGIT = /\\d/;\nvar SPACE = /\\s/;\n/**\n * Initialize the scanner character-based state machine for the given start state\n * @return {State} scanner starting state\n */\n\nfunction init$2() {\n var customProtocols = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n // Frequently used states\n var S_START = makeState();\n var S_NUM = makeAcceptingState(NUM);\n var S_DOMAIN = makeAcceptingState(DOMAIN);\n var S_DOMAIN_HYPHEN = makeState(); // domain followed by 1 or more hyphen characters\n\n var S_WS = makeAcceptingState(WS);\n var DOMAIN_REGEX_TRANSITIONS = [[DIGIT, S_DOMAIN], [LETTER, S_DOMAIN], [EMOJI, S_DOMAIN], [EMOJI_VARIATION, S_DOMAIN]]; // Create a state which emits a domain token\n\n var makeDomainState = function makeDomainState() {\n var state = makeAcceptingState(DOMAIN);\n state.j = {\n '-': S_DOMAIN_HYPHEN\n };\n state.jr = [].concat(DOMAIN_REGEX_TRANSITIONS);\n return state;\n }; // Create a state which does not emit a domain state but the usual alphanumeric\n // transitions are domains\n\n\n var makeNearDomainState = function makeNearDomainState(token) {\n var state = makeDomainState();\n state.t = token;\n return state;\n }; // States for special URL symbols that accept immediately after start\n\n\n makeBatchT(S_START, [[\"'\", makeAcceptingState(APOSTROPHE)], ['{', makeAcceptingState(OPENBRACE)], ['[', makeAcceptingState(OPENBRACKET)], ['<', makeAcceptingState(OPENANGLEBRACKET)], ['(', makeAcceptingState(OPENPAREN)], ['}', makeAcceptingState(CLOSEBRACE)], [']', makeAcceptingState(CLOSEBRACKET)], ['>', makeAcceptingState(CLOSEANGLEBRACKET)], [')', makeAcceptingState(CLOSEPAREN)], ['&', makeAcceptingState(AMPERSAND)], ['*', makeAcceptingState(ASTERISK)], ['@', makeAcceptingState(AT)], ['`', makeAcceptingState(BACKTICK)], ['^', makeAcceptingState(CARET)], [':', makeAcceptingState(COLON)], [',', makeAcceptingState(COMMA)], ['$', makeAcceptingState(DOLLAR)], ['.', makeAcceptingState(DOT)], ['=', makeAcceptingState(EQUALS)], ['!', makeAcceptingState(EXCLAMATION)], ['-', makeAcceptingState(HYPHEN)], ['%', makeAcceptingState(PERCENT)], ['|', makeAcceptingState(PIPE)], ['+', makeAcceptingState(PLUS)], ['#', makeAcceptingState(POUND)], ['?', makeAcceptingState(QUERY)], ['\"', makeAcceptingState(QUOTE)], ['/', makeAcceptingState(SLASH)], [';', makeAcceptingState(SEMI)], ['~', makeAcceptingState(TILDE)], ['_', makeAcceptingState(UNDERSCORE)], ['\\\\', makeAcceptingState(BACKSLASH)]]); // Whitespace jumps\n // Tokens of only non-newline whitespace are arbitrarily long\n\n makeT(S_START, '\\n', makeAcceptingState(NL));\n makeRegexT(S_START, SPACE, S_WS); // If any whitespace except newline, more whitespace!\n\n makeT(S_WS, '\\n', makeState()); // non-accepting state\n\n makeRegexT(S_WS, SPACE, S_WS); // Generates states for top-level domains\n // Note that this is most accurate when tlds are in alphabetical order\n\n for (var i = 0; i < tlds.length; i++) {\n makeChainT(S_START, tlds[i], makeNearDomainState(TLD), makeDomainState);\n } // Collect the states generated by different protocls\n\n\n var S_PROTOCOL_FILE = makeDomainState();\n var S_PROTOCOL_FTP = makeDomainState();\n var S_PROTOCOL_HTTP = makeDomainState();\n var S_MAILTO = makeDomainState();\n makeChainT(S_START, 'file', S_PROTOCOL_FILE, makeDomainState);\n makeChainT(S_START, 'ftp', S_PROTOCOL_FTP, makeDomainState);\n makeChainT(S_START, 'http', S_PROTOCOL_HTTP, makeDomainState);\n makeChainT(S_START, 'mailto', S_MAILTO, makeDomainState); // Protocol states\n\n var S_PROTOCOL_SECURE = makeDomainState();\n var S_FULL_PROTOCOL = makeAcceptingState(PROTOCOL); // Full protocol ends with COLON\n\n var S_FULL_MAILTO = makeAcceptingState(MAILTO); // Mailto ends with COLON\n // Secure protocols (end with 's')\n\n makeT(S_PROTOCOL_FTP, 's', S_PROTOCOL_SECURE);\n makeT(S_PROTOCOL_FTP, ':', S_FULL_PROTOCOL);\n makeT(S_PROTOCOL_HTTP, 's', S_PROTOCOL_SECURE);\n makeT(S_PROTOCOL_HTTP, ':', S_FULL_PROTOCOL); // Become protocol tokens after a COLON\n\n makeT(S_PROTOCOL_FILE, ':', S_FULL_PROTOCOL);\n makeT(S_PROTOCOL_SECURE, ':', S_FULL_PROTOCOL);\n makeT(S_MAILTO, ':', S_FULL_MAILTO); // Register custom protocols\n\n var S_CUSTOM_PROTOCOL = makeDomainState();\n\n for (var _i = 0; _i < customProtocols.length; _i++) {\n makeChainT(S_START, customProtocols[_i], S_CUSTOM_PROTOCOL, makeDomainState);\n }\n\n makeT(S_CUSTOM_PROTOCOL, ':', S_FULL_PROTOCOL); // Localhost\n\n makeChainT(S_START, 'localhost', makeNearDomainState(LOCALHOST), makeDomainState); // Everything else\n // DOMAINs make more DOMAINs\n // Number and character transitions\n\n makeRegexT(S_START, DIGIT, S_NUM);\n makeRegexT(S_START, LETTER, S_DOMAIN);\n makeRegexT(S_START, EMOJI, S_DOMAIN);\n makeRegexT(S_START, EMOJI_VARIATION, S_DOMAIN);\n makeRegexT(S_NUM, DIGIT, S_NUM);\n makeRegexT(S_NUM, LETTER, S_DOMAIN); // number becomes DOMAIN\n\n makeRegexT(S_NUM, EMOJI, S_DOMAIN); // number becomes DOMAIN\n\n makeRegexT(S_NUM, EMOJI_VARIATION, S_DOMAIN); // number becomes DOMAIN\n\n makeT(S_NUM, '-', S_DOMAIN_HYPHEN); // Default domain transitions\n\n makeT(S_DOMAIN, '-', S_DOMAIN_HYPHEN);\n makeT(S_DOMAIN_HYPHEN, '-', S_DOMAIN_HYPHEN);\n makeRegexT(S_DOMAIN, DIGIT, S_DOMAIN);\n makeRegexT(S_DOMAIN, LETTER, S_DOMAIN);\n makeRegexT(S_DOMAIN, EMOJI, S_DOMAIN);\n makeRegexT(S_DOMAIN, EMOJI_VARIATION, S_DOMAIN);\n makeRegexT(S_DOMAIN_HYPHEN, DIGIT, S_DOMAIN);\n makeRegexT(S_DOMAIN_HYPHEN, LETTER, S_DOMAIN);\n makeRegexT(S_DOMAIN_HYPHEN, EMOJI, S_DOMAIN);\n makeRegexT(S_DOMAIN_HYPHEN, EMOJI_VARIATION, S_DOMAIN); // Set default transition for start state (some symbol)\n\n S_START.jd = makeAcceptingState(SYM);\n return S_START;\n}\n/**\n\tGiven a string, returns an array of TOKEN instances representing the\n\tcomposition of that string.\n\n\t@method run\n\t@param {State} start scanner starting state\n\t@param {string} str input string to scan\n\t@return {{t: string, v: string, s: number, l: number}[]} list of tokens, each with a type and value\n*/\n\nfunction run$1(start, str) {\n // State machine is not case sensitive, so input is tokenized in lowercased\n // form (still returns the regular case though) Uses selective `toLowerCase`\n // is used because lowercasing the entire string causes the length and\n // character position to vary in some non-English strings with V8-based\n // runtimes.\n var iterable = stringToArray(str.replace(/[A-Z]/g, function (c) {\n return c.toLowerCase();\n }));\n var charCount = iterable.length; // <= len if there are emojis, etc\n\n var tokens = []; // return value\n // cursor through the string itself, accounting for characters that have\n // width with length 2 such as emojis\n\n var cursor = 0; // Cursor through the array-representation of the string\n\n var charCursor = 0; // Tokenize the string\n\n while (charCursor < charCount) {\n var state = start;\n var nextState = null;\n var tokenLength = 0;\n var latestAccepting = null;\n var sinceAccepts = -1;\n var charsSinceAccepts = -1;\n\n while (charCursor < charCount && (nextState = takeT(state, iterable[charCursor]))) {\n state = nextState; // Keep track of the latest accepting state\n\n if (state.accepts()) {\n sinceAccepts = 0;\n charsSinceAccepts = 0;\n latestAccepting = state;\n } else if (sinceAccepts >= 0) {\n sinceAccepts += iterable[charCursor].length;\n charsSinceAccepts++;\n }\n\n tokenLength += iterable[charCursor].length;\n cursor += iterable[charCursor].length;\n charCursor++;\n } // Roll back to the latest accepting state\n\n\n cursor -= sinceAccepts;\n charCursor -= charsSinceAccepts;\n tokenLength -= sinceAccepts; // No more jumps, just make a new token from the last accepting one\n // TODO: If possible, don't output v, instead output range where values ocur\n\n tokens.push({\n t: latestAccepting.t,\n // token type/name\n v: str.substr(cursor - tokenLength, tokenLength),\n // string value\n s: cursor - tokenLength,\n // start index\n e: cursor // end index (excluding)\n\n });\n }\n\n return tokens;\n}\n/**\n * Convert a String to an Array of characters, taking into account that some\n * characters like emojis take up two string indexes.\n *\n * Adapted from core-js (MIT license)\n * https://github.com/zloirock/core-js/blob/2d69cf5f99ab3ea3463c395df81e5a15b68f49d9/packages/core-js/internals/string-multibyte.js\n *\n * @function stringToArray\n * @param {string} str\n * @returns {string[]}\n */\n\nfunction stringToArray(str) {\n var result = [];\n var len = str.length;\n var index = 0;\n\n while (index < len) {\n var first = str.charCodeAt(index);\n var second = void 0;\n var char = first < 0xd800 || first > 0xdbff || index + 1 === len || (second = str.charCodeAt(index + 1)) < 0xdc00 || second > 0xdfff ? str[index] // single character\n : str.slice(index, index + 2); // two-index characters\n\n result.push(char);\n index += char.length;\n }\n\n return result;\n}\n\nfunction _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\n/**\n * @property {string} defaultProtocol\n * @property {{[string]: (event) => void}]} [events]\n */\nvar defaults = {\n defaultProtocol: 'http',\n events: null,\n format: noop,\n formatHref: noop,\n nl2br: false,\n tagName: 'a',\n target: null,\n rel: null,\n validate: true,\n truncate: 0,\n className: null,\n attributes: null,\n ignoreTags: []\n};\n/**\n * @class Options\n * @param {Object} [opts] Set option properties besides the defaults\n */\n\nfunction Options(opts) {\n opts = opts || {};\n this.defaultProtocol = 'defaultProtocol' in opts ? opts.defaultProtocol : defaults.defaultProtocol;\n this.events = 'events' in opts ? opts.events : defaults.events;\n this.format = 'format' in opts ? opts.format : defaults.format;\n this.formatHref = 'formatHref' in opts ? opts.formatHref : defaults.formatHref;\n this.nl2br = 'nl2br' in opts ? opts.nl2br : defaults.nl2br;\n this.tagName = 'tagName' in opts ? opts.tagName : defaults.tagName;\n this.target = 'target' in opts ? opts.target : defaults.target;\n this.rel = 'rel' in opts ? opts.rel : defaults.rel;\n this.validate = 'validate' in opts ? opts.validate : defaults.validate;\n this.truncate = 'truncate' in opts ? opts.truncate : defaults.truncate;\n this.className = 'className' in opts ? opts.className : defaults.className;\n this.attributes = opts.attributes || defaults.attributes;\n this.ignoreTags = []; // Make all tags names upper case\n\n var ignoredTags = 'ignoreTags' in opts ? opts.ignoreTags : defaults.ignoreTags;\n\n for (var i = 0; i < ignoredTags.length; i++) {\n this.ignoreTags.push(ignoredTags[i].toUpperCase());\n }\n}\nOptions.prototype = {\n /**\n * Given the token, return all options for how it should be displayed\n */\n resolve: function resolve(token) {\n var href = token.toHref(this.defaultProtocol);\n return {\n formatted: this.get('format', token.toString(), token),\n formattedHref: this.get('formatHref', href, token),\n tagName: this.get('tagName', href, token),\n className: this.get('className', href, token),\n target: this.get('target', href, token),\n rel: this.get('rel', href, token),\n events: this.getObject('events', href, token),\n attributes: this.getObject('attributes', href, token),\n truncate: this.get('truncate', href, token)\n };\n },\n\n /**\n * Returns true or false based on whether a token should be displayed as a\n * link based on the user options. By default,\n */\n check: function check(token) {\n return this.get('validate', token.toString(), token);\n },\n // Private methods\n\n /**\n * Resolve an option's value based on the value of the option and the given\n * params.\n * @param {string} key Name of option to use\n * @param operator will be passed to the target option if it's method\n * @param {MultiToken} token The token from linkify.tokenize\n */\n get: function get(key, operator, token) {\n var option = this[key];\n\n if (!option) {\n return option;\n }\n\n var optionValue;\n\n switch (_typeof(option)) {\n case 'function':\n return option(operator, token.t);\n\n case 'object':\n optionValue = token.t in option ? option[token.t] : defaults[key];\n return typeof optionValue === 'function' ? optionValue(operator, token.t) : optionValue;\n }\n\n return option;\n },\n getObject: function getObject(key, operator, token) {\n var option = this[key];\n return typeof option === 'function' ? option(operator, token.t) : option;\n }\n};\n\nfunction noop(val) {\n return val;\n}\n\nvar options = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tdefaults: defaults,\n\tOptions: Options\n});\n\n/******************************************************************************\n\tMulti-Tokens\n\tTokens composed of arrays of TextTokens\n******************************************************************************/\n\nfunction inherits(parent, child) {\n var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var extended = Object.create(parent.prototype);\n\n for (var p in props) {\n extended[p] = props[p];\n }\n\n extended.constructor = child;\n child.prototype = extended;\n return child;\n}\n/**\n\tAbstract class used for manufacturing tokens of text tokens. That is rather\n\tthan the value for a token being a small string of text, it's value an array\n\tof text tokens.\n\n\tUsed for grouping together URLs, emails, hashtags, and other potential\n\tcreations.\n\n\t@class MultiToken\n\t@param {string} value\n\t@param {{t: string, v: string, s: number, e: number}[]} tokens\n\t@abstract\n*/\n\n\nfunction MultiToken() {}\nMultiToken.prototype = {\n /**\n \tString representing the type for this token\n \t@property t\n \t@default 'token'\n */\n t: 'token',\n\n /**\n \tIs this multitoken a link?\n \t@property isLink\n \t@default false\n */\n isLink: false,\n\n /**\n \tReturn the string this token represents.\n \t@method toString\n \t@return {string}\n */\n toString: function toString() {\n return this.v;\n },\n\n /**\n \tWhat should the value for this token be in the `href` HTML attribute?\n \tReturns the `.toString` value by default.\n \t\t@method toHref\n \t@return {string}\n */\n toHref: function toHref() {\n return this.toString();\n },\n\n /**\n * The start index of this token in the original input string\n * @returns {number}\n */\n startIndex: function startIndex() {\n return this.tk[0].s;\n },\n\n /**\n * The end index of this token in the original input string (up to this\n * index but not including it)\n * @returns {number}\n */\n endIndex: function endIndex() {\n return this.tk[this.tk.length - 1].e;\n },\n\n /**\n \tReturns a hash of relevant values for this token, which includes keys\n \t* type - Kind of token ('url', 'email', etc.)\n \t* value - Original text\n \t* href - The value that should be added to the anchor tag's href\n \t\tattribute\n \t\t@method toObject\n \t@param {string} [protocol] `'http'` by default\n */\n toObject: function toObject() {\n var protocol = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaults.defaultProtocol;\n return {\n type: this.t,\n value: this.v,\n isLink: this.isLink,\n href: this.toHref(protocol),\n start: this.startIndex(),\n end: this.endIndex()\n };\n }\n}; // Base token\n/**\n * Create a new token that can be emitted by the parser state machine\n * @param {string} type readable type of the token\n * @param {object} props properties to assign or override, including isLink = true or false\n * @returns {(value: string, tokens: {t: string, v: string, s: number, e: number}) => MultiToken} new token class\n */\n\nfunction createTokenClass(type, props) {\n function Token(value, tokens) {\n this.t = type;\n this.v = value;\n this.tk = tokens;\n }\n\n inherits(MultiToken, Token, props);\n return Token;\n}\n/**\n\tRepresents an arbitrarily mailto email address with the prefix included\n\t@class MailtoEmail\n\t@extends MultiToken\n*/\n\nvar MailtoEmail = createTokenClass('email', {\n isLink: true\n});\n/**\n\tRepresents a list of tokens making up a valid email address\n\t@class Email\n\t@extends MultiToken\n*/\n\nvar Email = createTokenClass('email', {\n isLink: true,\n toHref: function toHref() {\n return 'mailto:' + this.toString();\n }\n});\n/**\n\tRepresents some plain text\n\t@class Text\n\t@extends MultiToken\n*/\n\nvar Text = createTokenClass('text');\n/**\n\tMulti-linebreak token - represents a line break\n\t@class Nl\n\t@extends MultiToken\n*/\n\nvar Nl = createTokenClass('nl');\n/**\n\tRepresents a list of text tokens making up a valid URL\n\t@class Url\n\t@extends MultiToken\n*/\n\nvar Url = createTokenClass('url', {\n isLink: true,\n\n /**\n \tLowercases relevant parts of the domain and adds the protocol if\n \trequired. Note that this will not escape unsafe HTML characters in the\n \tURL.\n \t\t@method href\n \t@param {string} protocol\n \t@return {string}\n */\n toHref: function toHref() {\n var protocol = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaults.defaultProtocol;\n var tokens = this.tk;\n var hasProtocol = false;\n var hasSlashSlash = false;\n var result = [];\n var i = 0; // Make the first part of the domain lowercase\n // Lowercase protocol\n\n while (tokens[i].t === PROTOCOL) {\n hasProtocol = true;\n result.push(tokens[i].v);\n i++;\n } // Skip slash-slash\n\n\n while (tokens[i].t === SLASH) {\n hasSlashSlash = true;\n result.push(tokens[i].v);\n i++;\n } // Continue pushing characters\n\n\n for (; i < tokens.length; i++) {\n result.push(tokens[i].v);\n }\n\n result = result.join('');\n\n if (!(hasProtocol || hasSlashSlash)) {\n result = \"\".concat(protocol, \"://\").concat(result);\n }\n\n return result;\n },\n hasProtocol: function hasProtocol() {\n return this.tk[0].t === PROTOCOL;\n }\n});\n\nvar multi = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tMultiToken: MultiToken,\n\tBase: MultiToken,\n\tcreateTokenClass: createTokenClass,\n\tMailtoEmail: MailtoEmail,\n\tEmail: Email,\n\tText: Text,\n\tNl: Nl,\n\tUrl: Url\n});\n\n/**\n\tNot exactly parser, more like the second-stage scanner (although we can\n\ttheoretically hotswap the code here with a real parser in the future... but\n\tfor a little URL-finding utility abstract syntax trees may be a little\n\toverkill).\n\n\tURL format: http://en.wikipedia.org/wiki/URI_scheme\n\tEmail format: http://en.wikipedia.org/wiki/Email_address (links to RFC in\n\treference)\n\n\t@module linkify\n\t@submodule parser\n\t@main run\n*/\n/**\n * Generate the parser multi token-based state machine\n * @returns {State} the starting state\n */\n\nfunction init$1() {\n // The universal starting state.\n var S_START = makeState(); // Intermediate states for URLs. Note that domains that begin with a protocol\n // are treated slighly differently from those that don't.\n\n var S_PROTOCOL = makeState(); // e.g., 'http:'\n\n var S_MAILTO = makeState(); // 'mailto:'\n\n var S_PROTOCOL_SLASH = makeState(); // e.g., 'http:/''\n\n var S_PROTOCOL_SLASH_SLASH = makeState(); // e.g.,'http://'\n\n var S_DOMAIN = makeState(); // parsed string ends with a potential domain name (A)\n\n var S_DOMAIN_DOT = makeState(); // (A) domain followed by DOT\n\n var S_TLD = makeAcceptingState(Url); // (A) Simplest possible URL with no query string\n\n var S_TLD_COLON = makeState(); // (A) URL followed by colon (potential port number here)\n\n var S_TLD_PORT = makeAcceptingState(Url); // TLD followed by a port number\n\n var S_URL = makeAcceptingState(Url); // Long URL with optional port and maybe query string\n\n var S_URL_NON_ACCEPTING = makeState(); // URL followed by some symbols (will not be part of the final URL)\n\n var S_URL_OPENBRACE = makeState(); // URL followed by {\n\n var S_URL_OPENBRACKET = makeState(); // URL followed by [\n\n var S_URL_OPENANGLEBRACKET = makeState(); // URL followed by <\n\n var S_URL_OPENPAREN = makeState(); // URL followed by (\n\n var S_URL_OPENBRACE_Q = makeAcceptingState(Url); // URL followed by { and some symbols that the URL can end it\n\n var S_URL_OPENBRACKET_Q = makeAcceptingState(Url); // URL followed by [ and some symbols that the URL can end it\n\n var S_URL_OPENANGLEBRACKET_Q = makeAcceptingState(Url); // URL followed by < and some symbols that the URL can end it\n\n var S_URL_OPENPAREN_Q = makeAcceptingState(Url); // URL followed by ( and some symbols that the URL can end it\n\n var S_URL_OPENBRACE_SYMS = makeState(); // S_URL_OPENBRACE_Q followed by some symbols it cannot end it\n\n var S_URL_OPENBRACKET_SYMS = makeState(); // S_URL_OPENBRACKET_Q followed by some symbols it cannot end it\n\n var S_URL_OPENANGLEBRACKET_SYMS = makeState(); // S_URL_OPENANGLEBRACKET_Q followed by some symbols it cannot end it\n\n var S_URL_OPENPAREN_SYMS = makeState(); // S_URL_OPENPAREN_Q followed by some symbols it cannot end it\n\n var S_EMAIL_DOMAIN = makeState(); // parsed string starts with local email info + @ with a potential domain name (C)\n\n var S_EMAIL_DOMAIN_DOT = makeState(); // (C) domain followed by DOT\n\n var S_EMAIL = makeAcceptingState(Email); // (C) Possible email address (could have more tlds)\n\n var S_EMAIL_COLON = makeState(); // (C) URL followed by colon (potential port number here)\n\n var S_EMAIL_PORT = makeAcceptingState(Email); // (C) Email address with a port\n\n var S_MAILTO_EMAIL = makeAcceptingState(MailtoEmail); // Email that begins with the mailto prefix (D)\n\n var S_MAILTO_EMAIL_NON_ACCEPTING = makeState(); // (D) Followed by some non-query string chars\n\n var S_LOCALPART = makeState(); // Local part of the email address\n\n var S_LOCALPART_AT = makeState(); // Local part of the email address plus @\n\n var S_LOCALPART_DOT = makeState(); // Local part of the email address plus '.' (localpart cannot end in .)\n\n var S_NL = makeAcceptingState(Nl); // single new line\n // Make path from start to protocol (with '//')\n\n makeT(S_START, NL, S_NL);\n makeT(S_START, PROTOCOL, S_PROTOCOL);\n makeT(S_START, MAILTO, S_MAILTO);\n makeT(S_PROTOCOL, SLASH, S_PROTOCOL_SLASH);\n makeT(S_PROTOCOL_SLASH, SLASH, S_PROTOCOL_SLASH_SLASH); // The very first potential domain name\n\n makeT(S_START, TLD, S_DOMAIN);\n makeT(S_START, DOMAIN, S_DOMAIN);\n makeT(S_START, LOCALHOST, S_TLD);\n makeT(S_START, NUM, S_DOMAIN); // Force URL for protocol followed by anything sane\n\n makeT(S_PROTOCOL_SLASH_SLASH, TLD, S_URL);\n makeT(S_PROTOCOL_SLASH_SLASH, DOMAIN, S_URL);\n makeT(S_PROTOCOL_SLASH_SLASH, NUM, S_URL);\n makeT(S_PROTOCOL_SLASH_SLASH, LOCALHOST, S_URL); // Account for dots and hyphens\n // hyphens are usually parts of domain names\n\n makeT(S_DOMAIN, DOT, S_DOMAIN_DOT);\n makeT(S_EMAIL_DOMAIN, DOT, S_EMAIL_DOMAIN_DOT); // Hyphen can jump back to a domain name\n // After the first domain and a dot, we can find either a URL or another domain\n\n makeT(S_DOMAIN_DOT, TLD, S_TLD);\n makeT(S_DOMAIN_DOT, DOMAIN, S_DOMAIN);\n makeT(S_DOMAIN_DOT, NUM, S_DOMAIN);\n makeT(S_DOMAIN_DOT, LOCALHOST, S_DOMAIN);\n makeT(S_EMAIL_DOMAIN_DOT, TLD, S_EMAIL);\n makeT(S_EMAIL_DOMAIN_DOT, DOMAIN, S_EMAIL_DOMAIN);\n makeT(S_EMAIL_DOMAIN_DOT, NUM, S_EMAIL_DOMAIN);\n makeT(S_EMAIL_DOMAIN_DOT, LOCALHOST, S_EMAIL_DOMAIN); // S_TLD accepts! But the URL could be longer, try to find a match greedily\n // The `run` function should be able to \"rollback\" to the accepting state\n\n makeT(S_TLD, DOT, S_DOMAIN_DOT);\n makeT(S_EMAIL, DOT, S_EMAIL_DOMAIN_DOT); // Become real URLs after `SLASH` or `COLON NUM SLASH`\n // Here PSS and non-PSS converge\n\n makeT(S_TLD, COLON, S_TLD_COLON);\n makeT(S_TLD, SLASH, S_URL);\n makeT(S_TLD_COLON, NUM, S_TLD_PORT);\n makeT(S_TLD_PORT, SLASH, S_URL);\n makeT(S_EMAIL, COLON, S_EMAIL_COLON);\n makeT(S_EMAIL_COLON, NUM, S_EMAIL_PORT); // Types of characters the URL can definitely end in\n\n var qsAccepting = [AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, DOMAIN, EQUALS, HYPHEN, LOCALHOST, NUM, PERCENT, PIPE, PLUS, POUND, PROTOCOL, SLASH, SYM, TILDE, TLD, UNDERSCORE]; // Types of tokens that can follow a URL and be part of the query string\n // but cannot be the very last characters\n // Characters that cannot appear in the URL at all should be excluded\n\n var qsNonAccepting = [APOSTROPHE, CLOSEANGLEBRACKET, CLOSEBRACE, CLOSEBRACKET, CLOSEPAREN, COLON, COMMA, DOT, EXCLAMATION, OPENANGLEBRACKET, OPENBRACE, OPENBRACKET, OPENPAREN, QUERY, QUOTE, SEMI]; // These states are responsible primarily for determining whether or not to\n // include the final round bracket.\n // URL, followed by an opening bracket\n\n makeT(S_URL, OPENBRACE, S_URL_OPENBRACE);\n makeT(S_URL, OPENBRACKET, S_URL_OPENBRACKET);\n makeT(S_URL, OPENANGLEBRACKET, S_URL_OPENANGLEBRACKET);\n makeT(S_URL, OPENPAREN, S_URL_OPENPAREN); // URL with extra symbols at the end, followed by an opening bracket\n\n makeT(S_URL_NON_ACCEPTING, OPENBRACE, S_URL_OPENBRACE);\n makeT(S_URL_NON_ACCEPTING, OPENBRACKET, S_URL_OPENBRACKET);\n makeT(S_URL_NON_ACCEPTING, OPENANGLEBRACKET, S_URL_OPENANGLEBRACKET);\n makeT(S_URL_NON_ACCEPTING, OPENPAREN, S_URL_OPENPAREN); // Closing bracket component. This character WILL be included in the URL\n\n makeT(S_URL_OPENBRACE, CLOSEBRACE, S_URL);\n makeT(S_URL_OPENBRACKET, CLOSEBRACKET, S_URL);\n makeT(S_URL_OPENANGLEBRACKET, CLOSEANGLEBRACKET, S_URL);\n makeT(S_URL_OPENPAREN, CLOSEPAREN, S_URL);\n makeT(S_URL_OPENBRACE_Q, CLOSEBRACE, S_URL);\n makeT(S_URL_OPENBRACKET_Q, CLOSEBRACKET, S_URL);\n makeT(S_URL_OPENANGLEBRACKET_Q, CLOSEANGLEBRACKET, S_URL);\n makeT(S_URL_OPENPAREN_Q, CLOSEPAREN, S_URL);\n makeT(S_URL_OPENBRACE_SYMS, CLOSEBRACE, S_URL);\n makeT(S_URL_OPENBRACKET_SYMS, CLOSEBRACKET, S_URL);\n makeT(S_URL_OPENANGLEBRACKET_SYMS, CLOSEANGLEBRACKET, S_URL);\n makeT(S_URL_OPENPAREN_SYMS, CLOSEPAREN, S_URL); // URL that beings with an opening bracket, followed by a symbols.\n // Note that the final state can still be `S_URL_OPENBRACE_Q` (if the URL only\n // has a single opening bracket for some reason).\n\n makeMultiT(S_URL_OPENBRACE, qsAccepting, S_URL_OPENBRACE_Q);\n makeMultiT(S_URL_OPENBRACKET, qsAccepting, S_URL_OPENBRACKET_Q);\n makeMultiT(S_URL_OPENANGLEBRACKET, qsAccepting, S_URL_OPENANGLEBRACKET_Q);\n makeMultiT(S_URL_OPENPAREN, qsAccepting, S_URL_OPENPAREN_Q);\n makeMultiT(S_URL_OPENBRACE, qsNonAccepting, S_URL_OPENBRACE_SYMS);\n makeMultiT(S_URL_OPENBRACKET, qsNonAccepting, S_URL_OPENBRACKET_SYMS);\n makeMultiT(S_URL_OPENANGLEBRACKET, qsNonAccepting, S_URL_OPENANGLEBRACKET_SYMS);\n makeMultiT(S_URL_OPENPAREN, qsNonAccepting, S_URL_OPENPAREN_SYMS); // URL that begins with an opening bracket, followed by some symbols\n\n makeMultiT(S_URL_OPENBRACE_Q, qsAccepting, S_URL_OPENBRACE_Q);\n makeMultiT(S_URL_OPENBRACKET_Q, qsAccepting, S_URL_OPENBRACKET_Q);\n makeMultiT(S_URL_OPENANGLEBRACKET_Q, qsAccepting, S_URL_OPENANGLEBRACKET_Q);\n makeMultiT(S_URL_OPENPAREN_Q, qsAccepting, S_URL_OPENPAREN_Q);\n makeMultiT(S_URL_OPENBRACE_Q, qsNonAccepting, S_URL_OPENBRACE_Q);\n makeMultiT(S_URL_OPENBRACKET_Q, qsNonAccepting, S_URL_OPENBRACKET_Q);\n makeMultiT(S_URL_OPENANGLEBRACKET_Q, qsNonAccepting, S_URL_OPENANGLEBRACKET_Q);\n makeMultiT(S_URL_OPENPAREN_Q, qsNonAccepting, S_URL_OPENPAREN_Q);\n makeMultiT(S_URL_OPENBRACE_SYMS, qsAccepting, S_URL_OPENBRACE_Q);\n makeMultiT(S_URL_OPENBRACKET_SYMS, qsAccepting, S_URL_OPENBRACKET_Q);\n makeMultiT(S_URL_OPENANGLEBRACKET_SYMS, qsAccepting, S_URL_OPENANGLEBRACKET_Q);\n makeMultiT(S_URL_OPENPAREN_SYMS, qsAccepting, S_URL_OPENPAREN_Q);\n makeMultiT(S_URL_OPENBRACE_SYMS, qsNonAccepting, S_URL_OPENBRACE_SYMS);\n makeMultiT(S_URL_OPENBRACKET_SYMS, qsNonAccepting, S_URL_OPENBRACKET_SYMS);\n makeMultiT(S_URL_OPENANGLEBRACKET_SYMS, qsNonAccepting, S_URL_OPENANGLEBRACKET_SYMS);\n makeMultiT(S_URL_OPENPAREN_SYMS, qsNonAccepting, S_URL_OPENPAREN_SYMS); // Account for the query string\n\n makeMultiT(S_URL, qsAccepting, S_URL);\n makeMultiT(S_URL_NON_ACCEPTING, qsAccepting, S_URL);\n makeMultiT(S_URL, qsNonAccepting, S_URL_NON_ACCEPTING);\n makeMultiT(S_URL_NON_ACCEPTING, qsNonAccepting, S_URL_NON_ACCEPTING); // Email address-specific state definitions\n // Note: We are not allowing '/' in email addresses since this would interfere\n // with real URLs\n // For addresses with the mailto prefix\n // 'mailto:' followed by anything sane is a valid email\n\n makeT(S_MAILTO, TLD, S_MAILTO_EMAIL);\n makeT(S_MAILTO, DOMAIN, S_MAILTO_EMAIL);\n makeT(S_MAILTO, NUM, S_MAILTO_EMAIL);\n makeT(S_MAILTO, LOCALHOST, S_MAILTO_EMAIL); // Greedily get more potential valid email values\n\n makeMultiT(S_MAILTO_EMAIL, qsAccepting, S_MAILTO_EMAIL);\n makeMultiT(S_MAILTO_EMAIL, qsNonAccepting, S_MAILTO_EMAIL_NON_ACCEPTING);\n makeMultiT(S_MAILTO_EMAIL_NON_ACCEPTING, qsAccepting, S_MAILTO_EMAIL);\n makeMultiT(S_MAILTO_EMAIL_NON_ACCEPTING, qsNonAccepting, S_MAILTO_EMAIL_NON_ACCEPTING); // For addresses without the mailto prefix\n // Tokens allowed in the localpart of the email\n\n var localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, CLOSEBRACE, DOLLAR, DOMAIN, EQUALS, HYPHEN, NUM, OPENBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, TLD, UNDERSCORE]; // Some of the tokens in `localpartAccepting` are already accounted for here and\n // will not be overwritten (don't worry)\n\n makeMultiT(S_DOMAIN, localpartAccepting, S_LOCALPART);\n makeT(S_DOMAIN, AT, S_LOCALPART_AT);\n makeMultiT(S_TLD, localpartAccepting, S_LOCALPART);\n makeT(S_TLD, AT, S_LOCALPART_AT);\n makeMultiT(S_DOMAIN_DOT, localpartAccepting, S_LOCALPART); // Now in localpart of address\n // TODO: IP addresses and what if the email starts with numbers?\n\n makeMultiT(S_LOCALPART, localpartAccepting, S_LOCALPART);\n makeT(S_LOCALPART, AT, S_LOCALPART_AT); // close to an email address now\n\n makeT(S_LOCALPART, DOT, S_LOCALPART_DOT);\n makeMultiT(S_LOCALPART_DOT, localpartAccepting, S_LOCALPART);\n makeT(S_LOCALPART_AT, TLD, S_EMAIL_DOMAIN);\n makeT(S_LOCALPART_AT, DOMAIN, S_EMAIL_DOMAIN);\n makeT(S_LOCALPART_AT, NUM, S_EMAIL_DOMAIN);\n makeT(S_LOCALPART_AT, LOCALHOST, S_EMAIL); // States following `@` defined above\n\n return S_START;\n}\n/**\n * Run the parser state machine on a list of scanned string-based tokens to\n * create a list of multi tokens, each of which represents a URL, email address,\n * plain text, etc.\n *\n * @param {State} start parser start state\n * @param {string} input the original input used to generate the given tokens\n * @param {{t: string, v: string, s: number, e: number}[]} tokens list of scanned tokens\n * @returns {MultiToken[]}\n */\n\nfunction run(start, input, tokens) {\n var len = tokens.length;\n var cursor = 0;\n var multis = [];\n var textTokens = [];\n\n while (cursor < len) {\n var state = start;\n var secondState = null;\n var nextState = null;\n var multiLength = 0;\n var latestAccepting = null;\n var sinceAccepts = -1;\n\n while (cursor < len && !(secondState = takeT(state, tokens[cursor].t))) {\n // Starting tokens with nowhere to jump to.\n // Consider these to be just plain text\n textTokens.push(tokens[cursor++]);\n }\n\n while (cursor < len && (nextState = secondState || takeT(state, tokens[cursor].t))) {\n // Get the next state\n secondState = null;\n state = nextState; // Keep track of the latest accepting state\n\n if (state.accepts()) {\n sinceAccepts = 0;\n latestAccepting = state;\n } else if (sinceAccepts >= 0) {\n sinceAccepts++;\n }\n\n cursor++;\n multiLength++;\n }\n\n if (sinceAccepts < 0) {\n // No accepting state was found, part of a regular text token\n // Add all the tokens we looked at to the text tokens array\n for (var i = cursor - multiLength; i < cursor; i++) {\n textTokens.push(tokens[i]);\n }\n } else {\n // Accepting state!\n // First close off the textTokens (if available)\n if (textTokens.length > 0) {\n multis.push(parserCreateMultiToken(Text, input, textTokens));\n textTokens = [];\n } // Roll back to the latest accepting state\n\n\n cursor -= sinceAccepts;\n multiLength -= sinceAccepts; // Create a new multitoken\n\n var Multi = latestAccepting.t;\n var subtokens = tokens.slice(cursor - multiLength, cursor);\n multis.push(parserCreateMultiToken(Multi, input, subtokens));\n }\n } // Finally close off the textTokens (if available)\n\n\n if (textTokens.length > 0) {\n multis.push(parserCreateMultiToken(Text, input, textTokens));\n }\n\n return multis;\n}\n/**\n * Utility function for instantiating a new multitoken with all the relevant\n * fields during parsing.\n * @param {Class} Multi class to instantiate\n * @param {string} input original input string\n * @param {{t: string, v: string, s: number, e: number}[]} tokens consecutive tokens scanned from input string\n * @returns {MultiToken}\n */\n\nfunction parserCreateMultiToken(Multi, input, tokens) {\n var startIdx = tokens[0].s;\n var endIdx = tokens[tokens.length - 1].e;\n var value = input.substr(startIdx, endIdx - startIdx);\n return new Multi(value, tokens);\n}\n\nvar warn = typeof console !== 'undefined' && console && console.warn || function () {}; // Side-effect initialization state\n\n\nvar INIT = {\n scanner: null,\n parser: null,\n pluginQueue: [],\n customProtocols: [],\n initialized: false\n};\n/**\n * De-register all plugins and reset the internal state-machine. Used for\n * testing; not required in practice.\n * @private\n */\n\nfunction reset() {\n INIT.scanner = null;\n INIT.parser = null;\n INIT.pluginQueue = [];\n INIT.customProtocols = [];\n INIT.initialized = false;\n}\n/**\n * Register a linkify extension plugin\n * @param {string} name of plugin to register\n * @param {Function} plugin function that accepts mutable linkify state\n */\n\nfunction registerPlugin(name, plugin) {\n for (var i = 0; i < INIT.pluginQueue.length; i++) {\n if (name === INIT.pluginQueue[i][0]) {\n warn(\"linkifyjs: plugin \\\"\".concat(name, \"\\\" already registered - will be overwritten\"));\n INIT.pluginQueue[i] = [name, plugin];\n return;\n }\n }\n\n INIT.pluginQueue.push([name, plugin]);\n\n if (INIT.initialized) {\n warn(\"linkifyjs: already initialized - will not register plugin \\\"\".concat(name, \"\\\" until you manually call linkify.init(). To avoid this warning, please register all plugins before invoking linkify the first time.\"));\n }\n}\n/**\n * Detect URLs with the following additional protocol. Anything following\n * \"protocol:\" will be considered a link.\n * @param {string} protocol\n */\n\nfunction registerCustomProtocol(protocol) {\n if (INIT.initialized) {\n warn(\"linkifyjs: already initialized - will not register custom protocol \\\"\".concat(protocol, \"\\\" until you manually call linkify.init(). To avoid this warning, please register all custom protocols before invoking linkify the first time.\"));\n }\n\n if (!/^[a-z-]+$/.test(protocol)) {\n throw Error('linkifyjs: protocols containing characters other than a-z or - (hyphen) are not supported');\n }\n\n INIT.customProtocols.push(protocol);\n}\n/**\n * Initialize the linkify state machine. Called automatically the first time\n * linkify is called on a string, but may be called manually as well.\n */\n\nfunction init() {\n // Initialize state machines\n INIT.scanner = {\n start: init$2(INIT.customProtocols),\n tokens: text\n };\n INIT.parser = {\n start: init$1(),\n tokens: multi\n };\n var utils = {\n createTokenClass: createTokenClass\n }; // Initialize plugins\n\n for (var i = 0; i < INIT.pluginQueue.length; i++) {\n INIT.pluginQueue[i][1]({\n scanner: INIT.scanner,\n parser: INIT.parser,\n utils: utils\n });\n }\n\n INIT.initialized = true;\n}\n/**\n\tParse a string into tokens that represent linkable and non-linkable sub-components\n\t@param {string} str\n\t@return {MultiToken[]} tokens\n*/\n\nfunction tokenize(str) {\n if (!INIT.initialized) {\n init();\n }\n\n return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));\n}\n/**\n\tFind a list of linkable items in the given string.\n\t@param {string} str string to find links in\n\t@param {string} [type] (optional) only find links of a specific type, e.g.,\n\t'url' or 'email'\n*/\n\nfunction find(str) {\n var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var tokens = tokenize(str);\n var filtered = [];\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i];\n\n if (token.isLink && (!type || token.t === type)) {\n filtered.push(token.toObject());\n }\n }\n\n return filtered;\n}\n/**\n * Is the given string valid linkable text of some sort. Note that this does not\n * trim the text for you.\n *\n * Optionally pass in a second `type` param, which is the type of link to test\n * for.\n *\n * For example,\n *\n * linkify.test(str, 'email');\n *\n * Returns `true` if str is a valid email.\n * @param {string} str string to test for links\n * @param {string} [type] optional specific link type to look for\n * @returns boolean true/false\n */\n\nfunction test(str) {\n var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var tokens = tokenize(str);\n return tokens.length === 1 && tokens[0].isLink && (!type || tokens[0].t === type);\n}\n\nexport { Options, find, init, options, registerCustomProtocol, registerPlugin, reset, test, tokenize };\n","import { combineTransactionSteps, getChangedRanges, getMarksBetween, findChildrenInRange, getAttributes, Mark, mergeAttributes, markPasteRule } from '@tiptap/core';\nimport { test, find } from 'linkifyjs';\nimport { Plugin, PluginKey } from 'prosemirror-state';\n\nfunction autolink(options) {\r\n return new Plugin({\r\n key: new PluginKey('autolink'),\r\n appendTransaction: (transactions, oldState, newState) => {\r\n const docChanges = transactions.some(transaction => transaction.docChanged)\r\n && !oldState.doc.eq(newState.doc);\r\n if (!docChanges) {\r\n return;\r\n }\r\n const { tr } = newState;\r\n const transform = combineTransactionSteps(oldState.doc, transactions);\r\n const { mapping } = transform;\r\n const changes = getChangedRanges(transform);\r\n changes.forEach(({ oldRange, newRange }) => {\r\n // at first we check if we have to remove links\r\n getMarksBetween(oldRange.from, oldRange.to, oldState.doc)\r\n .filter(item => item.mark.type === options.type)\r\n .forEach(oldMark => {\r\n const newFrom = mapping.map(oldMark.from);\r\n const newTo = mapping.map(oldMark.to);\r\n const newMarks = getMarksBetween(newFrom, newTo, newState.doc)\r\n .filter(item => item.mark.type === options.type);\r\n if (!newMarks.length) {\r\n return;\r\n }\r\n const newMark = newMarks[0];\r\n const oldLinkText = oldState.doc.textBetween(oldMark.from, oldMark.to, undefined, ' ');\r\n const newLinkText = newState.doc.textBetween(newMark.from, newMark.to, undefined, ' ');\r\n const wasLink = test(oldLinkText);\r\n const isLink = test(newLinkText);\r\n // remove only the link, if it was a link before too\r\n // because we don’t want to remove links that were set manually\r\n if (wasLink && !isLink) {\r\n tr.removeMark(newMark.from, newMark.to, options.type);\r\n }\r\n });\r\n // now let’s see if we can add new links\r\n findChildrenInRange(newState.doc, newRange, node => node.isTextblock)\r\n .forEach(textBlock => {\r\n // we need to define a placeholder for leaf nodes\r\n // so that the link position can be calculated correctly\r\n const text = newState.doc.textBetween(textBlock.pos, textBlock.pos + textBlock.node.nodeSize, undefined, ' ');\r\n find(text)\r\n .filter(link => link.isLink)\r\n // calculate link position\r\n .map(link => ({\r\n ...link,\r\n from: textBlock.pos + link.start + 1,\r\n to: textBlock.pos + link.end + 1,\r\n }))\r\n // check if link is within the changed range\r\n .filter(link => {\r\n const fromIsInRange = newRange.from >= link.from && newRange.from <= link.to;\r\n const toIsInRange = newRange.to >= link.from && newRange.to <= link.to;\r\n return fromIsInRange || toIsInRange;\r\n })\r\n // add link mark\r\n .forEach(link => {\r\n tr.addMark(link.from, link.to, options.type.create({\r\n href: link.href,\r\n }));\r\n });\r\n });\r\n });\r\n if (!tr.steps.length) {\r\n return;\r\n }\r\n return tr;\r\n },\r\n });\r\n}\n\nfunction clickHandler(options) {\r\n return new Plugin({\r\n key: new PluginKey('handleClickLink'),\r\n props: {\r\n handleClick: (view, pos, event) => {\r\n var _a;\r\n const attrs = getAttributes(view.state, options.type.name);\r\n const link = (_a = event.target) === null || _a === void 0 ? void 0 : _a.closest('a');\r\n if (link && attrs.href) {\r\n window.open(attrs.href, attrs.target);\r\n return true;\r\n }\r\n return false;\r\n },\r\n },\r\n });\r\n}\n\nfunction pasteHandler(options) {\r\n return new Plugin({\r\n key: new PluginKey('handlePasteLink'),\r\n props: {\r\n handlePaste: (view, event, slice) => {\r\n const { state } = view;\r\n const { selection } = state;\r\n const { empty } = selection;\r\n if (empty) {\r\n return false;\r\n }\r\n let textContent = '';\r\n slice.content.forEach(node => {\r\n textContent += node.textContent;\r\n });\r\n const link = find(textContent).find(item => item.isLink && item.value === textContent);\r\n if (!textContent || !link) {\r\n return false;\r\n }\r\n options.editor.commands.setMark(options.type, {\r\n href: link.href,\r\n });\r\n return true;\r\n },\r\n },\r\n });\r\n}\n\nconst Link = Mark.create({\r\n name: 'link',\r\n priority: 1000,\r\n keepOnSplit: false,\r\n inclusive() {\r\n return this.options.autolink;\r\n },\r\n addOptions() {\r\n return {\r\n openOnClick: true,\r\n linkOnPaste: true,\r\n autolink: true,\r\n HTMLAttributes: {\r\n target: '_blank',\r\n rel: 'noopener noreferrer nofollow',\r\n },\r\n };\r\n },\r\n addAttributes() {\r\n return {\r\n href: {\r\n default: null,\r\n },\r\n target: {\r\n default: this.options.HTMLAttributes.target,\r\n },\r\n };\r\n },\r\n parseHTML() {\r\n return [\r\n { tag: 'a[href]' },\r\n ];\r\n },\r\n renderHTML({ HTMLAttributes }) {\r\n return [\r\n 'a',\r\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\r\n 0,\r\n ];\r\n },\r\n addCommands() {\r\n return {\r\n setLink: attributes => ({ commands }) => {\r\n return commands.setMark(this.name, attributes);\r\n },\r\n toggleLink: attributes => ({ commands }) => {\r\n return commands.toggleMark(this.name, attributes, { extendEmptyMarkRange: true });\r\n },\r\n unsetLink: () => ({ commands }) => {\r\n return commands.unsetMark(this.name, { extendEmptyMarkRange: true });\r\n },\r\n };\r\n },\r\n addPasteRules() {\r\n return [\r\n markPasteRule({\r\n find: text => find(text)\r\n .filter(link => link.isLink)\r\n .map(link => ({\r\n text: link.value,\r\n index: link.start,\r\n data: link,\r\n })),\r\n type: this.type,\r\n getAttributes: match => {\r\n var _a;\r\n return ({\r\n href: (_a = match.data) === null || _a === void 0 ? void 0 : _a.href,\r\n });\r\n },\r\n }),\r\n ];\r\n },\r\n addProseMirrorPlugins() {\r\n const plugins = [];\r\n if (this.options.autolink) {\r\n plugins.push(autolink({\r\n type: this.type,\r\n }));\r\n }\r\n if (this.options.openOnClick) {\r\n plugins.push(clickHandler({\r\n type: this.type,\r\n }));\r\n }\r\n if (this.options.linkOnPaste) {\r\n plugins.push(pasteHandler({\r\n editor: this.editor,\r\n type: this.type,\r\n }));\r\n }\r\n return plugins;\r\n },\r\n});\n\nexport { Link, Link as default };\n//# sourceMappingURL=tiptap-extension-link.esm.js.map\n","/**\n** JAVASCRIPTS\n** Name: Editor\n********************************************************************************/\n\nimport { Editor } from '@tiptap/core'\nimport StarterKit from '@tiptap/starter-kit'\nimport Link from '@tiptap/extension-link'\n\n(function() {\n 'use strict';\n\n\n if(document.querySelectorAll('.js-editor').length > 0) {\n\n\n /**\n ** Variables\n ****************************************/\n\n // const $html = document.documentElement;\n const $editors = document.querySelectorAll('.js-editor');\n\n\n /**\n ** Events\n ****************************************/\n\n\n // Toggle\n\n $editors.forEach(($editor) => {\n const $label = $editor.querySelector('.js-editor-label');\n const $textarea = $editor.querySelector('.js-editor-textarea');\n const $content = $editor.querySelector('.js-editor-content');\n\n var editor = new Editor({\n element: $content,\n content: $textarea.value,\n extensions: [\n StarterKit,\n Link.configure({\n openOnClick: false,\n }),\n ],\n });\n\n\n // Update\n\n editor.on('update', ({ editor }) => {\n $textarea.value = editor.getHTML();\n\n if(editor.isActive('paragraph')) { $buttonText.classList.add('is-active'); } else { $buttonText.classList.remove('is-active'); }\n if(editor.isActive('heading', {level: 2})) { $buttonTitle.classList.add('is-active'); } else { $buttonTitle.classList.remove('is-active'); }\n if(editor.isActive('bold')) { $buttonBold.classList.add('is-active'); } else { $buttonBold.classList.remove('is-active'); }\n if(editor.isActive('italic')) { $buttonItalic.classList.add('is-active'); } else { $buttonItalic.classList.remove('is-active'); }\n if(editor.isActive('link')) {\n $buttonLink.classList.add('is-active');\n $buttonUnlink.classList.add('is-active');\n } else {\n $buttonLink.classList.remove('is-active');\n $buttonUnlink.classList.remove('is-active');\n }\n });\n\n editor.on('selectionUpdate', ({ editor }) => {\n if(editor.isActive('paragraph')) { $buttonText.classList.add('is-active'); } else { $buttonText.classList.remove('is-active'); }\n if(editor.isActive('heading', {level: 2})) { $buttonTitle.classList.add('is-active'); } else { $buttonTitle.classList.remove('is-active'); }\n if(editor.isActive('bold')) { $buttonBold.classList.add('is-active'); } else { $buttonBold.classList.remove('is-active'); }\n if(editor.isActive('italic')) { $buttonItalic.classList.add('is-active'); } else { $buttonItalic.classList.remove('is-active'); }\n if(editor.isActive('link')) {\n $buttonLink.classList.add('is-active');\n $buttonUnlink.classList.add('is-active');\n } else {\n $buttonLink.classList.remove('is-active');\n $buttonUnlink.classList.remove('is-active');\n }\n });\n\n $editor.addEventListener('keyup', () => {\n if(editor.isActive('paragraph')) { $buttonText.classList.add('is-active'); } else { $buttonText.classList.remove('is-active'); }\n if(editor.isActive('heading', {level: 2})) { $buttonTitle.classList.add('is-active'); } else { $buttonTitle.classList.remove('is-active'); }\n if(editor.isActive('bold')) { $buttonBold.classList.add('is-active'); } else { $buttonBold.classList.remove('is-active'); }\n if(editor.isActive('italic')) { $buttonItalic.classList.add('is-active'); } else { $buttonItalic.classList.remove('is-active'); }\n if(editor.isActive('link')) {\n $buttonLink.classList.add('is-active');\n $buttonUnlink.classList.add('is-active');\n } else {\n $buttonLink.classList.remove('is-active');\n $buttonUnlink.classList.remove('is-active');\n }\n });\n\n\n // Buttons\n\n const $buttonText = $editor.querySelector('.js-editor-text');\n const $buttonTitle = $editor.querySelector('.js-editor-title');\n const $buttonBold = $editor.querySelector('.js-editor-bold');\n const $buttonItalic = $editor.querySelector('.js-editor-italic');\n const $buttonLink = $editor.querySelector('.js-editor-link');\n const $buttonUnlink = $editor.querySelector('.js-editor-unlink');\n\n $buttonText.addEventListener('click', function(event) {\n event.preventDefault();\n editor.chain().focus().setParagraph().run();\n if(editor.isActive('paragraph')) { $buttonText.classList.add('is-active'); } else { $buttonText.classList.remove('is-active'); }\n });\n\n $buttonTitle.addEventListener('click', function(event) {\n event.preventDefault();\n editor.chain().focus().setHeading({level: 2}).run()\n if(editor.isActive('heading', {level: 2})) { $buttonTitle.classList.add('is-active'); } else { $buttonTitle.classList.remove('is-active'); }\n });\n\n $buttonBold.addEventListener('click', function(event) {\n event.preventDefault();\n editor.chain().focus().toggleBold().run();\n if(editor.isActive('bold')) { $buttonBold.classList.add('is-active'); } else { $buttonBold.classList.remove('is-active'); }\n });\n\n $buttonItalic.addEventListener('click', function(event) {\n event.preventDefault();\n editor.chain().focus().toggleItalic().run();\n if(editor.isActive('italic')) { $buttonItalic.classList.add('is-active'); } else { $buttonItalic.classList.remove('is-active'); }\n });\n\n $buttonLink.addEventListener('click', function(event) {\n event.preventDefault();\n\n const previousUrl = editor.getAttributes('link').href;\n const url = window.prompt('URL', previousUrl);\n\n // cancelled\n if (url === null) {\n return;\n }\n\n // empty\n if (url === '') {\n editor.chain().focus().extendMarkRange('link').unsetLink().run();\n $buttonLink.classList.remove('is-active');\n $buttonUnlink.classList.remove('is-active');\n return;\n }\n\n // update link\n editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run();\n $buttonLink.classList.add('is-active');\n $buttonUnlink.classList.add('is-active');\n });\n\n $buttonUnlink.addEventListener('click', function(event) {\n event.preventDefault();\n editor.chain().focus().unsetLink().run();\n $buttonUnlink.classList.remove('is-active');\n });\n\n });\n\n\n }\n\n})();\n","/**\n** JAVASCRIPTS\n** Name: Register\n********************************************************************************/\n\n(function() {\n 'use strict';\n\n\n if(document.querySelector('.js-register-toggle')) {\n\n\n /**\n ** Variables\n ****************************************/\n\n const $toggle = document.querySelector('.js-register-toggle');\n const $targets = document.querySelectorAll('.js-register-target-field');\n\n\n /**\n ** Events\n ****************************************/\n\n if($targets.length > 0) {\n\n\n // Init\n\n if($toggle.checked) {\n $targets.forEach(($target) => {\n $target.classList.remove('u-hidden');\n });\n }\n\n\n // Toggle\n\n $toggle.addEventListener('change', ()=>{\n if($toggle.checked) {\n $targets.forEach(($target) => {\n $target.classList.remove('u-hidden');\n });\n }\n else {\n $targets.forEach(($target) => {\n $target.classList.add('u-hidden');\n });\n }\n });\n\n\n }\n\n\n }\n\n})();\n","// import { throttle, debounce } from 'throttle-debounce';\n\nimport \"./front/components/header\";\nimport \"./front/components/dropdown\";\nimport \"./front/components/search\";\nimport \"./front/components/alert\";\nimport \"./front/components/footer\";\nimport \"./front/components/map\";\nimport \"./front/components/menu\";\nimport \"./front/components/password\";\nimport \"./front/components/visio\";\nimport \"./front/components/editor\";\nimport \"./front/components/register\";\n\nif(document.querySelector('.js-print')) {\n document.querySelector('.js-print').addEventListener('click', ()=>{\n window.print();\n });\n}\n"],"names":["document","querySelector","$html","documentElement","$toggle","querySelectorAll","offsetTop","window","outerWidth","lastScrollPos","ticking","setHeaderState","scrollPos","direction","classList","add","remove","forEach","$this","addEventListener","toggle","pageYOffset","scrollTop","requestAnimationFrame","windowWidth","Toggler","element","target","autoClose","expanded","mounted","handleClick","this","bind","handleKeyup","handleTarget","handleAutoClose","e","trigger","relatedTarget","contains","hide","removeEventListener","preventDefault","key","detail","toggler","setAttribute","show","focus","dispatchEvent","CustomEvent","id","tagName","removeAttribute","button","value","menu","update","labels","input","checked","label","push","innerHTML","getLabels","join","mount","searchs","hasScript","appendScript","script","createElement","type","src","initAutocomplete","once","body","appendChild","length","searchType","dataset","searchInput","latInput","lngInput","hasDownBeenPressed","autocomplete","keyCode","cancelBubble","hasRanOnce","event","Event","code","google","maps","options","componentRestrictions","types","places","Autocomplete","addListener","place","getPlace","geometry","location","lat","lng","components","address_components","address","name","component","long_name","city","postal_code","street","full_street","number","searchKey","$overlay","$openers","$closers","$form","$email","getAttribute","$open","$close","form","$control","$feedback","fetch","action","method","FormData","then","response","json","created","Object","keys","errors","$field","$text","Newsletter","feedback","email","email_control","email_feedback","gdpr","gdpr_control","gdpr_feedback","is_processing","handleFormSubmit","data","URLSearchParams","pair","append","headers","ok","status","Error","statusText","success","_this","invalid","catch","error","newsletterSuccess","newsletterFeedback","gdpr_error","newsletterError","footer","getElementById","togglers","newsletterElement","tmp","offsetWidth","footerToggler","getComputedStyle","getPropertyValue","callback","delay","timer","args","context","clearTimeout","setTimeout","apply","debounce","isTogglable","unmount","OrderedMap","content","map","L","scrollWheelZoom","zoomControl","setView","$events","$markers","markers","popupOptions","autoPan","minWidth","maxWidth","className","closeButton","tileLayer","attribution","subdomains","maxZoom","addTo","Control","Zoom","position","$event","$eventCard","$eventData","date","start","card","sort","a","b","parseInt","console","log","markerLat","markerLng","markerDate","$popupContent","toLowerCase","$popupCard","outerHTML","markerIcon","divIcon","html","marker","icon","bindPopup","bounds","LatLngBounds","fitBounds","on","popup","_source","_icon","$password","$input","$targets","$target","prototype","constructor","find","i","get","found","undefined","newKey","self","slice","splice","addToStart","concat","addToEnd","addBefore","without","f","prepend","from","size","subtract","result","prop","orderedmap","findDiffStart","pos","let","childCount","childA","child","childB","sameMarkup","isText","text","j","inner","nodeSize","findDiffEnd","posA","posB","iA","iB","same","minSize","Math","min","const","factor16","pow","recoverIndex","MapResult","deleted","recover","StepMap","ranges","inverted","diff","index","recoverOffset","mapResult","assoc","_map","simple","oldIndex","newIndex","oldSize","newSize","end","touches","oldStart","newStart","invert","toString","JSON","stringify","offset","n","empty","Mapping","mirror","to","copy","appendMap","mirrors","setMirror","appendMapping","mapping","startSize","mirr","getMirror","m","appendMappingInverted","totalSize","inverse","corr","classesById","create","Selection","$anchor","$head","SelectionRange","max","anchor","head","$from","$to","node","replace","tr","Slice","lastNode","lastChild","lastParent","openEnd","mapFrom","steps","ref","replaceRange","selectionToInsertionEnd","isInline","isTextblock","replaceWith","deleteRange","replaceRangeWith","findFrom","$pos","dir","textOnly","parent","inlineContent","TextSelection","findSelectionIn","depth","before","after","near","bias","AllSelection","atStart","doc","atEnd","fromJSON","RangeError","cls","jsonID","selectionClass","getBookmark","between","prototypeAccessors","visible","super","prototypeAccessors$1","$cursor","resolve","call","marks","marksAcross","ensureMarks","eq","other","TextBookmark","toJSON","dPos","NodeSelection","nodeAfter","$end","Fragment","NodeBookmark","isSelectable","spec","selectable","delete","sel","selection","setSelection","AllBookmark","isAtom","startLen","last","step","ReplaceStep","ReplaceAroundStep","_from","_to","_newFrom","newTo","deleteSelection","state","dispatch","scrollIntoView","joinBackward","view","endOfTextblock","parentOffset","$cut","findCutBefore","range","blockRange","liftTarget","lift","nodeBefore","isolating","deleteBarrier","textblockAt","side","only","firstChild","selectNodeBackward","joinForward","findCutAfter","selectNodeForward","newlineInCode","sameParent","insertText","defaultBlockAt","match","edgeCount","edge","hasRequiredAttrs","exitCode","above","indexAfter","contentMatchAt","canReplaceWith","createAndFill","createParagraphNear","insert","liftEmptyBlock","canSplit","split","conn","compatibleContent","canReplace","canJoin","clearIncompatible","joinMaybeClear","canDelAfter","findWrapping","matchType","validEnd","wrap","joinAt","selAfter","at","afterText","afterDepth","wrapIn","nodeType","attrs","wrapping","chainCommands","commands","backspace","del","pcBaseKeymap","isBlock","deflt","can","first","$first","setNodeMarkup","macBaseKeymap","wrapInList","listType","doJoin","outerRange","startIndex","$insert","NodeRange","endIndex","wrappers","joinBefore","splitDepth","splitPos","doWrapInList","liftListItem","itemType","endOfList","liftToOuterList","list","$start","item","indexBefore","liftOutOfList","navigator","test","platform","os","ie_edge","exec","userAgent","ie_upto10","ie_11up","ie","ie_version","documentMode","gecko","gecko_version","chrome","chrome_version","safari","vendor","ios","maxTouchPoints","mac","android","webkit","style","webkit_version","base","shift","brokenModifierNames","String","fromCharCode","hasOwnProperty","normalizeKeyName","alt","ctrl","meta","parts","mod","modifiers","altKey","ctrlKey","metaKey","shiftKey","keydownHandler","bindings","normalize","baseName","keyName","isChar","direct","charCodeAt","fromCode","withShift","isPlainObject","getType","getPrototypeOf","sharedDepth","applicable","nodesBetween","hasMarkup","setBlockType","nestedBefore","Plugin","props","handleKeyDown","inputRegex","Blockquote","Node","addOptions","HTMLAttributes","group","defining","parseHTML","tag","renderHTML","mergeAttributes","addCommands","setBlockquote","toggleBlockquote","toggleWrap","unsetBlockquote","addKeyboardShortcuts","editor","addInputRules","wrappingInputRule","starInputRegex","starPasteRegex","underscoreInputRegex","underscorePasteRegex","Bold","Mark","getAttrs","fontWeight","setBold","setMark","toggleBold","toggleMark","unsetBold","unsetMark","markInputRule","addPasteRules","markPasteRule","BulletList","itemTypeName","toggleBulletList","toggleList","pasteRegex","Code","excludes","setCode","toggleCode","unsetCode","backtickInputRegex","tildeInputRegex","CodeBlock","languageClassPrefix","addAttributes","language","default","_a","firstElementChild","filter","startsWith","attributes","class","preserveWhitespace","setCodeBlock","setNode","toggleCodeBlock","toggleNode","Backspace","isAtStart","textContent","clearNodes","Enter","isAtEnd","endsWithDoubleNewline","endsWith","chain","command","run","textblockTypeInputRule","getAttributes","groups","addProseMirrorPlugins","PluginKey","handlePaste","clipboardData","isActive","getData","vscode","vscodeData","parse","mode","replaceSelectionWith","setMeta","Document","topNode","DropCursorView","editorView","width","color","cursorPos","timeout","handlers","handler","dom","destroy","prevState","setCursor","updateOverlay","parentNode","removeChild","rect","nodeRect","nodeDOM","getBoundingClientRect","top","bottom","left","right","coords","coordsAtPos","parentLeft","parentTop","offsetParent","cssText","pageXOffset","scrollLeft","height","scheduleRemoval","dragover","editable","posAtCoords","clientX","clientY","inside","nodeAt","disableDropCursor","disabled","dragging","dropPoint","dragend","drop","dragleave","Dropcursor","Extension","GapCursor","valid","GapBookmark","d","closedBefore","closedAfter","override","allowGapCursor","defaultType","mustMove","search","next","$cur","Gapcursor","extendNodeSchema","extension","callOrReturn","getExtensionField","storage","HardBreak","keepMarks","inline","renderText","setHardBreak","storedMarks","splittableMarks","extensionManager","insertContent","filteredMarks","mark","includes","Heading","levels","level","rendered","setHeading","toggleHeading","reduce","items","RegExp","GOOD_LEAF_SIZE","RopeSequence","leafAppend","leafPrepend","appendInner","Append","sliceInner","getInner","forEachInner","forEachInvertedInner","elt","values","Leaf","__proto__","configurable","flatten","defineProperties","leftLen","ropeSequence","Branch","eventCount","popEvent","preserveItems","remap","remapping","remaining","transform","addAfter","Item","maybeStep","reverse","addTransform","histOptions","newItems","oldItems","lastItem","merged","docs","merge","pop","cutPoint","overflow","DEPTH_OVERFLOW","mirrorPos","mirrorOffset","addMaps","array","rebased","rebasedTransform","rebasedCount","rebasedItems","newUntil","iRebased","newMaps","branch","emptyItemCount","compress","count","upto","events","getMap","newItem","HistoryState","done","undone","prevRanges","prevTime","rangesFor","mapRanges","histTransaction","history","redo","mustPreserveItems","historyKey","config","added","newHist","historyState","cachedPreserveItems","cachedPreserveItemsPlugins","plugins","historyPreserveItems","closeHistoryKey","newGroupDelay","init","hist","historyTr","getMeta","appended","newGroup","time","docChanged","adjacent","isAdjacentTo","applyTransaction","handleDOMEvents","beforeinput","handled","inputType","undo","getState","History","HorizontalRule","setHorizontalRule","posAfter","contentMatch","Italic","fontStyle","setItalic","toggleItalic","unsetItalic","ListItem","splitListItem","Tab","sinkListItem","OrderedList","hasAttribute","attributesWithoutStart","toggleOrderedList","joinPredicate","Paragraph","priority","setParagraph","Strike","consuming","setStrike","toggleStrike","unsetStrike","Text","StarterKit","addExtensions","extensions","blockquote","configure","bold","_b","bulletList","_c","_d","codeBlock","_e","_f","dropcursor","_g","gapcursor","_h","hardBreak","_j","heading","_k","_l","horizontalRule","_m","italic","_o","listItem","_p","orderedList","_q","paragraph","_r","strike","_s","_t","State","token","jr","jd","t","accepts","tt","tokenOrState","nextState","makeState","templateState","takeT","assign","makeAcceptingState","makeT","startState","makeRegexT","regex","_nextState","makeMultiT","chars","makeBatchT","transitions","makeChainT","str","endState","defaultStateFactory","len","DOMAIN","LOCALHOST","TLD","NUM","PROTOCOL","MAILTO","WS","NL","OPENBRACE","OPENBRACKET","OPENANGLEBRACKET","OPENPAREN","CLOSEBRACE","CLOSEBRACKET","CLOSEANGLEBRACKET","CLOSEPAREN","AMPERSAND","APOSTROPHE","ASTERISK","AT","BACKSLASH","BACKTICK","CARET","COLON","COMMA","DOLLAR","DOT","EQUALS","EXCLAMATION","HYPHEN","PERCENT","PIPE","PLUS","POUND","QUERY","QUOTE","SEMI","SLASH","TILDE","UNDERSCORE","SYM","freeze","tlds","LETTER","EMOJI","EMOJI_VARIATION","DIGIT","SPACE","init$2","customProtocols","arguments","S_START","S_NUM","S_DOMAIN","S_DOMAIN_HYPHEN","S_WS","DOMAIN_REGEX_TRANSITIONS","makeDomainState","makeNearDomainState","S_PROTOCOL_FILE","S_PROTOCOL_FTP","S_PROTOCOL_HTTP","S_MAILTO","S_PROTOCOL_SECURE","S_FULL_PROTOCOL","S_FULL_MAILTO","S_CUSTOM_PROTOCOL","_i","defaults","MultiToken","createTokenClass","Token","tokens","v","tk","extended","p","inherits","isLink","toHref","s","toObject","protocol","href","MailtoEmail","Email","Nl","Url","hasProtocol","hasSlashSlash","multi","Base","init$1","S_PROTOCOL","S_PROTOCOL_SLASH","S_PROTOCOL_SLASH_SLASH","S_DOMAIN_DOT","S_TLD","S_TLD_COLON","S_TLD_PORT","S_URL","S_URL_NON_ACCEPTING","S_URL_OPENBRACE","S_URL_OPENBRACKET","S_URL_OPENANGLEBRACKET","S_URL_OPENPAREN","S_URL_OPENBRACE_Q","S_URL_OPENBRACKET_Q","S_URL_OPENANGLEBRACKET_Q","S_URL_OPENPAREN_Q","S_URL_OPENBRACE_SYMS","S_URL_OPENBRACKET_SYMS","S_URL_OPENANGLEBRACKET_SYMS","S_URL_OPENPAREN_SYMS","S_EMAIL_DOMAIN","S_EMAIL_DOMAIN_DOT","S_EMAIL","S_EMAIL_COLON","S_EMAIL_PORT","S_MAILTO_EMAIL","S_MAILTO_EMAIL_NON_ACCEPTING","S_LOCALPART","S_LOCALPART_AT","S_LOCALPART_DOT","S_NL","qsAccepting","qsNonAccepting","localpartAccepting","parserCreateMultiToken","Multi","startIdx","endIdx","substr","INIT","scanner","parser","pluginQueue","initialized","tokenize","utils","cursor","multis","textTokens","secondState","multiLength","latestAccepting","sinceAccepts","subtokens","iterable","second","char","stringToArray","c","charCount","charCursor","tokenLength","charsSinceAccepts","run$1","filtered","autolink","appendTransaction","transactions","oldState","newState","some","transaction","combineTransactionSteps","changes","getChangedRanges","oldRange","newRange","getMarksBetween","oldMark","newMarks","newMark","oldLinkText","textBetween","newLinkText","wasLink","removeMark","findChildrenInRange","textBlock","link","fromIsInRange","toIsInRange","addMark","$editor","$textarea","$content","Editor","Link","openOnClick","getHTML","$buttonText","$buttonTitle","$buttonBold","$buttonItalic","$buttonLink","$buttonUnlink","previousUrl","url","prompt","extendMarkRange","unsetLink","setLink","print"],"mappings":"81CAKA,cAIKA,SAASC,cAAc,cAAe,KAOjCC,EAAUF,SAASG,gBACTH,SAASC,cAAc,kBACjCG,EAAUJ,SAASK,iBAAiB,qBAEtCC,EAAiBC,OAAOC,YAAc,IAAO,GAAK,EAClDC,EAAgB,EAChBC,GAAgB,WAOXC,EAAeC,EAAWC,GAE9BD,GAAaN,EACdJ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