@pie-element/shared-editor-runtime 0.1.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/dist-86k79VvK.js +1829 -0
- package/dist/browser/dist-86k79VvK.js.map +1 -0
- package/dist/browser/dist-BiHYI9ZI.js +3508 -0
- package/dist/browser/dist-BiHYI9ZI.js.map +1 -0
- package/dist/browser/dist-BzUsSMiM.js +933 -0
- package/dist/browser/dist-BzUsSMiM.js.map +1 -0
- package/dist/browser/dist-DlTupuCB.js +8000 -0
- package/dist/browser/dist-DlTupuCB.js.map +1 -0
- package/dist/browser/dist-DyMj6m6j.js +996 -0
- package/dist/browser/dist-DyMj6m6j.js.map +1 -0
- package/dist/browser/prosemirror-state/index.js +2 -0
- package/dist/browser/tiptap-core/index.js +2 -0
- package/dist/browser/tiptap-extension-character-count/index.js +7 -0
- package/dist/browser/tiptap-extension-character-count/index.js.map +1 -0
- package/dist/browser/tiptap-extension-image/index.js +133 -0
- package/dist/browser/tiptap-extension-image/index.js.map +1 -0
- package/dist/browser/tiptap-extension-list-item/index.js +7 -0
- package/dist/browser/tiptap-extension-list-item/index.js.map +1 -0
- package/dist/browser/tiptap-extension-placeholder/index.js +7 -0
- package/dist/browser/tiptap-extension-placeholder/index.js.map +1 -0
- package/dist/browser/tiptap-extension-subscript/index.js +37 -0
- package/dist/browser/tiptap-extension-subscript/index.js.map +1 -0
- package/dist/browser/tiptap-extension-superscript/index.js +37 -0
- package/dist/browser/tiptap-extension-superscript/index.js.map +1 -0
- package/dist/browser/tiptap-extension-table/index.js +2 -0
- package/dist/browser/tiptap-extension-table-cell/index.js +7 -0
- package/dist/browser/tiptap-extension-table-cell/index.js.map +1 -0
- package/dist/browser/tiptap-extension-table-header/index.js +7 -0
- package/dist/browser/tiptap-extension-table-header/index.js.map +1 -0
- package/dist/browser/tiptap-extension-table-row/index.js +7 -0
- package/dist/browser/tiptap-extension-table-row/index.js.map +1 -0
- package/dist/browser/tiptap-extension-text-align/index.js +49 -0
- package/dist/browser/tiptap-extension-text-align/index.js.map +1 -0
- package/dist/browser/tiptap-extension-text-style/index.js +166 -0
- package/dist/browser/tiptap-extension-text-style/index.js.map +1 -0
- package/dist/browser/tiptap-extensions/index.js +2 -0
- package/dist/browser/tiptap-pm-state/index.js +2 -0
- package/dist/browser/tiptap-starter-kit/index.js +1642 -0
- package/dist/browser/tiptap-starter-kit/index.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-86k79VvK.js","names":["TableView"],"sources":["../../../../../node_modules/.bun/prosemirror-tables@1.8.5/node_modules/prosemirror-tables/dist/index.js","../../../../../node_modules/.bun/@tiptap+extension-table@3.31.3+9ea2bbe04937c6bd/node_modules/@tiptap/extension-table/dist/index.js"],"sourcesContent":["import { NodeSelection, Plugin, PluginKey, Selection, SelectionRange, TextSelection } from \"prosemirror-state\";\nimport { Fragment, Slice } from \"prosemirror-model\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport { keydownHandler } from \"prosemirror-keymap\";\nimport { Transform } from \"prosemirror-transform\";\n\n//#region src/tablemap.ts\nlet readFromCache;\nlet addToCache;\nif (typeof WeakMap != \"undefined\") {\n\tlet cache = /* @__PURE__ */ new WeakMap();\n\treadFromCache = (key) => cache.get(key);\n\taddToCache = (key, value) => {\n\t\tcache.set(key, value);\n\t\treturn value;\n\t};\n} else {\n\tconst cache = [];\n\tconst cacheSize = 10;\n\tlet cachePos = 0;\n\treadFromCache = (key) => {\n\t\tfor (let i = 0; i < cache.length; i += 2) if (cache[i] == key) return cache[i + 1];\n\t};\n\taddToCache = (key, value) => {\n\t\tif (cachePos == cacheSize) cachePos = 0;\n\t\tcache[cachePos++] = key;\n\t\treturn cache[cachePos++] = value;\n\t};\n}\n/**\n* A table map describes the structure of a given table. To avoid\n* recomputing them all the time, they are cached per table node. To\n* be able to do that, positions saved in the map are relative to the\n* start of the table, rather than the start of the document.\n*\n* @public\n*/\nvar TableMap = class {\n\tconstructor(width, height, map, problems) {\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\tthis.map = map;\n\t\tthis.problems = problems;\n\t}\n\tfindCell(pos) {\n\t\tfor (let i = 0; i < this.map.length; i++) {\n\t\t\tconst curPos = this.map[i];\n\t\t\tif (curPos != pos) continue;\n\t\t\tconst left = i % this.width;\n\t\t\tconst top = i / this.width | 0;\n\t\t\tlet right = left + 1;\n\t\t\tlet bottom = top + 1;\n\t\t\tfor (let j = 1; right < this.width && this.map[i + j] == curPos; j++) right++;\n\t\t\tfor (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++) bottom++;\n\t\t\treturn {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\tright,\n\t\t\t\tbottom\n\t\t\t};\n\t\t}\n\t\tthrow new RangeError(`No cell with offset ${pos} found`);\n\t}\n\tcolCount(pos) {\n\t\tfor (let i = 0; i < this.map.length; i++) if (this.map[i] == pos) return i % this.width;\n\t\tthrow new RangeError(`No cell with offset ${pos} found`);\n\t}\n\tnextCell(pos, axis, dir) {\n\t\tconst { left, right, top, bottom } = this.findCell(pos);\n\t\tif (axis == \"horiz\") {\n\t\t\tif (dir < 0 ? left == 0 : right == this.width) return null;\n\t\t\treturn this.map[top * this.width + (dir < 0 ? left - 1 : right)];\n\t\t} else {\n\t\t\tif (dir < 0 ? top == 0 : bottom == this.height) return null;\n\t\t\treturn this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];\n\t\t}\n\t}\n\trectBetween(a, b) {\n\t\tconst { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);\n\t\tconst { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);\n\t\treturn {\n\t\t\tleft: Math.min(leftA, leftB),\n\t\t\ttop: Math.min(topA, topB),\n\t\t\tright: Math.max(rightA, rightB),\n\t\t\tbottom: Math.max(bottomA, bottomB)\n\t\t};\n\t}\n\tcellsInRect(rect) {\n\t\tconst result = [];\n\t\tconst seen = {};\n\t\tfor (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {\n\t\t\tconst index = row * this.width + col;\n\t\t\tconst pos = this.map[index];\n\t\t\tif (seen[pos]) continue;\n\t\t\tseen[pos] = true;\n\t\t\tif (col == rect.left && col && this.map[index - 1] == pos || row == rect.top && row && this.map[index - this.width] == pos) continue;\n\t\t\tresult.push(pos);\n\t\t}\n\t\treturn result;\n\t}\n\tpositionAt(row, col, table) {\n\t\tfor (let i = 0, rowStart = 0;; i++) {\n\t\t\tconst rowEnd = rowStart + table.child(i).nodeSize;\n\t\t\tif (i == row) {\n\t\t\t\tlet index = col + row * this.width;\n\t\t\t\tconst rowEndIndex = (row + 1) * this.width;\n\t\t\t\twhile (index < rowEndIndex && this.map[index] < rowStart) index++;\n\t\t\t\treturn index == rowEndIndex ? rowEnd - 1 : this.map[index];\n\t\t\t}\n\t\t\trowStart = rowEnd;\n\t\t}\n\t}\n\tstatic get(table) {\n\t\treturn readFromCache(table) || addToCache(table, computeMap(table));\n\t}\n};\nfunction computeMap(table) {\n\tif (table.type.spec.tableRole != \"table\") throw new RangeError(\"Not a table node: \" + table.type.name);\n\tconst width = findWidth(table), height = table.childCount;\n\tconst map = [];\n\tlet mapPos = 0;\n\tlet problems = null;\n\tconst colWidths = [];\n\tfor (let i = 0, e = width * height; i < e; i++) map[i] = 0;\n\tfor (let row = 0, pos = 0; row < height; row++) {\n\t\tconst rowNode = table.child(row);\n\t\tpos++;\n\t\tfor (let i = 0;; i++) {\n\t\t\twhile (mapPos < map.length && map[mapPos] != 0) mapPos++;\n\t\t\tif (i == rowNode.childCount) break;\n\t\t\tconst cellNode = rowNode.child(i);\n\t\t\tconst { colspan, rowspan, colwidth } = cellNode.attrs;\n\t\t\tfor (let h = 0; h < rowspan; h++) {\n\t\t\t\tif (h + row >= height) {\n\t\t\t\t\t(problems || (problems = [])).push({\n\t\t\t\t\t\ttype: \"overlong_rowspan\",\n\t\t\t\t\t\tpos,\n\t\t\t\t\t\tn: rowspan - h\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst start = mapPos + h * width;\n\t\t\t\tfor (let w = 0; w < colspan; w++) {\n\t\t\t\t\tif (map[start + w] == 0) map[start + w] = pos;\n\t\t\t\t\telse (problems || (problems = [])).push({\n\t\t\t\t\t\ttype: \"collision\",\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tpos,\n\t\t\t\t\t\tn: colspan - w\n\t\t\t\t\t});\n\t\t\t\t\tconst colW = colwidth && colwidth[w];\n\t\t\t\t\tif (colW) {\n\t\t\t\t\t\tconst widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];\n\t\t\t\t\t\tif (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {\n\t\t\t\t\t\t\tcolWidths[widthIndex] = colW;\n\t\t\t\t\t\t\tcolWidths[widthIndex + 1] = 1;\n\t\t\t\t\t\t} else if (prev == colW) colWidths[widthIndex + 1]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapPos += colspan;\n\t\t\tpos += cellNode.nodeSize;\n\t\t}\n\t\tconst expectedPos = (row + 1) * width;\n\t\tlet missing = 0;\n\t\twhile (mapPos < expectedPos) if (map[mapPos++] == 0) missing++;\n\t\tif (missing) (problems || (problems = [])).push({\n\t\t\ttype: \"missing\",\n\t\t\trow,\n\t\t\tn: missing\n\t\t});\n\t\tpos++;\n\t}\n\tif (width === 0 || height === 0) (problems || (problems = [])).push({ type: \"zero_sized\" });\n\tconst tableMap = new TableMap(width, height, map, problems);\n\tlet badWidths = false;\n\tfor (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;\n\tif (badWidths) findBadColWidths(tableMap, colWidths, table);\n\treturn tableMap;\n}\nfunction findWidth(table) {\n\tlet width = -1;\n\tlet hasRowSpan = false;\n\tfor (let row = 0; row < table.childCount; row++) {\n\t\tconst rowNode = table.child(row);\n\t\tlet rowWidth = 0;\n\t\tif (hasRowSpan) for (let j = 0; j < row; j++) {\n\t\t\tconst prevRow = table.child(j);\n\t\t\tfor (let i = 0; i < prevRow.childCount; i++) {\n\t\t\t\tconst cell = prevRow.child(i);\n\t\t\t\tif (j + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;\n\t\t\t}\n\t\t}\n\t\tfor (let i = 0; i < rowNode.childCount; i++) {\n\t\t\tconst cell = rowNode.child(i);\n\t\t\trowWidth += cell.attrs.colspan;\n\t\t\tif (cell.attrs.rowspan > 1) hasRowSpan = true;\n\t\t}\n\t\tif (width == -1) width = rowWidth;\n\t\telse if (width != rowWidth) width = Math.max(width, rowWidth);\n\t}\n\treturn width;\n}\nfunction findBadColWidths(map, colWidths, table) {\n\tif (!map.problems) map.problems = [];\n\tconst seen = {};\n\tfor (let i = 0; i < map.map.length; i++) {\n\t\tconst pos = map.map[i];\n\t\tif (seen[pos]) continue;\n\t\tseen[pos] = true;\n\t\tconst node = table.nodeAt(pos);\n\t\tif (!node) throw new RangeError(`No cell with offset ${pos} found`);\n\t\tlet updated = null;\n\t\tconst attrs = node.attrs;\n\t\tfor (let j = 0; j < attrs.colspan; j++) {\n\t\t\tconst colWidth = colWidths[(i + j) % map.width * 2];\n\t\t\tif (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j] = colWidth;\n\t\t}\n\t\tif (updated) map.problems.unshift({\n\t\t\ttype: \"colwidth mismatch\",\n\t\t\tpos,\n\t\t\tcolwidth: updated\n\t\t});\n\t}\n}\nfunction freshColWidth(attrs) {\n\tif (attrs.colwidth) return attrs.colwidth.slice();\n\tconst result = [];\n\tfor (let i = 0; i < attrs.colspan; i++) result.push(0);\n\treturn result;\n}\n\n//#endregion\n//#region src/schema.ts\nfunction getCellAttrs(dom, extraAttrs) {\n\tif (typeof dom === \"string\") return {};\n\tconst widthAttr = dom.getAttribute(\"data-colwidth\");\n\tconst widths = widthAttr && /^\\d+(,\\d+)*$/.test(widthAttr) ? widthAttr.split(\",\").map((s) => Number(s)) : null;\n\tconst colspan = Number(dom.getAttribute(\"colspan\") || 1);\n\tconst result = {\n\t\tcolspan,\n\t\trowspan: Number(dom.getAttribute(\"rowspan\") || 1),\n\t\tcolwidth: widths && widths.length == colspan ? widths : null\n\t};\n\tfor (const prop in extraAttrs) {\n\t\tconst getter = extraAttrs[prop].getFromDOM;\n\t\tconst value = getter && getter(dom);\n\t\tif (value != null) result[prop] = value;\n\t}\n\treturn result;\n}\nfunction setCellAttrs(node, extraAttrs) {\n\tconst attrs = {};\n\tif (node.attrs.colspan != 1) attrs.colspan = node.attrs.colspan;\n\tif (node.attrs.rowspan != 1) attrs.rowspan = node.attrs.rowspan;\n\tif (node.attrs.colwidth) attrs[\"data-colwidth\"] = node.attrs.colwidth.join(\",\");\n\tfor (const prop in extraAttrs) {\n\t\tconst setter = extraAttrs[prop].setDOMAttr;\n\t\tif (setter) setter(node.attrs[prop], attrs);\n\t}\n\treturn attrs;\n}\nfunction validateColwidth(value) {\n\tif (value === null) return;\n\tif (!Array.isArray(value)) throw new TypeError(\"colwidth must be null or an array\");\n\tfor (const item of value) if (typeof item !== \"number\") throw new TypeError(\"colwidth must be null or an array of numbers\");\n}\n/**\n* This function creates a set of [node\n* specs](http://prosemirror.net/docs/ref/#model.SchemaSpec.nodes) for\n* `table`, `table_row`, and `table_cell` nodes types as used by this\n* module. The result can then be added to the set of nodes when\n* creating a schema.\n*\n* @public\n*/\nfunction tableNodes(options) {\n\tconst extraAttrs = options.cellAttributes || {};\n\tconst cellAttrs = {\n\t\tcolspan: {\n\t\t\tdefault: 1,\n\t\t\tvalidate: \"number\"\n\t\t},\n\t\trowspan: {\n\t\t\tdefault: 1,\n\t\t\tvalidate: \"number\"\n\t\t},\n\t\tcolwidth: {\n\t\t\tdefault: null,\n\t\t\tvalidate: validateColwidth\n\t\t}\n\t};\n\tfor (const prop in extraAttrs) cellAttrs[prop] = {\n\t\tdefault: extraAttrs[prop].default,\n\t\tvalidate: extraAttrs[prop].validate\n\t};\n\treturn {\n\t\ttable: {\n\t\t\tcontent: \"table_row+\",\n\t\t\ttableRole: \"table\",\n\t\t\tisolating: true,\n\t\t\tgroup: options.tableGroup,\n\t\t\tparseDOM: [{ tag: \"table\" }],\n\t\t\ttoDOM() {\n\t\t\t\treturn [\"table\", [\"tbody\", 0]];\n\t\t\t}\n\t\t},\n\t\ttable_row: {\n\t\t\tcontent: \"(table_cell | table_header)*\",\n\t\t\ttableRole: \"row\",\n\t\t\tparseDOM: [{ tag: \"tr\" }],\n\t\t\ttoDOM() {\n\t\t\t\treturn [\"tr\", 0];\n\t\t\t}\n\t\t},\n\t\ttable_cell: {\n\t\t\tcontent: options.cellContent,\n\t\t\tattrs: cellAttrs,\n\t\t\ttableRole: \"cell\",\n\t\t\tisolating: true,\n\t\t\tparseDOM: [{\n\t\t\t\ttag: \"td\",\n\t\t\t\tgetAttrs: (dom) => getCellAttrs(dom, extraAttrs)\n\t\t\t}],\n\t\t\ttoDOM(node) {\n\t\t\t\treturn [\n\t\t\t\t\t\"td\",\n\t\t\t\t\tsetCellAttrs(node, extraAttrs),\n\t\t\t\t\t0\n\t\t\t\t];\n\t\t\t}\n\t\t},\n\t\ttable_header: {\n\t\t\tcontent: options.cellContent,\n\t\t\tattrs: cellAttrs,\n\t\t\ttableRole: \"header_cell\",\n\t\t\tisolating: true,\n\t\t\tparseDOM: [{\n\t\t\t\ttag: \"th\",\n\t\t\t\tgetAttrs: (dom) => getCellAttrs(dom, extraAttrs)\n\t\t\t}],\n\t\t\ttoDOM(node) {\n\t\t\t\treturn [\n\t\t\t\t\t\"th\",\n\t\t\t\t\tsetCellAttrs(node, extraAttrs),\n\t\t\t\t\t0\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\t};\n}\n/**\n* @public\n*/\nfunction tableNodeTypes(schema) {\n\tlet result = schema.cached.tableNodeTypes;\n\tif (!result) {\n\t\tresult = schema.cached.tableNodeTypes = {};\n\t\tfor (const name in schema.nodes) {\n\t\t\tconst type = schema.nodes[name], role = type.spec.tableRole;\n\t\t\tif (role) result[role] = type;\n\t\t}\n\t}\n\treturn result;\n}\n\n//#endregion\n//#region src/util.ts\n/**\n* @public\n*/\nconst tableEditingKey = new PluginKey(\"selectingCells\");\n/**\n* @public\n*/\nfunction cellAround($pos) {\n\tfor (let d = $pos.depth - 1; d > 0; d--) if ($pos.node(d).type.spec.tableRole == \"row\") return $pos.node(0).resolve($pos.before(d + 1));\n\treturn null;\n}\nfunction cellWrapping($pos) {\n\tfor (let d = $pos.depth; d > 0; d--) {\n\t\tconst role = $pos.node(d).type.spec.tableRole;\n\t\tif (role === \"cell\" || role === \"header_cell\") return $pos.node(d);\n\t}\n\treturn null;\n}\n/**\n* @public\n*/\nfunction isInTable(state) {\n\tconst $head = state.selection.$head;\n\tfor (let d = $head.depth; d > 0; d--) if ($head.node(d).type.spec.tableRole == \"row\") return true;\n\treturn false;\n}\n/**\n* @internal\n*/\nfunction selectionCell(state) {\n\tconst sel = state.selection;\n\tif (\"$anchorCell\" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;\n\telse if (\"node\" in sel && sel.node && sel.node.type.spec.tableRole == \"cell\") return sel.$anchor;\n\tconst $cell = cellAround(sel.$head) || cellNear(sel.$head);\n\tif ($cell) return $cell;\n\tthrow new RangeError(`No cell found around position ${sel.head}`);\n}\n/**\n* @public\n*/\nfunction cellNear($pos) {\n\tfor (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {\n\t\tconst role = after.type.spec.tableRole;\n\t\tif (role == \"cell\" || role == \"header_cell\") return $pos.doc.resolve(pos);\n\t}\n\tfor (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {\n\t\tconst role = before.type.spec.tableRole;\n\t\tif (role == \"cell\" || role == \"header_cell\") return $pos.doc.resolve(pos - before.nodeSize);\n\t}\n}\n/**\n* @public\n*/\nfunction pointsAtCell($pos) {\n\treturn $pos.parent.type.spec.tableRole == \"row\" && !!$pos.nodeAfter;\n}\n/**\n* @public\n*/\nfunction moveCellForward($pos) {\n\treturn $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);\n}\n/**\n* @internal\n*/\nfunction inSameTable($cellA, $cellB) {\n\treturn $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);\n}\n/**\n* @public\n*/\nfunction findCell($pos) {\n\treturn TableMap.get($pos.node(-1)).findCell($pos.pos - $pos.start(-1));\n}\n/**\n* @public\n*/\nfunction colCount($pos) {\n\treturn TableMap.get($pos.node(-1)).colCount($pos.pos - $pos.start(-1));\n}\n/**\n* @public\n*/\nfunction nextCell($pos, axis, dir) {\n\tconst table = $pos.node(-1);\n\tconst map = TableMap.get(table);\n\tconst tableStart = $pos.start(-1);\n\tconst moved = map.nextCell($pos.pos - tableStart, axis, dir);\n\treturn moved == null ? null : $pos.node(0).resolve(tableStart + moved);\n}\n/**\n* @public\n*/\nfunction removeColSpan(attrs, pos, n = 1) {\n\tconst result = {\n\t\t...attrs,\n\t\tcolspan: attrs.colspan - n\n\t};\n\tif (result.colwidth) {\n\t\tresult.colwidth = result.colwidth.slice();\n\t\tresult.colwidth.splice(pos, n);\n\t\tif (!result.colwidth.some((w) => w > 0)) result.colwidth = null;\n\t}\n\treturn result;\n}\n/**\n* @public\n*/\nfunction addColSpan(attrs, pos, n = 1) {\n\tconst result = {\n\t\t...attrs,\n\t\tcolspan: attrs.colspan + n\n\t};\n\tif (result.colwidth) {\n\t\tresult.colwidth = result.colwidth.slice();\n\t\tfor (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);\n\t}\n\treturn result;\n}\n/**\n* @public\n*/\nfunction columnIsHeader(map, table, col) {\n\tconst headerCell = tableNodeTypes(table.type.schema).header_cell;\n\tfor (let row = 0; row < map.height; row++) if (table.nodeAt(map.map[col + row * map.width]).type != headerCell) return false;\n\treturn true;\n}\n\n//#endregion\n//#region src/cellselection.ts\n/**\n* A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)\n* subclass that represents a cell selection spanning part of a table.\n* With the plugin enabled, these will be created when the user\n* selects across cells, and will be drawn by giving selected cells a\n* `selectedCell` CSS class.\n*\n* @public\n*/\nvar CellSelection = class CellSelection extends Selection {\n\tconstructor($anchorCell, $headCell = $anchorCell) {\n\t\tconst table = $anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = $anchorCell.start(-1);\n\t\tconst rect = map.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);\n\t\tconst doc = $anchorCell.node(0);\n\t\tconst cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);\n\t\tcells.unshift($headCell.pos - tableStart);\n\t\tconst ranges = cells.map((pos) => {\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tif (!cell) throw new RangeError(`No cell with offset ${pos} found`);\n\t\t\tconst from = tableStart + pos + 1;\n\t\t\treturn new SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));\n\t\t});\n\t\tsuper(ranges[0].$from, ranges[0].$to, ranges);\n\t\tthis.$anchorCell = $anchorCell;\n\t\tthis.$headCell = $headCell;\n\t}\n\tmap(doc, mapping) {\n\t\tconst $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));\n\t\tconst $headCell = doc.resolve(mapping.map(this.$headCell.pos));\n\t\tif (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {\n\t\t\tconst tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);\n\t\t\tif (tableChanged && this.isRowSelection()) return CellSelection.rowSelection($anchorCell, $headCell);\n\t\t\telse if (tableChanged && this.isColSelection()) return CellSelection.colSelection($anchorCell, $headCell);\n\t\t\telse return new CellSelection($anchorCell, $headCell);\n\t\t}\n\t\treturn TextSelection.between($anchorCell, $headCell);\n\t}\n\tcontent() {\n\t\tconst table = this.$anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = this.$anchorCell.start(-1);\n\t\tconst rect = map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);\n\t\tconst seen = {};\n\t\tconst rows = [];\n\t\tfor (let row = rect.top; row < rect.bottom; row++) {\n\t\t\tconst rowContent = [];\n\t\t\tfor (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {\n\t\t\t\tconst pos = map.map[index];\n\t\t\t\tif (seen[pos]) continue;\n\t\t\t\tseen[pos] = true;\n\t\t\t\tconst cellRect = map.findCell(pos);\n\t\t\t\tlet cell = table.nodeAt(pos);\n\t\t\t\tif (!cell) throw new RangeError(`No cell with offset ${pos} found`);\n\t\t\t\tconst extraLeft = rect.left - cellRect.left;\n\t\t\t\tconst extraRight = cellRect.right - rect.right;\n\t\t\t\tif (extraLeft > 0 || extraRight > 0) {\n\t\t\t\t\tlet attrs = cell.attrs;\n\t\t\t\t\tif (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);\n\t\t\t\t\tif (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);\n\t\t\t\t\tif (cellRect.left < rect.left) {\n\t\t\t\t\t\tcell = cell.type.createAndFill(attrs);\n\t\t\t\t\t\tif (!cell) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);\n\t\t\t\t\t} else cell = cell.type.create(attrs, cell.content);\n\t\t\t\t}\n\t\t\t\tif (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {\n\t\t\t\t\tconst attrs = {\n\t\t\t\t\t\t...cell.attrs,\n\t\t\t\t\t\trowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)\n\t\t\t\t\t};\n\t\t\t\t\tif (cellRect.top < rect.top) cell = cell.type.createAndFill(attrs);\n\t\t\t\t\telse cell = cell.type.create(attrs, cell.content);\n\t\t\t\t}\n\t\t\t\trowContent.push(cell);\n\t\t\t}\n\t\t\trows.push(table.child(row).copy(Fragment.from(rowContent)));\n\t\t}\n\t\tconst fragment = this.isColSelection() && this.isRowSelection() ? table : rows;\n\t\treturn new Slice(Fragment.from(fragment), 1, 1);\n\t}\n\treplace(tr, content = Slice.empty) {\n\t\tconst mapFrom = tr.steps.length, ranges = this.ranges;\n\t\tfor (let i = 0; i < ranges.length; i++) {\n\t\t\tconst { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);\n\t\t\ttr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);\n\t\t}\n\t\tconst sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);\n\t\tif (sel) tr.setSelection(sel);\n\t}\n\treplaceWith(tr, node) {\n\t\tthis.replace(tr, new Slice(Fragment.from(node), 0, 0));\n\t}\n\tforEachCell(f) {\n\t\tconst table = this.$anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = this.$anchorCell.start(-1);\n\t\tconst cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));\n\t\tfor (let i = 0; i < cells.length; i++) f(table.nodeAt(cells[i]), tableStart + cells[i]);\n\t}\n\tisColSelection() {\n\t\tconst anchorTop = this.$anchorCell.index(-1);\n\t\tconst headTop = this.$headCell.index(-1);\n\t\tif (Math.min(anchorTop, headTop) > 0) return false;\n\t\tconst anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;\n\t\tconst headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;\n\t\treturn Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;\n\t}\n\tstatic colSelection($anchorCell, $headCell = $anchorCell) {\n\t\tconst table = $anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = $anchorCell.start(-1);\n\t\tconst anchorRect = map.findCell($anchorCell.pos - tableStart);\n\t\tconst headRect = map.findCell($headCell.pos - tableStart);\n\t\tconst doc = $anchorCell.node(0);\n\t\tif (anchorRect.top <= headRect.top) {\n\t\t\tif (anchorRect.top > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.left]);\n\t\t\tif (headRect.bottom < map.height) $headCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + headRect.right - 1]);\n\t\t} else {\n\t\t\tif (headRect.top > 0) $headCell = doc.resolve(tableStart + map.map[headRect.left]);\n\t\t\tif (anchorRect.bottom < map.height) $anchorCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]);\n\t\t}\n\t\treturn new CellSelection($anchorCell, $headCell);\n\t}\n\tisRowSelection() {\n\t\tconst table = this.$anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = this.$anchorCell.start(-1);\n\t\tconst anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);\n\t\tconst headLeft = map.colCount(this.$headCell.pos - tableStart);\n\t\tif (Math.min(anchorLeft, headLeft) > 0) return false;\n\t\tconst anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;\n\t\tconst headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;\n\t\treturn Math.max(anchorRight, headRight) == map.width;\n\t}\n\teq(other) {\n\t\treturn other instanceof CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;\n\t}\n\tstatic rowSelection($anchorCell, $headCell = $anchorCell) {\n\t\tconst table = $anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = $anchorCell.start(-1);\n\t\tconst anchorRect = map.findCell($anchorCell.pos - tableStart);\n\t\tconst headRect = map.findCell($headCell.pos - tableStart);\n\t\tconst doc = $anchorCell.node(0);\n\t\tif (anchorRect.left <= headRect.left) {\n\t\t\tif (anchorRect.left > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.top * map.width]);\n\t\t\tif (headRect.right < map.width) $headCell = doc.resolve(tableStart + map.map[map.width * (headRect.top + 1) - 1]);\n\t\t} else {\n\t\t\tif (headRect.left > 0) $headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);\n\t\t\tif (anchorRect.right < map.width) $anchorCell = doc.resolve(tableStart + map.map[map.width * (anchorRect.top + 1) - 1]);\n\t\t}\n\t\treturn new CellSelection($anchorCell, $headCell);\n\t}\n\ttoJSON() {\n\t\treturn {\n\t\t\ttype: \"cell\",\n\t\t\tanchor: this.$anchorCell.pos,\n\t\t\thead: this.$headCell.pos\n\t\t};\n\t}\n\tstatic fromJSON(doc, json) {\n\t\treturn new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));\n\t}\n\tstatic create(doc, anchorCell, headCell = anchorCell) {\n\t\treturn new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));\n\t}\n\tgetBookmark() {\n\t\treturn new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);\n\t}\n};\nCellSelection.prototype.visible = false;\nSelection.jsonID(\"cell\", CellSelection);\n/**\n* @public\n*/\nvar CellBookmark = class CellBookmark {\n\tconstructor(anchor, head) {\n\t\tthis.anchor = anchor;\n\t\tthis.head = head;\n\t}\n\tmap(mapping) {\n\t\treturn new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));\n\t}\n\tresolve(doc) {\n\t\tconst $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);\n\t\tif ($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)) return new CellSelection($anchorCell, $headCell);\n\t\telse return Selection.near($headCell, 1);\n\t}\n};\nfunction drawCellSelection(state) {\n\tif (!(state.selection instanceof CellSelection)) return null;\n\tconst cells = [];\n\tstate.selection.forEachCell((node, pos) => {\n\t\tcells.push(Decoration.node(pos, pos + node.nodeSize, { class: \"selectedCell\" }));\n\t});\n\treturn DecorationSet.create(state.doc, cells);\n}\nfunction isCellBoundarySelection({ $from, $to }) {\n\tif ($from.pos == $to.pos || $from.pos < $to.pos - 6) return false;\n\tlet afterFrom = $from.pos;\n\tlet beforeTo = $to.pos;\n\tlet depth = $from.depth;\n\tfor (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;\n\tfor (let d = $to.depth; d >= 0; d--, beforeTo--) if ($to.before(d + 1) > $to.start(d)) break;\n\treturn afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);\n}\nfunction isTextSelectionAcrossCells({ $from, $to }) {\n\tlet fromCellBoundaryNode;\n\tlet toCellBoundaryNode;\n\tfor (let i = $from.depth; i > 0; i--) {\n\t\tconst node = $from.node(i);\n\t\tif (node.type.spec.tableRole === \"cell\" || node.type.spec.tableRole === \"header_cell\") {\n\t\t\tfromCellBoundaryNode = node;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (let i = $to.depth; i > 0; i--) {\n\t\tconst node = $to.node(i);\n\t\tif (node.type.spec.tableRole === \"cell\" || node.type.spec.tableRole === \"header_cell\") {\n\t\t\ttoCellBoundaryNode = node;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;\n}\nfunction normalizeSelection(state, tr, allowTableNodeSelection) {\n\tconst sel = (tr || state).selection;\n\tconst doc = (tr || state).doc;\n\tlet normalize;\n\tlet role;\n\tif (sel instanceof NodeSelection && (role = sel.node.type.spec.tableRole)) {\n\t\tif (role == \"cell\" || role == \"header_cell\") normalize = CellSelection.create(doc, sel.from);\n\t\telse if (role == \"row\") {\n\t\t\tconst $cell = doc.resolve(sel.from + 1);\n\t\t\tnormalize = CellSelection.rowSelection($cell, $cell);\n\t\t} else if (!allowTableNodeSelection) {\n\t\t\tconst map = TableMap.get(sel.node);\n\t\t\tconst start = sel.from + 1;\n\t\t\tconst lastCell = start + map.map[map.width * map.height - 1];\n\t\t\tnormalize = CellSelection.create(doc, start + 1, lastCell);\n\t\t}\n\t} else if (sel instanceof TextSelection && isCellBoundarySelection(sel)) normalize = TextSelection.create(doc, sel.from);\n\telse if (sel instanceof TextSelection && isTextSelectionAcrossCells(sel)) normalize = TextSelection.create(doc, sel.$from.start(), sel.$from.end());\n\tif (normalize) (tr || (tr = state.tr)).setSelection(normalize);\n\treturn tr;\n}\n\n//#endregion\n//#region src/fixtables.ts\n/**\n* @public\n*/\nconst fixTablesKey = new PluginKey(\"fix-tables\");\n/**\n* Helper for iterating through the nodes in a document that changed\n* compared to the given previous document. Useful for avoiding\n* duplicate work on each transaction.\n*\n* @public\n*/\nfunction changedDescendants(old, cur, offset, f) {\n\tconst oldSize = old.childCount, curSize = cur.childCount;\n\touter: for (let i = 0, j = 0; i < curSize; i++) {\n\t\tconst child = cur.child(i);\n\t\tfor (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {\n\t\t\tj = scan + 1;\n\t\t\toffset += child.nodeSize;\n\t\t\tcontinue outer;\n\t\t}\n\t\tf(child, offset);\n\t\tif (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child, offset + 1, f);\n\t\telse child.nodesBetween(0, child.content.size, f, offset + 1);\n\t\toffset += child.nodeSize;\n\t}\n}\n/**\n* Inspect all tables in the given state's document and return a\n* transaction that fixes them, if necessary. If `oldState` was\n* provided, that is assumed to hold a previous, known-good state,\n* which will be used to avoid re-scanning unchanged parts of the\n* document.\n*\n* @public\n*/\nfunction fixTables(state, oldState) {\n\tlet tr;\n\tconst check = (node, pos) => {\n\t\tif (node.type.spec.tableRole == \"table\") tr = fixTable(state, node, pos, tr);\n\t};\n\tif (!oldState) state.doc.descendants(check);\n\telse if (oldState.doc != state.doc) changedDescendants(oldState.doc, state.doc, 0, check);\n\treturn tr;\n}\nfunction fixTable(state, table, tablePos, tr) {\n\tconst map = TableMap.get(table);\n\tif (!map.problems) return tr;\n\tif (!tr) tr = state.tr;\n\tconst mustAdd = [];\n\tfor (let i = 0; i < map.height; i++) mustAdd.push(0);\n\tfor (let i = 0; i < map.problems.length; i++) {\n\t\tconst prob = map.problems[i];\n\t\tif (prob.type == \"collision\") {\n\t\t\tconst cell = table.nodeAt(prob.pos);\n\t\t\tif (!cell) continue;\n\t\t\tconst attrs = cell.attrs;\n\t\t\tfor (let j = 0; j < attrs.rowspan; j++) mustAdd[prob.row + j] += prob.n;\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));\n\t\t} else if (prob.type == \"missing\") mustAdd[prob.row] += prob.n;\n\t\telse if (prob.type == \"overlong_rowspan\") {\n\t\t\tconst cell = table.nodeAt(prob.pos);\n\t\t\tif (!cell) continue;\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {\n\t\t\t\t...cell.attrs,\n\t\t\t\trowspan: cell.attrs.rowspan - prob.n\n\t\t\t});\n\t\t} else if (prob.type == \"colwidth mismatch\") {\n\t\t\tconst cell = table.nodeAt(prob.pos);\n\t\t\tif (!cell) continue;\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {\n\t\t\t\t...cell.attrs,\n\t\t\t\tcolwidth: prob.colwidth\n\t\t\t});\n\t\t} else if (prob.type == \"zero_sized\") {\n\t\t\tconst pos = tr.mapping.map(tablePos);\n\t\t\ttr.delete(pos, pos + table.nodeSize);\n\t\t}\n\t}\n\tlet first, last;\n\tfor (let i = 0; i < mustAdd.length; i++) if (mustAdd[i]) {\n\t\tif (first == null) first = i;\n\t\tlast = i;\n\t}\n\tfor (let i = 0, pos = tablePos + 1; i < map.height; i++) {\n\t\tconst row = table.child(i);\n\t\tconst end = pos + row.nodeSize;\n\t\tconst add = mustAdd[i];\n\t\tif (add > 0) {\n\t\t\tlet role = \"cell\";\n\t\t\tif (row.firstChild) role = row.firstChild.type.spec.tableRole;\n\t\t\tconst nodes = [];\n\t\t\tfor (let j = 0; j < add; j++) {\n\t\t\t\tconst node = tableNodeTypes(state.schema)[role].createAndFill();\n\t\t\t\tif (node) nodes.push(node);\n\t\t\t}\n\t\t\tconst side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;\n\t\t\ttr.insert(tr.mapping.map(side), nodes);\n\t\t}\n\t\tpos = end;\n\t}\n\treturn tr.setMeta(fixTablesKey, { fixTables: true });\n}\n\n//#endregion\n//#region src/utils/convert.ts\n/**\n* This function will transform the table node into a matrix of rows and columns\n* respecting merged cells, for example this table:\n*\n* ```\n* ┌──────┬──────┬─────────────┐\n* │ A1 │ B1 │ C1 │\n* ├──────┼──────┴──────┬──────┤\n* │ A2 │ B2 │ │\n* ├──────┼─────────────┤ D1 │\n* │ A3 │ B3 │ C3 │ │\n* └──────┴──────┴──────┴──────┘\n* ```\n*\n* will be converted to the below:\n*\n* ```javascript\n* [\n* [A1, B1, C1, null],\n* [A2, B2, null, D1],\n* [A3, B3, C3, null],\n* ]\n* ```\n* @internal\n*/\nfunction convertTableNodeToArrayOfRows(tableNode) {\n\tconst map = TableMap.get(tableNode);\n\tconst rows = [];\n\tconst rowCount = map.height;\n\tconst colCount$1 = map.width;\n\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\tconst row = [];\n\t\tfor (let colIndex = 0; colIndex < colCount$1; colIndex++) {\n\t\t\tconst cellIndex = rowIndex * colCount$1 + colIndex;\n\t\t\tconst cellPos = map.map[cellIndex];\n\t\t\tif (rowIndex > 0) {\n\t\t\t\tconst topCellIndex = cellIndex - colCount$1;\n\t\t\t\tif (cellPos === map.map[topCellIndex]) {\n\t\t\t\t\trow.push(null);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (colIndex > 0) {\n\t\t\t\tconst leftCellIndex = cellIndex - 1;\n\t\t\t\tif (cellPos === map.map[leftCellIndex]) {\n\t\t\t\t\trow.push(null);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\trow.push(tableNode.nodeAt(cellPos));\n\t\t}\n\t\trows.push(row);\n\t}\n\treturn rows;\n}\n/**\n* Convert an array of rows to a table node.\n*\n* @internal\n*/\nfunction convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {\n\tconst newRows = [];\n\tconst map = TableMap.get(tableNode);\n\tconst rowCount = map.height;\n\tconst colCount$1 = map.width;\n\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\tconst oldRow = tableNode.child(rowIndex);\n\t\tconst newCells = [];\n\t\tfor (let colIndex = 0; colIndex < colCount$1; colIndex++) {\n\t\t\tconst cell = arrayOfNodes[rowIndex][colIndex];\n\t\t\tif (!cell) continue;\n\t\t\tconst cellPos = map.map[rowIndex * map.width + colIndex];\n\t\t\tconst oldCell = tableNode.nodeAt(cellPos);\n\t\t\tif (!oldCell) continue;\n\t\t\tconst newCell = oldCell.type.createChecked(cell.attrs, cell.content, cell.marks);\n\t\t\tnewCells.push(newCell);\n\t\t}\n\t\tconst newRow = oldRow.type.createChecked(oldRow.attrs, newCells, oldRow.marks);\n\t\tnewRows.push(newRow);\n\t}\n\treturn tableNode.type.createChecked(tableNode.attrs, newRows, tableNode.marks);\n}\n\n//#endregion\n//#region src/utils/move-row-in-array-of-rows.ts\n/**\n* Move a row in an array of rows.\n*\n* @internal\n*/\nfunction moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, directionOverride) {\n\tconst direction = indexesOrigin[0] > indexesTarget[0] ? -1 : 1;\n\tconst rowsExtracted = rows.splice(indexesOrigin[0], indexesOrigin.length);\n\tconst positionOffset = rowsExtracted.length % 2 === 0 ? 1 : 0;\n\tlet target;\n\tif (directionOverride === -1 && direction === 1) target = indexesTarget[0] - 1;\n\telse if (directionOverride === 1 && direction === -1) target = indexesTarget[indexesTarget.length - 1] - positionOffset + 1;\n\telse target = direction === -1 ? indexesTarget[0] : indexesTarget[indexesTarget.length - 1] - positionOffset;\n\trows.splice(target, 0, ...rowsExtracted);\n\treturn rows;\n}\n\n//#endregion\n//#region src/utils/query.ts\n/**\n* Checks if the given object is a `CellSelection` instance.\n*\n* @internal\n*/\nfunction isCellSelection(value) {\n\treturn value instanceof CellSelection;\n}\n/**\n* Find the closest table node for a given position.\n*\n* @public\n*/\nfunction findTable($pos) {\n\treturn findParentNode((node) => node.type.spec.tableRole === \"table\", $pos);\n}\n/**\n* Try to find the anchor and head cell in the same table by using the given\n* anchor and head as hit points, or fallback to the selection's anchor and\n* head.\n*\n* @public\n*/\nfunction findCellRange(selection, anchorHit, headHit) {\n\tvar _ref, _ref2;\n\tif (anchorHit == null && headHit == null && isCellSelection(selection)) return [selection.$anchorCell, selection.$headCell];\n\tconst anchor = (_ref = anchorHit !== null && anchorHit !== void 0 ? anchorHit : headHit) !== null && _ref !== void 0 ? _ref : selection.anchor;\n\tconst head = (_ref2 = headHit !== null && headHit !== void 0 ? headHit : anchorHit) !== null && _ref2 !== void 0 ? _ref2 : selection.head;\n\tconst doc = selection.$head.doc;\n\tconst $anchorCell = findCellPos(doc, anchor);\n\tconst $headCell = findCellPos(doc, head);\n\tif ($anchorCell && $headCell && inSameTable($anchorCell, $headCell)) return [$anchorCell, $headCell];\n\treturn null;\n}\n/**\n* Try to find a resolved pos of a cell by using the given pos as a hit point.\n*\n* @public\n*/\nfunction findCellPos(doc, pos) {\n\tconst $pos = doc.resolve(pos);\n\treturn cellAround($pos) || cellNear($pos);\n}\n/**\n* Find the closest parent node that satisfies the predicate.\n*\n* @internal\n*/\nfunction findParentNode(predicate, $pos) {\n\tfor (let depth = $pos.depth; depth >= 0; depth -= 1) {\n\t\tconst node = $pos.node(depth);\n\t\tif (predicate(node)) return {\n\t\t\tnode,\n\t\t\tpos: depth === 0 ? 0 : $pos.before(depth),\n\t\t\tstart: $pos.start(depth),\n\t\t\tdepth\n\t\t};\n\t}\n\treturn null;\n}\n\n//#endregion\n//#region src/utils/get-cells.ts\n/**\n* Returns an array of cells in a column at the specified column index.\n*\n* @internal\n*/\nfunction getCellsInColumn(columnIndex, selection) {\n\tconst table = findTable(selection.$from);\n\tif (!table) return;\n\tconst map = TableMap.get(table.node);\n\tif (columnIndex < 0 || columnIndex > map.width - 1) return;\n\treturn map.cellsInRect({\n\t\tleft: columnIndex,\n\t\tright: columnIndex + 1,\n\t\ttop: 0,\n\t\tbottom: map.height\n\t}).map((nodePos) => {\n\t\tconst node = table.node.nodeAt(nodePos);\n\t\tconst pos = nodePos + table.start;\n\t\treturn {\n\t\t\tpos,\n\t\t\tstart: pos + 1,\n\t\t\tnode,\n\t\t\tdepth: table.depth + 2\n\t\t};\n\t});\n}\n/**\n* Returns an array of cells in a row at the specified row index.\n*\n* @internal\n*/\nfunction getCellsInRow(rowIndex, selection) {\n\tconst table = findTable(selection.$from);\n\tif (!table) return;\n\tconst map = TableMap.get(table.node);\n\tif (rowIndex < 0 || rowIndex > map.height - 1) return;\n\treturn map.cellsInRect({\n\t\tleft: 0,\n\t\tright: map.width,\n\t\ttop: rowIndex,\n\t\tbottom: rowIndex + 1\n\t}).map((nodePos) => {\n\t\tconst node = table.node.nodeAt(nodePos);\n\t\tconst pos = nodePos + table.start;\n\t\treturn {\n\t\t\tpos,\n\t\t\tstart: pos + 1,\n\t\t\tnode,\n\t\t\tdepth: table.depth + 2\n\t\t};\n\t});\n}\n\n//#endregion\n//#region src/utils/selection-range.ts\n/**\n* Returns a range of rectangular selection spanning all merged cells around a\n* column at index `columnIndex`.\n*\n* Original implementation from Atlassian (Apache License 2.0)\n*\n* https://bitbucket.org/atlassian/atlassian-frontend-mirror/src/5f91cb871e8248bc3bae5ddc30bb9fd9200fadbb/editor/editor-tables/src/utils/get-selection-range-in-column.ts#editor/editor-tables/src/utils/get-selection-range-in-column.ts\n*\n* @internal\n*/\nfunction getSelectionRangeInColumn(tr, startColIndex, endColIndex = startColIndex) {\n\tlet startIndex = startColIndex;\n\tlet endIndex = endColIndex;\n\tfor (let i = startColIndex; i >= 0; i--) {\n\t\tconst cells = getCellsInColumn(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.colspan + i - 1;\n\t\t\tif (maybeEndIndex >= startIndex) startIndex = i;\n\t\t\tif (maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tfor (let i = startColIndex; i <= endIndex; i++) {\n\t\tconst cells = getCellsInColumn(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.colspan + i - 1;\n\t\t\tif (cell.node.attrs.colspan > 1 && maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tconst indexes = [];\n\tfor (let i = startIndex; i <= endIndex; i++) {\n\t\tconst maybeCells = getCellsInColumn(i, tr.selection);\n\t\tif (maybeCells && maybeCells.length > 0) indexes.push(i);\n\t}\n\tstartIndex = indexes[0];\n\tendIndex = indexes[indexes.length - 1];\n\tconst firstSelectedColumnCells = getCellsInColumn(startIndex, tr.selection);\n\tconst firstRowCells = getCellsInRow(0, tr.selection);\n\tif (!firstSelectedColumnCells || !firstRowCells) return;\n\tconst $anchor = tr.doc.resolve(firstSelectedColumnCells[firstSelectedColumnCells.length - 1].pos);\n\tlet headCell;\n\tfor (let i = endIndex; i >= startIndex; i--) {\n\t\tconst columnCells = getCellsInColumn(i, tr.selection);\n\t\tif (columnCells && columnCells.length > 0) {\n\t\t\tfor (let j = firstRowCells.length - 1; j >= 0; j--) if (firstRowCells[j].pos === columnCells[0].pos) {\n\t\t\t\theadCell = columnCells[0];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (headCell) break;\n\t\t}\n\t}\n\tif (!headCell) return;\n\treturn {\n\t\t$anchor,\n\t\t$head: tr.doc.resolve(headCell.pos),\n\t\tindexes\n\t};\n}\n/**\n* Returns a range of rectangular selection spanning all merged cells around a\n* row at index `rowIndex`.\n*\n* Original implementation from Atlassian (Apache License 2.0)\n*\n* https://bitbucket.org/atlassian/atlassian-frontend-mirror/src/5f91cb871e8248bc3bae5ddc30bb9fd9200fadbb/editor/editor-tables/src/utils/get-selection-range-in-row.ts#editor/editor-tables/src/utils/get-selection-range-in-row.ts\n*\n* @internal\n*/\nfunction getSelectionRangeInRow(tr, startRowIndex, endRowIndex = startRowIndex) {\n\tlet startIndex = startRowIndex;\n\tlet endIndex = endRowIndex;\n\tfor (let i = startRowIndex; i >= 0; i--) {\n\t\tconst cells = getCellsInRow(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.rowspan + i - 1;\n\t\t\tif (maybeEndIndex >= startIndex) startIndex = i;\n\t\t\tif (maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tfor (let i = startRowIndex; i <= endIndex; i++) {\n\t\tconst cells = getCellsInRow(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.rowspan + i - 1;\n\t\t\tif (cell.node.attrs.rowspan > 1 && maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tconst indexes = [];\n\tfor (let i = startIndex; i <= endIndex; i++) {\n\t\tconst maybeCells = getCellsInRow(i, tr.selection);\n\t\tif (maybeCells && maybeCells.length > 0) indexes.push(i);\n\t}\n\tstartIndex = indexes[0];\n\tendIndex = indexes[indexes.length - 1];\n\tconst firstSelectedRowCells = getCellsInRow(startIndex, tr.selection);\n\tconst firstColumnCells = getCellsInColumn(0, tr.selection);\n\tif (!firstSelectedRowCells || !firstColumnCells) return;\n\tconst $anchor = tr.doc.resolve(firstSelectedRowCells[firstSelectedRowCells.length - 1].pos);\n\tlet headCell;\n\tfor (let i = endIndex; i >= startIndex; i--) {\n\t\tconst rowCells = getCellsInRow(i, tr.selection);\n\t\tif (rowCells && rowCells.length > 0) {\n\t\t\tfor (let j = firstColumnCells.length - 1; j >= 0; j--) if (firstColumnCells[j].pos === rowCells[0].pos) {\n\t\t\t\theadCell = rowCells[0];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (headCell) break;\n\t\t}\n\t}\n\tif (!headCell) return;\n\treturn {\n\t\t$anchor,\n\t\t$head: tr.doc.resolve(headCell.pos),\n\t\tindexes\n\t};\n}\n\n//#endregion\n//#region src/utils/transpose.ts\n/**\n* Transposes a 2D array by flipping columns to rows.\n*\n* Transposition is a familiar algebra concept where the matrix is flipped\n* along its diagonal. For more details, see:\n* https://en.wikipedia.org/wiki/Transpose\n*\n* @example\n* ```javascript\n* const arr = [\n* ['a1', 'a2', 'a3'],\n* ['b1', 'b2', 'b3'],\n* ['c1', 'c2', 'c3'],\n* ['d1', 'd2', 'd3'],\n* ];\n*\n* const result = transpose(arr);\n* result === [\n* ['a1', 'b1', 'c1', 'd1'],\n* ['a2', 'b2', 'c2', 'd2'],\n* ['a3', 'b3', 'c3', 'd3'],\n* ]\n* ```\n*/\nfunction transpose(array) {\n\treturn array[0].map((_, i) => {\n\t\treturn array.map((column) => column[i]);\n\t});\n}\n\n//#endregion\n//#region src/utils/move-column.ts\n/**\n* Move a column from index `origin` to index `target`.\n*\n* @internal\n*/\nfunction moveColumn(moveColParams) {\n\tvar _getSelectionRangeInC, _getSelectionRangeInC2;\n\tconst { tr, originIndex, targetIndex, select, pos } = moveColParams;\n\tconst table = findTable(tr.doc.resolve(pos));\n\tif (!table) return false;\n\tconst indexesOriginColumn = (_getSelectionRangeInC = getSelectionRangeInColumn(tr, originIndex)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.indexes;\n\tconst indexesTargetColumn = (_getSelectionRangeInC2 = getSelectionRangeInColumn(tr, targetIndex)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.indexes;\n\tif (!indexesOriginColumn || !indexesTargetColumn) return false;\n\tif (indexesOriginColumn.includes(targetIndex)) return false;\n\tconst newTable = moveTableColumn$1(table.node, indexesOriginColumn, indexesTargetColumn, 0);\n\ttr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);\n\tif (!select) return true;\n\tconst map = TableMap.get(newTable);\n\tconst start = table.start;\n\tconst index = targetIndex;\n\tconst lastCell = map.positionAt(map.height - 1, index, newTable);\n\tconst $lastCell = tr.doc.resolve(start + lastCell);\n\tconst firstCell = map.positionAt(0, index, newTable);\n\tconst $firstCell = tr.doc.resolve(start + firstCell);\n\ttr.setSelection(CellSelection.colSelection($lastCell, $firstCell));\n\treturn true;\n}\nfunction moveTableColumn$1(table, indexesOrigin, indexesTarget, direction) {\n\tlet rows = transpose(convertTableNodeToArrayOfRows(table));\n\trows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);\n\trows = transpose(rows);\n\treturn convertArrayOfRowsToTableNode(table, rows);\n}\n\n//#endregion\n//#region src/utils/move-row.ts\n/**\n* Move a row from index `origin` to index `target`.\n*\n* @internal\n*/\nfunction moveRow(moveRowParams) {\n\tvar _getSelectionRangeInR, _getSelectionRangeInR2;\n\tconst { tr, originIndex, targetIndex, select, pos } = moveRowParams;\n\tconst table = findTable(tr.doc.resolve(pos));\n\tif (!table) return false;\n\tconst indexesOriginRow = (_getSelectionRangeInR = getSelectionRangeInRow(tr, originIndex)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.indexes;\n\tconst indexesTargetRow = (_getSelectionRangeInR2 = getSelectionRangeInRow(tr, targetIndex)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.indexes;\n\tif (!indexesOriginRow || !indexesTargetRow) return false;\n\tif (indexesOriginRow.includes(targetIndex)) return false;\n\tconst newTable = moveTableRow$1(table.node, indexesOriginRow, indexesTargetRow, 0);\n\ttr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);\n\tif (!select) return true;\n\tconst map = TableMap.get(newTable);\n\tconst start = table.start;\n\tconst index = targetIndex;\n\tconst lastCell = map.positionAt(index, map.width - 1, newTable);\n\tconst $lastCell = tr.doc.resolve(start + lastCell);\n\tconst firstCell = map.positionAt(index, 0, newTable);\n\tconst $firstCell = tr.doc.resolve(start + firstCell);\n\ttr.setSelection(CellSelection.rowSelection($lastCell, $firstCell));\n\treturn true;\n}\nfunction moveTableRow$1(table, indexesOrigin, indexesTarget, direction) {\n\tlet rows = convertTableNodeToArrayOfRows(table);\n\trows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);\n\treturn convertArrayOfRowsToTableNode(table, rows);\n}\n\n//#endregion\n//#region src/commands.ts\n/**\n* Helper to get the selected rectangle in a table, if any. Adds table\n* map, table node, and table start offset to the object for\n* convenience.\n*\n* @public\n*/\nfunction selectedRect(state) {\n\tconst sel = state.selection;\n\tconst $pos = selectionCell(state);\n\tconst table = $pos.node(-1);\n\tconst tableStart = $pos.start(-1);\n\tconst map = TableMap.get(table);\n\treturn {\n\t\t...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),\n\t\ttableStart,\n\t\tmap,\n\t\ttable\n\t};\n}\n/**\n* Add a column at the given position in a table.\n*\n* @public\n*/\nfunction addColumn(tr, { map, tableStart, table }, col) {\n\tlet refColumn = col > 0 ? -1 : 0;\n\tif (columnIsHeader(map, table, col + refColumn)) refColumn = col == 0 || col == map.width ? null : 0;\n\tfor (let row = 0; row < map.height; row++) {\n\t\tconst index = row * map.width + col;\n\t\tif (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {\n\t\t\tconst pos = map.map[index];\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map.colCount(pos)));\n\t\t\trow += cell.attrs.rowspan - 1;\n\t\t} else {\n\t\t\tconst type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;\n\t\t\tconst pos = map.positionAt(row, col, table);\n\t\t\ttr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());\n\t\t}\n\t}\n\treturn tr;\n}\n/**\n* Command to add a column before the column with the selection.\n*\n* @public\n*/\nfunction addColumnBefore(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addColumn(state.tr, rect, rect.left));\n\t}\n\treturn true;\n}\n/**\n* Command to add a column after the column with the selection.\n*\n* @public\n*/\nfunction addColumnAfter(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addColumn(state.tr, rect, rect.right));\n\t}\n\treturn true;\n}\n/**\n* @public\n*/\nfunction removeColumn(tr, { map, table, tableStart }, col) {\n\tconst mapStart = tr.mapping.maps.length;\n\tfor (let row = 0; row < map.height;) {\n\t\tconst index = row * map.width + col;\n\t\tconst pos = map.map[index];\n\t\tconst cell = table.nodeAt(pos);\n\t\tconst attrs = cell.attrs;\n\t\tif (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map.colCount(pos)));\n\t\telse {\n\t\t\tconst start = tr.mapping.slice(mapStart).map(tableStart + pos);\n\t\t\ttr.delete(start, start + cell.nodeSize);\n\t\t}\n\t\trow += attrs.rowspan;\n\t}\n}\n/**\n* Command function that removes the selected columns from a table.\n*\n* @public\n*/\nfunction deleteColumn(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tconst tr = state.tr;\n\t\tif (rect.left == 0 && rect.right == rect.map.width) return false;\n\t\tfor (let i = rect.right - 1;; i--) {\n\t\t\tremoveColumn(tr, rect, i);\n\t\t\tif (i == rect.left) break;\n\t\t\tconst table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n\t\t\tif (!table) throw new RangeError(\"No table found\");\n\t\t\trect.table = table;\n\t\t\trect.map = TableMap.get(table);\n\t\t}\n\t\tdispatch(tr);\n\t}\n\treturn true;\n}\n/**\n* @public\n*/\nfunction rowIsHeader(map, table, row) {\n\tvar _table$nodeAt;\n\tconst headerCell = tableNodeTypes(table.type.schema).header_cell;\n\tfor (let col = 0; col < map.width; col++) if (((_table$nodeAt = table.nodeAt(map.map[col + row * map.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;\n\treturn true;\n}\n/**\n* @public\n*/\nfunction addRow(tr, { map, tableStart, table }, row) {\n\tlet rowPos = tableStart;\n\tfor (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;\n\tconst cells = [];\n\tlet refRow = row > 0 ? -1 : 0;\n\tif (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0;\n\tfor (let col = 0, index = map.width * row; col < map.width; col++, index++) if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {\n\t\tconst pos = map.map[index];\n\t\tconst attrs = table.nodeAt(pos).attrs;\n\t\ttr.setNodeMarkup(tableStart + pos, null, {\n\t\t\t...attrs,\n\t\t\trowspan: attrs.rowspan + 1\n\t\t});\n\t\tcol += attrs.colspan - 1;\n\t} else {\n\t\tvar _table$nodeAt2;\n\t\tconst type = refRow == null ? tableNodeTypes(table.type.schema).cell : (_table$nodeAt2 = table.nodeAt(map.map[index + refRow * map.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;\n\t\tconst node = type === null || type === void 0 ? void 0 : type.createAndFill();\n\t\tif (node) cells.push(node);\n\t}\n\ttr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));\n\treturn tr;\n}\n/**\n* Add a table row before the selection.\n*\n* @public\n*/\nfunction addRowBefore(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addRow(state.tr, rect, rect.top));\n\t}\n\treturn true;\n}\n/**\n* Add a table row after the selection.\n*\n* @public\n*/\nfunction addRowAfter(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addRow(state.tr, rect, rect.bottom));\n\t}\n\treturn true;\n}\n/**\n* @public\n*/\nfunction removeRow(tr, { map, table, tableStart }, row) {\n\tlet rowPos = 0;\n\tfor (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;\n\tconst nextRow = rowPos + table.child(row).nodeSize;\n\tconst mapFrom = tr.mapping.maps.length;\n\ttr.delete(rowPos + tableStart, nextRow + tableStart);\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (let col = 0, index = row * map.width; col < map.width; col++, index++) {\n\t\tconst pos = map.map[index];\n\t\tif (seen.has(pos)) continue;\n\t\tseen.add(pos);\n\t\tif (row > 0 && pos == map.map[index - map.width]) {\n\t\t\tconst attrs = table.nodeAt(pos).attrs;\n\t\t\ttr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, {\n\t\t\t\t...attrs,\n\t\t\t\trowspan: attrs.rowspan - 1\n\t\t\t});\n\t\t\tcol += attrs.colspan - 1;\n\t\t} else if (row < map.height && pos == map.map[index + map.width]) {\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tconst attrs = cell.attrs;\n\t\t\tconst copy = cell.type.create({\n\t\t\t\t...attrs,\n\t\t\t\trowspan: cell.attrs.rowspan - 1\n\t\t\t}, cell.content);\n\t\t\tconst newPos = map.positionAt(row + 1, col, table);\n\t\t\ttr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);\n\t\t\tcol += attrs.colspan - 1;\n\t\t}\n\t}\n}\n/**\n* Remove the selected rows from a table.\n*\n* @public\n*/\nfunction deleteRow(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\tif (rect.top == 0 && rect.bottom == rect.map.height) return false;\n\t\tfor (let i = rect.bottom - 1;; i--) {\n\t\t\tremoveRow(tr, rect, i);\n\t\t\tif (i == rect.top) break;\n\t\t\tconst table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n\t\t\tif (!table) throw new RangeError(\"No table found\");\n\t\t\trect.table = table;\n\t\t\trect.map = TableMap.get(rect.table);\n\t\t}\n\t\tdispatch(tr);\n\t}\n\treturn true;\n}\nfunction isEmpty(cell) {\n\tconst c = cell.content;\n\treturn c.childCount == 1 && c.child(0).isTextblock && c.child(0).childCount == 0;\n}\nfunction cellsOverlapRectangle({ width, height, map }, rect) {\n\tlet indexTop = rect.top * width + rect.left, indexLeft = indexTop;\n\tlet indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);\n\tfor (let i = rect.top; i < rect.bottom; i++) {\n\t\tif (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] || rect.right < width && map[indexRight] == map[indexRight + 1]) return true;\n\t\tindexLeft += width;\n\t\tindexRight += width;\n\t}\n\tfor (let i = rect.left; i < rect.right; i++) {\n\t\tif (rect.top > 0 && map[indexTop] == map[indexTop - width] || rect.bottom < height && map[indexBottom] == map[indexBottom + width]) return true;\n\t\tindexTop++;\n\t\tindexBottom++;\n\t}\n\treturn false;\n}\n/**\n* Merge the selected cells into a single cell. Only available when\n* the selected cells' outline forms a rectangle.\n*\n* @public\n*/\nfunction mergeCells(state, dispatch) {\n\tconst sel = state.selection;\n\tif (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;\n\tconst rect = selectedRect(state), { map } = rect;\n\tif (cellsOverlapRectangle(map, rect)) return false;\n\tif (dispatch) {\n\t\tconst tr = state.tr;\n\t\tconst seen = {};\n\t\tlet content = Fragment.empty;\n\t\tlet mergedPos;\n\t\tlet mergedCell;\n\t\tfor (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {\n\t\t\tconst cellPos = map.map[row * map.width + col];\n\t\t\tconst cell = rect.table.nodeAt(cellPos);\n\t\t\tif (seen[cellPos] || !cell) continue;\n\t\t\tseen[cellPos] = true;\n\t\t\tif (mergedPos == null) {\n\t\t\t\tmergedPos = cellPos;\n\t\t\t\tmergedCell = cell;\n\t\t\t} else {\n\t\t\t\tif (!isEmpty(cell)) content = content.append(cell.content);\n\t\t\t\tconst mapped = tr.mapping.map(cellPos + rect.tableStart);\n\t\t\t\ttr.delete(mapped, mapped + cell.nodeSize);\n\t\t\t}\n\t\t}\n\t\tif (mergedPos == null || mergedCell == null) return true;\n\t\ttr.setNodeMarkup(mergedPos + rect.tableStart, null, {\n\t\t\t...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),\n\t\t\trowspan: rect.bottom - rect.top\n\t\t});\n\t\tif (content.size > 0) {\n\t\t\tconst end = mergedPos + 1 + mergedCell.content.size;\n\t\t\tconst start = isEmpty(mergedCell) ? mergedPos + 1 : end;\n\t\t\ttr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);\n\t\t}\n\t\ttr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));\n\t\tdispatch(tr);\n\t}\n\treturn true;\n}\n/**\n* Split a selected cell, whose rowpan or colspan is greater than one,\n* into smaller cells. Use the first cell type for the new cells.\n*\n* @public\n*/\nfunction splitCell(state, dispatch) {\n\tconst nodeTypes = tableNodeTypes(state.schema);\n\treturn splitCellWithType(({ node }) => {\n\t\treturn nodeTypes[node.type.spec.tableRole];\n\t})(state, dispatch);\n}\n/**\n* Split a selected cell, whose rowpan or colspan is greater than one,\n* into smaller cells with the cell type (th, td) returned by getType function.\n*\n* @public\n*/\nfunction splitCellWithType(getCellType) {\n\treturn (state, dispatch) => {\n\t\tconst sel = state.selection;\n\t\tlet cellNode;\n\t\tlet cellPos;\n\t\tif (!(sel instanceof CellSelection)) {\n\t\t\tvar _cellAround;\n\t\t\tcellNode = cellWrapping(sel.$from);\n\t\t\tif (!cellNode) return false;\n\t\t\tcellPos = (_cellAround = cellAround(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;\n\t\t} else {\n\t\t\tif (sel.$anchorCell.pos != sel.$headCell.pos) return false;\n\t\t\tcellNode = sel.$anchorCell.nodeAfter;\n\t\t\tcellPos = sel.$anchorCell.pos;\n\t\t}\n\t\tif (cellNode == null || cellPos == null) return false;\n\t\tif (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;\n\t\tif (dispatch) {\n\t\t\tlet baseAttrs = cellNode.attrs;\n\t\t\tconst attrs = [];\n\t\t\tconst colwidth = baseAttrs.colwidth;\n\t\t\tif (baseAttrs.rowspan > 1) baseAttrs = {\n\t\t\t\t...baseAttrs,\n\t\t\t\trowspan: 1\n\t\t\t};\n\t\t\tif (baseAttrs.colspan > 1) baseAttrs = {\n\t\t\t\t...baseAttrs,\n\t\t\t\tcolspan: 1\n\t\t\t};\n\t\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\t\tfor (let i = 0; i < rect.right - rect.left; i++) attrs.push(colwidth ? {\n\t\t\t\t...baseAttrs,\n\t\t\t\tcolwidth: colwidth && colwidth[i] ? [colwidth[i]] : null\n\t\t\t} : baseAttrs);\n\t\t\tlet lastCell;\n\t\t\tfor (let row = rect.top; row < rect.bottom; row++) {\n\t\t\t\tlet pos = rect.map.positionAt(row, rect.left, rect.table);\n\t\t\t\tif (row == rect.top) pos += cellNode.nodeSize;\n\t\t\t\tfor (let col = rect.left, i = 0; col < rect.right; col++, i++) {\n\t\t\t\t\tif (col == rect.left && row == rect.top) continue;\n\t\t\t\t\ttr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType({\n\t\t\t\t\t\tnode: cellNode,\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tcol\n\t\t\t\t\t}).createAndFill(attrs[i]));\n\t\t\t\t}\n\t\t\t}\n\t\t\ttr.setNodeMarkup(cellPos, getCellType({\n\t\t\t\tnode: cellNode,\n\t\t\t\trow: rect.top,\n\t\t\t\tcol: rect.left\n\t\t\t}), attrs[0]);\n\t\t\tif (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\n/**\n* Returns a command that sets the given attribute to the given value,\n* and is only available when the currently selected cell doesn't\n* already have that attribute set to that value.\n*\n* @public\n*/\nfunction setCellAttr(name, value) {\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tconst $cell = selectionCell(state);\n\t\tif ($cell.nodeAfter.attrs[name] === value) return false;\n\t\tif (dispatch) {\n\t\t\tconst tr = state.tr;\n\t\t\tif (state.selection instanceof CellSelection) state.selection.forEachCell((node, pos) => {\n\t\t\t\tif (node.attrs[name] !== value) tr.setNodeMarkup(pos, null, {\n\t\t\t\t\t...node.attrs,\n\t\t\t\t\t[name]: value\n\t\t\t\t});\n\t\t\t});\n\t\t\telse tr.setNodeMarkup($cell.pos, null, {\n\t\t\t\t...$cell.nodeAfter.attrs,\n\t\t\t\t[name]: value\n\t\t\t});\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\nfunction deprecated_toggleHeader(type) {\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tif (dispatch) {\n\t\t\tconst types = tableNodeTypes(state.schema);\n\t\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\t\tconst cells = rect.map.cellsInRect(type == \"column\" ? {\n\t\t\t\tleft: rect.left,\n\t\t\t\ttop: 0,\n\t\t\t\tright: rect.right,\n\t\t\t\tbottom: rect.map.height\n\t\t\t} : type == \"row\" ? {\n\t\t\t\tleft: 0,\n\t\t\t\ttop: rect.top,\n\t\t\t\tright: rect.map.width,\n\t\t\t\tbottom: rect.bottom\n\t\t\t} : rect);\n\t\t\tconst nodes = cells.map((pos) => rect.table.nodeAt(pos));\n\t\t\tfor (let i = 0; i < cells.length; i++) if (nodes[i].type == types.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i], types.cell, nodes[i].attrs);\n\t\t\tif (tr.steps.length === 0) for (let i = 0; i < cells.length; i++) tr.setNodeMarkup(rect.tableStart + cells[i], types.header_cell, nodes[i].attrs);\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\nfunction isHeaderEnabledByType(type, rect, types) {\n\tconst cellPositions = rect.map.cellsInRect({\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: type == \"row\" ? rect.map.width : 1,\n\t\tbottom: type == \"column\" ? rect.map.height : 1\n\t});\n\tfor (let i = 0; i < cellPositions.length; i++) {\n\t\tconst cell = rect.table.nodeAt(cellPositions[i]);\n\t\tif (cell && cell.type !== types.header_cell) return false;\n\t}\n\treturn true;\n}\n/**\n* Toggles between row/column header and normal cells (Only applies to first row/column).\n* For deprecated behavior pass `useDeprecatedLogic` in options with true.\n*\n* @public\n*/\nfunction toggleHeader(type, options) {\n\toptions = options || { useDeprecatedLogic: false };\n\tif (options.useDeprecatedLogic) return deprecated_toggleHeader(type);\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tif (dispatch) {\n\t\t\tconst types = tableNodeTypes(state.schema);\n\t\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\t\tconst isHeaderRowEnabled = isHeaderEnabledByType(\"row\", rect, types);\n\t\t\tconst isHeaderColumnEnabled = isHeaderEnabledByType(\"column\", rect, types);\n\t\t\tconst selectionStartsAt = (type === \"column\" ? isHeaderRowEnabled : type === \"row\" ? isHeaderColumnEnabled : false) ? 1 : 0;\n\t\t\tconst cellsRect = type == \"column\" ? {\n\t\t\t\tleft: 0,\n\t\t\t\ttop: selectionStartsAt,\n\t\t\t\tright: 1,\n\t\t\t\tbottom: rect.map.height\n\t\t\t} : type == \"row\" ? {\n\t\t\t\tleft: selectionStartsAt,\n\t\t\t\ttop: 0,\n\t\t\t\tright: rect.map.width,\n\t\t\t\tbottom: 1\n\t\t\t} : rect;\n\t\t\tconst newType = type == \"column\" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == \"row\" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;\n\t\t\trect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {\n\t\t\t\tconst cellPos = relativeCellPos + rect.tableStart;\n\t\t\t\tconst cell = tr.doc.nodeAt(cellPos);\n\t\t\t\tif (cell) tr.setNodeMarkup(cellPos, newType, cell.attrs);\n\t\t\t});\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\n/**\n* Toggles whether the selected row contains header cells.\n*\n* @public\n*/\nconst toggleHeaderRow = toggleHeader(\"row\", { useDeprecatedLogic: true });\n/**\n* Toggles whether the selected column contains header cells.\n*\n* @public\n*/\nconst toggleHeaderColumn = toggleHeader(\"column\", { useDeprecatedLogic: true });\n/**\n* Toggles whether the selected cells are header cells.\n*\n* @public\n*/\nconst toggleHeaderCell = toggleHeader(\"cell\", { useDeprecatedLogic: true });\nfunction findNextCell($cell, dir) {\n\tif (dir < 0) {\n\t\tconst before = $cell.nodeBefore;\n\t\tif (before) return $cell.pos - before.nodeSize;\n\t\tfor (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {\n\t\t\tconst rowNode = $cell.node(-1).child(row);\n\t\t\tconst lastChild = rowNode.lastChild;\n\t\t\tif (lastChild) return rowEnd - 1 - lastChild.nodeSize;\n\t\t\trowEnd -= rowNode.nodeSize;\n\t\t}\n\t} else {\n\t\tif ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;\n\t\tconst table = $cell.node(-1);\n\t\tfor (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {\n\t\t\tconst rowNode = table.child(row);\n\t\t\tif (rowNode.childCount) return rowStart + 1;\n\t\t\trowStart += rowNode.nodeSize;\n\t\t}\n\t}\n\treturn null;\n}\n/**\n* Returns a command for selecting the next (direction=1) or previous\n* (direction=-1) cell in a table.\n*\n* @public\n*/\nfunction goToNextCell(direction) {\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tconst cell = findNextCell(selectionCell(state), direction);\n\t\tif (cell == null) return false;\n\t\tif (dispatch) {\n\t\t\tconst $cell = state.doc.resolve(cell);\n\t\t\tdispatch(state.tr.setSelection(TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());\n\t\t}\n\t\treturn true;\n\t};\n}\n/**\n* Deletes the table around the selection, if any.\n*\n* @public\n*/\nfunction deleteTable(state, dispatch) {\n\tconst $pos = state.selection.$anchor;\n\tfor (let d = $pos.depth; d > 0; d--) if ($pos.node(d).type.spec.tableRole == \"table\") {\n\t\tif (dispatch) dispatch(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView());\n\t\treturn true;\n\t}\n\treturn false;\n}\n/**\n* Deletes the content of the selected cells, if they are not empty.\n*\n* @public\n*/\nfunction deleteCellSelection(state, dispatch) {\n\tconst sel = state.selection;\n\tif (!(sel instanceof CellSelection)) return false;\n\tif (dispatch) {\n\t\tconst tr = state.tr;\n\t\tconst baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;\n\t\tsel.forEachCell((cell, pos) => {\n\t\t\tif (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));\n\t\t});\n\t\tif (tr.docChanged) dispatch(tr);\n\t}\n\treturn true;\n}\n/**\n* Move a table row from index `from` to index `to`.\n*\n* @public\n*/\nfunction moveTableRow(options) {\n\treturn (state, dispatch) => {\n\t\tconst { from: originIndex, to: targetIndex, select = true, pos = state.selection.from } = options;\n\t\tconst tr = state.tr;\n\t\tif (moveRow({\n\t\t\ttr,\n\t\t\toriginIndex,\n\t\t\ttargetIndex,\n\t\t\tselect,\n\t\t\tpos\n\t\t})) {\n\t\t\tdispatch === null || dispatch === void 0 || dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t};\n}\n/**\n* Move a table column from index `from` to index `to`.\n*\n* @public\n*/\nfunction moveTableColumn(options) {\n\treturn (state, dispatch) => {\n\t\tconst { from: originIndex, to: targetIndex, select = true, pos = state.selection.from } = options;\n\t\tconst tr = state.tr;\n\t\tif (moveColumn({\n\t\t\ttr,\n\t\t\toriginIndex,\n\t\t\ttargetIndex,\n\t\t\tselect,\n\t\t\tpos\n\t\t})) {\n\t\t\tdispatch === null || dispatch === void 0 || dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t};\n}\n\n//#endregion\n//#region src/copypaste.ts\n/**\n* Get a rectangular area of cells from a slice, or null if the outer\n* nodes of the slice aren't table cells or rows.\n*\n* @internal\n*/\nfunction pastedCells(slice) {\n\tif (slice.size === 0) return null;\n\tlet { content, openStart, openEnd } = slice;\n\twhile (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == \"table\")) {\n\t\topenStart--;\n\t\topenEnd--;\n\t\tcontent = content.child(0).content;\n\t}\n\tconst first = content.child(0);\n\tconst role = first.type.spec.tableRole;\n\tconst schema = first.type.schema, rows = [];\n\tif (role == \"row\") for (let i = 0; i < content.childCount; i++) {\n\t\tlet cells = content.child(i).content;\n\t\tconst left = i ? 0 : Math.max(0, openStart - 1);\n\t\tconst right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);\n\t\tif (left || right) cells = fitSlice(tableNodeTypes(schema).row, new Slice(cells, left, right)).content;\n\t\trows.push(cells);\n\t}\n\telse if (role == \"cell\" || role == \"header_cell\") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new Slice(content, openStart, openEnd)).content : content);\n\telse return null;\n\treturn ensureRectangular(schema, rows);\n}\nfunction ensureRectangular(schema, rows) {\n\tconst widths = [];\n\tfor (let i = 0; i < rows.length; i++) {\n\t\tconst row = rows[i];\n\t\tfor (let j = row.childCount - 1; j >= 0; j--) {\n\t\t\tconst { rowspan, colspan } = row.child(j).attrs;\n\t\t\tfor (let r = i; r < i + rowspan; r++) widths[r] = (widths[r] || 0) + colspan;\n\t\t}\n\t}\n\tlet width = 0;\n\tfor (let r = 0; r < widths.length; r++) width = Math.max(width, widths[r]);\n\tfor (let r = 0; r < widths.length; r++) {\n\t\tif (r >= rows.length) rows.push(Fragment.empty);\n\t\tif (widths[r] < width) {\n\t\t\tconst empty = tableNodeTypes(schema).cell.createAndFill();\n\t\t\tconst cells = [];\n\t\t\tfor (let i = widths[r]; i < width; i++) cells.push(empty);\n\t\t\trows[r] = rows[r].append(Fragment.from(cells));\n\t\t}\n\t}\n\treturn {\n\t\theight: rows.length,\n\t\twidth,\n\t\trows\n\t};\n}\nfunction fitSlice(nodeType, slice) {\n\tconst node = nodeType.createAndFill();\n\treturn new Transform(node).replace(0, node.content.size, slice).doc;\n}\n/**\n* Clip or extend (repeat) the given set of cells to cover the given\n* width and height. Will clip rowspan/colspan cells at the edges when\n* they stick out.\n*\n* @internal\n*/\nfunction clipCells({ width, height, rows }, newWidth, newHeight) {\n\tif (width != newWidth) {\n\t\tconst added = [];\n\t\tconst newRows = [];\n\t\tfor (let row = 0; row < rows.length; row++) {\n\t\t\tconst frag = rows[row], cells = [];\n\t\t\tfor (let col = added[row] || 0, i = 0; col < newWidth; i++) {\n\t\t\t\tlet cell = frag.child(i % frag.childCount);\n\t\t\t\tif (col + cell.attrs.colspan > newWidth) cell = cell.type.createChecked(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content);\n\t\t\t\tcells.push(cell);\n\t\t\t\tcol += cell.attrs.colspan;\n\t\t\t\tfor (let j = 1; j < cell.attrs.rowspan; j++) added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;\n\t\t\t}\n\t\t\tnewRows.push(Fragment.from(cells));\n\t\t}\n\t\trows = newRows;\n\t\twidth = newWidth;\n\t}\n\tif (height != newHeight) {\n\t\tconst newRows = [];\n\t\tfor (let row = 0, i = 0; row < newHeight; row++, i++) {\n\t\t\tconst cells = [], source = rows[i % height];\n\t\t\tfor (let j = 0; j < source.childCount; j++) {\n\t\t\t\tlet cell = source.child(j);\n\t\t\t\tif (row + cell.attrs.rowspan > newHeight) cell = cell.type.create({\n\t\t\t\t\t...cell.attrs,\n\t\t\t\t\trowspan: Math.max(1, newHeight - cell.attrs.rowspan)\n\t\t\t\t}, cell.content);\n\t\t\t\tcells.push(cell);\n\t\t\t}\n\t\t\tnewRows.push(Fragment.from(cells));\n\t\t}\n\t\trows = newRows;\n\t\theight = newHeight;\n\t}\n\treturn {\n\t\twidth,\n\t\theight,\n\t\trows\n\t};\n}\nfunction growTable(tr, map, table, start, width, height, mapFrom) {\n\tconst schema = tr.doc.type.schema;\n\tconst types = tableNodeTypes(schema);\n\tlet empty;\n\tlet emptyHead;\n\tif (width > map.width) for (let row = 0, rowEnd = 0; row < map.height; row++) {\n\t\tconst rowNode = table.child(row);\n\t\trowEnd += rowNode.nodeSize;\n\t\tconst cells = [];\n\t\tlet add;\n\t\tif (rowNode.lastChild == null || rowNode.lastChild.type == types.cell) add = empty || (empty = types.cell.createAndFill());\n\t\telse add = emptyHead || (emptyHead = types.header_cell.createAndFill());\n\t\tfor (let i = map.width; i < width; i++) cells.push(add);\n\t\ttr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);\n\t}\n\tif (height > map.height) {\n\t\tconst cells = [];\n\t\tfor (let i = 0, start$1 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {\n\t\t\tconst header = i >= map.width ? false : table.nodeAt(map.map[start$1 + i]).type == types.header_cell;\n\t\t\tcells.push(header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill()));\n\t\t}\n\t\tconst emptyRow = types.row.create(null, Fragment.from(cells)), rows = [];\n\t\tfor (let i = map.height; i < height; i++) rows.push(emptyRow);\n\t\ttr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);\n\t}\n\treturn !!(empty || emptyHead);\n}\nfunction isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {\n\tif (top == 0 || top == map.height) return false;\n\tlet found = false;\n\tfor (let col = left; col < right; col++) {\n\t\tconst index = top * map.width + col, pos = map.map[index];\n\t\tif (map.map[index - map.width] == pos) {\n\t\t\tfound = true;\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tconst { top: cellTop, left: cellLeft } = map.findCell(pos);\n\t\t\ttr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, {\n\t\t\t\t...cell.attrs,\n\t\t\t\trowspan: top - cellTop\n\t\t\t});\n\t\t\ttr.insert(tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)), cell.type.createAndFill({\n\t\t\t\t...cell.attrs,\n\t\t\t\trowspan: cellTop + cell.attrs.rowspan - top\n\t\t\t}));\n\t\t\tcol += cell.attrs.colspan - 1;\n\t\t}\n\t}\n\treturn found;\n}\nfunction isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {\n\tif (left == 0 || left == map.width) return false;\n\tlet found = false;\n\tfor (let row = top; row < bottom; row++) {\n\t\tconst index = row * map.width + left, pos = map.map[index];\n\t\tif (map.map[index - 1] == pos) {\n\t\t\tfound = true;\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tconst cellLeft = map.colCount(pos);\n\t\t\tconst updatePos = tr.mapping.slice(mapFrom).map(pos + start);\n\t\t\ttr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left - cellLeft, cell.attrs.colspan - (left - cellLeft)));\n\t\t\ttr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left - cellLeft)));\n\t\t\trow += cell.attrs.rowspan - 1;\n\t\t}\n\t}\n\treturn found;\n}\n/**\n* Insert the given set of cells (as returned by `pastedCells`) into a\n* table, at the position pointed at by rect.\n*\n* @internal\n*/\nfunction insertCells(state, dispatch, tableStart, rect, cells) {\n\tlet table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc;\n\tif (!table) throw new Error(\"No table found\");\n\tlet map = TableMap.get(table);\n\tconst { top, left } = rect;\n\tconst right = left + cells.width, bottom = top + cells.height;\n\tconst tr = state.tr;\n\tlet mapFrom = 0;\n\tfunction recomp() {\n\t\ttable = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;\n\t\tif (!table) throw new Error(\"No table found\");\n\t\tmap = TableMap.get(table);\n\t\tmapFrom = tr.mapping.maps.length;\n\t}\n\tif (growTable(tr, map, table, tableStart, right, bottom, mapFrom)) recomp();\n\tif (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom)) recomp();\n\tif (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom)) recomp();\n\tif (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom)) recomp();\n\tif (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom)) recomp();\n\tfor (let row = top; row < bottom; row++) {\n\t\tconst from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);\n\t\ttr.replace(tr.mapping.slice(mapFrom).map(from + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new Slice(cells.rows[row - top], 0, 0));\n\t}\n\trecomp();\n\ttr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map.positionAt(top, left, table)), tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))));\n\tdispatch(tr);\n}\n\n//#endregion\n//#region src/input.ts\nconst handleKeyDown = keydownHandler({\n\tArrowLeft: arrow(\"horiz\", -1),\n\tArrowRight: arrow(\"horiz\", 1),\n\tArrowUp: arrow(\"vert\", -1),\n\tArrowDown: arrow(\"vert\", 1),\n\t\"Shift-ArrowLeft\": shiftArrow(\"horiz\", -1),\n\t\"Shift-ArrowRight\": shiftArrow(\"horiz\", 1),\n\t\"Shift-ArrowUp\": shiftArrow(\"vert\", -1),\n\t\"Shift-ArrowDown\": shiftArrow(\"vert\", 1),\n\tBackspace: deleteCellSelection,\n\t\"Mod-Backspace\": deleteCellSelection,\n\tDelete: deleteCellSelection,\n\t\"Mod-Delete\": deleteCellSelection\n});\nfunction maybeSetSelection(state, dispatch, selection) {\n\tif (selection.eq(state.selection)) return false;\n\tif (dispatch) dispatch(state.tr.setSelection(selection).scrollIntoView());\n\treturn true;\n}\n/**\n* @internal\n*/\nfunction arrow(axis, dir) {\n\treturn (state, dispatch, view) => {\n\t\tif (!view) return false;\n\t\tconst sel = state.selection;\n\t\tif (sel instanceof CellSelection) return maybeSetSelection(state, dispatch, Selection.near(sel.$headCell, dir));\n\t\tif (axis != \"horiz\" && !sel.empty) return false;\n\t\tconst end = atEndOfCell(view, axis, dir);\n\t\tif (end == null) return false;\n\t\tif (axis == \"horiz\") return maybeSetSelection(state, dispatch, Selection.near(state.doc.resolve(sel.head + dir), dir));\n\t\telse {\n\t\t\tconst $cell = state.doc.resolve(end);\n\t\t\tconst $next = nextCell($cell, axis, dir);\n\t\t\tlet newSel;\n\t\t\tif ($next) newSel = Selection.near($next, 1);\n\t\t\telse if (dir < 0) newSel = Selection.near(state.doc.resolve($cell.before(-1)), -1);\n\t\t\telse newSel = Selection.near(state.doc.resolve($cell.after(-1)), 1);\n\t\t\treturn maybeSetSelection(state, dispatch, newSel);\n\t\t}\n\t};\n}\nfunction shiftArrow(axis, dir) {\n\treturn (state, dispatch, view) => {\n\t\tif (!view) return false;\n\t\tconst sel = state.selection;\n\t\tlet cellSel;\n\t\tif (sel instanceof CellSelection) cellSel = sel;\n\t\telse {\n\t\t\tconst end = atEndOfCell(view, axis, dir);\n\t\t\tif (end == null) return false;\n\t\t\tcellSel = new CellSelection(state.doc.resolve(end));\n\t\t}\n\t\tconst $head = nextCell(cellSel.$headCell, axis, dir);\n\t\tif (!$head) return false;\n\t\treturn maybeSetSelection(state, dispatch, new CellSelection(cellSel.$anchorCell, $head));\n\t};\n}\nfunction handleTripleClick(view, pos) {\n\tconst doc = view.state.doc, $cell = cellAround(doc.resolve(pos));\n\tif (!$cell) return false;\n\tview.dispatch(view.state.tr.setSelection(new CellSelection($cell)));\n\treturn true;\n}\n/**\n* @public\n*/\nfunction handlePaste(view, _, slice) {\n\tif (!isInTable(view.state)) return false;\n\tlet cells = pastedCells(slice);\n\tconst sel = view.state.selection;\n\tif (sel instanceof CellSelection) {\n\t\tif (!cells) cells = {\n\t\t\twidth: 1,\n\t\t\theight: 1,\n\t\t\trows: [Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice))]\n\t\t};\n\t\tconst table = sel.$anchorCell.node(-1);\n\t\tconst start = sel.$anchorCell.start(-1);\n\t\tconst rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);\n\t\tcells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);\n\t\tinsertCells(view.state, view.dispatch, start, rect, cells);\n\t\treturn true;\n\t} else if (cells) {\n\t\tconst $cell = selectionCell(view.state);\n\t\tconst start = $cell.start(-1);\n\t\tinsertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), cells);\n\t\treturn true;\n\t} else return false;\n}\nfunction handleMouseDown$1(view, startEvent) {\n\tvar _cellUnderMouse;\n\tif (startEvent.button != 0) return;\n\tif (startEvent.ctrlKey || startEvent.metaKey) return;\n\tconst startDOMCell = domInCell(view, startEvent.target);\n\tlet $anchor;\n\tif (startEvent.shiftKey && view.state.selection instanceof CellSelection) {\n\t\tsetCellSelection(view.state.selection.$anchorCell, startEvent);\n\t\tstartEvent.preventDefault();\n\t} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_cellUnderMouse = cellUnderMouse(view, startEvent)) === null || _cellUnderMouse === void 0 ? void 0 : _cellUnderMouse.pos) != $anchor.pos) {\n\t\tsetCellSelection($anchor, startEvent);\n\t\tstartEvent.preventDefault();\n\t} else if (!startDOMCell) return;\n\tfunction setCellSelection($anchor$1, event) {\n\t\tlet $head = cellUnderMouse(view, event);\n\t\tconst starting = tableEditingKey.getState(view.state) == null;\n\t\tif (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;\n\t\telse return;\n\t\tconst selection = new CellSelection($anchor$1, $head);\n\t\tif (starting || !view.state.selection.eq(selection)) {\n\t\t\tconst tr = view.state.tr.setSelection(selection);\n\t\t\tif (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);\n\t\t\tview.dispatch(tr);\n\t\t}\n\t}\n\tfunction stop() {\n\t\tview.root.removeEventListener(\"mouseup\", stop);\n\t\tview.root.removeEventListener(\"dragstart\", stop);\n\t\tview.root.removeEventListener(\"mousemove\", move);\n\t\tif (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));\n\t}\n\tfunction move(_event) {\n\t\tconst event = _event;\n\t\tconst anchor = tableEditingKey.getState(view.state);\n\t\tlet $anchor$1;\n\t\tif (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);\n\t\telse if (domInCell(view, event.target) != startDOMCell) {\n\t\t\t$anchor$1 = cellUnderMouse(view, startEvent);\n\t\t\tif (!$anchor$1) return stop();\n\t\t}\n\t\tif ($anchor$1) setCellSelection($anchor$1, event);\n\t}\n\tview.root.addEventListener(\"mouseup\", stop);\n\tview.root.addEventListener(\"dragstart\", stop);\n\tview.root.addEventListener(\"mousemove\", move);\n}\nfunction atEndOfCell(view, axis, dir) {\n\tif (!(view.state.selection instanceof TextSelection)) return null;\n\tconst { $head } = view.state.selection;\n\tfor (let d = $head.depth - 1; d >= 0; d--) {\n\t\tconst parent = $head.node(d);\n\t\tif ((dir < 0 ? $head.index(d) : $head.indexAfter(d)) != (dir < 0 ? 0 : parent.childCount)) return null;\n\t\tif (parent.type.spec.tableRole == \"cell\" || parent.type.spec.tableRole == \"header_cell\") {\n\t\t\tconst cellPos = $head.before(d);\n\t\t\tconst dirStr = axis == \"vert\" ? dir > 0 ? \"down\" : \"up\" : dir > 0 ? \"right\" : \"left\";\n\t\t\treturn view.endOfTextblock(dirStr) ? cellPos : null;\n\t\t}\n\t}\n\treturn null;\n}\nfunction domInCell(view, dom) {\n\tfor (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == \"TD\" || dom.nodeName == \"TH\") return dom;\n\treturn null;\n}\nfunction cellUnderMouse(view, event) {\n\tconst mousePos = view.posAtCoords({\n\t\tleft: event.clientX,\n\t\ttop: event.clientY\n\t});\n\tif (!mousePos) return null;\n\tlet { inside, pos } = mousePos;\n\treturn inside >= 0 && cellAround(view.state.doc.resolve(inside)) || cellAround(view.state.doc.resolve(pos));\n}\n\n//#endregion\n//#region src/tableview.ts\n/**\n* @public\n*/\nvar TableView = class {\n\tconstructor(node, defaultCellMinWidth) {\n\t\tthis.node = node;\n\t\tthis.defaultCellMinWidth = defaultCellMinWidth;\n\t\tthis.dom = document.createElement(\"div\");\n\t\tthis.dom.className = \"tableWrapper\";\n\t\tthis.table = this.dom.appendChild(document.createElement(\"table\"));\n\t\tthis.table.style.setProperty(\"--default-cell-min-width\", `${defaultCellMinWidth}px`);\n\t\tthis.colgroup = this.table.appendChild(document.createElement(\"colgroup\"));\n\t\tupdateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);\n\t\tthis.contentDOM = this.table.appendChild(document.createElement(\"tbody\"));\n\t}\n\tupdate(node) {\n\t\tif (node.type != this.node.type) return false;\n\t\tthis.node = node;\n\t\tupdateColumnsOnResize(node, this.colgroup, this.table, this.defaultCellMinWidth);\n\t\treturn true;\n\t}\n\tignoreMutation(record) {\n\t\treturn record.type == \"attributes\" && (record.target == this.table || this.colgroup.contains(record.target));\n\t}\n};\n/**\n* @public\n*/\nfunction updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {\n\tlet totalWidth = 0;\n\tlet fixedWidth = true;\n\tlet nextDOM = colgroup.firstChild;\n\tconst row = node.firstChild;\n\tif (!row) return;\n\tfor (let i = 0, col = 0; i < row.childCount; i++) {\n\t\tconst { colspan, colwidth } = row.child(i).attrs;\n\t\tfor (let j = 0; j < colspan; j++, col++) {\n\t\t\tconst hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];\n\t\t\tconst cssWidth = hasWidth ? hasWidth + \"px\" : \"\";\n\t\t\ttotalWidth += hasWidth || defaultCellMinWidth;\n\t\t\tif (!hasWidth) fixedWidth = false;\n\t\t\tif (!nextDOM) {\n\t\t\t\tconst col$1 = document.createElement(\"col\");\n\t\t\t\tcol$1.style.width = cssWidth;\n\t\t\t\tcolgroup.appendChild(col$1);\n\t\t\t} else {\n\t\t\t\tif (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;\n\t\t\t\tnextDOM = nextDOM.nextSibling;\n\t\t\t}\n\t\t}\n\t}\n\twhile (nextDOM) {\n\t\tvar _nextDOM$parentNode;\n\t\tconst after = nextDOM.nextSibling;\n\t\t(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);\n\t\tnextDOM = after;\n\t}\n\tif (fixedWidth) {\n\t\ttable.style.width = totalWidth + \"px\";\n\t\ttable.style.minWidth = \"\";\n\t} else {\n\t\ttable.style.width = \"\";\n\t\ttable.style.minWidth = totalWidth + \"px\";\n\t}\n}\n\n//#endregion\n//#region src/columnresizing.ts\n/**\n* @public\n*/\nconst columnResizingPluginKey = new PluginKey(\"tableColumnResizing\");\n/**\n* @public\n*/\nfunction columnResizing({ handleWidth = 5, cellMinWidth = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {\n\tconst plugin = new Plugin({\n\t\tkey: columnResizingPluginKey,\n\t\tstate: {\n\t\t\tinit(_, state) {\n\t\t\t\tvar _plugin$spec;\n\t\t\t\tconst nodeViews = (_plugin$spec = plugin.spec) === null || _plugin$spec === void 0 || (_plugin$spec = _plugin$spec.props) === null || _plugin$spec === void 0 ? void 0 : _plugin$spec.nodeViews;\n\t\t\t\tconst tableName = tableNodeTypes(state.schema).table.name;\n\t\t\t\tif (View && nodeViews) nodeViews[tableName] = (node, view) => {\n\t\t\t\t\treturn new View(node, defaultCellMinWidth, view);\n\t\t\t\t};\n\t\t\t\treturn new ResizeState(-1, false);\n\t\t\t},\n\t\t\tapply(tr, prev) {\n\t\t\t\treturn prev.apply(tr);\n\t\t\t}\n\t\t},\n\t\tprops: {\n\t\t\tattributes: (state) => {\n\t\t\t\tconst pluginState = columnResizingPluginKey.getState(state);\n\t\t\t\treturn pluginState && pluginState.activeHandle > -1 ? { class: \"resize-cursor\" } : {};\n\t\t\t},\n\t\t\thandleDOMEvents: {\n\t\t\t\tmousemove: (view, event) => {\n\t\t\t\t\thandleMouseMove(view, event, handleWidth, lastColumnResizable);\n\t\t\t\t},\n\t\t\t\tmouseleave: (view) => {\n\t\t\t\t\thandleMouseLeave(view);\n\t\t\t\t},\n\t\t\t\tmousedown: (view, event) => {\n\t\t\t\t\thandleMouseDown(view, event, cellMinWidth, defaultCellMinWidth);\n\t\t\t\t}\n\t\t\t},\n\t\t\tdecorations: (state) => {\n\t\t\t\tconst pluginState = columnResizingPluginKey.getState(state);\n\t\t\t\tif (pluginState && pluginState.activeHandle > -1) return handleDecorations(state, pluginState.activeHandle);\n\t\t\t},\n\t\t\tnodeViews: {}\n\t\t}\n\t});\n\treturn plugin;\n}\n/**\n* @public\n*/\nvar ResizeState = class ResizeState {\n\tconstructor(activeHandle, dragging) {\n\t\tthis.activeHandle = activeHandle;\n\t\tthis.dragging = dragging;\n\t}\n\tapply(tr) {\n\t\tconst state = this;\n\t\tconst action = tr.getMeta(columnResizingPluginKey);\n\t\tif (action && action.setHandle != null) return new ResizeState(action.setHandle, false);\n\t\tif (action && action.setDragging !== void 0) return new ResizeState(state.activeHandle, action.setDragging);\n\t\tif (state.activeHandle > -1 && tr.docChanged) {\n\t\t\tlet handle = tr.mapping.map(state.activeHandle, -1);\n\t\t\tif (!pointsAtCell(tr.doc.resolve(handle))) handle = -1;\n\t\t\treturn new ResizeState(handle, state.dragging);\n\t\t}\n\t\treturn state;\n\t}\n};\nfunction handleMouseMove(view, event, handleWidth, lastColumnResizable) {\n\tif (!view.editable) return;\n\tconst pluginState = columnResizingPluginKey.getState(view.state);\n\tif (!pluginState) return;\n\tif (!pluginState.dragging) {\n\t\tconst target = domCellAround(event.target);\n\t\tlet cell = -1;\n\t\tif (target) {\n\t\t\tconst { left, right } = target.getBoundingClientRect();\n\t\t\tif (event.clientX - left <= handleWidth) cell = edgeCell(view, event, \"left\", handleWidth);\n\t\t\telse if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, \"right\", handleWidth);\n\t\t}\n\t\tif (cell != pluginState.activeHandle) {\n\t\t\tif (!lastColumnResizable && cell !== -1) {\n\t\t\t\tconst $cell = view.state.doc.resolve(cell);\n\t\t\t\tconst table = $cell.node(-1);\n\t\t\t\tconst map = TableMap.get(table);\n\t\t\t\tconst tableStart = $cell.start(-1);\n\t\t\t\tif (map.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map.width - 1) return;\n\t\t\t}\n\t\t\tupdateHandle(view, cell);\n\t\t}\n\t}\n}\nfunction handleMouseLeave(view) {\n\tif (!view.editable) return;\n\tconst pluginState = columnResizingPluginKey.getState(view.state);\n\tif (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);\n}\nfunction handleMouseDown(view, event, cellMinWidth, defaultCellMinWidth) {\n\tvar _view$dom$ownerDocume;\n\tif (!view.editable) return false;\n\tconst win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;\n\tconst pluginState = columnResizingPluginKey.getState(view.state);\n\tif (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;\n\tconst cell = view.state.doc.nodeAt(pluginState.activeHandle);\n\tconst width = currentColWidth(view, pluginState.activeHandle, cell.attrs);\n\tview.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {\n\t\tstartX: event.clientX,\n\t\tstartWidth: width\n\t} }));\n\tfunction finish(event$1) {\n\t\twin.removeEventListener(\"mouseup\", finish);\n\t\twin.removeEventListener(\"mousemove\", move);\n\t\tconst pluginState$1 = columnResizingPluginKey.getState(view.state);\n\t\tif (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {\n\t\t\tupdateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth));\n\t\t\tview.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));\n\t\t}\n\t}\n\tfunction move(event$1) {\n\t\tif (!event$1.which) return finish(event$1);\n\t\tconst pluginState$1 = columnResizingPluginKey.getState(view.state);\n\t\tif (!pluginState$1) return;\n\t\tif (pluginState$1.dragging) {\n\t\t\tconst dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth);\n\t\t\tdisplayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);\n\t\t}\n\t}\n\tdisplayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);\n\twin.addEventListener(\"mouseup\", finish);\n\twin.addEventListener(\"mousemove\", move);\n\tevent.preventDefault();\n\treturn true;\n}\nfunction currentColWidth(view, cellPos, { colspan, colwidth }) {\n\tconst width = colwidth && colwidth[colwidth.length - 1];\n\tif (width) return width;\n\tconst dom = view.domAtPos(cellPos);\n\tlet domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;\n\tif (colwidth) {\n\t\tfor (let i = 0; i < colspan; i++) if (colwidth[i]) {\n\t\t\tdomWidth -= colwidth[i];\n\t\t\tparts--;\n\t\t}\n\t}\n\treturn domWidth / parts;\n}\nfunction domCellAround(target) {\n\twhile (target && target.nodeName != \"TD\" && target.nodeName != \"TH\") target = target.classList && target.classList.contains(\"ProseMirror\") ? null : target.parentNode;\n\treturn target;\n}\nfunction edgeCell(view, event, side, handleWidth) {\n\tconst offset = side == \"right\" ? -handleWidth : handleWidth;\n\tconst found = view.posAtCoords({\n\t\tleft: event.clientX + offset,\n\t\ttop: event.clientY\n\t});\n\tif (!found) return -1;\n\tconst { pos } = found;\n\tconst $cell = cellAround(view.state.doc.resolve(pos));\n\tif (!$cell) return -1;\n\tif (side == \"right\") return $cell.pos;\n\tconst map = TableMap.get($cell.node(-1)), start = $cell.start(-1);\n\tconst index = map.map.indexOf($cell.pos - start);\n\treturn index % map.width == 0 ? -1 : start + map.map[index - 1];\n}\nfunction draggedWidth(dragging, event, resizeMinWidth) {\n\tconst offset = event.clientX - dragging.startX;\n\treturn Math.max(resizeMinWidth, dragging.startWidth + offset);\n}\nfunction updateHandle(view, value) {\n\tview.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));\n}\nfunction updateColumnWidth(view, cell, width) {\n\tconst $cell = view.state.doc.resolve(cell);\n\tconst table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);\n\tconst col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\tconst tr = view.state.tr;\n\tfor (let row = 0; row < map.height; row++) {\n\t\tconst mapIndex = row * map.width + col;\n\t\tif (row && map.map[mapIndex] == map.map[mapIndex - map.width]) continue;\n\t\tconst pos = map.map[mapIndex];\n\t\tconst attrs = table.nodeAt(pos).attrs;\n\t\tconst index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);\n\t\tif (attrs.colwidth && attrs.colwidth[index] == width) continue;\n\t\tconst colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);\n\t\tcolwidth[index] = width;\n\t\ttr.setNodeMarkup(start + pos, null, {\n\t\t\t...attrs,\n\t\t\tcolwidth\n\t\t});\n\t}\n\tif (tr.docChanged) view.dispatch(tr);\n}\nfunction displayColumnWidth(view, cell, width, defaultCellMinWidth) {\n\tconst $cell = view.state.doc.resolve(cell);\n\tconst table = $cell.node(-1), start = $cell.start(-1);\n\tconst col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\tlet dom = view.domAtPos($cell.start(-1)).node;\n\twhile (dom && dom.nodeName != \"TABLE\") dom = dom.parentNode;\n\tif (!dom) return;\n\tupdateColumnsOnResize(table, dom.firstChild, dom, defaultCellMinWidth, col, width);\n}\nfunction zeroes(n) {\n\treturn Array(n).fill(0);\n}\nfunction handleDecorations(state, cell) {\n\tconst decorations = [];\n\tconst $cell = state.doc.resolve(cell);\n\tconst table = $cell.node(-1);\n\tif (!table) return DecorationSet.empty;\n\tconst map = TableMap.get(table);\n\tconst start = $cell.start(-1);\n\tconst col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\tfor (let row = 0; row < map.height; row++) {\n\t\tconst index = col + row * map.width;\n\t\tif ((col == map.width - 1 || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index] != map.map[index - map.width])) {\n\t\t\tvar _columnResizingPlugin;\n\t\t\tconst cellPos = map.map[index];\n\t\t\tconst pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;\n\t\t\tconst dom = document.createElement(\"div\");\n\t\t\tdom.className = \"column-resize-handle\";\n\t\t\tif ((_columnResizingPlugin = columnResizingPluginKey.getState(state)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(Decoration.node(start + cellPos, start + cellPos + table.nodeAt(cellPos).nodeSize, { class: \"column-resize-dragging\" }));\n\t\t\tdecorations.push(Decoration.widget(pos, dom));\n\t\t}\n\t}\n\treturn DecorationSet.create(state.doc, decorations);\n}\n\n//#endregion\n//#region src/index.ts\n/**\n* Creates a [plugin](http://prosemirror.net/docs/ref/#state.Plugin)\n* that, when added to an editor, enables cell-selection, handles\n* cell-based copy/paste, and makes sure tables stay well-formed (each\n* row has the same width, and cells don't overlap).\n*\n* You should probably put this plugin near the end of your array of\n* plugins, since it handles mouse and arrow key events in tables\n* rather broadly, and other plugins, like the gap cursor or the\n* column-width dragging plugin, might want to get a turn first to\n* perform more specific behavior.\n*\n* @public\n*/\nfunction tableEditing({ allowTableNodeSelection = false } = {}) {\n\treturn new Plugin({\n\t\tkey: tableEditingKey,\n\t\tstate: {\n\t\t\tinit() {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tapply(tr, cur) {\n\t\t\t\tconst set = tr.getMeta(tableEditingKey);\n\t\t\t\tif (set != null) return set == -1 ? null : set;\n\t\t\t\tif (cur == null || !tr.docChanged) return cur;\n\t\t\t\tconst { deleted, pos } = tr.mapping.mapResult(cur);\n\t\t\t\treturn deleted ? null : pos;\n\t\t\t}\n\t\t},\n\t\tprops: {\n\t\t\tdecorations: drawCellSelection,\n\t\t\thandleDOMEvents: { mousedown: handleMouseDown$1 },\n\t\t\tcreateSelectionBetween(view) {\n\t\t\t\treturn tableEditingKey.getState(view.state) != null ? view.state.selection : null;\n\t\t\t},\n\t\t\thandleTripleClick,\n\t\t\thandleKeyDown,\n\t\t\thandlePaste\n\t\t},\n\t\tappendTransaction(_, oldState, state) {\n\t\t\treturn normalizeSelection(state, fixTables(state, oldState), allowTableNodeSelection);\n\t\t}\n\t});\n}\n\n//#endregion\nexport { CellBookmark, CellSelection, ResizeState, TableMap, TableView, clipCells as __clipCells, insertCells as __insertCells, pastedCells as __pastedCells, addColSpan, addColumn, addColumnAfter, addColumnBefore, addRow, addRowAfter, addRowBefore, cellAround, cellNear, colCount, columnIsHeader, columnResizing, columnResizingPluginKey, deleteCellSelection, deleteColumn, deleteRow, deleteTable, findCell, findCellPos, findCellRange, findTable, fixTables, fixTablesKey, goToNextCell, handlePaste, inSameTable, isInTable, mergeCells, moveCellForward, moveTableColumn, moveTableRow, nextCell, pointsAtCell, removeColSpan, removeColumn, removeRow, rowIsHeader, selectedRect, selectionCell, setCellAttr, splitCell, splitCellWithType, tableEditing, tableEditingKey, tableNodeTypes, tableNodes, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, updateColumnsOnResize };\n//# sourceMappingURL=index.js.map","import { Extension, Node, callOrReturn, findParentNodeClosestToPos, getExtensionField, mergeAttributes } from \"@tiptap/core\";\nimport { TextSelection } from \"@tiptap/pm/state\";\nimport { CellSelection, addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, columnResizing, deleteColumn, deleteRow, deleteTable, fixTables, goToNextCell, mergeCells, setCellAttr, splitCell, tableEditing, toggleHeader, toggleHeaderCell } from \"@tiptap/pm/tables\";\n//#region src/utils/parseAlign.ts\n/**\n* Normalize unknown input into a supported table alignment\n*\n* @param value - A potential alignment value\n* @returns A valid TableCellAlign value or null\n*/\nfunction normalizeTableCellAlign(value) {\n\tif (value === \"left\" || value === \"right\" || value === \"center\") return value;\n\treturn null;\n}\n/**\n* Parse table cell alignment from an HTML element\n*\n* Prefers inline style (${\"`\"}text-align${\"`\"}) and falls back to the legacy\n* ${\"`\"}align${\"`\"} attribute.\n*\n* @param element - The table cell/header DOM element\n* @returns A valid TableCellAlign value or null\n*/\nfunction parseAlign(element) {\n\tconst styleAlign = (element.style.textAlign || \"\").trim().toLowerCase();\n\tconst attrAlign = (element.getAttribute(\"align\") || \"\").trim().toLowerCase();\n\treturn normalizeTableCellAlign(styleAlign || attrAlign);\n}\n/**\n* Normalize alignment from a generic attrs object that may include an align field\n*\n* @param attributes - A node attrs-like object with an optional align field\n* @returns A valid TableCellAlign value or null.\n*/\nfunction normalizeTableCellAlignFromAttributes(attributes) {\n\treturn normalizeTableCellAlign(attributes === null || attributes === void 0 ? void 0 : attributes.align);\n}\n/**\n* Create a reusable Tiptap attribute config for table alignment\n*\n* @returns A Tiptap Attribute definition that parses and renders table alignment\n*/\nfunction createAlignAttribute() {\n\treturn {\n\t\tdefault: null,\n\t\tparseHTML: (element) => parseAlign(element),\n\t\trenderHTML: (attributes) => {\n\t\t\tif (!attributes.align) return {};\n\t\t\treturn { style: `text-align: ${attributes.align}` };\n\t\t}\n\t};\n}\n//#endregion\n//#region src/utils/parseColwidth.ts\n/**\n* reads the width of the `<col>` element matching a cell's column from the table's `<colgroup>`\n*\n* @param element - The table cell/header DOM element\n* @returns - An array with the column width in pixels or null\n*/\nfunction parseColgroupWidth(element) {\n\tvar _table$querySelectorA;\n\tconst row = element.parentElement;\n\tconst table = element.closest(\"table\");\n\tif (!row || !table) return null;\n\tconst cellIndex = Array.from(row.children).indexOf(element);\n\tconst width = (_table$querySelectorA = table.querySelectorAll(\"colgroup > col\")[cellIndex]) === null || _table$querySelectorA === void 0 ? void 0 : _table$querySelectorA.getAttribute(\"width\");\n\treturn width ? [parseInt(width, 10)] : null;\n}\n/**\n* Parse the column width/s of a table cell/header from an HTML element.\n* it prefers the `colwidth` attribute and if not-provided falls back to the `width` attribute\n* of the matching `<col>` element in the table's `<colgroup>`.\n*\n* @param element - The table cell/header DOM element\n* @returns - An array of column widths in pixels or null\n*/\nfunction parseColwidth(element) {\n\tconst colwidth = element.getAttribute(\"colwidth\");\n\tif (colwidth) return colwidth.split(\",\").map((width) => parseInt(width, 10));\n\treturn parseColgroupWidth(element);\n}\n//#endregion\n//#region src/utils/fillEmptyCellContent.ts\nconst COLLAPSIBLE_WHITESPACE = /[ \\t\\r\\n\\f]+/g;\n/** Whether a cell/header element has no child elements and only collapsible whitespace. */\nfunction isEmptyCellElement(element) {\n\tvar _element$textContent;\n\tif (element.children.length > 0) return false;\n\treturn ((_element$textContent = element.textContent) !== null && _element$textContent !== void 0 ? _element$textContent : \"\").replace(COLLAPSIBLE_WHITESPACE, \"\") === \"\";\n}\n/** Builds a cell/header's minimal `block+` content, derived from the node type. */\nfunction fillEmptyCellContent(cellType) {\n\tconst filled = cellType.createAndFill();\n\tif (!filled) throw new Error(`[tiptap error]: \"${cellType.name}\" has no default content to backfill.`);\n\treturn filled.content;\n}\n//#endregion\n//#region src/cell/table-cell.ts\n/**\n* This extension allows you to create table cells.\n* @see https://www.tiptap.dev/api/nodes/table-cell\n*/\nconst TableCell = Node.create({\n\tname: \"tableCell\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"block+\",\n\taddAttributes() {\n\t\treturn {\n\t\t\tcolspan: { default: 1 },\n\t\t\trowspan: { default: 1 },\n\t\t\tcolwidth: {\n\t\t\t\tdefault: null,\n\t\t\t\tparseHTML: parseColwidth\n\t\t\t},\n\t\t\talign: createAlignAttribute()\n\t\t};\n\t},\n\ttableRole: \"cell\",\n\tisolating: true,\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: \"td\",\n\t\t\tgetAttrs: (node) => isEmptyCellElement(node) ? {} : false,\n\t\t\tgetContent: (_node, schema) => fillEmptyCellContent(schema.nodes[this.name])\n\t\t}, { tag: \"td\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"td\",\n\t\t\tmergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t}\n});\n//#endregion\n//#region src/header/table-header.ts\n/**\n* This extension allows you to create table headers.\n* @see https://www.tiptap.dev/api/nodes/table-header\n*/\nconst TableHeader = Node.create({\n\tname: \"tableHeader\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"block+\",\n\taddAttributes() {\n\t\treturn {\n\t\t\tcolspan: { default: 1 },\n\t\t\trowspan: { default: 1 },\n\t\t\tcolwidth: {\n\t\t\t\tdefault: null,\n\t\t\t\tparseHTML: parseColwidth\n\t\t\t},\n\t\t\talign: createAlignAttribute()\n\t\t};\n\t},\n\ttableRole: \"header_cell\",\n\tisolating: true,\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: \"th\",\n\t\t\tgetAttrs: (node) => isEmptyCellElement(node) ? {} : false,\n\t\t\tgetContent: (_node, schema) => fillEmptyCellContent(schema.nodes[this.name])\n\t\t}, { tag: \"th\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"th\",\n\t\t\tmergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t}\n});\n//#endregion\n//#region src/row/table-row.ts\n/**\n* This extension allows you to create table rows.\n* @see https://www.tiptap.dev/api/nodes/table-row\n*/\nconst TableRow = Node.create({\n\tname: \"tableRow\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"(tableCell | tableHeader)*\",\n\ttableRole: \"row\",\n\tparseHTML() {\n\t\treturn [{ tag: \"tr\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"tr\",\n\t\t\tmergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t}\n});\n//#endregion\n//#region src/table/utilities/colStyle.ts\nfunction getColStyleDeclaration(minWidth, width) {\n\tif (width) return [\"width\", `${Math.max(width, minWidth)}px`];\n\treturn [\"min-width\", `${minWidth}px`];\n}\n//#endregion\n//#region src/table/TableView.ts\nfunction updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {\n\tlet totalWidth = 0;\n\tlet fixedWidth = true;\n\tlet nextDOM = colgroup.firstChild;\n\tconst row = node.firstChild;\n\tif (row !== null) for (let i = 0, col = 0; i < row.childCount; i += 1) {\n\t\tconst { colspan, colwidth } = row.child(i).attrs;\n\t\tfor (let j = 0; j < colspan; j += 1, col += 1) {\n\t\t\tconst hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];\n\t\t\tconst cssWidth = hasWidth ? `${hasWidth}px` : \"\";\n\t\t\ttotalWidth += hasWidth || cellMinWidth;\n\t\t\tif (!hasWidth) fixedWidth = false;\n\t\t\tif (!nextDOM) {\n\t\t\t\tconst colElement = document.createElement(\"col\");\n\t\t\t\tconst [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth);\n\t\t\t\tcolElement.style.setProperty(propertyKey, propertyValue);\n\t\t\t\tcolgroup.appendChild(colElement);\n\t\t\t} else {\n\t\t\t\tif (nextDOM.style.width !== cssWidth) {\n\t\t\t\t\tconst [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth);\n\t\t\t\t\tnextDOM.style.setProperty(propertyKey, propertyValue);\n\t\t\t\t}\n\t\t\t\tnextDOM = nextDOM.nextSibling;\n\t\t\t}\n\t\t}\n\t}\n\twhile (nextDOM) {\n\t\tvar _nextDOM$parentNode;\n\t\tconst after = nextDOM.nextSibling;\n\t\t(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);\n\t\tnextDOM = after;\n\t}\n\tconst hasUserWidth = node.attrs.style && typeof node.attrs.style === \"string\" && /\\bwidth\\s*:/i.test(node.attrs.style);\n\tif (fixedWidth && !hasUserWidth) {\n\t\ttable.style.width = `${totalWidth}px`;\n\t\ttable.style.minWidth = \"\";\n\t} else {\n\t\ttable.style.width = \"\";\n\t\ttable.style.minWidth = `${totalWidth}px`;\n\t}\n}\nvar TableView = class {\n\tconstructor(node, cellMinWidth, _view, HTMLAttributes = {}) {\n\t\tthis.node = node;\n\t\tthis.cellMinWidth = cellMinWidth;\n\t\tthis.dom = document.createElement(\"div\");\n\t\tthis.dom.className = \"tableWrapper\";\n\t\tthis.table = this.dom.appendChild(document.createElement(\"table\"));\n\t\tfor (const [key, value] of Object.entries(HTMLAttributes)) if (value !== void 0 && value !== null) {\n\t\t\tif (key === \"style\") this.table.style.cssText = String(value);\n\t\t\telse this.table.setAttribute(key, String(value));\n\t\t}\n\t\tif (node.attrs.style) this.table.style.cssText = node.attrs.style;\n\t\tthis.colgroup = this.table.appendChild(document.createElement(\"colgroup\"));\n\t\tupdateColumns(node, this.colgroup, this.table, cellMinWidth);\n\t\tthis.contentDOM = this.table.appendChild(document.createElement(\"tbody\"));\n\t}\n\tupdate(node) {\n\t\tif (node.type !== this.node.type) return false;\n\t\tthis.node = node;\n\t\tupdateColumns(node, this.colgroup, this.table, this.cellMinWidth);\n\t\treturn true;\n\t}\n\tignoreMutation(mutation) {\n\t\tconst target = mutation.target;\n\t\tconst isInsideWrapper = this.dom.contains(target);\n\t\tconst isInsideContent = this.contentDOM.contains(target);\n\t\tif (isInsideWrapper && !isInsideContent) {\n\t\t\tif (mutation.type === \"attributes\" || mutation.type === \"childList\" || mutation.type === \"characterData\") return true;\n\t\t}\n\t\treturn false;\n\t}\n};\n//#endregion\n//#region src/table/utilities/createColGroup.ts\nfunction createColGroup(node, cellMinWidth, overrideCol, overrideValue) {\n\tlet totalWidth = 0;\n\tlet fixedWidth = true;\n\tconst cols = [];\n\tconst row = node.firstChild;\n\tif (!row) return {};\n\tfor (let i = 0, col = 0; i < row.childCount; i += 1) {\n\t\tconst { colspan, colwidth } = row.child(i).attrs;\n\t\tfor (let j = 0; j < colspan; j += 1, col += 1) {\n\t\t\tconst hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];\n\t\t\ttotalWidth += hasWidth || cellMinWidth;\n\t\t\tif (!hasWidth) fixedWidth = false;\n\t\t\tconst [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth);\n\t\t\tcols.push([\"col\", { style: `${property}: ${value}` }]);\n\t\t}\n\t}\n\tconst tableWidth = fixedWidth ? `${totalWidth}px` : \"\";\n\tconst tableMinWidth = fixedWidth ? \"\" : `${totalWidth}px`;\n\treturn {\n\t\tcolgroup: [\n\t\t\t\"colgroup\",\n\t\t\t{},\n\t\t\t...cols\n\t\t],\n\t\ttableWidth,\n\t\ttableMinWidth\n\t};\n}\n//#endregion\n//#region src/table/utilities/createCell.ts\nfunction createCell(cellType, cellContent) {\n\tif (cellContent) return cellType.createChecked(null, cellContent);\n\treturn cellType.createAndFill();\n}\n//#endregion\n//#region src/table/utilities/getTableNodeTypes.ts\nfunction getTableNodeTypes(schema) {\n\tif (schema.cached.tableNodeTypes) return schema.cached.tableNodeTypes;\n\tconst roles = {};\n\tObject.keys(schema.nodes).forEach((type) => {\n\t\tconst nodeType = schema.nodes[type];\n\t\tif (nodeType.spec.tableRole) roles[nodeType.spec.tableRole] = nodeType;\n\t});\n\tschema.cached.tableNodeTypes = roles;\n\treturn roles;\n}\n//#endregion\n//#region src/table/utilities/createTable.ts\nfunction createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {\n\tconst types = getTableNodeTypes(schema);\n\tconst headerCells = [];\n\tconst cells = [];\n\tfor (let index = 0; index < colsCount; index += 1) {\n\t\tconst cell = createCell(types.cell, cellContent);\n\t\tif (cell) cells.push(cell);\n\t\tif (withHeaderRow) {\n\t\t\tconst headerCell = createCell(types.header_cell, cellContent);\n\t\t\tif (headerCell) headerCells.push(headerCell);\n\t\t}\n\t}\n\tconst rows = [];\n\tfor (let index = 0; index < rowsCount; index += 1) rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells));\n\treturn types.table.createChecked(null, rows);\n}\n//#endregion\n//#region src/table/utilities/isCellSelection.ts\nfunction isCellSelection(value) {\n\treturn value instanceof CellSelection;\n}\n//#endregion\n//#region src/table/utilities/deleteTableWhenAllCellsSelected.ts\nconst deleteTableWhenAllCellsSelected = ({ editor }) => {\n\tconst { selection } = editor.state;\n\tif (!isCellSelection(selection)) return false;\n\tlet cellCount = 0;\n\tconst table = findParentNodeClosestToPos(selection.ranges[0].$from, (node) => {\n\t\treturn node.type.name === \"table\";\n\t});\n\ttable === null || table === void 0 || table.node.descendants((node) => {\n\t\tif (node.type.name === \"table\") return false;\n\t\tif ([\"tableCell\", \"tableHeader\"].includes(node.type.name)) cellCount += 1;\n\t});\n\tif (!(cellCount === selection.ranges.length)) return false;\n\teditor.commands.deleteTable();\n\treturn true;\n};\n//#endregion\n//#region src/table/utilities/keepCursorInTable.ts\nfunction keepCursorInTable(tr, tablePos) {\n\tconst mappedTablePos = tr.mapping.map(tablePos);\n\tconst stillInTable = findParentNodeClosestToPos(tr.selection.$from, (node) => node.type.name === \"table\");\n\tif ((stillInTable === null || stillInTable === void 0 ? void 0 : stillInTable.pos) === mappedTablePos) return;\n\tconst tableNode = tr.doc.nodeAt(mappedTablePos);\n\tif (!tableNode) return;\n\tconst endOfTable = mappedTablePos + tableNode.nodeSize - 1;\n\ttr.setSelection(TextSelection.near(tr.doc.resolve(endOfTable), -1));\n}\n//#endregion\n//#region src/table/utilities/markdown.ts\nconst DEFAULT_CELL_LINE_SEPARATOR = \"\u001f\";\n/**\n* Walk a single table-row line and escape any `|` characters that appear\n* inside backtick code spans so marked's cell splitter ignores them.\n* Backslash escape sequences outside code spans are passed through untouched.\n* If a backtick run has no matching closer on the same line it is emitted\n* as-is — no over-escaping for malformed input.\n*/\nfunction escapeTableCellPipes(line) {\n\tlet result = \"\";\n\tlet i = 0;\n\twhile (i < line.length) {\n\t\tif (line[i] === \"\\\\\" && i + 1 < line.length) {\n\t\t\tresult += line[i] + line[i + 1];\n\t\t\ti += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (line[i] !== \"`\") {\n\t\t\tresult += line[i++];\n\t\t\tcontinue;\n\t\t}\n\t\tlet runLen = 0;\n\t\twhile (i + runLen < line.length && line[i + runLen] === \"`\") runLen += 1;\n\t\tlet j = i + runLen;\n\t\tlet found = false;\n\t\twhile (j < line.length) {\n\t\t\tif (line[j] !== \"`\") {\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet closeLen = 0;\n\t\t\twhile (j + closeLen < line.length && line[j + closeLen] === \"`\") closeLen += 1;\n\t\t\tif (closeLen === runLen) {\n\t\t\t\tconst spanContent = line.slice(i + runLen, j);\n\t\t\t\tresult += line.slice(i, i + runLen) + spanContent.replace(/\\\\\\||\\|/g, (match) => match === \"|\" ? \"\\\\|\" : match) + line.slice(j, j + runLen);\n\t\t\t\ti = j + runLen;\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tj += closeLen;\n\t\t}\n\t\tif (!found) {\n\t\t\tresult += line.slice(i, i + runLen);\n\t\t\ti += runLen;\n\t\t}\n\t}\n\treturn result;\n}\n/**\n* Escape pipe characters inside backtick code spans on table-row lines.\n* marked's `splitCells` only recognises backslash-escaped pipes (`\\|`) and\n* splits on every other `|`, so \\`a || b\\` in a table cell would be treated\n* as multiple column delimiters. Escaping them here lets `splitCells` skip\n* them; it already converts `\\|` → `|` after splitting, so the cell content\n* is restored correctly.\n*/\nfunction preprocessTablePipes(src) {\n\treturn src.split(\"\\n\").map((line) => {\n\t\tif (!line.includes(\"|\") || !line.includes(\"`\")) return line;\n\t\treturn escapeTableCellPipes(line);\n\t}).join(\"\\n\");\n}\nfunction collapseWhitespace(s) {\n\treturn (s || \"\").replace(/\\s+/g, \" \").trim();\n}\nfunction renderTableToMarkdown(node, h, options = {}) {\n\tvar _options$cellLineSepa;\n\tconst cellSep = (_options$cellLineSepa = options.cellLineSeparator) !== null && _options$cellLineSepa !== void 0 ? _options$cellLineSepa : \"\u001f\";\n\tif (!node || !node.content || node.content.length === 0) return \"\";\n\tconst rows = [];\n\tnode.content.forEach((rowNode) => {\n\t\tconst cells = [];\n\t\tif (rowNode.content) rowNode.content.forEach((cellNode) => {\n\t\t\tlet raw = \"\";\n\t\t\tif (cellNode.content && Array.isArray(cellNode.content) && cellNode.content.length > 1) raw = cellNode.content.map((child) => h.renderChildren(child)).join(cellSep);\n\t\t\telse raw = cellNode.content ? h.renderChildren(cellNode.content) : \"\";\n\t\t\tconst text = collapseWhitespace(raw.split(cellSep).join(\"\\n\").replace(/[ \\t]*\\r?\\n[ \\t]*/g, \"<br>\"));\n\t\t\tconst isHeader = cellNode.type === \"tableHeader\";\n\t\t\tconst align = normalizeTableCellAlignFromAttributes(cellNode.attrs);\n\t\t\tcells.push({\n\t\t\t\ttext,\n\t\t\t\tisHeader,\n\t\t\t\talign\n\t\t\t});\n\t\t});\n\t\trows.push(cells);\n\t});\n\tconst columnCount = rows.reduce((max, r) => Math.max(max, r.length), 0);\n\tif (columnCount === 0) return \"\";\n\tconst colWidths = Array.from({ length: columnCount }).fill(0);\n\trows.forEach((r) => {\n\t\tfor (let i = 0; i < columnCount; i += 1) {\n\t\t\tvar _r$i;\n\t\t\tconst len = (((_r$i = r[i]) === null || _r$i === void 0 ? void 0 : _r$i.text) || \"\").length;\n\t\t\tif (len > colWidths[i]) colWidths[i] = len;\n\t\t\tif (colWidths[i] < 3) colWidths[i] = 3;\n\t\t}\n\t});\n\tconst pad = (s, width) => s + \" \".repeat(Math.max(0, width - s.length));\n\tconst headerRow = rows[0];\n\tconst hasHeader = headerRow.some((c) => c.isHeader);\n\tconst colAlignments = Array.from({ length: columnCount }).fill(null);\n\trows.forEach((r) => {\n\t\tfor (let i = 0; i < columnCount; i += 1) {\n\t\t\tvar _r$i2;\n\t\t\tif (!colAlignments[i] && ((_r$i2 = r[i]) === null || _r$i2 === void 0 ? void 0 : _r$i2.align)) colAlignments[i] = r[i].align;\n\t\t}\n\t});\n\tlet out = \"\\n\";\n\tconst headerTexts = Array.from({ length: columnCount }).map((_, i) => hasHeader ? headerRow[i] && headerRow[i].text || \"\" : \"\");\n\tout += `| ${headerTexts.map((t, i) => pad(t, colWidths[i])).join(\" | \")} |\\n`;\n\tout += `| ${colWidths.map((w, index) => {\n\t\tconst dashCount = Math.max(3, w);\n\t\tconst alignment = colAlignments[index];\n\t\tif (alignment === \"left\") return `:${\"-\".repeat(dashCount)}`;\n\t\tif (alignment === \"right\") return `${\"-\".repeat(dashCount)}:`;\n\t\tif (alignment === \"center\") return `:${\"-\".repeat(dashCount)}:`;\n\t\treturn \"-\".repeat(dashCount);\n\t}).join(\" | \")} |\\n`;\n\t(hasHeader ? rows.slice(1) : rows).forEach((r) => {\n\t\tout += `| ${Array.from({ length: columnCount }).fill(0).map((_, i) => pad(r[i] && r[i].text || \"\", colWidths[i])).join(\" | \")} |\\n`;\n\t});\n\treturn out;\n}\n//#endregion\n//#region src/table/table.ts\n/**\n* This extension allows you to create tables.\n* @see https://www.tiptap.dev/api/nodes/table\n*/\nconst Table = Node.create({\n\tname: \"table\",\n\taddOptions() {\n\t\treturn {\n\t\t\tHTMLAttributes: {},\n\t\t\tresizable: false,\n\t\t\trenderWrapper: false,\n\t\t\thandleWidth: 5,\n\t\t\tcellMinWidth: 25,\n\t\t\tView: TableView,\n\t\t\tlastColumnResizable: true,\n\t\t\tallowTableNodeSelection: false\n\t\t};\n\t},\n\tcontent: \"tableRow+\",\n\ttableRole: \"table\",\n\tisolating: true,\n\tgroup: \"block\",\n\tparseHTML() {\n\t\treturn [{ tag: \"table\" }];\n\t},\n\trenderHTML({ node, HTMLAttributes }) {\n\t\tconst { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth);\n\t\tconst userStyles = HTMLAttributes.style;\n\t\tfunction getTableStyle() {\n\t\t\tif (userStyles) return userStyles;\n\t\t\treturn tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`;\n\t\t}\n\t\tconst table = [\n\t\t\t\"table\",\n\t\t\tmergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { style: getTableStyle() }),\n\t\t\tcolgroup,\n\t\t\t[\"tbody\", 0]\n\t\t];\n\t\treturn this.options.renderWrapper ? [\n\t\t\t\"div\",\n\t\t\t{ class: \"tableWrapper\" },\n\t\t\ttable\n\t\t] : table;\n\t},\n\tparseMarkdown: (token, h) => {\n\t\tconst rows = [];\n\t\tconst alignments = Array.isArray(token.align) ? token.align : [];\n\t\tif (token.header) {\n\t\t\tconst headerCells = [];\n\t\t\ttoken.header.forEach((cell, index) => {\n\t\t\t\tvar _alignments$index;\n\t\t\t\tconst align = normalizeTableCellAlign((_alignments$index = alignments[index]) !== null && _alignments$index !== void 0 ? _alignments$index : cell.align);\n\t\t\t\tconst attrs = align ? { align } : {};\n\t\t\t\theaderCells.push(h.createNode(\"tableHeader\", attrs, [{\n\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\tcontent: h.parseInline(cell.tokens)\n\t\t\t\t}]));\n\t\t\t});\n\t\t\trows.push(h.createNode(\"tableRow\", {}, headerCells));\n\t\t}\n\t\tif (token.rows) token.rows.forEach((row) => {\n\t\t\tconst bodyCells = [];\n\t\t\trow.forEach((cell, index) => {\n\t\t\t\tvar _alignments$index2;\n\t\t\t\tconst align = normalizeTableCellAlign((_alignments$index2 = alignments[index]) !== null && _alignments$index2 !== void 0 ? _alignments$index2 : cell.align);\n\t\t\t\tconst attrs = align ? { align } : {};\n\t\t\t\tbodyCells.push(h.createNode(\"tableCell\", attrs, [{\n\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\tcontent: h.parseInline(cell.tokens)\n\t\t\t\t}]));\n\t\t\t});\n\t\t\trows.push(h.createNode(\"tableRow\", {}, bodyCells));\n\t\t});\n\t\treturn h.createNode(\"table\", void 0, rows);\n\t},\n\trenderMarkdown: (node, h) => {\n\t\treturn renderTableToMarkdown(node, h);\n\t},\n\tmarkdownTokenizer: {\n\t\tname: \"table\",\n\t\tlevel: \"block\",\n\t\tstart: (src) => {\n\t\t\tconst lines = src.split(\"\\n\");\n\t\t\tif (lines.length < 2) return -1;\n\t\t\tconst sep = lines[1];\n\t\t\tif (!/^[ \\t|:]*-[ \\t|:-]*$/.test(sep) || !sep.includes(\"|\")) return -1;\n\t\t\treturn lines[0].includes(\"|\") ? 0 : -1;\n\t\t},\n\t\ttokenize(src, _tokens, helper) {\n\t\t\tconst blankLineIndex = src.indexOf(\"\\n\\n\");\n\t\t\tconst candidate = blankLineIndex >= 0 ? src.slice(0, blankLineIndex) : src;\n\t\t\tconst candidateLines = candidate.split(\"\\n\");\n\t\t\tif (candidateLines.length < 2) return void 0;\n\t\t\tconst sep = candidateLines[1];\n\t\t\tif (!/^[ \\t|:]*-[ \\t|:-]*$/.test(sep) || !sep.includes(\"|\")) return void 0;\n\t\t\tconst preprocessed = preprocessTablePipes(candidate);\n\t\t\tif (preprocessed === candidate) return void 0;\n\t\t\tconst tableToken = helper.blockTokens(preprocessed)[0];\n\t\t\tif ((tableToken === null || tableToken === void 0 ? void 0 : tableToken.type) !== \"table\" || !tableToken.raw) return void 0;\n\t\t\tconst lineCount = tableToken.raw.split(\"\\n\").length;\n\t\t\tconst raw = src.split(\"\\n\").slice(0, lineCount).join(\"\\n\");\n\t\t\treturn {\n\t\t\t\t...tableToken,\n\t\t\t\traw\n\t\t\t};\n\t\t}\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tinsertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => {\n\t\t\t\tconst node = createTable(editor.schema, rows, cols, withHeaderRow);\n\t\t\t\tif (dispatch) {\n\t\t\t\t\tconst offset = tr.selection.from + 1;\n\t\t\t\t\ttr.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr.doc.resolve(offset)));\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\taddColumnBefore: () => ({ state, dispatch }) => {\n\t\t\t\treturn addColumnBefore(state, dispatch);\n\t\t\t},\n\t\t\taddColumnAfter: () => ({ state, dispatch }) => {\n\t\t\t\treturn addColumnAfter(state, dispatch);\n\t\t\t},\n\t\t\tdeleteColumn: () => ({ state, dispatch }) => {\n\t\t\t\tconst table = findParentNodeClosestToPos(state.selection.$from, (node) => node.type.name === \"table\");\n\t\t\t\treturn deleteColumn(state, dispatch && ((tr) => {\n\t\t\t\t\tif (table) keepCursorInTable(tr, table.pos);\n\t\t\t\t\tdispatch(tr);\n\t\t\t\t}));\n\t\t\t},\n\t\t\taddRowBefore: () => ({ state, dispatch }) => {\n\t\t\t\treturn addRowBefore(state, dispatch);\n\t\t\t},\n\t\t\taddRowAfter: () => ({ state, dispatch }) => {\n\t\t\t\treturn addRowAfter(state, dispatch);\n\t\t\t},\n\t\t\tdeleteRow: () => ({ state, dispatch }) => {\n\t\t\t\tconst table = findParentNodeClosestToPos(state.selection.$from, (node) => node.type.name === \"table\");\n\t\t\t\treturn deleteRow(state, dispatch && ((tr) => {\n\t\t\t\t\tif (table) keepCursorInTable(tr, table.pos);\n\t\t\t\t\tdispatch(tr);\n\t\t\t\t}));\n\t\t\t},\n\t\t\tdeleteTable: () => ({ state, dispatch }) => {\n\t\t\t\treturn deleteTable(state, dispatch);\n\t\t\t},\n\t\t\tmergeCells: () => ({ state, dispatch }) => {\n\t\t\t\treturn mergeCells(state, dispatch);\n\t\t\t},\n\t\t\tsplitCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn splitCell(state, dispatch);\n\t\t\t},\n\t\t\ttoggleHeaderColumn: () => ({ state, dispatch }) => {\n\t\t\t\treturn toggleHeader(\"column\")(state, dispatch);\n\t\t\t},\n\t\t\ttoggleHeaderRow: () => ({ state, dispatch }) => {\n\t\t\t\treturn toggleHeader(\"row\")(state, dispatch);\n\t\t\t},\n\t\t\ttoggleHeaderCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn toggleHeaderCell(state, dispatch);\n\t\t\t},\n\t\t\tmergeOrSplit: () => ({ state, dispatch }) => {\n\t\t\t\tif (mergeCells(state, dispatch)) return true;\n\t\t\t\treturn splitCell(state, dispatch);\n\t\t\t},\n\t\t\tsetCellAttribute: (name, value) => ({ state, dispatch }) => {\n\t\t\t\treturn setCellAttr(name, value)(state, dispatch);\n\t\t\t},\n\t\t\tgoToNextCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn goToNextCell(1)(state, dispatch);\n\t\t\t},\n\t\t\tgoToPreviousCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn goToNextCell(-1)(state, dispatch);\n\t\t\t},\n\t\t\tfixTables: () => ({ state, dispatch }) => {\n\t\t\t\tif (dispatch) fixTables(state);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tsetCellSelection: (position) => ({ tr, dispatch }) => {\n\t\t\t\tif (dispatch) {\n\t\t\t\t\tconst selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell);\n\t\t\t\t\ttr.setSelection(selection);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\tTab: () => {\n\t\t\t\tif (this.editor.commands.goToNextCell()) return true;\n\t\t\t\tif (!this.editor.can().addRowAfter()) return false;\n\t\t\t\treturn this.editor.chain().addRowAfter().goToNextCell().run();\n\t\t\t},\n\t\t\t\"Shift-Tab\": () => this.editor.commands.goToPreviousCell(),\n\t\t\tBackspace: deleteTableWhenAllCellsSelected,\n\t\t\t\"Mod-Backspace\": deleteTableWhenAllCellsSelected,\n\t\t\tDelete: deleteTableWhenAllCellsSelected,\n\t\t\t\"Mod-Delete\": deleteTableWhenAllCellsSelected\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [...this.options.resizable && this.editor.isEditable ? [columnResizing({\n\t\t\thandleWidth: this.options.handleWidth,\n\t\t\tcellMinWidth: this.options.cellMinWidth,\n\t\t\tdefaultCellMinWidth: this.options.cellMinWidth,\n\t\t\tView: this.options.View,\n\t\t\tlastColumnResizable: this.options.lastColumnResizable\n\t\t})] : [], tableEditing({ allowTableNodeSelection: this.options.allowTableNodeSelection })];\n\t},\n\taddNodeView() {\n\t\tconst isResizable = this.options.resizable && this.editor.isEditable;\n\t\tconst View = this.options.View;\n\t\tif (isResizable || !View) return null;\n\t\treturn ({ node, view, HTMLAttributes }) => {\n\t\t\tconst mergedAttributes = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes);\n\t\t\treturn new View(node, this.options.cellMinWidth, view, mergedAttributes);\n\t\t};\n\t},\n\textendNodeSchema(extension) {\n\t\tconst context = {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage\n\t\t};\n\t\treturn { tableRole: callOrReturn(getExtensionField(extension, \"tableRole\", context)) };\n\t}\n});\n//#endregion\n//#region src/kit/index.ts\n/**\n* The table kit is a collection of table editor extensions.\n*\n* It’s a good starting point for building your own table in Tiptap.\n*/\nconst TableKit = Extension.create({\n\tname: \"tableKit\",\n\taddExtensions() {\n\t\tconst extensions = [];\n\t\tif (this.options.table !== false) extensions.push(Table.configure(this.options.table));\n\t\tif (this.options.tableCell !== false) extensions.push(TableCell.configure(this.options.tableCell));\n\t\tif (this.options.tableHeader !== false) extensions.push(TableHeader.configure(this.options.tableHeader));\n\t\tif (this.options.tableRow !== false) extensions.push(TableRow.configure(this.options.tableRow));\n\t\treturn extensions;\n\t}\n});\n//#endregion\nexport { DEFAULT_CELL_LINE_SEPARATOR, Table, TableCell, TableHeader, TableKit, TableRow, TableView, createColGroup, createTable, escapeTableCellPipes, preprocessTablePipes, renderTableToMarkdown, updateColumns };\n\n//# source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