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,EAAME,EAAIuH,GACjBhI,IACX,CAOAisB,WAAW1rB,EAAME,EAAIuH,GAEjB,OADAikB,EAAWjsB,KAAMO,EAAME,EAAIuH,GACpBhI,IACX,CAOAosB,kBAAkB/rB,EAAKgsB,EAAYC,GAE/B,OADAF,EAAkBpsB,KAAMK,EAAKgsB,EAAYC,GAClCtsB,IACX,E","sources":["webpack://ida-jandaya/./node_modules/prosemirror-state/dist/index.js","webpack://ida-jandaya/./node_modules/prosemirror-tables/dist/index.js","webpack://ida-jandaya/./node_modules/prosemirror-transform/dist/index.js"],"sourcesContent":["import { Slice, Fragment, Mark, Node } from 'prosemirror-model';\nimport { ReplaceStep, ReplaceAroundStep, Transform } from 'prosemirror-transform';\n\nconst classesById = Object.create(null);\n/**\nSuperclass for editor selections. Every selection type should\nextend this. Should not be instantiated directly.\n*/\nclass Selection {\n /**\n Initialize a selection with the head and anchor and ranges. If no\n ranges are given, constructs a single range across `$anchor` and\n `$head`.\n */\n constructor(\n /**\n The resolved anchor of the selection (the side that stays in\n place when the selection is modified).\n */\n $anchor, \n /**\n The resolved head of the selection (the side that moves when\n the selection is modified).\n */\n $head, ranges) {\n this.$anchor = $anchor;\n this.$head = $head;\n this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];\n }\n /**\n The selection's anchor, as an unresolved position.\n */\n get anchor() { return this.$anchor.pos; }\n /**\n The selection's head.\n */\n get head() { return this.$head.pos; }\n /**\n The lower bound of the selection's main range.\n */\n get from() { return this.$from.pos; }\n /**\n The upper bound of the selection's main range.\n */\n get to() { return this.$to.pos; }\n /**\n The resolved lower bound of the selection's main range.\n */\n get $from() {\n return this.ranges[0].$from;\n }\n /**\n The resolved upper bound of the selection's main range.\n */\n get $to() {\n return this.ranges[0].$to;\n }\n /**\n Indicates whether the selection contains any content.\n */\n get empty() {\n let ranges = this.ranges;\n for (let i = 0; i < ranges.length; i++)\n if (ranges[i].$from.pos != ranges[i].$to.pos)\n return false;\n return true;\n }\n /**\n Get the content of this selection as a slice.\n */\n content() {\n return this.$from.doc.slice(this.from, this.to, true);\n }\n /**\n Replace the selection with a slice or, if no slice is given,\n delete the selection. Will append to the given transaction.\n */\n replace(tr, content = Slice.empty) {\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 let lastNode = content.content.lastChild, lastParent = null;\n for (let i = 0; i < content.openEnd; i++) {\n lastParent = lastNode;\n lastNode = lastNode.lastChild;\n }\n let mapFrom = tr.steps.length, ranges = this.ranges;\n for (let i = 0; i < ranges.length; i++) {\n let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);\n tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);\n if (i == 0)\n selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1);\n }\n }\n /**\n Replace the selection with the given node, appending the changes\n to the given transaction.\n */\n replaceWith(tr, node) {\n let mapFrom = tr.steps.length, ranges = this.ranges;\n for (let i = 0; i < ranges.length; i++) {\n let { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);\n let from = mapping.map($from.pos), to = mapping.map($to.pos);\n if (i) {\n tr.deleteRange(from, to);\n }\n else {\n tr.replaceRangeWith(from, to, node);\n selectionToInsertionEnd(tr, mapFrom, node.isInline ? -1 : 1);\n }\n }\n }\n /**\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.\n */\n static findFrom($pos, dir, textOnly = false) {\n let inner = $pos.parent.inlineContent ? new TextSelection($pos)\n : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);\n if (inner)\n return inner;\n for (let depth = $pos.depth - 1; depth >= 0; depth--) {\n let 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)\n return found;\n }\n return null;\n }\n /**\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.\n */\n static near($pos, bias = 1) {\n return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0));\n }\n /**\n Find the cursor or leaf node selection closest to the start of\n the given document. Will return an\n [`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position\n exists.\n */\n static atStart(doc) {\n return findSelectionIn(doc, doc, 0, 0, 1) || new AllSelection(doc);\n }\n /**\n Find the cursor or leaf node selection closest to the end of the\n given document.\n */\n static atEnd(doc) {\n return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1) || new AllSelection(doc);\n }\n /**\n Deserialize the JSON representation of a selection. Must be\n implemented for custom classes (as a static class method).\n */\n static fromJSON(doc, json) {\n if (!json || !json.type)\n throw new RangeError(\"Invalid input for Selection.fromJSON\");\n let cls = classesById[json.type];\n if (!cls)\n throw new RangeError(`No selection type ${json.type} defined`);\n return cls.fromJSON(doc, json);\n }\n /**\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.\n */\n static jsonID(id, selectionClass) {\n if (id in classesById)\n 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 Get a [bookmark](https://prosemirror.net/docs/ref/#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.\n */\n getBookmark() {\n return TextSelection.between(this.$anchor, this.$head).getBookmark();\n }\n}\nSelection.prototype.visible = true;\n/**\nRepresents a selected range in a document.\n*/\nclass SelectionRange {\n /**\n Create a range.\n */\n constructor(\n /**\n The lower bound of the range.\n */\n $from, \n /**\n The upper bound of the range.\n */\n $to) {\n this.$from = $from;\n this.$to = $to;\n }\n}\nlet warnedAboutTextSelection = false;\nfunction checkTextSelection($pos) {\n if (!warnedAboutTextSelection && !$pos.parent.inlineContent) {\n warnedAboutTextSelection = true;\n console[\"warn\"](\"TextSelection endpoint not pointing into a node with inline content (\" + $pos.parent.type.name + \")\");\n }\n}\n/**\nA text selection represents a classical editor selection, with a\nhead (the moving side) and anchor (immobile side), both of which\npoint into textblock nodes. It can be empty (a regular cursor\nposition).\n*/\nclass TextSelection extends Selection {\n /**\n Construct a text selection between the given points.\n */\n constructor($anchor, $head = $anchor) {\n checkTextSelection($anchor);\n checkTextSelection($head);\n super($anchor, $head);\n }\n /**\n Returns a resolved position if this is a cursor selection (an\n empty text selection), and null otherwise.\n */\n get $cursor() { return this.$anchor.pos == this.$head.pos ? this.$head : null; }\n map(doc, mapping) {\n let $head = doc.resolve(mapping.map(this.head));\n if (!$head.parent.inlineContent)\n return Selection.near($head);\n let $anchor = doc.resolve(mapping.map(this.anchor));\n return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head);\n }\n replace(tr, content = Slice.empty) {\n super.replace(tr, content);\n if (content == Slice.empty) {\n let marks = this.$from.marksAcross(this.$to);\n if (marks)\n tr.ensureMarks(marks);\n }\n }\n eq(other) {\n return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head;\n }\n getBookmark() {\n return new TextBookmark(this.anchor, this.head);\n }\n toJSON() {\n return { type: \"text\", anchor: this.anchor, head: this.head };\n }\n /**\n @internal\n */\n static 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 Create a text selection from non-resolved positions.\n */\n static create(doc, anchor, head = anchor) {\n let $anchor = doc.resolve(anchor);\n return new this($anchor, head == anchor ? $anchor : doc.resolve(head));\n }\n /**\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`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document\n doesn't contain a valid text position.\n */\n static between($anchor, $head, bias) {\n let dPos = $anchor.pos - $head.pos;\n if (!bias || dPos)\n bias = dPos >= 0 ? 1 : -1;\n if (!$head.parent.inlineContent) {\n let found = Selection.findFrom($head, bias, true) || Selection.findFrom($head, -bias, true);\n if (found)\n $head = found.$head;\n else\n return Selection.near($head, bias);\n }\n if (!$anchor.parent.inlineContent) {\n if (dPos == 0) {\n $anchor = $head;\n }\n else {\n $anchor = (Selection.findFrom($anchor, -bias, true) || Selection.findFrom($anchor, bias, true)).$anchor;\n if (($anchor.pos < $head.pos) != (dPos < 0))\n $anchor = $head;\n }\n }\n return new TextSelection($anchor, $head);\n }\n}\nSelection.jsonID(\"text\", TextSelection);\nclass TextBookmark {\n constructor(anchor, head) {\n this.anchor = anchor;\n this.head = head;\n }\n map(mapping) {\n return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head));\n }\n resolve(doc) {\n return TextSelection.between(doc.resolve(this.anchor), doc.resolve(this.head));\n }\n}\n/**\nA node selection is a selection that points at a single node. All\nnodes marked [selectable](https://prosemirror.net/docs/ref/#model.NodeSpec.selectable) can be the\ntarget of a node selection. In such a selection, `from` and `to`\npoint directly before and after the selected node, `anchor` equals\n`from`, and `head` equals `to`..\n*/\nclass NodeSelection extends Selection {\n /**\n Create a node selection. Does not verify the validity of its\n argument.\n */\n constructor($pos) {\n let node = $pos.nodeAfter;\n let $end = $pos.node(0).resolve($pos.pos + node.nodeSize);\n super($pos, $end);\n this.node = node;\n }\n map(doc, mapping) {\n let { deleted, pos } = mapping.mapResult(this.anchor);\n let $pos = doc.resolve(pos);\n if (deleted)\n return Selection.near($pos);\n return new NodeSelection($pos);\n }\n content() {\n return new Slice(Fragment.from(this.node), 0, 0);\n }\n eq(other) {\n return other instanceof NodeSelection && other.anchor == this.anchor;\n }\n toJSON() {\n return { type: \"node\", anchor: this.anchor };\n }\n getBookmark() { return new NodeBookmark(this.anchor); }\n /**\n @internal\n */\n static 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 Create a node selection from non-resolved positions.\n */\n static create(doc, from) {\n return new NodeSelection(doc.resolve(from));\n }\n /**\n Determines whether the given node may be selected as a node\n selection.\n */\n static isSelectable(node) {\n return !node.isText && node.type.spec.selectable !== false;\n }\n}\nNodeSelection.prototype.visible = false;\nSelection.jsonID(\"node\", NodeSelection);\nclass NodeBookmark {\n constructor(anchor) {\n this.anchor = anchor;\n }\n map(mapping) {\n let { deleted, pos } = mapping.mapResult(this.anchor);\n return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos);\n }\n resolve(doc) {\n let $pos = doc.resolve(this.anchor), node = $pos.nodeAfter;\n if (node && NodeSelection.isSelectable(node))\n return new NodeSelection($pos);\n return Selection.near($pos);\n }\n}\n/**\nA selection type that represents selecting the whole document\n(which can not necessarily be expressed with a text selection, when\nthere are for example leaf block nodes at the start or end of the\ndocument).\n*/\nclass AllSelection extends Selection {\n /**\n Create an all-selection over the given document.\n */\n constructor(doc) {\n super(doc.resolve(0), doc.resolve(doc.content.size));\n }\n replace(tr, content = Slice.empty) {\n if (content == Slice.empty) {\n tr.delete(0, tr.doc.content.size);\n let sel = Selection.atStart(tr.doc);\n if (!sel.eq(tr.selection))\n tr.setSelection(sel);\n }\n else {\n super.replace(tr, content);\n }\n }\n toJSON() { return { type: \"all\" }; }\n /**\n @internal\n */\n static fromJSON(doc) { return new AllSelection(doc); }\n map(doc) { return new AllSelection(doc); }\n eq(other) { return other instanceof AllSelection; }\n getBookmark() { return AllBookmark; }\n}\nSelection.jsonID(\"all\", AllSelection);\nconst AllBookmark = {\n map() { return this; },\n resolve(doc) { return new AllSelection(doc); }\n};\n// FIXME we'll need some awareness of text direction when scanning for selections\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 = false) {\n if (node.inlineContent)\n return TextSelection.create(doc, pos);\n for (let i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {\n let child = node.child(i);\n if (!child.isAtom) {\n let inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);\n if (inner)\n return inner;\n }\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 return null;\n}\nfunction selectionToInsertionEnd(tr, startLen, bias) {\n let last = tr.steps.length - 1;\n if (last < startLen)\n return;\n let step = tr.steps[last];\n if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep))\n return;\n let map = tr.mapping.maps[last], end;\n map.forEach((_from, _to, _newFrom, newTo) => { if (end == null)\n end = newTo; });\n tr.setSelection(Selection.near(tr.doc.resolve(end), bias));\n}\n\nconst UPDATED_SEL = 1, UPDATED_MARKS = 2, UPDATED_SCROLL = 4;\n/**\nAn editor state transaction, which can be applied to a state to\ncreate an updated state. Use\n[`EditorState.tr`](https://prosemirror.net/docs/ref/#state.EditorState.tr) to create an instance.\n\nTransactions track changes to the document (they are a subclass of\n[`Transform`](https://prosemirror.net/docs/ref/#transform.Transform)), but also other state changes,\nlike selection updates and adjustments of the set of [stored\nmarks](https://prosemirror.net/docs/ref/#state.EditorState.storedMarks). In addition, you can store\nmetadata properties in a transaction, which are extra pieces of\ninformation that client code or plugins can use to describe what a\ntransaction represents, so that they can update their [own\nstate](https://prosemirror.net/docs/ref/#state.StateField) accordingly.\n\nThe [editor view](https://prosemirror.net/docs/ref/#view.EditorView) uses a few metadata properties:\nit will attach a property `\"pointer\"` with the value `true` to\nselection transactions directly caused by mouse or touch input, and\na `\"uiEvent\"` property of that may be `\"paste\"`, `\"cut\"`, or `\"drop\"`.\n*/\nclass Transaction extends Transform {\n /**\n @internal\n */\n constructor(state) {\n super(state.doc);\n // The step count for which the current selection is valid.\n this.curSelectionFor = 0;\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 this.time = Date.now();\n this.curSelection = state.selection;\n this.storedMarks = state.storedMarks;\n }\n /**\n The transaction's current selection. This defaults to the editor\n selection [mapped](https://prosemirror.net/docs/ref/#state.Selection.map) through the steps in the\n transaction, but can be overwritten with\n [`setSelection`](https://prosemirror.net/docs/ref/#state.Transaction.setSelection).\n */\n get selection() {\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 Update the transaction's current selection. Will determine the\n selection that the editor gets when the transaction is applied.\n */\n 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 Whether the selection was explicitly updated by this transaction.\n */\n get selectionSet() {\n return (this.updated & UPDATED_SEL) > 0;\n }\n /**\n Set the current stored marks.\n */\n setStoredMarks(marks) {\n this.storedMarks = marks;\n this.updated |= UPDATED_MARKS;\n return this;\n }\n /**\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 */\n ensureMarks(marks) {\n if (!Mark.sameSet(this.storedMarks || this.selection.$from.marks(), marks))\n this.setStoredMarks(marks);\n return this;\n }\n /**\n Add a mark to the set of stored marks.\n */\n addStoredMark(mark) {\n return this.ensureMarks(mark.addToSet(this.storedMarks || this.selection.$head.marks()));\n }\n /**\n Remove a mark or mark type from the set of stored marks.\n */\n removeStoredMark(mark) {\n return this.ensureMarks(mark.removeFromSet(this.storedMarks || this.selection.$head.marks()));\n }\n /**\n Whether the stored marks were explicitly set for this transaction.\n */\n get storedMarksSet() {\n return (this.updated & UPDATED_MARKS) > 0;\n }\n /**\n @internal\n */\n addStep(step, doc) {\n super.addStep(step, doc);\n this.updated = this.updated & ~UPDATED_MARKS;\n this.storedMarks = null;\n }\n /**\n Update the timestamp for the transaction.\n */\n setTime(time) {\n this.time = time;\n return this;\n }\n /**\n Replace the current selection with the given slice.\n */\n replaceSelection(slice) {\n this.selection.replace(this, slice);\n return this;\n }\n /**\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 */\n replaceSelectionWith(node, inheritMarks = true) {\n let selection = this.selection;\n if (inheritMarks)\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 Delete the selection.\n */\n deleteSelection() {\n this.selection.replace(this);\n return this;\n }\n /**\n Replace the given range, or the selection if no range is given,\n with a text node containing the given string.\n */\n insertText(text, from, to) {\n let schema = this.doc.type.schema;\n if (from == null) {\n if (!text)\n return this.deleteSelection();\n return this.replaceSelectionWith(schema.text(text), true);\n }\n else {\n if (to == null)\n to = from;\n to = to == null ? from : to;\n if (!text)\n return this.deleteRange(from, to);\n let marks = this.storedMarks;\n if (!marks) {\n let $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)\n this.setSelection(Selection.near(this.selection.$to));\n return this;\n }\n }\n /**\n Store a metadata property in this transaction, keyed either by\n name or by plugin.\n */\n setMeta(key, value) {\n this.meta[typeof key == \"string\" ? key : key.key] = value;\n return this;\n }\n /**\n Retrieve a metadata property for a given name or plugin.\n */\n getMeta(key) {\n return this.meta[typeof key == \"string\" ? key : key.key];\n }\n /**\n Returns true if this transaction doesn't contain any metadata,\n and can thus safely be extended.\n */\n get isGeneric() {\n for (let _ in this.meta)\n return false;\n return true;\n }\n /**\n Indicate that the editor should scroll the selection into view\n when updated to the state produced by this transaction.\n */\n scrollIntoView() {\n this.updated |= UPDATED_SCROLL;\n return this;\n }\n /**\n True when this transaction has had `scrollIntoView` called on it.\n */\n get scrolledIntoView() {\n return (this.updated & UPDATED_SCROLL) > 0;\n }\n}\n\nfunction bind(f, self) {\n return !self || !f ? f : f.bind(self);\n}\nclass FieldDesc {\n constructor(name, desc, self) {\n this.name = name;\n this.init = bind(desc.init, self);\n this.apply = bind(desc.apply, self);\n }\n}\nconst baseFields = [\n new FieldDesc(\"doc\", {\n init(config) { return config.doc || config.schema.topNodeType.createAndFill(); },\n apply(tr) { return tr.doc; }\n }),\n new FieldDesc(\"selection\", {\n init(config, instance) { return config.selection || Selection.atStart(instance.doc); },\n apply(tr) { return tr.selection; }\n }),\n new FieldDesc(\"storedMarks\", {\n init(config) { return config.storedMarks || null; },\n apply(tr, _marks, _old, state) { return state.selection.$cursor ? tr.storedMarks : null; }\n }),\n new FieldDesc(\"scrollToSelection\", {\n init() { return 0; },\n apply(tr, prev) { return tr.scrolledIntoView ? prev + 1 : prev; }\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.\nclass Configuration {\n constructor(schema, plugins) {\n this.schema = schema;\n this.plugins = [];\n this.pluginsByKey = Object.create(null);\n this.fields = baseFields.slice();\n if (plugins)\n plugins.forEach(plugin => {\n if (this.pluginsByKey[plugin.key])\n throw new RangeError(\"Adding different instances of a keyed plugin (\" + plugin.key + \")\");\n this.plugins.push(plugin);\n this.pluginsByKey[plugin.key] = plugin;\n if (plugin.spec.state)\n this.fields.push(new FieldDesc(plugin.key, plugin.spec.state, plugin));\n });\n }\n}\n/**\nThe state of a ProseMirror editor is represented by an object of\nthis type. A state is a persistent data structure—it isn't\nupdated, but rather a new state value is computed from an old one\nusing the [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) method.\n\nA state holds a number of built-in fields, and plugins can\n[define](https://prosemirror.net/docs/ref/#state.PluginSpec.state) additional fields.\n*/\nclass EditorState {\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n config) {\n this.config = config;\n }\n /**\n The schema of the state's document.\n */\n get schema() {\n return this.config.schema;\n }\n /**\n The plugins that are active in this state.\n */\n get plugins() {\n return this.config.plugins;\n }\n /**\n Apply the given transaction to produce a new state.\n */\n apply(tr) {\n return this.applyTransaction(tr).state;\n }\n /**\n @internal\n */\n filterTransaction(tr, ignore = -1) {\n for (let i = 0; i < this.config.plugins.length; i++)\n if (i != ignore) {\n let 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 Verbose variant of [`apply`](https://prosemirror.net/docs/ref/#state.EditorState.apply) that\n returns the precise transactions that were applied (which might\n be influenced by the [transaction\n hooks](https://prosemirror.net/docs/ref/#state.PluginSpec.filterTransaction) of\n plugins) along with the new state.\n */\n applyTransaction(rootTr) {\n if (!this.filterTransaction(rootTr))\n return { state: this, transactions: [] };\n let 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 let haveNew = false;\n for (let i = 0; i < this.config.plugins.length; i++) {\n let plugin = this.config.plugins[i];\n if (plugin.spec.appendTransaction) {\n let n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this;\n let 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 (let 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)\n seen[i] = { state: newState, n: trs.length };\n }\n }\n if (!haveNew)\n return { state: newState, transactions: trs };\n }\n }\n /**\n @internal\n */\n applyInner(tr) {\n if (!tr.before.eq(this.doc))\n throw new RangeError(\"Applying a mismatched transaction\");\n let newInstance = new EditorState(this.config), fields = this.config.fields;\n for (let i = 0; i < fields.length; i++) {\n let field = fields[i];\n newInstance[field.name] = field.apply(tr, this[field.name], this, newInstance);\n }\n return newInstance;\n }\n /**\n Start a [transaction](https://prosemirror.net/docs/ref/#state.Transaction) from this state.\n */\n get tr() { return new Transaction(this); }\n /**\n Create a new state.\n */\n static create(config) {\n let $config = new Configuration(config.doc ? config.doc.type.schema : config.schema, config.plugins);\n let instance = new EditorState($config);\n for (let 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 Create a new state based on this one, but with an adjusted set\n of active plugins. State fields that exist in both sets of\n plugins are kept unchanged. Those that no longer exist are\n dropped, and those that are new are initialized using their\n [`init`](https://prosemirror.net/docs/ref/#state.StateField.init) method, passing in the new\n configuration object..\n */\n reconfigure(config) {\n let $config = new Configuration(this.schema, config.plugins);\n let fields = $config.fields, instance = new EditorState($config);\n for (let i = 0; i < fields.length; i++) {\n let name = fields[i].name;\n instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config, instance);\n }\n return instance;\n }\n /**\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.\n */\n toJSON(pluginFields) {\n let result = { doc: this.doc.toJSON(), selection: this.selection.toJSON() };\n if (this.storedMarks)\n result.storedMarks = this.storedMarks.map(m => m.toJSON());\n if (pluginFields && typeof pluginFields == 'object')\n for (let prop in pluginFields) {\n if (prop == \"doc\" || prop == \"selection\")\n throw new RangeError(\"The JSON fields `doc` and `selection` are reserved\");\n let plugin = pluginFields[prop], state = plugin.spec.state;\n if (state && state.toJSON)\n result[prop] = state.toJSON.call(plugin, this[plugin.key]);\n }\n return result;\n }\n /**\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 static fromJSON(config, json, pluginFields) {\n if (!json)\n throw new RangeError(\"Invalid input for EditorState.fromJSON\");\n if (!config.schema)\n throw new RangeError(\"Required config field 'schema' missing\");\n let $config = new Configuration(config.schema, config.plugins);\n let instance = new EditorState($config);\n $config.fields.forEach(field => {\n if (field.name == \"doc\") {\n instance.doc = Node.fromJSON(config.schema, json.doc);\n }\n else if (field.name == \"selection\") {\n instance.selection = Selection.fromJSON(instance.doc, json.selection);\n }\n else if (field.name == \"storedMarks\") {\n if (json.storedMarks)\n instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON);\n }\n else {\n if (pluginFields)\n for (let prop in pluginFields) {\n let plugin = pluginFields[prop], state = plugin.spec.state;\n if (plugin.key == field.name && state && state.fromJSON &&\n Object.prototype.hasOwnProperty.call(json, prop)) {\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\nfunction bindProps(obj, self, target) {\n for (let prop in obj) {\n let val = obj[prop];\n if (val instanceof Function)\n val = val.bind(self);\n else if (prop == \"handleDOMEvents\")\n val = bindProps(val, self, {});\n target[prop] = val;\n }\n return target;\n}\n/**\nPlugins bundle functionality that can be added to an editor.\nThey are part of the [editor state](https://prosemirror.net/docs/ref/#state.EditorState) and\nmay influence that state and the view that contains it.\n*/\nclass Plugin {\n /**\n Create a plugin.\n */\n constructor(\n /**\n The plugin's [spec object](https://prosemirror.net/docs/ref/#state.PluginSpec).\n */\n spec) {\n this.spec = spec;\n /**\n The [props](https://prosemirror.net/docs/ref/#view.EditorProps) exported by this plugin.\n */\n this.props = {};\n if (spec.props)\n bindProps(spec.props, this, this.props);\n this.key = spec.key ? spec.key.key : createKey(\"plugin\");\n }\n /**\n Extract the plugin's state field from an editor state.\n */\n getState(state) { return state[this.key]; }\n}\nconst keys = Object.create(null);\nfunction createKey(name) {\n if (name in keys)\n return name + \"$\" + ++keys[name];\n keys[name] = 0;\n return name + \"$\";\n}\n/**\nA key is used to [tag](https://prosemirror.net/docs/ref/#state.PluginSpec.key) plugins in a way\nthat makes it possible to find them, given an editor state.\nAssigning a key does mean only one plugin of that type can be\nactive in a state.\n*/\nclass PluginKey {\n /**\n Create a plugin key.\n */\n constructor(name = \"key\") { this.key = createKey(name); }\n /**\n Get the active plugin with this key, if any, from an editor\n state.\n */\n get(state) { return state.config.pluginsByKey[this.key]; }\n /**\n Get the plugin's state from an editor state.\n */\n getState(state) { return state[this.key]; }\n}\n\nexport { AllSelection, EditorState, NodeSelection, Plugin, PluginKey, Selection, SelectionRange, TextSelection, Transaction };\n","// src/index.ts\nimport { Plugin as Plugin2 } from \"prosemirror-state\";\n\n// src/cellselection.ts\nimport { Fragment, Slice } from \"prosemirror-model\";\nimport {\n NodeSelection as NodeSelection2,\n Selection,\n SelectionRange,\n TextSelection\n} from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\n\n// src/tablemap.ts\nvar readFromCache;\nvar addToCache;\nif (typeof WeakMap != \"undefined\") {\n let cache = /* @__PURE__ */ new WeakMap();\n readFromCache = (key) => cache.get(key);\n addToCache = (key, value) => {\n cache.set(key, value);\n return value;\n };\n} else {\n const cache = [];\n const cacheSize = 10;\n let cachePos = 0;\n readFromCache = (key) => {\n for (let i = 0; i < cache.length; i += 2)\n if (cache[i] == key)\n return cache[i + 1];\n };\n addToCache = (key, value) => {\n if (cachePos == cacheSize)\n cachePos = 0;\n cache[cachePos++] = key;\n return cache[cachePos++] = value;\n };\n}\nvar TableMap = class {\n constructor(width, height, map, problems) {\n this.width = width;\n this.height = height;\n this.map = map;\n this.problems = problems;\n }\n findCell(pos) {\n for (let i = 0; i < this.map.length; i++) {\n const curPos = this.map[i];\n if (curPos != pos)\n continue;\n const left = i % this.width;\n const top = i / this.width | 0;\n let right = left + 1;\n let bottom = top + 1;\n for (let j = 1; right < this.width && this.map[i + j] == curPos; j++) {\n right++;\n }\n for (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++) {\n bottom++;\n }\n return { left, top, right, bottom };\n }\n throw new RangeError(`No cell with offset ${pos} found`);\n }\n colCount(pos) {\n for (let i = 0; i < this.map.length; i++) {\n if (this.map[i] == pos) {\n return i % this.width;\n }\n }\n throw new RangeError(`No cell with offset ${pos} found`);\n }\n nextCell(pos, axis, dir) {\n const { left, right, top, bottom } = this.findCell(pos);\n if (axis == \"horiz\") {\n if (dir < 0 ? left == 0 : right == this.width)\n return null;\n return this.map[top * this.width + (dir < 0 ? left - 1 : right)];\n } else {\n if (dir < 0 ? top == 0 : bottom == this.height)\n return null;\n return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];\n }\n }\n rectBetween(a, b) {\n const {\n left: leftA,\n right: rightA,\n top: topA,\n bottom: bottomA\n } = this.findCell(a);\n const {\n left: leftB,\n right: rightB,\n top: topB,\n bottom: bottomB\n } = this.findCell(b);\n return {\n left: Math.min(leftA, leftB),\n top: Math.min(topA, topB),\n right: Math.max(rightA, rightB),\n bottom: Math.max(bottomA, bottomB)\n };\n }\n cellsInRect(rect) {\n const result = [];\n const seen = {};\n for (let row = rect.top; row < rect.bottom; row++) {\n for (let col = rect.left; col < rect.right; col++) {\n const index = row * this.width + col;\n const pos = this.map[index];\n if (seen[pos])\n continue;\n seen[pos] = true;\n if (col == rect.left && col && this.map[index - 1] == pos || row == rect.top && row && this.map[index - this.width] == pos) {\n continue;\n }\n result.push(pos);\n }\n }\n return result;\n }\n positionAt(row, col, table) {\n for (let i = 0, rowStart = 0; ; i++) {\n const rowEnd = rowStart + table.child(i).nodeSize;\n if (i == row) {\n let index = col + row * this.width;\n const rowEndIndex = (row + 1) * this.width;\n while (index < rowEndIndex && this.map[index] < rowStart)\n index++;\n return index == rowEndIndex ? rowEnd - 1 : this.map[index];\n }\n rowStart = rowEnd;\n }\n }\n static get(table) {\n return readFromCache(table) || addToCache(table, computeMap(table));\n }\n};\nfunction computeMap(table) {\n if (table.type.spec.tableRole != \"table\")\n throw new RangeError(\"Not a table node: \" + table.type.name);\n const width = findWidth(table), height = table.childCount;\n const map = [];\n let mapPos = 0;\n let problems = null;\n const colWidths = [];\n for (let i = 0, e = width * height; i < e; i++)\n map[i] = 0;\n for (let row = 0, pos = 0; row < height; row++) {\n const rowNode = table.child(row);\n pos++;\n for (let i = 0; ; i++) {\n while (mapPos < map.length && map[mapPos] != 0)\n mapPos++;\n if (i == rowNode.childCount)\n break;\n const cellNode = rowNode.child(i);\n const { colspan, rowspan, colwidth } = cellNode.attrs;\n for (let h = 0; h < rowspan; h++) {\n if (h + row >= height) {\n (problems || (problems = [])).push({\n type: \"overlong_rowspan\",\n pos,\n n: rowspan - h\n });\n break;\n }\n const start = mapPos + h * width;\n for (let w = 0; w < colspan; w++) {\n if (map[start + w] == 0)\n map[start + w] = pos;\n else\n (problems || (problems = [])).push({\n type: \"collision\",\n row,\n pos,\n n: colspan - w\n });\n const colW = colwidth && colwidth[w];\n if (colW) {\n const widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];\n if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {\n colWidths[widthIndex] = colW;\n colWidths[widthIndex + 1] = 1;\n } else if (prev == colW) {\n colWidths[widthIndex + 1]++;\n }\n }\n }\n }\n mapPos += colspan;\n pos += cellNode.nodeSize;\n }\n const expectedPos = (row + 1) * width;\n let missing = 0;\n while (mapPos < expectedPos)\n if (map[mapPos++] == 0)\n missing++;\n if (missing)\n (problems || (problems = [])).push({ type: \"missing\", row, n: missing });\n pos++;\n }\n const tableMap = new TableMap(width, height, map, problems);\n let badWidths = false;\n for (let i = 0; !badWidths && i < colWidths.length; i += 2)\n if (colWidths[i] != null && colWidths[i + 1] < height)\n badWidths = true;\n if (badWidths)\n findBadColWidths(tableMap, colWidths, table);\n return tableMap;\n}\nfunction findWidth(table) {\n let width = -1;\n let hasRowSpan = false;\n for (let row = 0; row < table.childCount; row++) {\n const rowNode = table.child(row);\n let rowWidth = 0;\n if (hasRowSpan)\n for (let j = 0; j < row; j++) {\n const prevRow = table.child(j);\n for (let i = 0; i < prevRow.childCount; i++) {\n const cell = prevRow.child(i);\n if (j + cell.attrs.rowspan > row)\n rowWidth += cell.attrs.colspan;\n }\n }\n for (let i = 0; i < rowNode.childCount; i++) {\n const cell = rowNode.child(i);\n rowWidth += cell.attrs.colspan;\n if (cell.attrs.rowspan > 1)\n hasRowSpan = true;\n }\n if (width == -1)\n width = rowWidth;\n else if (width != rowWidth)\n width = Math.max(width, rowWidth);\n }\n return width;\n}\nfunction findBadColWidths(map, colWidths, table) {\n if (!map.problems)\n map.problems = [];\n const seen = {};\n for (let i = 0; i < map.map.length; i++) {\n const pos = map.map[i];\n if (seen[pos])\n continue;\n seen[pos] = true;\n const node = table.nodeAt(pos);\n if (!node) {\n throw new RangeError(`No cell with offset ${pos} found`);\n }\n let updated = null;\n const attrs = node.attrs;\n for (let j = 0; j < attrs.colspan; j++) {\n const col = (i + j) % map.width;\n const colWidth = colWidths[col * 2];\n if (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth))\n (updated || (updated = freshColWidth(attrs)))[j] = colWidth;\n }\n if (updated)\n map.problems.unshift({\n type: \"colwidth mismatch\",\n pos,\n colwidth: updated\n });\n }\n}\nfunction freshColWidth(attrs) {\n if (attrs.colwidth)\n return attrs.colwidth.slice();\n const result = [];\n for (let i = 0; i < attrs.colspan; i++)\n result.push(0);\n return result;\n}\n\n// src/util.ts\nimport { PluginKey } from \"prosemirror-state\";\n\n// src/schema.ts\nfunction getCellAttrs(dom, extraAttrs) {\n if (typeof dom === \"string\") {\n return {};\n }\n const widthAttr = dom.getAttribute(\"data-colwidth\");\n const widths = widthAttr && /^\\d+(,\\d+)*$/.test(widthAttr) ? widthAttr.split(\",\").map((s) => Number(s)) : null;\n const colspan = Number(dom.getAttribute(\"colspan\") || 1);\n const result = {\n colspan,\n rowspan: Number(dom.getAttribute(\"rowspan\") || 1),\n colwidth: widths && widths.length == colspan ? widths : null\n };\n for (const prop in extraAttrs) {\n const getter = extraAttrs[prop].getFromDOM;\n const value = getter && getter(dom);\n if (value != null) {\n result[prop] = value;\n }\n }\n return result;\n}\nfunction setCellAttrs(node, extraAttrs) {\n const attrs = {};\n if (node.attrs.colspan != 1)\n attrs.colspan = node.attrs.colspan;\n if (node.attrs.rowspan != 1)\n attrs.rowspan = node.attrs.rowspan;\n if (node.attrs.colwidth)\n attrs[\"data-colwidth\"] = node.attrs.colwidth.join(\",\");\n for (const prop in extraAttrs) {\n const setter = extraAttrs[prop].setDOMAttr;\n if (setter)\n setter(node.attrs[prop], attrs);\n }\n return attrs;\n}\nfunction tableNodes(options) {\n const extraAttrs = options.cellAttributes || {};\n const cellAttrs = {\n colspan: { default: 1 },\n rowspan: { default: 1 },\n colwidth: { default: null }\n };\n for (const prop in extraAttrs)\n cellAttrs[prop] = { default: extraAttrs[prop].default };\n return {\n table: {\n content: \"table_row+\",\n tableRole: \"table\",\n isolating: true,\n group: options.tableGroup,\n parseDOM: [{ tag: \"table\" }],\n toDOM() {\n return [\"table\", [\"tbody\", 0]];\n }\n },\n table_row: {\n content: \"(table_cell | table_header)*\",\n tableRole: \"row\",\n parseDOM: [{ tag: \"tr\" }],\n toDOM() {\n return [\"tr\", 0];\n }\n },\n table_cell: {\n content: options.cellContent,\n attrs: cellAttrs,\n tableRole: \"cell\",\n isolating: true,\n parseDOM: [\n { tag: \"td\", getAttrs: (dom) => getCellAttrs(dom, extraAttrs) }\n ],\n toDOM(node) {\n return [\"td\", setCellAttrs(node, extraAttrs), 0];\n }\n },\n table_header: {\n content: options.cellContent,\n attrs: cellAttrs,\n tableRole: \"header_cell\",\n isolating: true,\n parseDOM: [\n { tag: \"th\", getAttrs: (dom) => getCellAttrs(dom, extraAttrs) }\n ],\n toDOM(node) {\n return [\"th\", setCellAttrs(node, extraAttrs), 0];\n }\n }\n };\n}\nfunction tableNodeTypes(schema) {\n let result = schema.cached.tableNodeTypes;\n if (!result) {\n result = schema.cached.tableNodeTypes = {};\n for (const name in schema.nodes) {\n const type = schema.nodes[name], role = type.spec.tableRole;\n if (role)\n result[role] = type;\n }\n }\n return result;\n}\n\n// src/util.ts\nvar tableEditingKey = new PluginKey(\"selectingCells\");\nfunction cellAround($pos) {\n for (let d = $pos.depth - 1; d > 0; d--)\n if ($pos.node(d).type.spec.tableRole == \"row\")\n return $pos.node(0).resolve($pos.before(d + 1));\n return null;\n}\nfunction cellWrapping($pos) {\n for (let d = $pos.depth; d > 0; d--) {\n const role = $pos.node(d).type.spec.tableRole;\n if (role === \"cell\" || role === \"header_cell\")\n return $pos.node(d);\n }\n return null;\n}\nfunction isInTable(state) {\n const $head = state.selection.$head;\n for (let d = $head.depth; d > 0; d--)\n if ($head.node(d).type.spec.tableRole == \"row\")\n return true;\n return false;\n}\nfunction selectionCell(state) {\n const sel = state.selection;\n if (\"$anchorCell\" in sel && sel.$anchorCell) {\n return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;\n } else if (\"node\" in sel && sel.node && sel.node.type.spec.tableRole == \"cell\") {\n return sel.$anchor;\n }\n const $cell = cellAround(sel.$head) || cellNear(sel.$head);\n if ($cell) {\n return $cell;\n }\n throw new RangeError(`No cell found around position ${sel.head}`);\n}\nfunction cellNear($pos) {\n for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {\n const role = after.type.spec.tableRole;\n if (role == \"cell\" || role == \"header_cell\")\n return $pos.doc.resolve(pos);\n }\n for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {\n const role = before.type.spec.tableRole;\n if (role == \"cell\" || role == \"header_cell\")\n return $pos.doc.resolve(pos - before.nodeSize);\n }\n}\nfunction pointsAtCell($pos) {\n return $pos.parent.type.spec.tableRole == \"row\" && !!$pos.nodeAfter;\n}\nfunction moveCellForward($pos) {\n return $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);\n}\nfunction inSameTable($cellA, $cellB) {\n return $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);\n}\nfunction findCell($pos) {\n return TableMap.get($pos.node(-1)).findCell($pos.pos - $pos.start(-1));\n}\nfunction colCount($pos) {\n return TableMap.get($pos.node(-1)).colCount($pos.pos - $pos.start(-1));\n}\nfunction nextCell($pos, axis, dir) {\n const table = $pos.node(-1);\n const map = TableMap.get(table);\n const tableStart = $pos.start(-1);\n const moved = map.nextCell($pos.pos - tableStart, axis, dir);\n return moved == null ? null : $pos.node(0).resolve(tableStart + moved);\n}\nfunction removeColSpan(attrs, pos, n = 1) {\n const result = { ...attrs, colspan: attrs.colspan - n };\n if (result.colwidth) {\n result.colwidth = result.colwidth.slice();\n result.colwidth.splice(pos, n);\n if (!result.colwidth.some((w) => w > 0))\n result.colwidth = null;\n }\n return result;\n}\nfunction addColSpan(attrs, pos, n = 1) {\n const result = { ...attrs, colspan: attrs.colspan + n };\n if (result.colwidth) {\n result.colwidth = result.colwidth.slice();\n for (let i = 0; i < n; i++)\n result.colwidth.splice(pos, 0, 0);\n }\n return result;\n}\nfunction columnIsHeader(map, table, col) {\n const headerCell = tableNodeTypes(table.type.schema).header_cell;\n for (let row = 0; row < map.height; row++)\n if (table.nodeAt(map.map[col + row * map.width]).type != headerCell)\n return false;\n return true;\n}\n\n// src/cellselection.ts\nvar CellSelection = class extends Selection {\n constructor($anchorCell, $headCell = $anchorCell) {\n const table = $anchorCell.node(-1);\n const map = TableMap.get(table);\n const tableStart = $anchorCell.start(-1);\n const rect = map.rectBetween(\n $anchorCell.pos - tableStart,\n $headCell.pos - tableStart\n );\n const doc = $anchorCell.node(0);\n const cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);\n cells.unshift($headCell.pos - tableStart);\n const ranges = cells.map((pos) => {\n const cell = table.nodeAt(pos);\n if (!cell) {\n throw RangeError(`No cell with offset ${pos} found`);\n }\n const from = tableStart + pos + 1;\n return new SelectionRange(\n doc.resolve(from),\n doc.resolve(from + cell.content.size)\n );\n });\n super(ranges[0].$from, ranges[0].$to, ranges);\n this.$anchorCell = $anchorCell;\n this.$headCell = $headCell;\n }\n map(doc, mapping) {\n const $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));\n const $headCell = doc.resolve(mapping.map(this.$headCell.pos));\n if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {\n const tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);\n if (tableChanged && this.isRowSelection())\n return CellSelection.rowSelection($anchorCell, $headCell);\n else if (tableChanged && this.isColSelection())\n return CellSelection.colSelection($anchorCell, $headCell);\n else\n return new CellSelection($anchorCell, $headCell);\n }\n return TextSelection.between($anchorCell, $headCell);\n }\n content() {\n const table = this.$anchorCell.node(-1);\n const map = TableMap.get(table);\n const tableStart = this.$anchorCell.start(-1);\n const rect = map.rectBetween(\n this.$anchorCell.pos - tableStart,\n this.$headCell.pos - tableStart\n );\n const seen = {};\n const rows = [];\n for (let row = rect.top; row < rect.bottom; row++) {\n const rowContent = [];\n for (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {\n const pos = map.map[index];\n if (seen[pos])\n continue;\n seen[pos] = true;\n const cellRect = map.findCell(pos);\n let cell = table.nodeAt(pos);\n if (!cell) {\n throw RangeError(`No cell with offset ${pos} found`);\n }\n const extraLeft = rect.left - cellRect.left;\n const extraRight = cellRect.right - rect.right;\n if (extraLeft > 0 || extraRight > 0) {\n let attrs = cell.attrs;\n if (extraLeft > 0) {\n attrs = removeColSpan(attrs, 0, extraLeft);\n }\n if (extraRight > 0) {\n attrs = removeColSpan(\n attrs,\n attrs.colspan - extraRight,\n extraRight\n );\n }\n if (cellRect.left < rect.left) {\n cell = cell.type.createAndFill(attrs);\n if (!cell) {\n throw RangeError(\n `Could not create cell with attrs ${JSON.stringify(attrs)}`\n );\n }\n } else {\n cell = cell.type.create(attrs, cell.content);\n }\n }\n if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {\n const attrs = {\n ...cell.attrs,\n rowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)\n };\n if (cellRect.top < rect.top) {\n cell = cell.type.createAndFill(attrs);\n } else {\n cell = cell.type.create(attrs, cell.content);\n }\n }\n rowContent.push(cell);\n }\n rows.push(table.child(row).copy(Fragment.from(rowContent)));\n }\n const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;\n return new Slice(Fragment.from(fragment), 1, 1);\n }\n replace(tr, content = Slice.empty) {\n const mapFrom = tr.steps.length, ranges = this.ranges;\n for (let i = 0; i < ranges.length; i++) {\n const { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);\n tr.replace(\n mapping.map($from.pos),\n mapping.map($to.pos),\n i ? Slice.empty : content\n );\n }\n const sel = Selection.findFrom(\n tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)),\n -1\n );\n if (sel)\n tr.setSelection(sel);\n }\n replaceWith(tr, node) {\n this.replace(tr, new Slice(Fragment.from(node), 0, 0));\n }\n forEachCell(f) {\n const table = this.$anchorCell.node(-1);\n const map = TableMap.get(table);\n const tableStart = this.$anchorCell.start(-1);\n const cells = map.cellsInRect(\n map.rectBetween(\n this.$anchorCell.pos - tableStart,\n this.$headCell.pos - tableStart\n )\n );\n for (let i = 0; i < cells.length; i++) {\n f(table.nodeAt(cells[i]), tableStart + cells[i]);\n }\n }\n isColSelection() {\n const anchorTop = this.$anchorCell.index(-1);\n const headTop = this.$headCell.index(-1);\n if (Math.min(anchorTop, headTop) > 0)\n return false;\n const anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;\n const headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;\n return Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;\n }\n static colSelection($anchorCell, $headCell = $anchorCell) {\n const table = $anchorCell.node(-1);\n const map = TableMap.get(table);\n const tableStart = $anchorCell.start(-1);\n const anchorRect = map.findCell($anchorCell.pos - tableStart);\n const headRect = map.findCell($headCell.pos - tableStart);\n const doc = $anchorCell.node(0);\n if (anchorRect.top <= headRect.top) {\n if (anchorRect.top > 0)\n $anchorCell = doc.resolve(tableStart + map.map[anchorRect.left]);\n if (headRect.bottom < map.height)\n $headCell = doc.resolve(\n tableStart + map.map[map.width * (map.height - 1) + headRect.right - 1]\n );\n } else {\n if (headRect.top > 0)\n $headCell = doc.resolve(tableStart + map.map[headRect.left]);\n if (anchorRect.bottom < map.height)\n $anchorCell = doc.resolve(\n tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]\n );\n }\n return new CellSelection($anchorCell, $headCell);\n }\n isRowSelection() {\n const table = this.$anchorCell.node(-1);\n const map = TableMap.get(table);\n const tableStart = this.$anchorCell.start(-1);\n const anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);\n const headLeft = map.colCount(this.$headCell.pos - tableStart);\n if (Math.min(anchorLeft, headLeft) > 0)\n return false;\n const anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;\n const headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;\n return Math.max(anchorRight, headRight) == map.width;\n }\n eq(other) {\n return other instanceof CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;\n }\n static rowSelection($anchorCell, $headCell = $anchorCell) {\n const table = $anchorCell.node(-1);\n const map = TableMap.get(table);\n const tableStart = $anchorCell.start(-1);\n const anchorRect = map.findCell($anchorCell.pos - tableStart);\n const headRect = map.findCell($headCell.pos - tableStart);\n const doc = $anchorCell.node(0);\n if (anchorRect.left <= headRect.left) {\n if (anchorRect.left > 0)\n $anchorCell = doc.resolve(\n tableStart + map.map[anchorRect.top * map.width]\n );\n if (headRect.right < map.width)\n $headCell = doc.resolve(\n tableStart + map.map[map.width * (headRect.top + 1) - 1]\n );\n } else {\n if (headRect.left > 0)\n $headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);\n if (anchorRect.right < map.width)\n $anchorCell = doc.resolve(\n tableStart + map.map[map.width * (anchorRect.top + 1) - 1]\n );\n }\n return new CellSelection($anchorCell, $headCell);\n }\n toJSON() {\n return {\n type: \"cell\",\n anchor: this.$anchorCell.pos,\n head: this.$headCell.pos\n };\n }\n static fromJSON(doc, json) {\n return new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));\n }\n static create(doc, anchorCell, headCell = anchorCell) {\n return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));\n }\n getBookmark() {\n return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);\n }\n};\nCellSelection.prototype.visible = false;\nSelection.jsonID(\"cell\", CellSelection);\nvar CellBookmark = class {\n constructor(anchor, head) {\n this.anchor = anchor;\n this.head = head;\n }\n map(mapping) {\n return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));\n }\n resolve(doc) {\n const $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);\n if ($anchorCell.parent.type.spec.tableRole == \"row\" && $headCell.parent.type.spec.tableRole == \"row\" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell))\n return new CellSelection($anchorCell, $headCell);\n else\n return Selection.near($headCell, 1);\n }\n};\nfunction drawCellSelection(state) {\n if (!(state.selection instanceof CellSelection))\n return null;\n const cells = [];\n state.selection.forEachCell((node, pos) => {\n cells.push(\n Decoration.node(pos, pos + node.nodeSize, { class: \"selectedCell\" })\n );\n });\n return DecorationSet.create(state.doc, cells);\n}\nfunction isCellBoundarySelection({ $from, $to }) {\n if ($from.pos == $to.pos || $from.pos < $from.pos - 6)\n return false;\n let afterFrom = $from.pos;\n let beforeTo = $to.pos;\n let depth = $from.depth;\n for (; depth >= 0; depth--, afterFrom++)\n if ($from.after(depth + 1) < $from.end(depth))\n break;\n for (let d = $to.depth; d >= 0; d--, beforeTo--)\n if ($to.before(d + 1) > $to.start(d))\n break;\n return afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);\n}\nfunction isTextSelectionAcrossCells({ $from, $to }) {\n let fromCellBoundaryNode;\n let toCellBoundaryNode;\n for (let i = $from.depth; i > 0; i--) {\n const node = $from.node(i);\n if (node.type.spec.tableRole === \"cell\" || node.type.spec.tableRole === \"header_cell\") {\n fromCellBoundaryNode = node;\n break;\n }\n }\n for (let i = $to.depth; i > 0; i--) {\n const node = $to.node(i);\n if (node.type.spec.tableRole === \"cell\" || node.type.spec.tableRole === \"header_cell\") {\n toCellBoundaryNode = node;\n break;\n }\n }\n return fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;\n}\nfunction normalizeSelection(state, tr, allowTableNodeSelection) {\n const sel = (tr || state).selection;\n const doc = (tr || state).doc;\n let normalize;\n let role;\n if (sel instanceof NodeSelection2 && (role = sel.node.type.spec.tableRole)) {\n if (role == \"cell\" || role == \"header_cell\") {\n normalize = CellSelection.create(doc, sel.from);\n } else if (role == \"row\") {\n const $cell = doc.resolve(sel.from + 1);\n normalize = CellSelection.rowSelection($cell, $cell);\n } else if (!allowTableNodeSelection) {\n const map = TableMap.get(sel.node);\n const start = sel.from + 1;\n const lastCell = start + map.map[map.width * map.height - 1];\n normalize = CellSelection.create(doc, start + 1, lastCell);\n }\n } else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) {\n normalize = TextSelection.create(doc, sel.from);\n } else if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) {\n normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());\n }\n if (normalize)\n (tr || (tr = state.tr)).setSelection(normalize);\n return tr;\n}\n\n// src/fixtables.ts\nimport { PluginKey as PluginKey2 } from \"prosemirror-state\";\nvar fixTablesKey = new PluginKey2(\"fix-tables\");\nfunction changedDescendants(old, cur, offset, f) {\n const oldSize = old.childCount, curSize = cur.childCount;\n outer:\n for (let i = 0, j = 0; i < curSize; i++) {\n const child = cur.child(i);\n for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) {\n if (old.child(scan) == child) {\n j = scan + 1;\n offset += child.nodeSize;\n continue outer;\n }\n }\n f(child, offset);\n if (j < oldSize && old.child(j).sameMarkup(child))\n changedDescendants(old.child(j), child, offset + 1, f);\n else\n child.nodesBetween(0, child.content.size, f, offset + 1);\n offset += child.nodeSize;\n }\n}\nfunction fixTables(state, oldState) {\n let tr;\n const check = (node, pos) => {\n if (node.type.spec.tableRole == \"table\")\n tr = fixTable(state, node, pos, tr);\n };\n if (!oldState)\n state.doc.descendants(check);\n else if (oldState.doc != state.doc)\n changedDescendants(oldState.doc, state.doc, 0, check);\n return tr;\n}\nfunction fixTable(state, table, tablePos, tr) {\n const map = TableMap.get(table);\n if (!map.problems)\n return tr;\n if (!tr)\n tr = state.tr;\n const mustAdd = [];\n for (let i = 0; i < map.height; i++)\n mustAdd.push(0);\n for (let i = 0; i < map.problems.length; i++) {\n const prob = map.problems[i];\n if (prob.type == \"collision\") {\n const cell = table.nodeAt(prob.pos);\n if (!cell)\n continue;\n const attrs = cell.attrs;\n for (let j = 0; j < attrs.rowspan; j++)\n mustAdd[prob.row + j] += prob.n;\n tr.setNodeMarkup(\n tr.mapping.map(tablePos + 1 + prob.pos),\n null,\n removeColSpan(attrs, attrs.colspan - prob.n, prob.n)\n );\n } else if (prob.type == \"missing\") {\n mustAdd[prob.row] += prob.n;\n } else if (prob.type == \"overlong_rowspan\") {\n const cell = table.nodeAt(prob.pos);\n if (!cell)\n continue;\n tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {\n ...cell.attrs,\n rowspan: cell.attrs.rowspan - prob.n\n });\n } else if (prob.type == \"colwidth mismatch\") {\n const cell = table.nodeAt(prob.pos);\n if (!cell)\n continue;\n tr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {\n ...cell.attrs,\n colwidth: prob.colwidth\n });\n }\n }\n let first, last;\n for (let i = 0; i < mustAdd.length; i++)\n if (mustAdd[i]) {\n if (first == null)\n first = i;\n last = i;\n }\n for (let i = 0, pos = tablePos + 1; i < map.height; i++) {\n const row = table.child(i);\n const end = pos + row.nodeSize;\n const add = mustAdd[i];\n if (add > 0) {\n let role = \"cell\";\n if (row.firstChild) {\n role = row.firstChild.type.spec.tableRole;\n }\n const nodes = [];\n for (let j = 0; j < add; j++) {\n const node = tableNodeTypes(state.schema)[role].createAndFill();\n if (node)\n nodes.push(node);\n }\n const side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;\n tr.insert(tr.mapping.map(side), nodes);\n }\n pos = end;\n }\n return tr.setMeta(fixTablesKey, { fixTables: true });\n}\n\n// src/input.ts\nimport { Fragment as Fragment3, Slice as Slice3 } from \"prosemirror-model\";\nimport {\n Selection as Selection2,\n TextSelection as TextSelection2\n} from \"prosemirror-state\";\nimport { keydownHandler } from \"prosemirror-keymap\";\n\n// src/copypaste.ts\nimport { Fragment as Fragment2, Slice as Slice2 } from \"prosemirror-model\";\nimport { Transform } from \"prosemirror-transform\";\nfunction pastedCells(slice) {\n if (!slice.size)\n return null;\n let { content, openStart, openEnd } = slice;\n while (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == \"table\")) {\n openStart--;\n openEnd--;\n content = content.child(0).content;\n }\n const first = content.child(0);\n const role = first.type.spec.tableRole;\n const schema = first.type.schema, rows = [];\n if (role == \"row\") {\n for (let i = 0; i < content.childCount; i++) {\n let cells = content.child(i).content;\n const left = i ? 0 : Math.max(0, openStart - 1);\n const right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);\n if (left || right)\n cells = fitSlice(\n tableNodeTypes(schema).row,\n new Slice2(cells, left, right)\n ).content;\n rows.push(cells);\n }\n } else if (role == \"cell\" || role == \"header_cell\") {\n rows.push(\n openStart || openEnd ? fitSlice(\n tableNodeTypes(schema).row,\n new Slice2(content, openStart, openEnd)\n ).content : content\n );\n } else {\n return null;\n }\n return ensureRectangular(schema, rows);\n}\nfunction ensureRectangular(schema, rows) {\n const widths = [];\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n for (let j = row.childCount - 1; j >= 0; j--) {\n const { rowspan, colspan } = row.child(j).attrs;\n for (let r = i; r < i + rowspan; r++)\n widths[r] = (widths[r] || 0) + colspan;\n }\n }\n let width = 0;\n for (let r = 0; r < widths.length; r++)\n width = Math.max(width, widths[r]);\n for (let r = 0; r < widths.length; r++) {\n if (r >= rows.length)\n rows.push(Fragment2.empty);\n if (widths[r] < width) {\n const empty = tableNodeTypes(schema).cell.createAndFill();\n const cells = [];\n for (let i = widths[r]; i < width; i++) {\n cells.push(empty);\n }\n rows[r] = rows[r].append(Fragment2.from(cells));\n }\n }\n return { height: rows.length, width, rows };\n}\nfunction fitSlice(nodeType, slice) {\n const node = nodeType.createAndFill();\n const tr = new Transform(node).replace(0, node.content.size, slice);\n return tr.doc;\n}\nfunction clipCells({ width, height, rows }, newWidth, newHeight) {\n if (width != newWidth) {\n const added = [];\n const newRows = [];\n for (let row = 0; row < rows.length; row++) {\n const frag = rows[row], cells = [];\n for (let col = added[row] || 0, i = 0; col < newWidth; i++) {\n let cell = frag.child(i % frag.childCount);\n if (col + cell.attrs.colspan > newWidth)\n cell = cell.type.createChecked(\n removeColSpan(\n cell.attrs,\n cell.attrs.colspan,\n col + cell.attrs.colspan - newWidth\n ),\n cell.content\n );\n cells.push(cell);\n col += cell.attrs.colspan;\n for (let j = 1; j < cell.attrs.rowspan; j++)\n added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;\n }\n newRows.push(Fragment2.from(cells));\n }\n rows = newRows;\n width = newWidth;\n }\n if (height != newHeight) {\n const newRows = [];\n for (let row = 0, i = 0; row < newHeight; row++, i++) {\n const cells = [], source = rows[i % height];\n for (let j = 0; j < source.childCount; j++) {\n let cell = source.child(j);\n if (row + cell.attrs.rowspan > newHeight)\n cell = cell.type.create(\n {\n ...cell.attrs,\n rowspan: Math.max(1, newHeight - cell.attrs.rowspan)\n },\n cell.content\n );\n cells.push(cell);\n }\n newRows.push(Fragment2.from(cells));\n }\n rows = newRows;\n height = newHeight;\n }\n return { width, height, rows };\n}\nfunction growTable(tr, map, table, start, width, height, mapFrom) {\n const schema = tr.doc.type.schema;\n const types = tableNodeTypes(schema);\n let empty;\n let emptyHead;\n if (width > map.width) {\n for (let row = 0, rowEnd = 0; row < map.height; row++) {\n const rowNode = table.child(row);\n rowEnd += rowNode.nodeSize;\n const cells = [];\n let add;\n if (rowNode.lastChild == null || rowNode.lastChild.type == types.cell)\n add = empty || (empty = types.cell.createAndFill());\n else\n add = emptyHead || (emptyHead = types.header_cell.createAndFill());\n for (let i = map.width; i < width; i++)\n cells.push(add);\n tr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);\n }\n }\n if (height > map.height) {\n const cells = [];\n for (let i = 0, start2 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {\n const header = i >= map.width ? false : table.nodeAt(map.map[start2 + i]).type == types.header_cell;\n cells.push(\n header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill())\n );\n }\n const emptyRow = types.row.create(null, Fragment2.from(cells)), rows = [];\n for (let i = map.height; i < height; i++)\n rows.push(emptyRow);\n tr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);\n }\n return !!(empty || emptyHead);\n}\nfunction isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {\n if (top == 0 || top == map.height)\n return false;\n let found = false;\n for (let col = left; col < right; col++) {\n const index = top * map.width + col, pos = map.map[index];\n if (map.map[index - map.width] == pos) {\n found = true;\n const cell = table.nodeAt(pos);\n const { top: cellTop, left: cellLeft } = map.findCell(pos);\n tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, {\n ...cell.attrs,\n rowspan: top - cellTop\n });\n tr.insert(\n tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)),\n cell.type.createAndFill({\n ...cell.attrs,\n rowspan: cellTop + cell.attrs.rowspan - top\n })\n );\n col += cell.attrs.colspan - 1;\n }\n }\n return found;\n}\nfunction isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {\n if (left == 0 || left == map.width)\n return false;\n let found = false;\n for (let row = top; row < bottom; row++) {\n const index = row * map.width + left, pos = map.map[index];\n if (map.map[index - 1] == pos) {\n found = true;\n const cell = table.nodeAt(pos);\n const cellLeft = map.colCount(pos);\n const updatePos = tr.mapping.slice(mapFrom).map(pos + start);\n tr.setNodeMarkup(\n updatePos,\n null,\n removeColSpan(\n cell.attrs,\n left - cellLeft,\n cell.attrs.colspan - (left - cellLeft)\n )\n );\n tr.insert(\n updatePos + cell.nodeSize,\n cell.type.createAndFill(\n removeColSpan(cell.attrs, 0, left - cellLeft)\n )\n );\n row += cell.attrs.rowspan - 1;\n }\n }\n return found;\n}\nfunction insertCells(state, dispatch, tableStart, rect, cells) {\n let table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc;\n if (!table) {\n throw new Error(\"No table found\");\n }\n let map = TableMap.get(table);\n const { top, left } = rect;\n const right = left + cells.width, bottom = top + cells.height;\n const tr = state.tr;\n let mapFrom = 0;\n function recomp() {\n table = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;\n if (!table) {\n throw new Error(\"No table found\");\n }\n map = TableMap.get(table);\n mapFrom = tr.mapping.maps.length;\n }\n if (growTable(tr, map, table, tableStart, right, bottom, mapFrom))\n recomp();\n if (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom))\n recomp();\n if (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom))\n recomp();\n if (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom))\n recomp();\n if (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom))\n recomp();\n for (let row = top; row < bottom; row++) {\n const from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);\n tr.replace(\n tr.mapping.slice(mapFrom).map(from + tableStart),\n tr.mapping.slice(mapFrom).map(to + tableStart),\n new Slice2(cells.rows[row - top], 0, 0)\n );\n }\n recomp();\n tr.setSelection(\n new CellSelection(\n tr.doc.resolve(tableStart + map.positionAt(top, left, table)),\n tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))\n )\n );\n dispatch(tr);\n}\n\n// src/input.ts\nvar handleKeyDown = keydownHandler({\n ArrowLeft: arrow(\"horiz\", -1),\n ArrowRight: arrow(\"horiz\", 1),\n ArrowUp: arrow(\"vert\", -1),\n ArrowDown: arrow(\"vert\", 1),\n \"Shift-ArrowLeft\": shiftArrow(\"horiz\", -1),\n \"Shift-ArrowRight\": shiftArrow(\"horiz\", 1),\n \"Shift-ArrowUp\": shiftArrow(\"vert\", -1),\n \"Shift-ArrowDown\": shiftArrow(\"vert\", 1),\n Backspace: deleteCellSelection,\n \"Mod-Backspace\": deleteCellSelection,\n Delete: deleteCellSelection,\n \"Mod-Delete\": deleteCellSelection\n});\nfunction maybeSetSelection(state, dispatch, selection) {\n if (selection.eq(state.selection))\n return false;\n if (dispatch)\n dispatch(state.tr.setSelection(selection).scrollIntoView());\n return true;\n}\nfunction arrow(axis, dir) {\n return (state, dispatch, view) => {\n if (!view)\n return false;\n const sel = state.selection;\n if (sel instanceof CellSelection) {\n return maybeSetSelection(\n state,\n dispatch,\n Selection2.near(sel.$headCell, dir)\n );\n }\n if (axis != \"horiz\" && !sel.empty)\n return false;\n const end = atEndOfCell(view, axis, dir);\n if (end == null)\n return false;\n if (axis == \"horiz\") {\n return maybeSetSelection(\n state,\n dispatch,\n Selection2.near(state.doc.resolve(sel.head + dir), dir)\n );\n } else {\n const $cell = state.doc.resolve(end);\n const $next = nextCell($cell, axis, dir);\n let newSel;\n if ($next)\n newSel = Selection2.near($next, 1);\n else if (dir < 0)\n newSel = Selection2.near(state.doc.resolve($cell.before(-1)), -1);\n else\n newSel = Selection2.near(state.doc.resolve($cell.after(-1)), 1);\n return maybeSetSelection(state, dispatch, newSel);\n }\n };\n}\nfunction shiftArrow(axis, dir) {\n return (state, dispatch, view) => {\n if (!view)\n return false;\n const sel = state.selection;\n let cellSel;\n if (sel instanceof CellSelection) {\n cellSel = sel;\n } else {\n const end = atEndOfCell(view, axis, dir);\n if (end == null)\n return false;\n cellSel = new CellSelection(state.doc.resolve(end));\n }\n const $head = nextCell(cellSel.$headCell, axis, dir);\n if (!$head)\n return false;\n return maybeSetSelection(\n state,\n dispatch,\n new CellSelection(cellSel.$anchorCell, $head)\n );\n };\n}\nfunction deleteCellSelection(state, dispatch) {\n const sel = state.selection;\n if (!(sel instanceof CellSelection))\n return false;\n if (dispatch) {\n const tr = state.tr;\n const baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;\n sel.forEachCell((cell, pos) => {\n if (!cell.content.eq(baseContent))\n tr.replace(\n tr.mapping.map(pos + 1),\n tr.mapping.map(pos + cell.nodeSize - 1),\n new Slice3(baseContent, 0, 0)\n );\n });\n if (tr.docChanged)\n dispatch(tr);\n }\n return true;\n}\nfunction handleTripleClick(view, pos) {\n const doc = view.state.doc, $cell = cellAround(doc.resolve(pos));\n if (!$cell)\n return false;\n view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));\n return true;\n}\nfunction handlePaste(view, _, slice) {\n if (!isInTable(view.state))\n return false;\n let cells = pastedCells(slice);\n const sel = view.state.selection;\n if (sel instanceof CellSelection) {\n if (!cells)\n cells = {\n width: 1,\n height: 1,\n rows: [\n Fragment3.from(\n fitSlice(tableNodeTypes(view.state.schema).cell, slice)\n )\n ]\n };\n const table = sel.$anchorCell.node(-1);\n const start = sel.$anchorCell.start(-1);\n const rect = TableMap.get(table).rectBetween(\n sel.$anchorCell.pos - start,\n sel.$headCell.pos - start\n );\n cells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);\n insertCells(view.state, view.dispatch, start, rect, cells);\n return true;\n } else if (cells) {\n const $cell = selectionCell(view.state);\n const start = $cell.start(-1);\n insertCells(\n view.state,\n view.dispatch,\n start,\n TableMap.get($cell.node(-1)).findCell($cell.pos - start),\n cells\n );\n return true;\n } else {\n return false;\n }\n}\nfunction handleMouseDown(view, startEvent) {\n var _a;\n if (startEvent.ctrlKey || startEvent.metaKey)\n return;\n const startDOMCell = domInCell(view, startEvent.target);\n let $anchor;\n if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {\n setCellSelection(view.state.selection.$anchorCell, startEvent);\n startEvent.preventDefault();\n } else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_a = cellUnderMouse(view, startEvent)) == null ? void 0 : _a.pos) != $anchor.pos) {\n setCellSelection($anchor, startEvent);\n startEvent.preventDefault();\n } else if (!startDOMCell) {\n return;\n }\n function setCellSelection($anchor2, event) {\n let $head = cellUnderMouse(view, event);\n const starting = tableEditingKey.getState(view.state) == null;\n if (!$head || !inSameTable($anchor2, $head)) {\n if (starting)\n $head = $anchor2;\n else\n return;\n }\n const selection = new CellSelection($anchor2, $head);\n if (starting || !view.state.selection.eq(selection)) {\n const tr = view.state.tr.setSelection(selection);\n if (starting)\n tr.setMeta(tableEditingKey, $anchor2.pos);\n view.dispatch(tr);\n }\n }\n function stop() {\n view.root.removeEventListener(\"mouseup\", stop);\n view.root.removeEventListener(\"dragstart\", stop);\n view.root.removeEventListener(\"mousemove\", move);\n if (tableEditingKey.getState(view.state) != null)\n view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));\n }\n function move(_event) {\n const event = _event;\n const anchor = tableEditingKey.getState(view.state);\n let $anchor2;\n if (anchor != null) {\n $anchor2 = view.state.doc.resolve(anchor);\n } else if (domInCell(view, event.target) != startDOMCell) {\n $anchor2 = cellUnderMouse(view, startEvent);\n if (!$anchor2)\n return stop();\n }\n if ($anchor2)\n setCellSelection($anchor2, event);\n }\n view.root.addEventListener(\"mouseup\", stop);\n view.root.addEventListener(\"dragstart\", stop);\n view.root.addEventListener(\"mousemove\", move);\n}\nfunction atEndOfCell(view, axis, dir) {\n if (!(view.state.selection instanceof TextSelection2))\n return null;\n const { $head } = view.state.selection;\n for (let d = $head.depth - 1; d >= 0; d--) {\n const parent = $head.node(d), index = dir < 0 ? $head.index(d) : $head.indexAfter(d);\n if (index != (dir < 0 ? 0 : parent.childCount))\n return null;\n if (parent.type.spec.tableRole == \"cell\" || parent.type.spec.tableRole == \"header_cell\") {\n const cellPos = $head.before(d);\n const dirStr = axis == \"vert\" ? dir > 0 ? \"down\" : \"up\" : dir > 0 ? \"right\" : \"left\";\n return view.endOfTextblock(dirStr) ? cellPos : null;\n }\n }\n return null;\n}\nfunction domInCell(view, dom) {\n for (; dom && dom != view.dom; dom = dom.parentNode) {\n if (dom.nodeName == \"TD\" || dom.nodeName == \"TH\") {\n return dom;\n }\n }\n return null;\n}\nfunction cellUnderMouse(view, event) {\n const mousePos = view.posAtCoords({\n left: event.clientX,\n top: event.clientY\n });\n if (!mousePos)\n return null;\n return mousePos ? cellAround(view.state.doc.resolve(mousePos.pos)) : null;\n}\n\n// src/columnresizing.ts\nimport { Plugin, PluginKey as PluginKey3 } from \"prosemirror-state\";\nimport {\n Decoration as Decoration2,\n DecorationSet as DecorationSet2\n} from \"prosemirror-view\";\n\n// src/tableview.ts\nvar TableView = class {\n constructor(node, cellMinWidth) {\n this.node = node;\n this.cellMinWidth = cellMinWidth;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"tableWrapper\";\n this.table = this.dom.appendChild(document.createElement(\"table\"));\n this.colgroup = this.table.appendChild(document.createElement(\"colgroup\"));\n updateColumnsOnResize(node, this.colgroup, this.table, cellMinWidth);\n this.contentDOM = this.table.appendChild(document.createElement(\"tbody\"));\n }\n update(node) {\n if (node.type != this.node.type)\n return false;\n this.node = node;\n updateColumnsOnResize(node, this.colgroup, this.table, this.cellMinWidth);\n return true;\n }\n ignoreMutation(record) {\n return record.type == \"attributes\" && (record.target == this.table || this.colgroup.contains(record.target));\n }\n};\nfunction updateColumnsOnResize(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {\n var _a;\n let totalWidth = 0;\n let fixedWidth = true;\n let nextDOM = colgroup.firstChild;\n const row = node.firstChild;\n if (!row)\n return;\n for (let i = 0, col = 0; i < row.childCount; i++) {\n const { colspan, colwidth } = row.child(i).attrs;\n for (let j = 0; j < colspan; j++, col++) {\n const hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];\n const cssWidth = hasWidth ? hasWidth + \"px\" : \"\";\n totalWidth += hasWidth || cellMinWidth;\n if (!hasWidth)\n fixedWidth = false;\n if (!nextDOM) {\n colgroup.appendChild(document.createElement(\"col\")).style.width = cssWidth;\n } else {\n if (nextDOM.style.width != cssWidth)\n nextDOM.style.width = cssWidth;\n nextDOM = nextDOM.nextSibling;\n }\n }\n }\n while (nextDOM) {\n const after = nextDOM.nextSibling;\n (_a = nextDOM.parentNode) == null ? void 0 : _a.removeChild(nextDOM);\n nextDOM = after;\n }\n if (fixedWidth) {\n table.style.width = totalWidth + \"px\";\n table.style.minWidth = \"\";\n } else {\n table.style.width = \"\";\n table.style.minWidth = totalWidth + \"px\";\n }\n}\n\n// src/columnresizing.ts\nvar columnResizingPluginKey = new PluginKey3(\n \"tableColumnResizing\"\n);\nfunction columnResizing({\n handleWidth = 5,\n cellMinWidth = 25,\n View = TableView,\n lastColumnResizable = true\n} = {}) {\n const plugin = new Plugin({\n key: columnResizingPluginKey,\n state: {\n init(_, state) {\n plugin.spec.props.nodeViews[tableNodeTypes(state.schema).table.name] = (node, view) => new View(node, cellMinWidth, view);\n return new ResizeState(-1, false);\n },\n apply(tr, prev) {\n return prev.apply(tr);\n }\n },\n props: {\n attributes: (state) => {\n const pluginState = columnResizingPluginKey.getState(state);\n return pluginState && pluginState.activeHandle > -1 ? { class: \"resize-cursor\" } : {};\n },\n handleDOMEvents: {\n mousemove: (view, event) => {\n handleMouseMove(\n view,\n event,\n handleWidth,\n cellMinWidth,\n lastColumnResizable\n );\n },\n mouseleave: (view) => {\n handleMouseLeave(view);\n },\n mousedown: (view, event) => {\n handleMouseDown2(view, event, cellMinWidth);\n }\n },\n decorations: (state) => {\n const pluginState = columnResizingPluginKey.getState(state);\n if (pluginState && pluginState.activeHandle > -1) {\n return handleDecorations(state, pluginState.activeHandle);\n }\n },\n nodeViews: {}\n }\n });\n return plugin;\n}\nvar ResizeState = class {\n constructor(activeHandle, dragging) {\n this.activeHandle = activeHandle;\n this.dragging = dragging;\n }\n apply(tr) {\n const state = this;\n const action = tr.getMeta(columnResizingPluginKey);\n if (action && action.setHandle != null)\n return new ResizeState(action.setHandle, false);\n if (action && action.setDragging !== void 0)\n return new ResizeState(state.activeHandle, action.setDragging);\n if (state.activeHandle > -1 && tr.docChanged) {\n let handle = tr.mapping.map(state.activeHandle, -1);\n if (!pointsAtCell(tr.doc.resolve(handle))) {\n handle = -1;\n }\n return new ResizeState(handle, state.dragging);\n }\n return state;\n }\n};\nfunction handleMouseMove(view, event, handleWidth, cellMinWidth, lastColumnResizable) {\n const pluginState = columnResizingPluginKey.getState(view.state);\n if (!pluginState)\n return;\n if (!pluginState.dragging) {\n const target = domCellAround(event.target);\n let cell = -1;\n if (target) {\n const { left, right } = target.getBoundingClientRect();\n if (event.clientX - left <= handleWidth)\n cell = edgeCell(view, event, \"left\");\n else if (right - event.clientX <= handleWidth)\n cell = edgeCell(view, event, \"right\");\n }\n if (cell != pluginState.activeHandle) {\n if (!lastColumnResizable && cell !== -1) {\n const $cell = view.state.doc.resolve(cell);\n const table = $cell.node(-1);\n const map = TableMap.get(table);\n const tableStart = $cell.start(-1);\n const col = map.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1;\n if (col == map.width - 1) {\n return;\n }\n }\n updateHandle(view, cell);\n }\n }\n}\nfunction handleMouseLeave(view) {\n const pluginState = columnResizingPluginKey.getState(view.state);\n if (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging)\n updateHandle(view, -1);\n}\nfunction handleMouseDown2(view, event, cellMinWidth) {\n const pluginState = columnResizingPluginKey.getState(view.state);\n if (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging)\n return false;\n const cell = view.state.doc.nodeAt(pluginState.activeHandle);\n const width = currentColWidth(view, pluginState.activeHandle, cell.attrs);\n view.dispatch(\n view.state.tr.setMeta(columnResizingPluginKey, {\n setDragging: { startX: event.clientX, startWidth: width }\n })\n );\n function finish(event2) {\n window.removeEventListener(\"mouseup\", finish);\n window.removeEventListener(\"mousemove\", move);\n const pluginState2 = columnResizingPluginKey.getState(view.state);\n if (pluginState2 == null ? void 0 : pluginState2.dragging) {\n updateColumnWidth(\n view,\n pluginState2.activeHandle,\n draggedWidth(pluginState2.dragging, event2, cellMinWidth)\n );\n view.dispatch(\n view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null })\n );\n }\n }\n function move(event2) {\n if (!event2.which)\n return finish(event2);\n const pluginState2 = columnResizingPluginKey.getState(view.state);\n if (!pluginState2)\n return;\n if (pluginState2.dragging) {\n const dragged = draggedWidth(pluginState2.dragging, event2, cellMinWidth);\n displayColumnWidth(view, pluginState2.activeHandle, dragged, cellMinWidth);\n }\n }\n window.addEventListener(\"mouseup\", finish);\n window.addEventListener(\"mousemove\", move);\n event.preventDefault();\n return true;\n}\nfunction currentColWidth(view, cellPos, { colspan, colwidth }) {\n const width = colwidth && colwidth[colwidth.length - 1];\n if (width)\n return width;\n const dom = view.domAtPos(cellPos);\n const node = dom.node.childNodes[dom.offset];\n let domWidth = node.offsetWidth, parts = colspan;\n if (colwidth) {\n for (let i = 0; i < colspan; i++)\n if (colwidth[i]) {\n domWidth -= colwidth[i];\n parts--;\n }\n }\n return domWidth / parts;\n}\nfunction domCellAround(target) {\n while (target && target.nodeName != \"TD\" && target.nodeName != \"TH\")\n target = target.classList && target.classList.contains(\"ProseMirror\") ? null : target.parentNode;\n return target;\n}\nfunction edgeCell(view, event, side) {\n const found = view.posAtCoords({ left: event.clientX, top: event.clientY });\n if (!found)\n return -1;\n const { pos } = found;\n const $cell = cellAround(view.state.doc.resolve(pos));\n if (!$cell)\n return -1;\n if (side == \"right\")\n return $cell.pos;\n const map = TableMap.get($cell.node(-1)), start = $cell.start(-1);\n const index = map.map.indexOf($cell.pos - start);\n return index % map.width == 0 ? -1 : start + map.map[index - 1];\n}\nfunction draggedWidth(dragging, event, cellMinWidth) {\n const offset = event.clientX - dragging.startX;\n return Math.max(cellMinWidth, dragging.startWidth + offset);\n}\nfunction updateHandle(view, value) {\n view.dispatch(\n view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value })\n );\n}\nfunction updateColumnWidth(view, cell, width) {\n const $cell = view.state.doc.resolve(cell);\n const table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);\n const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n const tr = view.state.tr;\n for (let row = 0; row < map.height; row++) {\n const mapIndex = row * map.width + col;\n if (row && map.map[mapIndex] == map.map[mapIndex - map.width])\n continue;\n const pos = map.map[mapIndex];\n const attrs = table.nodeAt(pos).attrs;\n const index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);\n if (attrs.colwidth && attrs.colwidth[index] == width)\n continue;\n const colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);\n colwidth[index] = width;\n tr.setNodeMarkup(start + pos, null, { ...attrs, colwidth });\n }\n if (tr.docChanged)\n view.dispatch(tr);\n}\nfunction displayColumnWidth(view, cell, width, cellMinWidth) {\n const $cell = view.state.doc.resolve(cell);\n const table = $cell.node(-1), start = $cell.start(-1);\n const col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n let dom = view.domAtPos($cell.start(-1)).node;\n while (dom && dom.nodeName != \"TABLE\") {\n dom = dom.parentNode;\n }\n if (!dom)\n return;\n updateColumnsOnResize(\n table,\n dom.firstChild,\n dom,\n cellMinWidth,\n col,\n width\n );\n}\nfunction zeroes(n) {\n return Array(n).fill(0);\n}\nfunction handleDecorations(state, cell) {\n const decorations = [];\n const $cell = state.doc.resolve(cell);\n const table = $cell.node(-1);\n if (!table) {\n return DecorationSet2.empty;\n }\n const map = TableMap.get(table);\n const start = $cell.start(-1);\n const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan;\n for (let row = 0; row < map.height; row++) {\n const index = col + row * map.width - 1;\n if ((col == map.width || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index - 1] != map.map[index - 1 - map.width])) {\n const cellPos = map.map[index];\n const pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;\n const dom = document.createElement(\"div\");\n dom.className = \"column-resize-handle\";\n decorations.push(Decoration2.widget(pos, dom));\n }\n }\n return DecorationSet2.create(state.doc, decorations);\n}\n\n// src/commands.ts\nimport { Fragment as Fragment4 } from \"prosemirror-model\";\nimport {\n TextSelection as TextSelection3\n} from \"prosemirror-state\";\nfunction selectedRect(state) {\n const sel = state.selection;\n const $pos = selectionCell(state);\n const table = $pos.node(-1);\n const tableStart = $pos.start(-1);\n const map = TableMap.get(table);\n const rect = sel instanceof CellSelection ? map.rectBetween(\n sel.$anchorCell.pos - tableStart,\n sel.$headCell.pos - tableStart\n ) : map.findCell($pos.pos - tableStart);\n return { ...rect, tableStart, map, table };\n}\nfunction addColumn(tr, { map, tableStart, table }, col) {\n let refColumn = col > 0 ? -1 : 0;\n if (columnIsHeader(map, table, col + refColumn)) {\n refColumn = col == 0 || col == map.width ? null : 0;\n }\n for (let row = 0; row < map.height; row++) {\n const index = row * map.width + col;\n if (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {\n const pos = map.map[index];\n const cell = table.nodeAt(pos);\n tr.setNodeMarkup(\n tr.mapping.map(tableStart + pos),\n null,\n addColSpan(cell.attrs, col - map.colCount(pos))\n );\n row += cell.attrs.rowspan - 1;\n } else {\n const type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;\n const pos = map.positionAt(row, col, table);\n tr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());\n }\n }\n return tr;\n}\nfunction addColumnBefore(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const rect = selectedRect(state);\n dispatch(addColumn(state.tr, rect, rect.left));\n }\n return true;\n}\nfunction addColumnAfter(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const rect = selectedRect(state);\n dispatch(addColumn(state.tr, rect, rect.right));\n }\n return true;\n}\nfunction removeColumn(tr, { map, table, tableStart }, col) {\n const mapStart = tr.mapping.maps.length;\n for (let row = 0; row < map.height; ) {\n const index = row * map.width + col;\n const pos = map.map[index];\n const cell = table.nodeAt(pos);\n const attrs = cell.attrs;\n if (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) {\n tr.setNodeMarkup(\n tr.mapping.slice(mapStart).map(tableStart + pos),\n null,\n removeColSpan(attrs, col - map.colCount(pos))\n );\n } else {\n const start = tr.mapping.slice(mapStart).map(tableStart + pos);\n tr.delete(start, start + cell.nodeSize);\n }\n row += attrs.rowspan;\n }\n}\nfunction deleteColumn(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const rect = selectedRect(state);\n const tr = state.tr;\n if (rect.left == 0 && rect.right == rect.map.width)\n return false;\n for (let i = rect.right - 1; ; i--) {\n removeColumn(tr, rect, i);\n if (i == rect.left)\n break;\n const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n if (!table) {\n throw RangeError(\"No table found\");\n }\n rect.table = table;\n rect.map = TableMap.get(table);\n }\n dispatch(tr);\n }\n return true;\n}\nfunction rowIsHeader(map, table, row) {\n var _a;\n const headerCell = tableNodeTypes(table.type.schema).header_cell;\n for (let col = 0; col < map.width; col++)\n if (((_a = table.nodeAt(map.map[col + row * map.width])) == null ? void 0 : _a.type) != headerCell)\n return false;\n return true;\n}\nfunction addRow(tr, { map, tableStart, table }, row) {\n var _a;\n let rowPos = tableStart;\n for (let i = 0; i < row; i++)\n rowPos += table.child(i).nodeSize;\n const cells = [];\n let refRow = row > 0 ? -1 : 0;\n if (rowIsHeader(map, table, row + refRow))\n refRow = row == 0 || row == map.height ? null : 0;\n for (let col = 0, index = map.width * row; col < map.width; col++, index++) {\n if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {\n const pos = map.map[index];\n const attrs = table.nodeAt(pos).attrs;\n tr.setNodeMarkup(tableStart + pos, null, {\n ...attrs,\n rowspan: attrs.rowspan + 1\n });\n col += attrs.colspan - 1;\n } else {\n const type = refRow == null ? tableNodeTypes(table.type.schema).cell : (_a = table.nodeAt(map.map[index + refRow * map.width])) == null ? void 0 : _a.type;\n const node = type == null ? void 0 : type.createAndFill();\n if (node)\n cells.push(node);\n }\n }\n tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));\n return tr;\n}\nfunction addRowBefore(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const rect = selectedRect(state);\n dispatch(addRow(state.tr, rect, rect.top));\n }\n return true;\n}\nfunction addRowAfter(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const rect = selectedRect(state);\n dispatch(addRow(state.tr, rect, rect.bottom));\n }\n return true;\n}\nfunction removeRow(tr, { map, table, tableStart }, row) {\n let rowPos = 0;\n for (let i = 0; i < row; i++)\n rowPos += table.child(i).nodeSize;\n const nextRow = rowPos + table.child(row).nodeSize;\n const mapFrom = tr.mapping.maps.length;\n tr.delete(rowPos + tableStart, nextRow + tableStart);\n for (let col = 0, index = row * map.width; col < map.width; col++, index++) {\n const pos = map.map[index];\n if (row > 0 && pos == map.map[index - map.width]) {\n const attrs = table.nodeAt(pos).attrs;\n tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, {\n ...attrs,\n rowspan: attrs.rowspan - 1\n });\n col += attrs.colspan - 1;\n } else if (row < map.width && pos == map.map[index + map.width]) {\n const cell = table.nodeAt(pos);\n const attrs = cell.attrs;\n const copy = cell.type.create(\n { ...attrs, rowspan: cell.attrs.rowspan - 1 },\n cell.content\n );\n const newPos = map.positionAt(row + 1, col, table);\n tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);\n col += attrs.colspan - 1;\n }\n }\n}\nfunction deleteRow(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const rect = selectedRect(state), tr = state.tr;\n if (rect.top == 0 && rect.bottom == rect.map.height)\n return false;\n for (let i = rect.bottom - 1; ; i--) {\n removeRow(tr, rect, i);\n if (i == rect.top)\n break;\n const table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n if (!table) {\n throw RangeError(\"No table found\");\n }\n rect.table = table;\n rect.map = TableMap.get(rect.table);\n }\n dispatch(tr);\n }\n return true;\n}\nfunction isEmpty(cell) {\n const c = cell.content;\n return c.childCount == 1 && c.child(0).isTextblock && c.child(0).childCount == 0;\n}\nfunction cellsOverlapRectangle({ width, height, map }, rect) {\n let indexTop = rect.top * width + rect.left, indexLeft = indexTop;\n let indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);\n for (let i = rect.top; i < rect.bottom; i++) {\n if (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] || rect.right < width && map[indexRight] == map[indexRight + 1])\n return true;\n indexLeft += width;\n indexRight += width;\n }\n for (let i = rect.left; i < rect.right; i++) {\n if (rect.top > 0 && map[indexTop] == map[indexTop - width] || rect.bottom < height && map[indexBottom] == map[indexBottom + width])\n return true;\n indexTop++;\n indexBottom++;\n }\n return false;\n}\nfunction mergeCells(state, dispatch) {\n const sel = state.selection;\n if (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos)\n return false;\n const rect = selectedRect(state), { map } = rect;\n if (cellsOverlapRectangle(map, rect))\n return false;\n if (dispatch) {\n const tr = state.tr;\n const seen = {};\n let content = Fragment4.empty;\n let mergedPos;\n let mergedCell;\n for (let row = rect.top; row < rect.bottom; row++) {\n for (let col = rect.left; col < rect.right; col++) {\n const cellPos = map.map[row * map.width + col];\n const cell = rect.table.nodeAt(cellPos);\n if (seen[cellPos] || !cell)\n continue;\n seen[cellPos] = true;\n if (mergedPos == null) {\n mergedPos = cellPos;\n mergedCell = cell;\n } else {\n if (!isEmpty(cell))\n content = content.append(cell.content);\n const mapped = tr.mapping.map(cellPos + rect.tableStart);\n tr.delete(mapped, mapped + cell.nodeSize);\n }\n }\n }\n if (mergedPos == null || mergedCell == null) {\n return true;\n }\n tr.setNodeMarkup(mergedPos + rect.tableStart, null, {\n ...addColSpan(\n mergedCell.attrs,\n mergedCell.attrs.colspan,\n rect.right - rect.left - mergedCell.attrs.colspan\n ),\n rowspan: rect.bottom - rect.top\n });\n if (content.size) {\n const end = mergedPos + 1 + mergedCell.content.size;\n const start = isEmpty(mergedCell) ? mergedPos + 1 : end;\n tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);\n }\n tr.setSelection(\n new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart))\n );\n dispatch(tr);\n }\n return true;\n}\nfunction splitCell(state, dispatch) {\n const nodeTypes = tableNodeTypes(state.schema);\n return splitCellWithType(({ node }) => {\n return nodeTypes[node.type.spec.tableRole];\n })(state, dispatch);\n}\nfunction splitCellWithType(getCellType) {\n return (state, dispatch) => {\n var _a;\n const sel = state.selection;\n let cellNode;\n let cellPos;\n if (!(sel instanceof CellSelection)) {\n cellNode = cellWrapping(sel.$from);\n if (!cellNode)\n return false;\n cellPos = (_a = cellAround(sel.$from)) == null ? void 0 : _a.pos;\n } else {\n if (sel.$anchorCell.pos != sel.$headCell.pos)\n return false;\n cellNode = sel.$anchorCell.nodeAfter;\n cellPos = sel.$anchorCell.pos;\n }\n if (cellNode == null || cellPos == null) {\n return false;\n }\n if (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) {\n return false;\n }\n if (dispatch) {\n let baseAttrs = cellNode.attrs;\n const attrs = [];\n const colwidth = baseAttrs.colwidth;\n if (baseAttrs.rowspan > 1)\n baseAttrs = { ...baseAttrs, rowspan: 1 };\n if (baseAttrs.colspan > 1)\n baseAttrs = { ...baseAttrs, colspan: 1 };\n const rect = selectedRect(state), tr = state.tr;\n for (let i = 0; i < rect.right - rect.left; i++)\n attrs.push(\n colwidth ? {\n ...baseAttrs,\n colwidth: colwidth && colwidth[i] ? [colwidth[i]] : null\n } : baseAttrs\n );\n let lastCell;\n for (let row = rect.top; row < rect.bottom; row++) {\n let pos = rect.map.positionAt(row, rect.left, rect.table);\n if (row == rect.top)\n pos += cellNode.nodeSize;\n for (let col = rect.left, i = 0; col < rect.right; col++, i++) {\n if (col == rect.left && row == rect.top)\n continue;\n tr.insert(\n lastCell = tr.mapping.map(pos + rect.tableStart, 1),\n getCellType({ node: cellNode, row, col }).createAndFill(attrs[i])\n );\n }\n }\n tr.setNodeMarkup(\n cellPos,\n getCellType({ node: cellNode, row: rect.top, col: rect.left }),\n attrs[0]\n );\n if (sel instanceof CellSelection)\n tr.setSelection(\n new CellSelection(\n tr.doc.resolve(sel.$anchorCell.pos),\n lastCell ? tr.doc.resolve(lastCell) : void 0\n )\n );\n dispatch(tr);\n }\n return true;\n };\n}\nfunction setCellAttr(name, value) {\n return function(state, dispatch) {\n if (!isInTable(state))\n return false;\n const $cell = selectionCell(state);\n if ($cell.nodeAfter.attrs[name] === value)\n return false;\n if (dispatch) {\n const tr = state.tr;\n if (state.selection instanceof CellSelection)\n state.selection.forEachCell((node, pos) => {\n if (node.attrs[name] !== value)\n tr.setNodeMarkup(pos, null, {\n ...node.attrs,\n [name]: value\n });\n });\n else\n tr.setNodeMarkup($cell.pos, null, {\n ...$cell.nodeAfter.attrs,\n [name]: value\n });\n dispatch(tr);\n }\n return true;\n };\n}\nfunction deprecated_toggleHeader(type) {\n return function(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const types = tableNodeTypes(state.schema);\n const rect = selectedRect(state), tr = state.tr;\n const cells = rect.map.cellsInRect(\n type == \"column\" ? {\n left: rect.left,\n top: 0,\n right: rect.right,\n bottom: rect.map.height\n } : type == \"row\" ? {\n left: 0,\n top: rect.top,\n right: rect.map.width,\n bottom: rect.bottom\n } : rect\n );\n const nodes = cells.map((pos) => rect.table.nodeAt(pos));\n for (let i = 0; i < cells.length; i++)\n if (nodes[i].type == types.header_cell)\n tr.setNodeMarkup(\n rect.tableStart + cells[i],\n types.cell,\n nodes[i].attrs\n );\n if (tr.steps.length == 0)\n for (let i = 0; i < cells.length; i++)\n tr.setNodeMarkup(\n rect.tableStart + cells[i],\n types.header_cell,\n nodes[i].attrs\n );\n dispatch(tr);\n }\n return true;\n };\n}\nfunction isHeaderEnabledByType(type, rect, types) {\n const cellPositions = rect.map.cellsInRect({\n left: 0,\n top: 0,\n right: type == \"row\" ? rect.map.width : 1,\n bottom: type == \"column\" ? rect.map.height : 1\n });\n for (let i = 0; i < cellPositions.length; i++) {\n const cell = rect.table.nodeAt(cellPositions[i]);\n if (cell && cell.type !== types.header_cell) {\n return false;\n }\n }\n return true;\n}\nfunction toggleHeader(type, options) {\n options = options || { useDeprecatedLogic: false };\n if (options.useDeprecatedLogic)\n return deprecated_toggleHeader(type);\n return function(state, dispatch) {\n if (!isInTable(state))\n return false;\n if (dispatch) {\n const types = tableNodeTypes(state.schema);\n const rect = selectedRect(state), tr = state.tr;\n const isHeaderRowEnabled = isHeaderEnabledByType(\"row\", rect, types);\n const isHeaderColumnEnabled = isHeaderEnabledByType(\n \"column\",\n rect,\n types\n );\n const isHeaderEnabled = type === \"column\" ? isHeaderRowEnabled : type === \"row\" ? isHeaderColumnEnabled : false;\n const selectionStartsAt = isHeaderEnabled ? 1 : 0;\n const cellsRect = type == \"column\" ? {\n left: 0,\n top: selectionStartsAt,\n right: 1,\n bottom: rect.map.height\n } : type == \"row\" ? {\n left: selectionStartsAt,\n top: 0,\n right: rect.map.width,\n bottom: 1\n } : rect;\n const newType = type == \"column\" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == \"row\" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;\n rect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {\n const cellPos = relativeCellPos + rect.tableStart;\n const cell = tr.doc.nodeAt(cellPos);\n if (cell) {\n tr.setNodeMarkup(cellPos, newType, cell.attrs);\n }\n });\n dispatch(tr);\n }\n return true;\n };\n}\nvar toggleHeaderRow = toggleHeader(\"row\", {\n useDeprecatedLogic: true\n});\nvar toggleHeaderColumn = toggleHeader(\"column\", {\n useDeprecatedLogic: true\n});\nvar toggleHeaderCell = toggleHeader(\"cell\", {\n useDeprecatedLogic: true\n});\nfunction findNextCell($cell, dir) {\n if (dir < 0) {\n const before = $cell.nodeBefore;\n if (before)\n return $cell.pos - before.nodeSize;\n for (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {\n const rowNode = $cell.node(-1).child(row);\n const lastChild = rowNode.lastChild;\n if (lastChild) {\n return rowEnd - 1 - lastChild.nodeSize;\n }\n rowEnd -= rowNode.nodeSize;\n }\n } else {\n if ($cell.index() < $cell.parent.childCount - 1) {\n return $cell.pos + $cell.nodeAfter.nodeSize;\n }\n const table = $cell.node(-1);\n for (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {\n const rowNode = table.child(row);\n if (rowNode.childCount)\n return rowStart + 1;\n rowStart += rowNode.nodeSize;\n }\n }\n return null;\n}\nfunction goToNextCell(direction) {\n return function(state, dispatch) {\n if (!isInTable(state))\n return false;\n const cell = findNextCell(selectionCell(state), direction);\n if (cell == null)\n return false;\n if (dispatch) {\n const $cell = state.doc.resolve(cell);\n dispatch(\n state.tr.setSelection(TextSelection3.between($cell, moveCellForward($cell))).scrollIntoView()\n );\n }\n return true;\n };\n}\nfunction deleteTable(state, dispatch) {\n const $pos = state.selection.$anchor;\n for (let d = $pos.depth; d > 0; d--) {\n const node = $pos.node(d);\n if (node.type.spec.tableRole == \"table\") {\n if (dispatch)\n dispatch(\n state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView()\n );\n return true;\n }\n }\n return false;\n}\n\n// src/index.ts\nfunction tableEditing({\n allowTableNodeSelection = false\n} = {}) {\n return new Plugin2({\n key: tableEditingKey,\n state: {\n init() {\n return null;\n },\n apply(tr, cur) {\n const set = tr.getMeta(tableEditingKey);\n if (set != null)\n return set == -1 ? null : set;\n if (cur == null || !tr.docChanged)\n return cur;\n const { deleted, pos } = tr.mapping.mapResult(cur);\n return deleted ? null : pos;\n }\n },\n props: {\n decorations: drawCellSelection,\n handleDOMEvents: {\n mousedown: handleMouseDown\n },\n createSelectionBetween(view) {\n return tableEditingKey.getState(view.state) != null ? view.state.selection : null;\n },\n handleTripleClick,\n handleKeyDown,\n handlePaste\n },\n appendTransaction(_, oldState, state) {\n return normalizeSelection(\n state,\n fixTables(state, oldState),\n allowTableNodeSelection\n );\n }\n });\n}\nexport {\n CellBookmark,\n CellSelection,\n ResizeState,\n TableMap,\n TableView,\n clipCells as __clipCells,\n insertCells as __insertCells,\n pastedCells as __pastedCells,\n addColSpan,\n addColumn,\n addColumnAfter,\n addColumnBefore,\n addRow,\n addRowAfter,\n addRowBefore,\n cellAround,\n colCount,\n columnIsHeader,\n columnResizing,\n columnResizingPluginKey,\n deleteColumn,\n deleteRow,\n deleteTable,\n findCell,\n fixTables,\n fixTablesKey,\n goToNextCell,\n handlePaste,\n inSameTable,\n isInTable,\n mergeCells,\n moveCellForward,\n nextCell,\n pointsAtCell,\n removeColSpan,\n removeColumn,\n removeRow,\n rowIsHeader,\n selectedRect,\n selectionCell,\n setCellAttr,\n splitCell,\n splitCellWithType,\n tableEditing,\n tableEditingKey,\n tableNodeTypes,\n tableNodes,\n toggleHeader,\n toggleHeaderCell,\n toggleHeaderColumn,\n toggleHeaderRow,\n updateColumnsOnResize\n};\n","import { ReplaceError, Slice, Fragment, MarkType, Mark } from 'prosemirror-model';\n\n// Recovery values encode a range index and an offset. They are\n// represented as numbers, because tons of them will be created when\n// mapping, for example, a large number of decorations. The number's\n// lower 16 bits provide the index, the remaining bits the offset.\n//\n// Note: We intentionally don't use bit shift operators to en- and\n// decode these, since those clip to 32 bits, which we might in rare\n// cases want to overflow. A 64-bit float can represent 48-bit\n// integers precisely.\nconst lower16 = 0xffff;\nconst factor16 = Math.pow(2, 16);\nfunction makeRecover(index, offset) { return index + offset * factor16; }\nfunction recoverIndex(value) { return value & lower16; }\nfunction recoverOffset(value) { return (value - (value & lower16)) / factor16; }\nconst DEL_BEFORE = 1, DEL_AFTER = 2, DEL_ACROSS = 4, DEL_SIDE = 8;\n/**\nAn object representing a mapped position with extra\ninformation.\n*/\nclass MapResult {\n /**\n @internal\n */\n constructor(\n /**\n The mapped version of the position.\n */\n pos, \n /**\n @internal\n */\n delInfo, \n /**\n @internal\n */\n recover) {\n this.pos = pos;\n this.delInfo = delInfo;\n this.recover = recover;\n }\n /**\n Tells you whether the position was deleted, that is, whether the\n step removed the token on the side queried (via the `assoc`)\n argument from the document.\n */\n get deleted() { return (this.delInfo & DEL_SIDE) > 0; }\n /**\n Tells you whether the token before the mapped position was deleted.\n */\n get deletedBefore() { return (this.delInfo & (DEL_BEFORE | DEL_ACROSS)) > 0; }\n /**\n True when the token after the mapped position was deleted.\n */\n get deletedAfter() { return (this.delInfo & (DEL_AFTER | DEL_ACROSS)) > 0; }\n /**\n Tells whether any of the steps mapped through deletes across the\n position (including both the token before and after the\n position).\n */\n get deletedAcross() { return (this.delInfo & DEL_ACROSS) > 0; }\n}\n/**\nA map describing the deletions and insertions made by a step, which\ncan be used to find the correspondence between positions in the\npre-step version of a document and the same position in the\npost-step version.\n*/\nclass StepMap {\n /**\n Create a position map. The modifications to the document are\n represented as an array of numbers, in which each group of three\n represents a modified chunk as `[start, oldSize, newSize]`.\n */\n constructor(\n /**\n @internal\n */\n ranges, \n /**\n @internal\n */\n inverted = false) {\n this.ranges = ranges;\n this.inverted = inverted;\n if (!ranges.length && StepMap.empty)\n return StepMap.empty;\n }\n /**\n @internal\n */\n recover(value) {\n let diff = 0, index = recoverIndex(value);\n if (!this.inverted)\n for (let i = 0; i < index; i++)\n diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];\n return this.ranges[index * 3] + diff + recoverOffset(value);\n }\n mapResult(pos, assoc = 1) { return this._map(pos, assoc, false); }\n map(pos, assoc = 1) { return this._map(pos, assoc, true); }\n /**\n @internal\n */\n _map(pos, assoc, simple) {\n let diff = 0, oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;\n for (let i = 0; i < this.ranges.length; i += 3) {\n let start = this.ranges[i] - (this.inverted ? diff : 0);\n if (start > pos)\n break;\n let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex], end = start + oldSize;\n if (pos <= end) {\n let side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;\n let result = start + diff + (side < 0 ? 0 : newSize);\n if (simple)\n return result;\n let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);\n let del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;\n if (assoc < 0 ? pos != start : pos != end)\n del |= DEL_SIDE;\n return new MapResult(result, del, recover);\n }\n diff += newSize - oldSize;\n }\n return simple ? pos + diff : new MapResult(pos + diff, 0, null);\n }\n /**\n @internal\n */\n touches(pos, recover) {\n let diff = 0, index = recoverIndex(recover);\n let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;\n for (let i = 0; i < this.ranges.length; i += 3) {\n let start = this.ranges[i] - (this.inverted ? diff : 0);\n if (start > pos)\n break;\n let oldSize = this.ranges[i + oldIndex], end = start + oldSize;\n if (pos <= end && i == index * 3)\n return true;\n diff += this.ranges[i + newIndex] - oldSize;\n }\n return false;\n }\n /**\n Calls the given function on each of the changed ranges included in\n this map.\n */\n forEach(f) {\n let oldIndex = this.inverted ? 2 : 1, newIndex = this.inverted ? 1 : 2;\n for (let i = 0, diff = 0; i < this.ranges.length; i += 3) {\n let start = this.ranges[i], oldStart = start - (this.inverted ? diff : 0), newStart = start + (this.inverted ? 0 : diff);\n let oldSize = this.ranges[i + oldIndex], newSize = this.ranges[i + newIndex];\n f(oldStart, oldStart + oldSize, newStart, newStart + newSize);\n diff += newSize - oldSize;\n }\n }\n /**\n Create an inverted version of this map. The result can be used to\n map positions in the post-step document to the pre-step document.\n */\n invert() {\n return new StepMap(this.ranges, !this.inverted);\n }\n /**\n @internal\n */\n toString() {\n return (this.inverted ? \"-\" : \"\") + JSON.stringify(this.ranges);\n }\n /**\n Create a map that moves all positions by offset `n` (which may be\n negative). This can be useful when applying steps meant for a\n sub-document to a larger document, or vice-versa.\n */\n static offset(n) {\n return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);\n }\n}\n/**\nA StepMap that contains no changed ranges.\n*/\nStepMap.empty = new StepMap([]);\n/**\nA mapping represents a pipeline of zero or more [step\nmaps](https://prosemirror.net/docs/ref/#transform.StepMap). It has special provisions for losslessly\nhandling mapping positions through a series of steps in which some\nsteps are inverted versions of earlier steps. (This comes up when\n‘[rebasing](/docs/guide/#transform.rebasing)’ steps for\ncollaboration or history management.)\n*/\nclass Mapping {\n /**\n Create a new mapping with the given position maps.\n */\n constructor(\n /**\n The step maps in this mapping.\n */\n maps = [], \n /**\n @internal\n */\n mirror, \n /**\n The starting position in the `maps` array, used when `map` or\n `mapResult` is called.\n */\n from = 0, \n /**\n The end position in the `maps` array.\n */\n to = maps.length) {\n this.maps = maps;\n this.mirror = mirror;\n this.from = from;\n this.to = to;\n }\n /**\n Create a mapping that maps only through a part of this one.\n */\n slice(from = 0, to = this.maps.length) {\n return new Mapping(this.maps, this.mirror, from, to);\n }\n /**\n @internal\n */\n copy() {\n return new Mapping(this.maps.slice(), this.mirror && this.mirror.slice(), this.from, this.to);\n }\n /**\n Add a step map to the end of this mapping. If `mirrors` is\n given, it should be the index of the step map that is the mirror\n image of this one.\n */\n appendMap(map, mirrors) {\n this.to = this.maps.push(map);\n if (mirrors != null)\n this.setMirror(this.maps.length - 1, mirrors);\n }\n /**\n Add all the step maps in a given mapping to this one (preserving\n mirroring information).\n */\n appendMapping(mapping) {\n for (let i = 0, startSize = this.maps.length; i < mapping.maps.length; i++) {\n let mirr = mapping.getMirror(i);\n this.appendMap(mapping.maps[i], mirr != null && mirr < i ? startSize + mirr : undefined);\n }\n }\n /**\n Finds the offset of the step map that mirrors the map at the\n given offset, in this mapping (as per the second argument to\n `appendMap`).\n */\n getMirror(n) {\n if (this.mirror)\n for (let i = 0; i < this.mirror.length; i++)\n if (this.mirror[i] == n)\n return this.mirror[i + (i % 2 ? -1 : 1)];\n }\n /**\n @internal\n */\n setMirror(n, m) {\n if (!this.mirror)\n this.mirror = [];\n this.mirror.push(n, m);\n }\n /**\n Append the inverse of the given mapping to this one.\n */\n appendMappingInverted(mapping) {\n for (let i = mapping.maps.length - 1, totalSize = this.maps.length + mapping.maps.length; i >= 0; i--) {\n let mirr = mapping.getMirror(i);\n this.appendMap(mapping.maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : undefined);\n }\n }\n /**\n Create an inverted version of this mapping.\n */\n invert() {\n let inverse = new Mapping;\n inverse.appendMappingInverted(this);\n return inverse;\n }\n /**\n Map a position through this mapping.\n */\n map(pos, assoc = 1) {\n if (this.mirror)\n return this._map(pos, assoc, true);\n for (let i = this.from; i < this.to; i++)\n pos = this.maps[i].map(pos, assoc);\n return pos;\n }\n /**\n Map a position through this mapping, returning a mapping\n result.\n */\n mapResult(pos, assoc = 1) { return this._map(pos, assoc, false); }\n /**\n @internal\n */\n _map(pos, assoc, simple) {\n let delInfo = 0;\n for (let i = this.from; i < this.to; i++) {\n let map = this.maps[i], result = map.mapResult(pos, assoc);\n if (result.recover != null) {\n let corr = this.getMirror(i);\n if (corr != null && corr > i && corr < this.to) {\n i = corr;\n pos = this.maps[corr].recover(result.recover);\n continue;\n }\n }\n delInfo |= result.delInfo;\n pos = result.pos;\n }\n return simple ? pos : new MapResult(pos, delInfo, null);\n }\n}\n\nconst stepsByID = Object.create(null);\n/**\nA step object represents an atomic change. It generally applies\nonly to the document it was created for, since the positions\nstored in it will only make sense for that document.\n\nNew steps are defined by creating classes that extend `Step`,\noverriding the `apply`, `invert`, `map`, `getMap` and `fromJSON`\nmethods, and registering your class with a unique\nJSON-serialization identifier using\n[`Step.jsonID`](https://prosemirror.net/docs/ref/#transform.Step^jsonID).\n*/\nclass Step {\n /**\n Get the step map that represents the changes made by this step,\n and which can be used to transform between positions in the old\n and the new document.\n */\n getMap() { return StepMap.empty; }\n /**\n Try to merge this step with another one, to be applied directly\n after it. Returns the merged step when possible, null if the\n steps can't be merged.\n */\n merge(other) { return null; }\n /**\n Deserialize a step from its JSON representation. Will call\n through to the step class' own implementation of this method.\n */\n static fromJSON(schema, json) {\n if (!json || !json.stepType)\n throw new RangeError(\"Invalid input for Step.fromJSON\");\n let type = stepsByID[json.stepType];\n if (!type)\n throw new RangeError(`No step type ${json.stepType} defined`);\n return type.fromJSON(schema, json);\n }\n /**\n To be able to serialize steps to JSON, each step needs a string\n ID to attach to its JSON representation. Use this method to\n register an ID for your step classes. Try to pick something\n that's unlikely to clash with steps from other modules.\n */\n static jsonID(id, stepClass) {\n if (id in stepsByID)\n throw new RangeError(\"Duplicate use of step JSON ID \" + id);\n stepsByID[id] = stepClass;\n stepClass.prototype.jsonID = id;\n return stepClass;\n }\n}\n/**\nThe result of [applying](https://prosemirror.net/docs/ref/#transform.Step.apply) a step. Contains either a\nnew document or a failure value.\n*/\nclass StepResult {\n /**\n @internal\n */\n constructor(\n /**\n The transformed document, if successful.\n */\n doc, \n /**\n The failure message, if unsuccessful.\n */\n failed) {\n this.doc = doc;\n this.failed = failed;\n }\n /**\n Create a successful step result.\n */\n static ok(doc) { return new StepResult(doc, null); }\n /**\n Create a failed step result.\n */\n static fail(message) { return new StepResult(null, message); }\n /**\n Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given\n arguments. Create a successful result if it succeeds, and a\n failed one if it throws a `ReplaceError`.\n */\n static fromReplace(doc, from, to, slice) {\n try {\n return StepResult.ok(doc.replace(from, to, slice));\n }\n catch (e) {\n if (e instanceof ReplaceError)\n return StepResult.fail(e.message);\n throw e;\n }\n }\n}\n\nfunction mapFragment(fragment, f, parent) {\n let mapped = [];\n for (let i = 0; i < fragment.childCount; i++) {\n let child = fragment.child(i);\n if (child.content.size)\n child = child.copy(mapFragment(child.content, f, child));\n if (child.isInline)\n child = f(child, parent, i);\n mapped.push(child);\n }\n return Fragment.fromArray(mapped);\n}\n/**\nAdd a mark to all inline content between two positions.\n*/\nclass AddMarkStep extends Step {\n /**\n Create a mark step.\n */\n constructor(\n /**\n The start of the marked range.\n */\n from, \n /**\n The end of the marked range.\n */\n to, \n /**\n The mark to add.\n */\n mark) {\n super();\n this.from = from;\n this.to = to;\n this.mark = mark;\n }\n apply(doc) {\n let oldSlice = doc.slice(this.from, this.to), $from = doc.resolve(this.from);\n let parent = $from.node($from.sharedDepth(this.to));\n let slice = new Slice(mapFragment(oldSlice.content, (node, parent) => {\n if (!node.isAtom || !parent.type.allowsMarkType(this.mark.type))\n return node;\n return node.mark(this.mark.addToSet(node.marks));\n }, parent), oldSlice.openStart, oldSlice.openEnd);\n return StepResult.fromReplace(doc, this.from, this.to, slice);\n }\n invert() {\n return new RemoveMarkStep(this.from, this.to, this.mark);\n }\n map(mapping) {\n let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n if (from.deleted && to.deleted || from.pos >= to.pos)\n return null;\n return new AddMarkStep(from.pos, to.pos, this.mark);\n }\n merge(other) {\n if (other instanceof AddMarkStep &&\n other.mark.eq(this.mark) &&\n this.from <= other.to && this.to >= other.from)\n return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);\n return null;\n }\n toJSON() {\n return { stepType: \"addMark\", mark: this.mark.toJSON(),\n from: this.from, to: this.to };\n }\n /**\n @internal\n */\n static fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\")\n throw new RangeError(\"Invalid input for AddMarkStep.fromJSON\");\n return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));\n }\n}\nStep.jsonID(\"addMark\", AddMarkStep);\n/**\nRemove a mark from all inline content between two positions.\n*/\nclass RemoveMarkStep extends Step {\n /**\n Create a mark-removing step.\n */\n constructor(\n /**\n The start of the unmarked range.\n */\n from, \n /**\n The end of the unmarked range.\n */\n to, \n /**\n The mark to remove.\n */\n mark) {\n super();\n this.from = from;\n this.to = to;\n this.mark = mark;\n }\n apply(doc) {\n let oldSlice = doc.slice(this.from, this.to);\n let slice = new Slice(mapFragment(oldSlice.content, node => {\n return node.mark(this.mark.removeFromSet(node.marks));\n }, doc), oldSlice.openStart, oldSlice.openEnd);\n return StepResult.fromReplace(doc, this.from, this.to, slice);\n }\n invert() {\n return new AddMarkStep(this.from, this.to, this.mark);\n }\n map(mapping) {\n let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n if (from.deleted && to.deleted || from.pos >= to.pos)\n return null;\n return new RemoveMarkStep(from.pos, to.pos, this.mark);\n }\n merge(other) {\n if (other instanceof RemoveMarkStep &&\n other.mark.eq(this.mark) &&\n this.from <= other.to && this.to >= other.from)\n return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);\n return null;\n }\n toJSON() {\n return { stepType: \"removeMark\", mark: this.mark.toJSON(),\n from: this.from, to: this.to };\n }\n /**\n @internal\n */\n static fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\")\n throw new RangeError(\"Invalid input for RemoveMarkStep.fromJSON\");\n return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));\n }\n}\nStep.jsonID(\"removeMark\", RemoveMarkStep);\n/**\nAdd a mark to a specific node.\n*/\nclass AddNodeMarkStep extends Step {\n /**\n Create a node mark step.\n */\n constructor(\n /**\n The position of the target node.\n */\n pos, \n /**\n The mark to add.\n */\n mark) {\n super();\n this.pos = pos;\n this.mark = mark;\n }\n apply(doc) {\n let node = doc.nodeAt(this.pos);\n if (!node)\n return StepResult.fail(\"No node at mark step's position\");\n let updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));\n return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));\n }\n invert(doc) {\n let node = doc.nodeAt(this.pos);\n if (node) {\n let newSet = this.mark.addToSet(node.marks);\n if (newSet.length == node.marks.length) {\n for (let i = 0; i < node.marks.length; i++)\n if (!node.marks[i].isInSet(newSet))\n return new AddNodeMarkStep(this.pos, node.marks[i]);\n return new AddNodeMarkStep(this.pos, this.mark);\n }\n }\n return new RemoveNodeMarkStep(this.pos, this.mark);\n }\n map(mapping) {\n let pos = mapping.mapResult(this.pos, 1);\n return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);\n }\n toJSON() {\n return { stepType: \"addNodeMark\", pos: this.pos, mark: this.mark.toJSON() };\n }\n /**\n @internal\n */\n static fromJSON(schema, json) {\n if (typeof json.pos != \"number\")\n throw new RangeError(\"Invalid input for AddNodeMarkStep.fromJSON\");\n return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));\n }\n}\nStep.jsonID(\"addNodeMark\", AddNodeMarkStep);\n/**\nRemove a mark from a specific node.\n*/\nclass RemoveNodeMarkStep extends Step {\n /**\n Create a mark-removing step.\n */\n constructor(\n /**\n The position of the target node.\n */\n pos, \n /**\n The mark to remove.\n */\n mark) {\n super();\n this.pos = pos;\n this.mark = mark;\n }\n apply(doc) {\n let node = doc.nodeAt(this.pos);\n if (!node)\n return StepResult.fail(\"No node at mark step's position\");\n let updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));\n return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));\n }\n invert(doc) {\n let node = doc.nodeAt(this.pos);\n if (!node || !this.mark.isInSet(node.marks))\n return this;\n return new AddNodeMarkStep(this.pos, this.mark);\n }\n map(mapping) {\n let pos = mapping.mapResult(this.pos, 1);\n return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);\n }\n toJSON() {\n return { stepType: \"removeNodeMark\", pos: this.pos, mark: this.mark.toJSON() };\n }\n /**\n @internal\n */\n static fromJSON(schema, json) {\n if (typeof json.pos != \"number\")\n throw new RangeError(\"Invalid input for RemoveNodeMarkStep.fromJSON\");\n return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));\n }\n}\nStep.jsonID(\"removeNodeMark\", RemoveNodeMarkStep);\n\n/**\nReplace a part of the document with a slice of new content.\n*/\nclass ReplaceStep extends Step {\n /**\n The given `slice` should fit the 'gap' between `from` and\n `to`—the depths must line up, and the surrounding nodes must be\n able to be joined with the open sides of the slice. When\n `structure` is true, the step will fail if the content between\n from and to is not just a sequence of closing and then opening\n tokens (this is to guard against rebased replace steps\n overwriting something they weren't supposed to).\n */\n constructor(\n /**\n The start position of the replaced range.\n */\n from, \n /**\n The end position of the replaced range.\n */\n to, \n /**\n The slice to insert.\n */\n slice, \n /**\n @internal\n */\n structure = false) {\n super();\n this.from = from;\n this.to = to;\n this.slice = slice;\n this.structure = structure;\n }\n apply(doc) {\n if (this.structure && contentBetween(doc, this.from, this.to))\n return StepResult.fail(\"Structure replace would overwrite content\");\n return StepResult.fromReplace(doc, this.from, this.to, this.slice);\n }\n getMap() {\n return new StepMap([this.from, this.to - this.from, this.slice.size]);\n }\n invert(doc) {\n return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));\n }\n map(mapping) {\n let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n if (from.deletedAcross && to.deletedAcross)\n return null;\n return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);\n }\n merge(other) {\n if (!(other instanceof ReplaceStep) || other.structure || this.structure)\n return null;\n if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {\n let slice = this.slice.size + other.slice.size == 0 ? Slice.empty\n : new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);\n return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);\n }\n else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {\n let slice = this.slice.size + other.slice.size == 0 ? Slice.empty\n : new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);\n return new ReplaceStep(other.from, this.to, slice, this.structure);\n }\n else {\n return null;\n }\n }\n toJSON() {\n let json = { stepType: \"replace\", from: this.from, to: this.to };\n if (this.slice.size)\n json.slice = this.slice.toJSON();\n if (this.structure)\n json.structure = true;\n return json;\n }\n /**\n @internal\n */\n static fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\")\n throw new RangeError(\"Invalid input for ReplaceStep.fromJSON\");\n return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);\n }\n}\nStep.jsonID(\"replace\", ReplaceStep);\n/**\nReplace a part of the document with a slice of content, but\npreserve a range of the replaced content by moving it into the\nslice.\n*/\nclass ReplaceAroundStep extends Step {\n /**\n Create a replace-around step with the given range and gap.\n `insert` should be the point in the slice into which the content\n of the gap should be moved. `structure` has the same meaning as\n it has in the [`ReplaceStep`](https://prosemirror.net/docs/ref/#transform.ReplaceStep) class.\n */\n constructor(\n /**\n The start position of the replaced range.\n */\n from, \n /**\n The end position of the replaced range.\n */\n to, \n /**\n The start of preserved range.\n */\n gapFrom, \n /**\n The end of preserved range.\n */\n gapTo, \n /**\n The slice to insert.\n */\n slice, \n /**\n The position in the slice where the preserved range should be\n inserted.\n */\n insert, \n /**\n @internal\n */\n structure = false) {\n super();\n this.from = from;\n this.to = to;\n this.gapFrom = gapFrom;\n this.gapTo = gapTo;\n this.slice = slice;\n this.insert = insert;\n this.structure = structure;\n }\n apply(doc) {\n if (this.structure && (contentBetween(doc, this.from, this.gapFrom) ||\n contentBetween(doc, this.gapTo, this.to)))\n return StepResult.fail(\"Structure gap-replace would overwrite content\");\n let gap = doc.slice(this.gapFrom, this.gapTo);\n if (gap.openStart || gap.openEnd)\n return StepResult.fail(\"Gap is not a flat range\");\n let inserted = this.slice.insertAt(this.insert, gap.content);\n if (!inserted)\n return StepResult.fail(\"Content does not fit in gap\");\n return StepResult.fromReplace(doc, this.from, this.to, inserted);\n }\n getMap() {\n return new StepMap([this.from, this.gapFrom - this.from, this.insert,\n this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);\n }\n invert(doc) {\n let gap = this.gapTo - this.gapFrom;\n return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);\n }\n map(mapping) {\n let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);\n let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);\n if ((from.deletedAcross && to.deletedAcross) || gapFrom < from.pos || gapTo > to.pos)\n return null;\n return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);\n }\n toJSON() {\n let json = { stepType: \"replaceAround\", from: this.from, to: this.to,\n gapFrom: this.gapFrom, gapTo: this.gapTo, insert: this.insert };\n if (this.slice.size)\n json.slice = this.slice.toJSON();\n if (this.structure)\n json.structure = true;\n return json;\n }\n /**\n @internal\n */\n static fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\" ||\n typeof json.gapFrom != \"number\" || typeof json.gapTo != \"number\" || typeof json.insert != \"number\")\n throw new RangeError(\"Invalid input for ReplaceAroundStep.fromJSON\");\n return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);\n }\n}\nStep.jsonID(\"replaceAround\", ReplaceAroundStep);\nfunction contentBetween(doc, from, to) {\n let $from = doc.resolve(from), dist = to - from, depth = $from.depth;\n while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {\n depth--;\n dist--;\n }\n if (dist > 0) {\n let next = $from.node(depth).maybeChild($from.indexAfter(depth));\n while (dist > 0) {\n if (!next || next.isLeaf)\n return true;\n next = next.firstChild;\n dist--;\n }\n }\n return false;\n}\n\nfunction addMark(tr, from, to, mark) {\n let removed = [], added = [];\n let removing, adding;\n tr.doc.nodesBetween(from, to, (node, pos, parent) => {\n if (!node.isInline)\n return;\n let marks = node.marks;\n if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {\n let start = Math.max(pos, from), end = Math.min(pos + node.nodeSize, to);\n let newSet = mark.addToSet(marks);\n for (let i = 0; i < marks.length; i++) {\n if (!marks[i].isInSet(newSet)) {\n if (removing && removing.to == start && removing.mark.eq(marks[i]))\n removing.to = end;\n else\n removed.push(removing = new RemoveMarkStep(start, end, marks[i]));\n }\n }\n if (adding && adding.to == start)\n adding.to = end;\n else\n added.push(adding = new AddMarkStep(start, end, mark));\n }\n });\n removed.forEach(s => tr.step(s));\n added.forEach(s => tr.step(s));\n}\nfunction removeMark(tr, from, to, mark) {\n let matched = [], step = 0;\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (!node.isInline)\n return;\n step++;\n let toRemove = null;\n if (mark instanceof MarkType) {\n let set = node.marks, found;\n while (found = mark.isInSet(set)) {\n (toRemove || (toRemove = [])).push(found);\n set = found.removeFromSet(set);\n }\n }\n else if (mark) {\n if (mark.isInSet(node.marks))\n toRemove = [mark];\n }\n else {\n toRemove = node.marks;\n }\n if (toRemove && toRemove.length) {\n let end = Math.min(pos + node.nodeSize, to);\n for (let i = 0; i < toRemove.length; i++) {\n let style = toRemove[i], found;\n for (let j = 0; j < matched.length; j++) {\n let m = matched[j];\n if (m.step == step - 1 && style.eq(matched[j].style))\n found = m;\n }\n if (found) {\n found.to = end;\n found.step = step;\n }\n else {\n matched.push({ style, from: Math.max(pos, from), to: end, step });\n }\n }\n }\n });\n matched.forEach(m => tr.step(new RemoveMarkStep(m.from, m.to, m.style)));\n}\nfunction clearIncompatible(tr, pos, parentType, match = parentType.contentMatch) {\n let node = tr.doc.nodeAt(pos);\n let delSteps = [], cur = pos + 1;\n for (let i = 0; i < node.childCount; i++) {\n let child = node.child(i), end = cur + child.nodeSize;\n let allowed = match.matchType(child.type);\n if (!allowed) {\n delSteps.push(new ReplaceStep(cur, end, Slice.empty));\n }\n else {\n match = allowed;\n for (let j = 0; j < child.marks.length; j++)\n if (!parentType.allowsMarkType(child.marks[j].type))\n tr.step(new RemoveMarkStep(cur, end, child.marks[j]));\n }\n cur = end;\n }\n if (!match.validEnd) {\n let fill = match.fillBefore(Fragment.empty, true);\n tr.replace(cur, cur, new Slice(fill, 0, 0));\n }\n for (let i = delSteps.length - 1; i >= 0; i--)\n tr.step(delSteps[i]);\n}\n\nfunction canCut(node, start, end) {\n return (start == 0 || node.canReplace(start, node.childCount)) &&\n (end == node.childCount || node.canReplace(0, end));\n}\n/**\nTry to find a target depth to which the content in the given range\ncan be lifted. Will not go across\n[isolating](https://prosemirror.net/docs/ref/#model.NodeSpec.isolating) parent nodes.\n*/\nfunction liftTarget(range) {\n let parent = range.parent;\n let content = parent.content.cutByIndex(range.startIndex, range.endIndex);\n for (let depth = range.depth;; --depth) {\n let node = range.$from.node(depth);\n let index = range.$from.index(depth), endIndex = range.$to.indexAfter(depth);\n if (depth < range.depth && node.canReplace(index, endIndex, content))\n return depth;\n if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex))\n break;\n }\n return null;\n}\nfunction lift(tr, range, target) {\n let { $from, $to, depth } = range;\n let gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);\n let start = gapStart, end = gapEnd;\n let before = Fragment.empty, openStart = 0;\n for (let d = depth, splitting = false; d > target; d--)\n if (splitting || $from.index(d) > 0) {\n splitting = true;\n before = Fragment.from($from.node(d).copy(before));\n openStart++;\n }\n else {\n start--;\n }\n let after = Fragment.empty, openEnd = 0;\n for (let d = depth, splitting = false; d > target; d--)\n if (splitting || $to.after(d + 1) < $to.end(d)) {\n splitting = true;\n after = Fragment.from($to.node(d).copy(after));\n openEnd++;\n }\n else {\n end++;\n }\n tr.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new Slice(before.append(after), openStart, openEnd), before.size - openStart, true));\n}\n/**\nTry to find a valid way to wrap the content in the given range in a\nnode of the given type. May introduce extra nodes around and inside\nthe wrapper node, if necessary. Returns null if no valid wrapping\ncould be found. When `innerRange` is given, that range's content is\nused as the content to fit into the wrapping, instead of the\ncontent of `range`.\n*/\nfunction findWrapping(range, nodeType, attrs = null, innerRange = range) {\n let around = findWrappingOutside(range, nodeType);\n let inner = around && findWrappingInside(innerRange, nodeType);\n if (!inner)\n return null;\n return around.map(withAttrs)\n .concat({ type: nodeType, attrs }).concat(inner.map(withAttrs));\n}\nfunction withAttrs(type) { return { type, attrs: null }; }\nfunction findWrappingOutside(range, type) {\n let { parent, startIndex, endIndex } = range;\n let around = parent.contentMatchAt(startIndex).findWrapping(type);\n if (!around)\n return null;\n let outer = around.length ? around[0] : type;\n return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;\n}\nfunction findWrappingInside(range, type) {\n let { parent, startIndex, endIndex } = range;\n let inner = parent.child(startIndex);\n let inside = type.contentMatch.findWrapping(inner.type);\n if (!inside)\n return null;\n let lastType = inside.length ? inside[inside.length - 1] : type;\n let innerMatch = lastType.contentMatch;\n for (let i = startIndex; innerMatch && i < endIndex; i++)\n innerMatch = innerMatch.matchType(parent.child(i).type);\n if (!innerMatch || !innerMatch.validEnd)\n return null;\n return inside;\n}\nfunction wrap(tr, range, wrappers) {\n let content = Fragment.empty;\n for (let i = wrappers.length - 1; i >= 0; i--) {\n if (content.size) {\n let match = wrappers[i].type.contentMatch.matchFragment(content);\n if (!match || !match.validEnd)\n throw new RangeError(\"Wrapper type given to Transform.wrap does not form valid content of its parent wrapper\");\n }\n content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));\n }\n let start = range.start, end = range.end;\n tr.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));\n}\nfunction setBlockType(tr, from, to, type, attrs) {\n if (!type.isTextblock)\n throw new RangeError(\"Type given to setBlockType should be a textblock\");\n let mapFrom = tr.steps.length;\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isTextblock && !node.hasMarkup(type, attrs) && canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {\n // Ensure all markup that isn't allowed in the new node type is cleared\n tr.clearIncompatible(tr.mapping.slice(mapFrom).map(pos, 1), type);\n let mapping = tr.mapping.slice(mapFrom);\n let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);\n tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrs, null, node.marks)), 0, 0), 1, true));\n return false;\n }\n });\n}\nfunction canChangeType(doc, pos, type) {\n let $pos = doc.resolve(pos), index = $pos.index();\n return $pos.parent.canReplaceWith(index, index + 1, type);\n}\n/**\nChange the type, attributes, and/or marks of the node at `pos`.\nWhen `type` isn't given, the existing node type is preserved,\n*/\nfunction setNodeMarkup(tr, pos, type, attrs, marks) {\n let node = tr.doc.nodeAt(pos);\n if (!node)\n throw new RangeError(\"No node at given position\");\n if (!type)\n type = node.type;\n let newNode = type.create(attrs, null, marks || node.marks);\n if (node.isLeaf)\n return tr.replaceWith(pos, pos + node.nodeSize, newNode);\n if (!type.validContent(node.content))\n throw new RangeError(\"Invalid content for node type \" + type.name);\n tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));\n}\n/**\nCheck whether splitting at the given position is allowed.\n*/\nfunction canSplit(doc, pos, depth = 1, typesAfter) {\n let $pos = doc.resolve(pos), base = $pos.depth - depth;\n let innerType = (typesAfter && typesAfter[typesAfter.length - 1]) || $pos.parent;\n if (base < 0 || $pos.parent.type.spec.isolating ||\n !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) ||\n !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount)))\n return false;\n for (let d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {\n let node = $pos.node(d), index = $pos.index(d);\n if (node.type.spec.isolating)\n return false;\n let rest = node.content.cutByIndex(index, node.childCount);\n let after = (typesAfter && typesAfter[i]) || node;\n if (after != node)\n rest = rest.replaceChild(0, after.type.create(after.attrs));\n if (!node.canReplace(index + 1, node.childCount) || !after.type.validContent(rest))\n return false;\n }\n let index = $pos.indexAfter(base);\n let baseType = typesAfter && typesAfter[0];\n return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);\n}\nfunction split(tr, pos, depth = 1, typesAfter) {\n let $pos = tr.doc.resolve(pos), before = Fragment.empty, after = Fragment.empty;\n for (let d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {\n before = Fragment.from($pos.node(d).copy(before));\n let typeAfter = typesAfter && typesAfter[i];\n after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));\n }\n tr.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true));\n}\n/**\nTest whether the blocks before and after a given position can be\njoined.\n*/\nfunction canJoin(doc, pos) {\n let $pos = doc.resolve(pos), index = $pos.index();\n return joinable($pos.nodeBefore, $pos.nodeAfter) &&\n $pos.parent.canReplace(index, index + 1);\n}\nfunction joinable(a, b) {\n return !!(a && b && !a.isLeaf && a.canAppend(b));\n}\n/**\nFind an ancestor of the given position that can be joined to the\nblock before (or after if `dir` is positive). Returns the joinable\npoint, if any.\n*/\nfunction joinPoint(doc, pos, dir = -1) {\n let $pos = doc.resolve(pos);\n for (let d = $pos.depth;; d--) {\n let before, after, index = $pos.index(d);\n if (d == $pos.depth) {\n before = $pos.nodeBefore;\n after = $pos.nodeAfter;\n }\n else if (dir > 0) {\n before = $pos.node(d + 1);\n index++;\n after = $pos.node(d).maybeChild(index);\n }\n else {\n before = $pos.node(d).maybeChild(index - 1);\n after = $pos.node(d + 1);\n }\n if (before && !before.isTextblock && joinable(before, after) &&\n $pos.node(d).canReplace(index, index + 1))\n return pos;\n if (d == 0)\n break;\n pos = dir < 0 ? $pos.before(d) : $pos.after(d);\n }\n}\nfunction join(tr, pos, depth) {\n let step = new ReplaceStep(pos - depth, pos + depth, Slice.empty, true);\n tr.step(step);\n}\n/**\nTry to find a point where a node of the given type can be inserted\nnear `pos`, by searching up the node hierarchy when `pos` itself\nisn't a valid place but is at the start or end of a node. Return\nnull if no position was found.\n*/\nfunction insertPoint(doc, pos, nodeType) {\n let $pos = doc.resolve(pos);\n if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType))\n return pos;\n if ($pos.parentOffset == 0)\n for (let d = $pos.depth - 1; d >= 0; d--) {\n let index = $pos.index(d);\n if ($pos.node(d).canReplaceWith(index, index, nodeType))\n return $pos.before(d + 1);\n if (index > 0)\n return null;\n }\n if ($pos.parentOffset == $pos.parent.content.size)\n for (let d = $pos.depth - 1; d >= 0; d--) {\n let index = $pos.indexAfter(d);\n if ($pos.node(d).canReplaceWith(index, index, nodeType))\n return $pos.after(d + 1);\n if (index < $pos.node(d).childCount)\n return null;\n }\n return null;\n}\n/**\nFinds a position at or around the given position where the given\nslice can be inserted. Will look at parent nodes' nearest boundary\nand try there, even if the original position wasn't directly at the\nstart or end of that node. Returns null when no position was found.\n*/\nfunction dropPoint(doc, pos, slice) {\n let $pos = doc.resolve(pos);\n if (!slice.content.size)\n return pos;\n let content = slice.content;\n for (let i = 0; i < slice.openStart; i++)\n content = content.firstChild.content;\n for (let pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {\n for (let d = $pos.depth; d >= 0; d--) {\n let bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;\n let insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);\n let parent = $pos.node(d), fits = false;\n if (pass == 1) {\n fits = parent.canReplace(insertPos, insertPos, content);\n }\n else {\n let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);\n fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);\n }\n if (fits)\n return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);\n }\n }\n return null;\n}\n\n/**\n‘Fit’ a slice into a given position in the document, producing a\n[step](https://prosemirror.net/docs/ref/#transform.Step) that inserts it. Will return null if\nthere's no meaningful way to insert the slice here, or inserting it\nwould be a no-op (an empty slice over an empty range).\n*/\nfunction replaceStep(doc, from, to = from, slice = Slice.empty) {\n if (from == to && !slice.size)\n return null;\n let $from = doc.resolve(from), $to = doc.resolve(to);\n // Optimization -- avoid work if it's obvious that it's not needed.\n if (fitsTrivially($from, $to, slice))\n return new ReplaceStep(from, to, slice);\n return new Fitter($from, $to, slice).fit();\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// 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`.\nclass Fitter {\n constructor($from, $to, unplaced) {\n this.$from = $from;\n this.$to = $to;\n this.unplaced = unplaced;\n this.frontier = [];\n this.placed = Fragment.empty;\n for (let i = 0; i <= $from.depth; i++) {\n let node = $from.node(i);\n this.frontier.push({\n type: node.type,\n match: node.contentMatchAt($from.indexAfter(i))\n });\n }\n for (let i = $from.depth; i > 0; i--)\n this.placed = Fragment.from($from.node(i).copy(this.placed));\n }\n get depth() { return this.frontier.length - 1; }\n 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 let fit = this.findFittable();\n if (fit)\n this.placeNodes(fit);\n else\n 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 let moveInline = this.mustMoveInline(), placedSize = this.placed.size - this.depth - this.$from.depth;\n let $from = this.$from, $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));\n if (!$to)\n return null;\n // If closing to `$to` succeeded, create a step\n let 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--;\n openEnd--;\n }\n let 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 return null;\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.\n findFittable() {\n let startDepth = this.unplaced.openStart;\n for (let cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {\n let node = cur.firstChild;\n if (cur.childCount > 1)\n openEnd = 0;\n if (node.type.spec.isolating && openEnd <= d) {\n startDepth = d;\n break;\n }\n cur = node.content;\n }\n // Only try wrapping nodes (pass 2) after finding a place without\n // wrapping failed.\n for (let pass = 1; pass <= 2; pass++) {\n for (let sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {\n let fragment, parent = null;\n if (sliceDepth) {\n parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;\n fragment = parent.content;\n }\n else {\n fragment = this.unplaced.content;\n }\n let first = fragment.firstChild;\n for (let frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {\n let { type, match } = this.frontier[frontierDepth], wrap, inject = null;\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 : parent && type.compatibleContent(parent.type)))\n return { sliceDepth, frontierDepth, parent, 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, frontierDepth, parent, wrap };\n // Don't continue looking further up if the parent node\n // would fit here.\n if (parent && match.matchType(parent.type))\n break;\n }\n }\n }\n }\n openMore() {\n let { content, openStart, openEnd } = this.unplaced;\n let inner = contentAt(content, openStart);\n if (!inner.childCount || inner.firstChild.isLeaf)\n return false;\n this.unplaced = new Slice(content, openStart + 1, Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0));\n return true;\n }\n dropNode() {\n let { content, openStart, openEnd } = this.unplaced;\n let inner = contentAt(content, openStart);\n if (inner.childCount <= 1 && openStart > 0) {\n let openAtEnd = content.size - openStart <= openStart + inner.size;\n this.unplaced = new Slice(dropFromFragment(content, openStart - 1, 1), openStart - 1, openAtEnd ? openStart - 1 : openEnd);\n }\n else {\n this.unplaced = new Slice(dropFromFragment(content, openStart, 1), openStart, openEnd);\n }\n }\n // Move content from the unplaced slice at `sliceDepth` to the\n // frontier node at `frontierDepth`. Close that frontier node when\n // applicable.\n placeNodes({ sliceDepth, frontierDepth, parent, inject, wrap }) {\n while (this.depth > frontierDepth)\n this.closeFrontierNode();\n if (wrap)\n for (let i = 0; i < wrap.length; i++)\n this.openFrontierNode(wrap[i]);\n let slice = this.unplaced, fragment = parent ? parent.content : slice.content;\n let openStart = slice.openStart - sliceDepth;\n let taken = 0, add = [];\n let { match, type } = this.frontier[frontierDepth];\n if (inject) {\n for (let i = 0; i < inject.childCount; i++)\n add.push(inject.child(i));\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 let 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 let next = fragment.child(taken), matches = match.matchType(next.type);\n if (!matches)\n 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, taken == fragment.childCount ? openEndCount : -1));\n }\n }\n let toEnd = taken == fragment.childCount;\n if (!toEnd)\n openEndCount = -1;\n this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add));\n this.frontier[frontierDepth].match = match;\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 // Add new frontier nodes for any open nodes at the end.\n for (let i = 0, cur = fragment; i < openEndCount; i++) {\n let node = cur.lastChild;\n this.frontier.push({ type: node.type, match: node.contentMatchAt(node.childCount) });\n cur = node.content;\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), sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1);\n }\n mustMoveInline() {\n if (!this.$to.parent.isTextblock)\n return -1;\n let 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))\n return -1;\n let { depth } = this.$to, after = this.$to.after(depth);\n while (depth > 1 && after == this.$to.end(--depth))\n ++after;\n return after;\n }\n findCloseLevel($to) {\n scan: for (let i = Math.min(this.depth, $to.depth); i >= 0; i--) {\n let { match, type } = this.frontier[i];\n let dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));\n let fit = contentAfterFits($to, i, type, match, dropInner);\n if (!fit)\n continue;\n for (let d = i - 1; d >= 0; d--) {\n let { match, type } = this.frontier[d];\n let matches = contentAfterFits($to, d, type, match, true);\n if (!matches || matches.childCount)\n continue scan;\n }\n return { depth: i, fit, move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to };\n }\n }\n close($to) {\n let close = this.findCloseLevel($to);\n if (!close)\n return null;\n while (this.depth > close.depth)\n this.closeFrontierNode();\n if (close.fit.childCount)\n this.placed = addToFragment(this.placed, close.depth, close.fit);\n $to = close.move;\n for (let d = close.depth + 1; d <= $to.depth; d++) {\n let 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 openFrontierNode(type, attrs = null, content) {\n let 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, match: type.contentMatch });\n }\n closeFrontierNode() {\n let open = this.frontier.pop();\n let add = open.match.fillBefore(Fragment.empty, true);\n if (add.childCount)\n this.placed = addToFragment(this.placed, this.frontier.length, add);\n }\n}\nfunction dropFromFragment(fragment, depth, count) {\n if (depth == 0)\n return fragment.cutByIndex(count, fragment.childCount);\n return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)));\n}\nfunction addToFragment(fragment, depth, content) {\n if (depth == 0)\n return fragment.append(content);\n return fragment.replaceChild(fragment.childCount - 1, fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content)));\n}\nfunction contentAt(fragment, depth) {\n for (let i = 0; i < depth; i++)\n fragment = fragment.firstChild.content;\n return fragment;\n}\nfunction closeNodeStart(node, openStart, openEnd) {\n if (openStart <= 0)\n return node;\n let 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)\n frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(Fragment.empty, true));\n }\n return node.copy(frag);\n}\nfunction contentAfterFits($to, depth, type, match, open) {\n let node = $to.node(depth), index = open ? $to.indexAfter(depth) : $to.index(depth);\n if (index == node.childCount && !type.compatibleContent(node.type))\n return null;\n let fit = match.fillBefore(node.content, true, index);\n return fit && !invalidMarks(type, node.content, index) ? fit : null;\n}\nfunction invalidMarks(type, fragment, start) {\n for (let i = start; i < fragment.childCount; i++)\n if (!type.allowsMarks(fragment.child(i).marks))\n return true;\n return false;\n}\nfunction definesContent(type) {\n return type.spec.defining || type.spec.definingForContent;\n}\nfunction replaceRange(tr, from, to, slice) {\n if (!slice.size)\n return tr.deleteRange(from, to);\n let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);\n if (fitsTrivially($from, $to, slice))\n return tr.step(new ReplaceStep(from, to, slice));\n let targetDepths = coveredDepths($from, tr.doc.resolve(to));\n // Can't replace the whole document, so remove 0 if it's present\n if (targetDepths[targetDepths.length - 1] == 0)\n targetDepths.pop();\n // Negative numbers represent not expansion over the whole node at\n // that depth, but replacing from $from.before(-D) to $to.pos.\n let 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 (let d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {\n let spec = $from.node(d).type.spec;\n if (spec.defining || spec.definingAsContext || spec.isolating)\n break;\n if (targetDepths.indexOf(d) > -1)\n preferredTarget = d;\n else if ($from.before(d) == pos)\n targetDepths.splice(1, 0, -d);\n }\n // Try to fit each possible depth of the slice into each possible\n // target depth, starting with the preferred depths.\n let preferredTargetIndex = targetDepths.indexOf(preferredTarget);\n let leftNodes = [], preferredDepth = slice.openStart;\n for (let content = slice.content, i = 0;; i++) {\n let node = content.firstChild;\n leftNodes.push(node);\n if (i == slice.openStart)\n break;\n content = node.content;\n }\n // Back up preferredDepth to cover defining textblocks directly\n // above it, possibly skipping a non-defining textblock.\n for (let d = preferredDepth - 1; d >= 0; d--) {\n let type = leftNodes[d].type, def = definesContent(type);\n if (def && $from.node(preferredTargetIndex).type != type)\n preferredDepth = d;\n else if (def || !type.isTextblock)\n break;\n }\n for (let j = slice.openStart; j >= 0; j--) {\n let openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);\n let insert = leftNodes[openDepth];\n if (!insert)\n continue;\n for (let i = 0; i < targetDepths.length; i++) {\n // Loop over possible expansion levels, starting with the\n // preferred one\n let targetDepth = targetDepths[(i + preferredTargetIndex) % targetDepths.length], expand = true;\n if (targetDepth < 0) {\n expand = false;\n targetDepth = -targetDepth;\n }\n let parent = $from.node(targetDepth - 1), index = $from.index(targetDepth - 1);\n if (parent.canReplaceWith(index, index, insert.type, insert.marks))\n return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice(closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd));\n }\n }\n let startSteps = tr.steps.length;\n for (let i = targetDepths.length - 1; i >= 0; i--) {\n tr.replace(from, to, slice);\n if (tr.steps.length > startSteps)\n break;\n let depth = targetDepths[i];\n if (depth < 0)\n continue;\n from = $from.before(depth);\n to = $to.after(depth);\n }\n}\nfunction closeFragment(fragment, depth, oldOpen, newOpen, parent) {\n if (depth < oldOpen) {\n let first = fragment.firstChild;\n fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));\n }\n if (depth > newOpen) {\n let match = parent.contentMatchAt(0);\n let start = match.fillBefore(fragment).append(fragment);\n fragment = start.append(match.matchFragment(start).fillBefore(Fragment.empty, true));\n }\n return fragment;\n}\nfunction replaceRangeWith(tr, from, to, node) {\n if (!node.isInline && from == to && tr.doc.resolve(from).parent.content.size) {\n let point = insertPoint(tr.doc, from, node.type);\n if (point != null)\n from = to = point;\n }\n tr.replaceRange(from, to, new Slice(Fragment.from(node), 0, 0));\n}\nfunction deleteRange(tr, from, to) {\n let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);\n let covered = coveredDepths($from, $to);\n for (let i = 0; i < covered.length; i++) {\n let depth = covered[i], last = i == covered.length - 1;\n if ((last && depth == 0) || $from.node(depth).type.contentMatch.validEnd)\n return tr.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 tr.delete($from.before(depth), $to.after(depth));\n }\n for (let 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 tr.delete($from.before(d), to);\n }\n tr.delete(from, to);\n}\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 let result = [], minDepth = Math.min($from.depth, $to.depth);\n for (let d = minDepth; d >= 0; d--) {\n let 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)\n 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\n/**\nUpdate an attribute in a specific node.\n*/\nclass AttrStep extends Step {\n /**\n Construct an attribute step.\n */\n constructor(\n /**\n The position of the target node.\n */\n pos, \n /**\n The attribute to set.\n */\n attr, \n // The attribute's new value.\n value) {\n super();\n this.pos = pos;\n this.attr = attr;\n this.value = value;\n }\n apply(doc) {\n let node = doc.nodeAt(this.pos);\n if (!node)\n return StepResult.fail(\"No node at attribute step's position\");\n let attrs = Object.create(null);\n for (let name in node.attrs)\n attrs[name] = node.attrs[name];\n attrs[this.attr] = this.value;\n let updated = node.type.create(attrs, null, node.marks);\n return StepResult.fromReplace(doc, this.pos, this.pos + 1, new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1));\n }\n getMap() {\n return StepMap.empty;\n }\n invert(doc) {\n return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);\n }\n map(mapping) {\n let pos = mapping.mapResult(this.pos, 1);\n return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value);\n }\n toJSON() {\n return { stepType: \"attr\", pos: this.pos, attr: this.attr, value: this.value };\n }\n static fromJSON(schema, json) {\n if (typeof json.pos != \"number\" || typeof json.attr != \"string\")\n throw new RangeError(\"Invalid input for AttrStep.fromJSON\");\n return new AttrStep(json.pos, json.attr, json.value);\n }\n}\nStep.jsonID(\"attr\", AttrStep);\n\n/**\n@internal\n*/\nlet TransformError = class extends Error {\n};\nTransformError = function TransformError(message) {\n let err = Error.call(this, message);\n err.__proto__ = TransformError.prototype;\n return err;\n};\nTransformError.prototype = Object.create(Error.prototype);\nTransformError.prototype.constructor = TransformError;\nTransformError.prototype.name = \"TransformError\";\n/**\nAbstraction to build up and track an array of\n[steps](https://prosemirror.net/docs/ref/#transform.Step) representing a document transformation.\n\nMost transforming methods return the `Transform` object itself, so\nthat they can be chained.\n*/\nclass Transform {\n /**\n Create a transform that starts with the given document.\n */\n constructor(\n /**\n The current document (the result of applying the steps in the\n transform).\n */\n doc) {\n this.doc = doc;\n /**\n The steps in this transform.\n */\n this.steps = [];\n /**\n The documents before each of the steps.\n */\n this.docs = [];\n /**\n A mapping with the maps for each of the steps in this transform.\n */\n this.mapping = new Mapping;\n }\n /**\n The starting document.\n */\n get before() { return this.docs.length ? this.docs[0] : this.doc; }\n /**\n Apply a new step in this transform, saving the result. Throws an\n error when the step fails.\n */\n step(step) {\n let result = this.maybeStep(step);\n if (result.failed)\n throw new TransformError(result.failed);\n return this;\n }\n /**\n Try to apply a step in this transformation, ignoring it if it\n fails. Returns the step result.\n */\n maybeStep(step) {\n let result = step.apply(this.doc);\n if (!result.failed)\n this.addStep(step, result.doc);\n return result;\n }\n /**\n True when the document has been changed (when there are any\n steps).\n */\n get docChanged() {\n return this.steps.length > 0;\n }\n /**\n @internal\n */\n addStep(step, doc) {\n this.docs.push(this.doc);\n this.steps.push(step);\n this.mapping.appendMap(step.getMap());\n this.doc = doc;\n }\n /**\n Replace the part of the document between `from` and `to` with the\n given `slice`.\n */\n replace(from, to = from, slice = Slice.empty) {\n let step = replaceStep(this.doc, from, to, slice);\n if (step)\n this.step(step);\n return this;\n }\n /**\n Replace the given range with the given content, which may be a\n fragment, node, or array of nodes.\n */\n replaceWith(from, to, content) {\n return this.replace(from, to, new Slice(Fragment.from(content), 0, 0));\n }\n /**\n Delete the content between the given positions.\n */\n delete(from, to) {\n return this.replace(from, to, Slice.empty);\n }\n /**\n Insert the given content at the given position.\n */\n insert(pos, content) {\n return this.replaceWith(pos, pos, content);\n }\n /**\n Replace a range of the document with a given slice, using\n `from`, `to`, and the slice's\n [`openStart`](https://prosemirror.net/docs/ref/#model.Slice.openStart) property as hints, rather\n than fixed start and end points. This method may grow the\n replaced area or close open nodes in the slice in order to get a\n fit that is more in line with WYSIWYG expectations, by dropping\n fully covered parent nodes of the replaced region when they are\n marked [non-defining as\n context](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext), or including an\n open parent node from the slice that _is_ marked as [defining\n its content](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).\n \n This is the method, for example, to handle paste. The similar\n [`replace`](https://prosemirror.net/docs/ref/#transform.Transform.replace) method is a more\n primitive tool which will _not_ move the start and end of its given\n range, and is useful in situations where you need more precise\n control over what happens.\n */\n replaceRange(from, to, slice) {\n replaceRange(this, from, to, slice);\n return this;\n }\n /**\n Replace the given range with a node, but use `from` and `to` as\n hints, rather than precise positions. When from and to are the same\n and are at the start or end of a parent node in which the given\n node doesn't fit, this method may _move_ them out towards a parent\n that does allow the given node to be placed. When the given range\n completely covers a parent node, this method may completely replace\n that parent node.\n */\n replaceRangeWith(from, to, node) {\n replaceRangeWith(this, from, to, node);\n return this;\n }\n /**\n Delete the given range, expanding it to cover fully covered\n parent nodes until a valid replace is found.\n */\n deleteRange(from, to) {\n deleteRange(this, from, to);\n return this;\n }\n /**\n Split the content in the given range off from its parent, if there\n is sibling content before or after it, and move it up the tree to\n the depth specified by `target`. You'll probably want to use\n [`liftTarget`](https://prosemirror.net/docs/ref/#transform.liftTarget) to compute `target`, to make\n sure the lift is valid.\n */\n lift(range, target) {\n lift(this, range, target);\n return this;\n }\n /**\n Join the blocks around the given position. If depth is 2, their\n last and first siblings are also joined, and so on.\n */\n join(pos, depth = 1) {\n join(this, pos, depth);\n return this;\n }\n /**\n Wrap the given [range](https://prosemirror.net/docs/ref/#model.NodeRange) in the given set of wrappers.\n The wrappers are assumed to be valid in this position, and should\n probably be computed with [`findWrapping`](https://prosemirror.net/docs/ref/#transform.findWrapping).\n */\n wrap(range, wrappers) {\n wrap(this, range, wrappers);\n return this;\n }\n /**\n Set the type of all textblocks (partly) between `from` and `to` to\n the given node type with the given attributes.\n */\n setBlockType(from, to = from, type, attrs = null) {\n setBlockType(this, from, to, type, attrs);\n return this;\n }\n /**\n Change the type, attributes, and/or marks of the node at `pos`.\n When `type` isn't given, the existing node type is preserved,\n */\n setNodeMarkup(pos, type, attrs = null, marks) {\n setNodeMarkup(this, pos, type, attrs, marks);\n return this;\n }\n /**\n Set a single attribute on a given node to a new value.\n */\n setNodeAttribute(pos, attr, value) {\n this.step(new AttrStep(pos, attr, value));\n return this;\n }\n /**\n Add a mark to the node at position `pos`.\n */\n addNodeMark(pos, mark) {\n this.step(new AddNodeMarkStep(pos, mark));\n return this;\n }\n /**\n Remove a mark (or a mark of the given type) from the node at\n position `pos`.\n */\n removeNodeMark(pos, mark) {\n if (!(mark instanceof Mark)) {\n let node = this.doc.nodeAt(pos);\n if (!node)\n throw new RangeError(\"No node at position \" + pos);\n mark = mark.isInSet(node.marks);\n if (!mark)\n return this;\n }\n this.step(new RemoveNodeMarkStep(pos, mark));\n return this;\n }\n /**\n Split the node at the given position, and optionally, if `depth` is\n greater than one, any number of nodes above that. By default, the\n parts split off will inherit the node type of the original node.\n This can be changed by passing an array of types and attributes to\n use after the split.\n */\n split(pos, depth = 1, typesAfter) {\n split(this, pos, depth, typesAfter);\n return this;\n }\n /**\n Add the given mark to the inline content between `from` and `to`.\n */\n addMark(from, to, mark) {\n addMark(this, from, to, mark);\n return this;\n }\n /**\n Remove marks from inline nodes between `from` and `to`. When\n `mark` is a single mark, remove precisely that mark. When it is\n a mark type, remove all marks of that type. When it is null,\n remove all marks of any type.\n */\n removeMark(from, to, mark) {\n removeMark(this, from, to, mark);\n return this;\n }\n /**\n Removes all marks and nodes from the content of the node at\n `pos` that don't match the given new parent node type. Accepts\n an optional starting [content match](https://prosemirror.net/docs/ref/#model.ContentMatch) as\n third argument.\n */\n clearIncompatible(pos, parentType, match) {\n clearIncompatible(this, pos, parentType, match);\n return this;\n }\n}\n\nexport { AddMarkStep, AddNodeMarkStep, AttrStep, MapResult, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, TransformError, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };\n"],"names":["classesById","Object","create","Selection","constructor","$anchor","$head","ranges","this","SelectionRange","min","max","anchor","pos","head","from","$from","to","$to","empty","i","length","content","doc","slice","replace","tr","lastNode","lastChild","lastParent","openEnd","mapFrom","steps","mapping","replaceRange","map","selectionToInsertionEnd","isInline","isTextblock","replaceWith","node","deleteRange","replaceRangeWith","static","$pos","dir","textOnly","inner","parent","inlineContent","TextSelection","findSelectionIn","index","depth","found","before","after","bias","findFrom","AllSelection","size","childCount","json","type","RangeError","cls","fromJSON","id","selectionClass","prototype","jsonID","getBookmark","between","visible","warnedAboutTextSelection","checkTextSelection","console","name","super","$cursor","resolve","near","marks","marksAcross","ensureMarks","eq","other","TextBookmark","toJSON","dPos","NodeSelection","nodeAfter","$end","nodeSize","deleted","mapResult","NodeBookmark","isText","spec","selectable","isSelectable","delete","sel","atStart","selection","setSelection","AllBookmark","text","child","isAtom","startLen","last","step","end","maps","forEach","_from","_to","_newFrom","newTo","UPDATED_SEL","UPDATED_MARKS","UPDATED_SCROLL","Transaction","state","curSelectionFor","updated","meta","time","Date","now","curSelection","storedMarks","selectionSet","setStoredMarks","addStoredMark","mark","addToSet","removeStoredMark","removeFromSet","storedMarksSet","addStep","setTime","replaceSelection","replaceSelectionWith","inheritMarks","deleteSelection","insertText","schema","setMeta","key","value","getMeta","isGeneric","_","scrollIntoView","scrolledIntoView","bind","f","self","FieldDesc","desc","init","apply","baseFields","config","topNodeType","createAndFill","instance","_marks","_old","prev","Configuration","plugins","pluginsByKey","fields","plugin","push","EditorState","applyTransaction","filterTransaction","ignore","call","rootTr","transactions","trs","newState","applyInner","seen","haveNew","appendTransaction","n","oldState","j","newInstance","field","$config","reconfigure","hasOwnProperty","pluginFields","result","m","prop","markFromJSON","bindProps","obj","target","val","Function","Plugin","props","createKey","getState","keys","PluginKey","get","readFromCache","addToCache","WeakMap","cache","set","cacheSize","cachePos","TableMap","width","height","problems","findCell","curPos","left","top","right","bottom","colCount","nextCell","axis","rectBetween","a","b","leftA","rightA","topA","bottomA","leftB","rightB","topB","bottomB","Math","cellsInRect","rect","row","col","positionAt","table","rowStart","rowEnd","rowEndIndex","computeMap","tableRole","findWidth","mapPos","colWidths","e","rowNode","cellNode","colspan","rowspan","colwidth","attrs","h","start","w","colW","widthIndex","expectedPos","missing","tableMap","badWidths","findBadColWidths","hasRowSpan","rowWidth","prevRow","cell","nodeAt","colWidth","freshColWidth","unshift","getCellAttrs","dom","extraAttrs","widthAttr","getAttribute","widths","test","split","s","Number","getter","getFromDOM","setCellAttrs","join","setter","setDOMAttr","tableNodes","options","cellAttributes","cellAttrs","default","isolating","group","tableGroup","parseDOM","tag","toDOM","table_row","table_cell","cellContent","getAttrs","table_header","tableNodeTypes","cached","nodes","role","tableEditingKey","cellAround","d","cellWrapping","isInTable","selectionCell","$anchorCell","$headCell","$cell","cellNear","firstChild","nodeBefore","pointsAtCell","moveCellForward","inSameTable","$cellA","$cellB","tableStart","moved","removeColSpan","splice","some","addColSpan","columnIsHeader","headerCell","header_cell","CellSelection","cells","filter","p","tableChanged","isRowSelection","rowSelection","isColSelection","colSelection","rows","rowContent","cellRect","extraLeft","extraRight","JSON","stringify","copy","fragment","forEachCell","anchorTop","headTop","anchorBottom","headBottom","anchorRect","headRect","anchorLeft","headLeft","anchorRight","headRight","anchorCell","headCell","CellBookmark","drawCellSelection","class","isCellBoundarySelection","afterFrom","beforeTo","isTextSelectionAcrossCells","fromCellBoundaryNode","toCellBoundaryNode","parentOffset","normalizeSelection","allowTableNodeSelection","normalize","lastCell","fixTablesKey","changedDescendants","old","cur","offset","oldSize","curSize","outer","scan","sameMarkup","nodesBetween","fixTables","check","fixTable","descendants","tablePos","mustAdd","prob","setNodeMarkup","first","add","side","insert","pastedCells","openStart","fitSlice","ensureRectangular","r","append","nodeType","clipCells","newWidth","newHeight","added","newRows","frag","createChecked","source","growTable","types","emptyHead","start2","header","emptyRow","isolateHorizontal","cellTop","cellLeft","isolateVertical","updatePos","insertCells","dispatch","Error","recomp","handleKeyDown","ArrowLeft","arrow","ArrowRight","ArrowUp","ArrowDown","shiftArrow","Backspace","deleteCellSelection","Delete","maybeSetSelection","view","atEndOfCell","$next","newSel","cellSel","baseContent","docChanged","handleTripleClick","handlePaste","handleMouseDown","startEvent","_a","ctrlKey","metaKey","startDOMCell","domInCell","shiftKey","setCellSelection","preventDefault","cellUnderMouse","$anchor2","event","starting","stop","root","removeEventListener","move","_event","addEventListener","indexAfter","cellPos","dirStr","endOfTextblock","parentNode","nodeName","mousePos","posAtCoords","clientX","clientY","TableView","cellMinWidth","document","createElement","className","appendChild","colgroup","updateColumnsOnResize","contentDOM","update","ignoreMutation","record","contains","overrideCol","overrideValue","totalWidth","fixedWidth","nextDOM","hasWidth","cssWidth","style","nextSibling","removeChild","minWidth","columnResizingPluginKey","columnResizing","handleWidth","View","lastColumnResizable","nodeViews","ResizeState","attributes","pluginState","activeHandle","handleDOMEvents","mousemove","handleMouseMove","mouseleave","handleMouseLeave","mousedown","handleMouseDown2","decorations","handleDecorations","dragging","action","setHandle","setDragging","handle","domCellAround","getBoundingClientRect","edgeCell","updateHandle","currentColWidth","finish","event2","window","pluginState2","updateColumnWidth","draggedWidth","which","dragged","displayColumnWidth","startX","startWidth","domAtPos","childNodes","domWidth","offsetWidth","parts","classList","indexOf","mapIndex","zeroes","Array","fill","selectedRect","addColumn","refColumn","addColumnBefore","addColumnAfter","removeColumn","mapStart","deleteColumn","rowIsHeader","addRow","rowPos","refRow","addRowBefore","addRowAfter","removeRow","nextRow","newPos","deleteRow","isEmpty","c","cellsOverlapRectangle","indexTop","indexLeft","indexBottom","indexRight","mergeCells","mergedPos","mergedCell","mapped","splitCell","nodeTypes","splitCellWithType","getCellType","baseAttrs","setCellAttr","deprecated_toggleHeader","isHeaderEnabledByType","cellPositions","toggleHeader","useDeprecatedLogic","isHeaderRowEnabled","isHeaderColumnEnabled","isHeaderEnabled","selectionStartsAt","cellsRect","newType","relativeCellPos","toggleHeaderRow","toggleHeaderColumn","toggleHeaderCell","findNextCell","goToNextCell","direction","deleteTable","tableEditing","createSelectionBetween","lower16","factor16","pow","makeRecover","recoverIndex","recoverOffset","DEL_BEFORE","DEL_AFTER","DEL_ACROSS","DEL_SIDE","MapResult","delInfo","recover","deletedBefore","deletedAfter","deletedAcross","StepMap","inverted","diff","assoc","_map","simple","oldIndex","newIndex","newSize","del","touches","oldStart","newStart","invert","toString","Mapping","mirror","appendMap","mirrors","setMirror","appendMapping","startSize","mirr","getMirror","undefined","appendMappingInverted","totalSize","inverse","corr","stepsByID","Step","getMap","merge","stepType","stepClass","StepResult","failed","message","ok","fail","mapFragment","AddMarkStep","oldSlice","sharedDepth","allowsMarkType","fromReplace","RemoveMarkStep","AddNodeMarkStep","isLeaf","newSet","isInSet","RemoveNodeMarkStep","ReplaceStep","structure","contentBetween","ReplaceAroundStep","gapFrom","gapTo","gap","inserted","insertAt","removeBetween","dist","next","maybeChild","addMark","removing","adding","removed","removeMark","matched","toRemove","clearIncompatible","parentType","match","contentMatch","delSteps","allowed","matchType","validEnd","fillBefore","canCut","canReplace","liftTarget","range","cutByIndex","startIndex","endIndex","lift","gapStart","gapEnd","splitting","findWrapping","innerRange","around","findWrappingOutside","findWrappingInside","withAttrs","concat","contentMatchAt","canReplaceWith","inside","lastType","innerMatch","wrap","wrappers","matchFragment","setBlockType","hasMarkup","canChangeType","startM","endM","newNode","validContent","canSplit","typesAfter","base","innerType","rest","replaceChild","baseType","typeAfter","canJoin","joinable","canAppend","insertPoint","dropPoint","pass","insertPos","fits","wrapping","replaceStep","fitsTrivially","Fitter","fit","unplaced","frontier","placed","findFittable","placeNodes","openMore","dropNode","moveInline","mustMoveInline","placedSize","close","startDepth","sliceDepth","contentAt","frontierDepth","inject","compatibleContent","openAtEnd","dropFromFragment","closeFrontierNode","openFrontierNode","taken","openEndCount","matches","closeNodeStart","allowedMarks","toEnd","addToFragment","level","contentAfterFits","findCloseLevel","dropInner","open","pop","count","invalidMarks","allowsMarks","definesContent","defining","definingForContent","targetDepths","coveredDepths","preferredTarget","definingAsContext","preferredTargetIndex","leftNodes","preferredDepth","def","openDepth","targetDepth","expand","closeFragment","startSteps","oldOpen","newOpen","point","covered","minDepth","AttrStep","attr","TransformError","err","__proto__","Transform","docs","maybeStep","setNodeAttribute","addNodeMark","removeNodeMark"],"sourceRoot":""}