@tiptap/extension-table 3.0.0 → 3.0.2-beta.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.
Files changed (230) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/cell/index.cjs +68 -0
  4. package/dist/cell/index.cjs.map +1 -0
  5. package/dist/cell/index.d.cts +33 -0
  6. package/dist/cell/index.d.ts +33 -0
  7. package/dist/cell/index.js +41 -0
  8. package/dist/cell/index.js.map +1 -0
  9. package/dist/header/index.cjs +68 -0
  10. package/dist/header/index.cjs.map +1 -0
  11. package/dist/header/index.d.cts +33 -0
  12. package/dist/header/index.d.ts +33 -0
  13. package/dist/header/index.js +41 -0
  14. package/dist/header/index.js.map +1 -0
  15. package/dist/index.cjs +480 -321
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +305 -0
  18. package/dist/index.d.ts +305 -0
  19. package/dist/index.js +465 -316
  20. package/dist/index.js.map +1 -1
  21. package/dist/kit/index.cjs +497 -0
  22. package/dist/kit/index.cjs.map +1 -0
  23. package/dist/kit/index.d.cts +252 -0
  24. package/dist/kit/index.d.ts +252 -0
  25. package/dist/kit/index.js +490 -0
  26. package/dist/kit/index.js.map +1 -0
  27. package/dist/row/index.cjs +49 -0
  28. package/dist/row/index.cjs.map +1 -0
  29. package/dist/row/index.d.cts +33 -0
  30. package/dist/row/index.d.ts +33 -0
  31. package/dist/row/index.js +22 -0
  32. package/dist/row/index.js.map +1 -0
  33. package/dist/table/index.cjs +384 -0
  34. package/dist/table/index.cjs.map +1 -0
  35. package/dist/{packages/extension-table/src/table.d.ts → table/index.d.cts} +45 -19
  36. package/dist/table/index.d.ts +220 -0
  37. package/dist/table/index.js +373 -0
  38. package/dist/table/index.js.map +1 -0
  39. package/package.json +53 -11
  40. package/src/cell/index.ts +1 -0
  41. package/src/cell/table-cell.ts +60 -0
  42. package/src/header/index.ts +1 -0
  43. package/src/header/table-header.ts +60 -0
  44. package/src/index.ts +6 -7
  45. package/src/kit/index.ts +64 -0
  46. package/src/row/index.ts +1 -0
  47. package/src/row/table-row.ts +38 -0
  48. package/src/table/TableView.ts +108 -0
  49. package/src/table/index.ts +3 -0
  50. package/src/{table.ts → table/table.ts} +56 -64
  51. package/src/table/utilities/colStyle.ts +9 -0
  52. package/src/{utilities → table/utilities}/createCell.ts +1 -1
  53. package/src/{utilities → table/utilities}/createColGroup.ts +24 -6
  54. package/src/{utilities → table/utilities}/createTable.ts +1 -1
  55. package/src/{utilities → table/utilities}/deleteTableWhenAllCellsSelected.ts +2 -1
  56. package/src/{utilities → table/utilities}/getTableNodeTypes.ts +1 -1
  57. package/src/types.ts +19 -0
  58. package/dist/index.umd.js +0 -358
  59. package/dist/index.umd.js.map +0 -1
  60. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  61. package/dist/packages/core/src/Editor.d.ts +0 -161
  62. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  63. package/dist/packages/core/src/Extension.d.ts +0 -343
  64. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  65. package/dist/packages/core/src/InputRule.d.ts +0 -42
  66. package/dist/packages/core/src/Mark.d.ts +0 -451
  67. package/dist/packages/core/src/Node.d.ts +0 -611
  68. package/dist/packages/core/src/NodePos.d.ts +0 -44
  69. package/dist/packages/core/src/NodeView.d.ts +0 -31
  70. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  71. package/dist/packages/core/src/Tracker.d.ts +0 -11
  72. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  73. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  74. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  75. package/dist/packages/core/src/commands/command.d.ts +0 -18
  76. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  77. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  78. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  79. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  80. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  81. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  82. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  83. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  84. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  85. package/dist/packages/core/src/commands/first.d.ts +0 -14
  86. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  87. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  88. package/dist/packages/core/src/commands/index.d.ts +0 -55
  89. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  90. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  91. package/dist/packages/core/src/commands/join.d.ts +0 -41
  92. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  93. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  94. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  95. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  96. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  97. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  98. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  99. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  100. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  101. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  102. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  103. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  104. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  105. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  106. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  107. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  108. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  109. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  110. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  111. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  112. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  113. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  114. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  115. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  116. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  117. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  118. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  119. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  120. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  121. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  122. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  123. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  124. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  125. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  126. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  127. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  128. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  129. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  130. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  131. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  132. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  133. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  134. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  136. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  137. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  138. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  139. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  140. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  141. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  142. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  143. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  144. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  145. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  146. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  147. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  148. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  149. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  150. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  151. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  152. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  153. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  154. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  155. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  156. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  157. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  158. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  159. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  160. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  161. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  162. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  163. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  164. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  165. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  166. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  167. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  168. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  169. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  170. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  171. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  172. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  173. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  174. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  175. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  176. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  177. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  178. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  179. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  180. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  181. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  182. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  183. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  184. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  185. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  186. package/dist/packages/core/src/index.d.ts +0 -24
  187. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  188. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  189. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  190. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  191. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  192. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  193. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  194. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  195. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  196. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  197. package/dist/packages/core/src/style.d.ts +0 -1
  198. package/dist/packages/core/src/types.d.ts +0 -255
  199. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  200. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  201. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  202. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  203. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  204. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  205. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  206. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  207. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  208. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  209. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  210. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  211. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  212. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  213. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  214. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  215. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  216. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  217. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  218. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  219. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  220. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  221. package/dist/packages/extension-table/src/TableView.d.ts +0 -17
  222. package/dist/packages/extension-table/src/index.d.ts +0 -5
  223. package/dist/packages/extension-table/src/utilities/createCell.d.ts +0 -2
  224. package/dist/packages/extension-table/src/utilities/createColGroup.d.ts +0 -19
  225. package/dist/packages/extension-table/src/utilities/createTable.d.ts +0 -2
  226. package/dist/packages/extension-table/src/utilities/deleteTableWhenAllCellsSelected.d.ts +0 -2
  227. package/dist/packages/extension-table/src/utilities/getTableNodeTypes.d.ts +0 -4
  228. package/dist/packages/extension-table/src/utilities/isCellSelection.d.ts +0 -2
  229. package/src/TableView.ts +0 -100
  230. /package/src/{utilities → table/utilities}/isCellSelection.ts +0 -0
package/dist/index.umd.js DELETED
@@ -1,358 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/pm/tables')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/pm/tables'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-table"] = {}, global.core, global.state, global.tables));
5
- })(this, (function (exports, core, state, tables) { 'use strict';
6
-
7
- function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
8
- let totalWidth = 0;
9
- let fixedWidth = true;
10
- let nextDOM = colgroup.firstChild;
11
- const row = node.firstChild;
12
- for (let i = 0, col = 0; i < row.childCount; i += 1) {
13
- const { colspan, colwidth } = row.child(i).attrs;
14
- for (let j = 0; j < colspan; j += 1, col += 1) {
15
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
16
- const cssWidth = hasWidth ? `${hasWidth}px` : '';
17
- totalWidth += hasWidth || cellMinWidth;
18
- if (!hasWidth) {
19
- fixedWidth = false;
20
- }
21
- if (!nextDOM) {
22
- colgroup.appendChild(document.createElement('col')).style.width = cssWidth;
23
- }
24
- else {
25
- if (nextDOM.style.width !== cssWidth) {
26
- nextDOM.style.width = cssWidth;
27
- }
28
- nextDOM = nextDOM.nextSibling;
29
- }
30
- }
31
- }
32
- while (nextDOM) {
33
- const after = nextDOM.nextSibling;
34
- nextDOM.parentNode.removeChild(nextDOM);
35
- nextDOM = after;
36
- }
37
- if (fixedWidth) {
38
- table.style.width = `${totalWidth}px`;
39
- table.style.minWidth = '';
40
- }
41
- else {
42
- table.style.width = '';
43
- table.style.minWidth = `${totalWidth}px`;
44
- }
45
- }
46
- class TableView {
47
- constructor(node, cellMinWidth) {
48
- this.node = node;
49
- this.cellMinWidth = cellMinWidth;
50
- this.dom = document.createElement('div');
51
- this.dom.className = 'tableWrapper';
52
- this.table = this.dom.appendChild(document.createElement('table'));
53
- this.colgroup = this.table.appendChild(document.createElement('colgroup'));
54
- updateColumns(node, this.colgroup, this.table, cellMinWidth);
55
- this.contentDOM = this.table.appendChild(document.createElement('tbody'));
56
- }
57
- update(node) {
58
- if (node.type !== this.node.type) {
59
- return false;
60
- }
61
- this.node = node;
62
- updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
63
- return true;
64
- }
65
- ignoreMutation(mutation) {
66
- return (mutation.type === 'attributes'
67
- && (mutation.target === this.table || this.colgroup.contains(mutation.target)));
68
- }
69
- }
70
-
71
- /**
72
- * Creates a colgroup element for a table node in ProseMirror.
73
- *
74
- * @param node - The ProseMirror node representing the table.
75
- * @param cellMinWidth - The minimum width of a cell in the table.
76
- * @param overrideCol - (Optional) The index of the column to override the width of.
77
- * @param overrideValue - (Optional) The width value to use for the overridden column.
78
- * @returns An object containing the colgroup element, the total width of the table, and the minimum width of the table.
79
- */
80
- function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
81
- let totalWidth = 0;
82
- let fixedWidth = true;
83
- const cols = [];
84
- const row = node.firstChild;
85
- if (!row) {
86
- return {};
87
- }
88
- for (let i = 0, col = 0; i < row.childCount; i += 1) {
89
- const { colspan, colwidth } = row.child(i).attrs;
90
- for (let j = 0; j < colspan; j += 1, col += 1) {
91
- const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
92
- const cssWidth = hasWidth ? `${hasWidth}px` : '';
93
- totalWidth += hasWidth || cellMinWidth;
94
- if (!hasWidth) {
95
- fixedWidth = false;
96
- }
97
- cols.push(['col', cssWidth ? { style: `width: ${cssWidth}` } : {}]);
98
- }
99
- }
100
- const tableWidth = fixedWidth ? `${totalWidth}px` : '';
101
- const tableMinWidth = fixedWidth ? '' : `${totalWidth}px`;
102
- const colgroup = ['colgroup', {}, ...cols];
103
- return { colgroup, tableWidth, tableMinWidth };
104
- }
105
-
106
- function createCell(cellType, cellContent) {
107
- if (cellContent) {
108
- return cellType.createChecked(null, cellContent);
109
- }
110
- return cellType.createAndFill();
111
- }
112
-
113
- function getTableNodeTypes(schema) {
114
- if (schema.cached.tableNodeTypes) {
115
- return schema.cached.tableNodeTypes;
116
- }
117
- const roles = {};
118
- Object.keys(schema.nodes).forEach(type => {
119
- const nodeType = schema.nodes[type];
120
- if (nodeType.spec.tableRole) {
121
- roles[nodeType.spec.tableRole] = nodeType;
122
- }
123
- });
124
- schema.cached.tableNodeTypes = roles;
125
- return roles;
126
- }
127
-
128
- function createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {
129
- const types = getTableNodeTypes(schema);
130
- const headerCells = [];
131
- const cells = [];
132
- for (let index = 0; index < colsCount; index += 1) {
133
- const cell = createCell(types.cell, cellContent);
134
- if (cell) {
135
- cells.push(cell);
136
- }
137
- if (withHeaderRow) {
138
- const headerCell = createCell(types.header_cell, cellContent);
139
- if (headerCell) {
140
- headerCells.push(headerCell);
141
- }
142
- }
143
- }
144
- const rows = [];
145
- for (let index = 0; index < rowsCount; index += 1) {
146
- rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells));
147
- }
148
- return types.table.createChecked(null, rows);
149
- }
150
-
151
- function isCellSelection(value) {
152
- return value instanceof tables.CellSelection;
153
- }
154
-
155
- const deleteTableWhenAllCellsSelected = ({ editor }) => {
156
- const { selection } = editor.state;
157
- if (!isCellSelection(selection)) {
158
- return false;
159
- }
160
- let cellCount = 0;
161
- const table = core.findParentNodeClosestToPos(selection.ranges[0].$from, node => {
162
- return node.type.name === 'table';
163
- });
164
- table === null || table === void 0 ? void 0 : table.node.descendants(node => {
165
- if (node.type.name === 'table') {
166
- return false;
167
- }
168
- if (['tableCell', 'tableHeader'].includes(node.type.name)) {
169
- cellCount += 1;
170
- }
171
- });
172
- const allCellsSelected = cellCount === selection.ranges.length;
173
- if (!allCellsSelected) {
174
- return false;
175
- }
176
- editor.commands.deleteTable();
177
- return true;
178
- };
179
-
180
- /**
181
- * This extension allows you to create tables.
182
- * @see https://www.tiptap.dev/api/nodes/table
183
- */
184
- const Table = core.Node.create({
185
- name: 'table',
186
- // @ts-ignore
187
- addOptions() {
188
- return {
189
- HTMLAttributes: {},
190
- resizable: false,
191
- handleWidth: 5,
192
- cellMinWidth: 25,
193
- // TODO: fix
194
- View: TableView,
195
- lastColumnResizable: true,
196
- allowTableNodeSelection: false,
197
- };
198
- },
199
- content: 'tableRow+',
200
- tableRole: 'table',
201
- isolating: true,
202
- group: 'block',
203
- parseHTML() {
204
- return [{ tag: 'table' }];
205
- },
206
- renderHTML({ node, HTMLAttributes }) {
207
- const { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth);
208
- const table = [
209
- 'table',
210
- core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
211
- style: tableWidth
212
- ? `width: ${tableWidth}`
213
- : `minWidth: ${tableMinWidth}`,
214
- }),
215
- colgroup,
216
- ['tbody', 0],
217
- ];
218
- return table;
219
- },
220
- addCommands() {
221
- return {
222
- insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => {
223
- const node = createTable(editor.schema, rows, cols, withHeaderRow);
224
- if (dispatch) {
225
- const offset = tr.selection.from + 1;
226
- tr.replaceSelectionWith(node)
227
- .scrollIntoView()
228
- .setSelection(state.TextSelection.near(tr.doc.resolve(offset)));
229
- }
230
- return true;
231
- },
232
- addColumnBefore: () => ({ state, dispatch }) => {
233
- return tables.addColumnBefore(state, dispatch);
234
- },
235
- addColumnAfter: () => ({ state, dispatch }) => {
236
- return tables.addColumnAfter(state, dispatch);
237
- },
238
- deleteColumn: () => ({ state, dispatch }) => {
239
- return tables.deleteColumn(state, dispatch);
240
- },
241
- addRowBefore: () => ({ state, dispatch }) => {
242
- return tables.addRowBefore(state, dispatch);
243
- },
244
- addRowAfter: () => ({ state, dispatch }) => {
245
- return tables.addRowAfter(state, dispatch);
246
- },
247
- deleteRow: () => ({ state, dispatch }) => {
248
- return tables.deleteRow(state, dispatch);
249
- },
250
- deleteTable: () => ({ state, dispatch }) => {
251
- return tables.deleteTable(state, dispatch);
252
- },
253
- mergeCells: () => ({ state, dispatch }) => {
254
- return tables.mergeCells(state, dispatch);
255
- },
256
- splitCell: () => ({ state, dispatch }) => {
257
- return tables.splitCell(state, dispatch);
258
- },
259
- toggleHeaderColumn: () => ({ state, dispatch }) => {
260
- return tables.toggleHeader('column')(state, dispatch);
261
- },
262
- toggleHeaderRow: () => ({ state, dispatch }) => {
263
- return tables.toggleHeader('row')(state, dispatch);
264
- },
265
- toggleHeaderCell: () => ({ state, dispatch }) => {
266
- return tables.toggleHeaderCell(state, dispatch);
267
- },
268
- mergeOrSplit: () => ({ state, dispatch }) => {
269
- if (tables.mergeCells(state, dispatch)) {
270
- return true;
271
- }
272
- return tables.splitCell(state, dispatch);
273
- },
274
- setCellAttribute: (name, value) => ({ state, dispatch }) => {
275
- return tables.setCellAttr(name, value)(state, dispatch);
276
- },
277
- goToNextCell: () => ({ state, dispatch }) => {
278
- return tables.goToNextCell(1)(state, dispatch);
279
- },
280
- goToPreviousCell: () => ({ state, dispatch }) => {
281
- return tables.goToNextCell(-1)(state, dispatch);
282
- },
283
- fixTables: () => ({ state, dispatch }) => {
284
- if (dispatch) {
285
- tables.fixTables(state);
286
- }
287
- return true;
288
- },
289
- setCellSelection: position => ({ tr, dispatch }) => {
290
- if (dispatch) {
291
- const selection = tables.CellSelection.create(tr.doc, position.anchorCell, position.headCell);
292
- // @ts-ignore
293
- tr.setSelection(selection);
294
- }
295
- return true;
296
- },
297
- };
298
- },
299
- addKeyboardShortcuts() {
300
- return {
301
- Tab: () => {
302
- if (this.editor.commands.goToNextCell()) {
303
- return true;
304
- }
305
- if (!this.editor.can().addRowAfter()) {
306
- return false;
307
- }
308
- return this.editor.chain().addRowAfter().goToNextCell().run();
309
- },
310
- 'Shift-Tab': () => this.editor.commands.goToPreviousCell(),
311
- Backspace: deleteTableWhenAllCellsSelected,
312
- 'Mod-Backspace': deleteTableWhenAllCellsSelected,
313
- Delete: deleteTableWhenAllCellsSelected,
314
- 'Mod-Delete': deleteTableWhenAllCellsSelected,
315
- };
316
- },
317
- addProseMirrorPlugins() {
318
- const isResizable = this.options.resizable && this.editor.isEditable;
319
- return [
320
- ...(isResizable
321
- ? [
322
- tables.columnResizing({
323
- handleWidth: this.options.handleWidth,
324
- cellMinWidth: this.options.cellMinWidth,
325
- // @ts-ignore (incorrect type)
326
- View: this.options.View,
327
- // TODO: PR for @types/prosemirror-tables
328
- // @ts-ignore (incorrect type)
329
- lastColumnResizable: this.options.lastColumnResizable,
330
- }),
331
- ]
332
- : []),
333
- tables.tableEditing({
334
- allowTableNodeSelection: this.options.allowTableNodeSelection,
335
- }),
336
- ];
337
- },
338
- extendNodeSchema(extension) {
339
- const context = {
340
- name: extension.name,
341
- options: extension.options,
342
- storage: extension.storage,
343
- };
344
- return {
345
- tableRole: core.callOrReturn(core.getExtensionField(extension, 'tableRole', context)),
346
- };
347
- },
348
- });
349
-
350
- exports.Table = Table;
351
- exports.createColGroup = createColGroup;
352
- exports.createTable = createTable;
353
- exports.default = Table;
354
-
355
- Object.defineProperty(exports, '__esModule', { value: true });
356
-
357
- }));
358
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/TableView.ts","../src/utilities/createColGroup.ts","../src/utilities/createCell.ts","../src/utilities/getTableNodeTypes.ts","../src/utilities/createTable.ts","../src/utilities/isCellSelection.ts","../src/utilities/deleteTableWhenAllCellsSelected.ts","../src/table.ts"],"sourcesContent":["// @ts-nocheck\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { NodeView } from '@tiptap/pm/view'\n\nexport function updateColumns(\n node: ProseMirrorNode,\n colgroup: Element,\n table: Element,\n cellMinWidth: number,\n overrideCol?: number,\n overrideValue?: any,\n) {\n let totalWidth = 0\n let fixedWidth = true\n let nextDOM = colgroup.firstChild\n const row = node.firstChild\n\n for (let i = 0, col = 0; i < row.childCount; i += 1) {\n const { colspan, colwidth } = row.child(i).attrs\n\n for (let j = 0; j < colspan; j += 1, col += 1) {\n const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j]\n const cssWidth = hasWidth ? `${hasWidth}px` : ''\n\n totalWidth += hasWidth || cellMinWidth\n\n if (!hasWidth) {\n fixedWidth = false\n }\n\n if (!nextDOM) {\n colgroup.appendChild(document.createElement('col')).style.width = cssWidth\n } else {\n if (nextDOM.style.width !== cssWidth) {\n nextDOM.style.width = cssWidth\n }\n\n nextDOM = nextDOM.nextSibling\n }\n }\n }\n\n while (nextDOM) {\n const after = nextDOM.nextSibling\n\n nextDOM.parentNode.removeChild(nextDOM)\n nextDOM = after\n }\n\n if (fixedWidth) {\n table.style.width = `${totalWidth}px`\n table.style.minWidth = ''\n } else {\n table.style.width = ''\n table.style.minWidth = `${totalWidth}px`\n }\n}\n\nexport class TableView implements NodeView {\n node: ProseMirrorNode\n\n cellMinWidth: number\n\n dom: Element\n\n table: Element\n\n colgroup: Element\n\n contentDOM: Element\n\n constructor(node: ProseMirrorNode, cellMinWidth: number) {\n this.node = node\n this.cellMinWidth = cellMinWidth\n this.dom = document.createElement('div')\n this.dom.className = 'tableWrapper'\n this.table = this.dom.appendChild(document.createElement('table'))\n this.colgroup = this.table.appendChild(document.createElement('colgroup'))\n updateColumns(node, this.colgroup, this.table, cellMinWidth)\n this.contentDOM = this.table.appendChild(document.createElement('tbody'))\n }\n\n update(node: ProseMirrorNode) {\n if (node.type !== this.node.type) {\n return false\n }\n\n this.node = node\n updateColumns(node, this.colgroup, this.table, this.cellMinWidth)\n\n return true\n }\n\n ignoreMutation(mutation: MutationRecord | { type: 'selection'; target: Element }) {\n return (\n mutation.type === 'attributes'\n && (mutation.target === this.table || this.colgroup.contains(mutation.target))\n )\n }\n}\n","import { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'\n\n/**\n * Creates a colgroup element for a table node in ProseMirror.\n *\n * @param node - The ProseMirror node representing the table.\n * @param cellMinWidth - The minimum width of a cell in the table.\n * @param overrideCol - (Optional) The index of the column to override the width of.\n * @param overrideValue - (Optional) The width value to use for the overridden column.\n * @returns An object containing the colgroup element, the total width of the table, and the minimum width of the table.\n */\nexport function createColGroup(\n node: ProseMirrorNode,\n cellMinWidth: number,\n overrideCol?: number,\n overrideValue?: any,\n) {\n let totalWidth = 0\n let fixedWidth = true\n const cols: DOMOutputSpec[] = []\n const row = node.firstChild\n\n if (!row) {\n return {}\n }\n\n for (let i = 0, col = 0; i < row.childCount; i += 1) {\n const { colspan, colwidth } = row.child(i).attrs\n\n for (let j = 0; j < colspan; j += 1, col += 1) {\n const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j]\n const cssWidth = hasWidth ? `${hasWidth}px` : ''\n\n totalWidth += hasWidth || cellMinWidth\n\n if (!hasWidth) {\n fixedWidth = false\n }\n\n cols.push(['col', cssWidth ? { style: `width: ${cssWidth}` } : {}])\n }\n }\n\n const tableWidth = fixedWidth ? `${totalWidth}px` : ''\n const tableMinWidth = fixedWidth ? '' : `${totalWidth}px`\n\n const colgroup: DOMOutputSpec = ['colgroup', {}, ...cols]\n\n return { colgroup, tableWidth, tableMinWidth }\n}\n","import { Fragment, Node as ProsemirrorNode, NodeType } from '@tiptap/pm/model'\n\nexport function createCell(\n cellType: NodeType,\n cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,\n): ProsemirrorNode | null | undefined {\n if (cellContent) {\n return cellType.createChecked(null, cellContent)\n }\n\n return cellType.createAndFill()\n}\n","import { NodeType, Schema } from '@tiptap/pm/model'\n\nexport function getTableNodeTypes(schema: Schema): { [key: string]: NodeType } {\n if (schema.cached.tableNodeTypes) {\n return schema.cached.tableNodeTypes\n }\n\n const roles: { [key: string]: NodeType } = {}\n\n Object.keys(schema.nodes).forEach(type => {\n const nodeType = schema.nodes[type]\n\n if (nodeType.spec.tableRole) {\n roles[nodeType.spec.tableRole] = nodeType\n }\n })\n\n schema.cached.tableNodeTypes = roles\n\n return roles\n}\n","import { Fragment, Node as ProsemirrorNode, Schema } from '@tiptap/pm/model'\n\nimport { createCell } from './createCell.js'\nimport { getTableNodeTypes } from './getTableNodeTypes.js'\n\nexport function createTable(\n schema: Schema,\n rowsCount: number,\n colsCount: number,\n withHeaderRow: boolean,\n cellContent?: Fragment | ProsemirrorNode | Array<ProsemirrorNode>,\n): ProsemirrorNode {\n const types = getTableNodeTypes(schema)\n const headerCells: ProsemirrorNode[] = []\n const cells: ProsemirrorNode[] = []\n\n for (let index = 0; index < colsCount; index += 1) {\n const cell = createCell(types.cell, cellContent)\n\n if (cell) {\n cells.push(cell)\n }\n\n if (withHeaderRow) {\n const headerCell = createCell(types.header_cell, cellContent)\n\n if (headerCell) {\n headerCells.push(headerCell)\n }\n }\n }\n\n const rows: ProsemirrorNode[] = []\n\n for (let index = 0; index < rowsCount; index += 1) {\n rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells))\n }\n\n return types.table.createChecked(null, rows)\n}\n","import { CellSelection } from '@tiptap/pm/tables'\n\nexport function isCellSelection(value: unknown): value is CellSelection {\n return value instanceof CellSelection\n}\n","import { findParentNodeClosestToPos, KeyboardShortcutCommand } from '@tiptap/core'\n\nimport { isCellSelection } from './isCellSelection.js'\n\nexport const deleteTableWhenAllCellsSelected: KeyboardShortcutCommand = ({ editor }) => {\n const { selection } = editor.state\n\n if (!isCellSelection(selection)) {\n return false\n }\n\n let cellCount = 0\n const table = findParentNodeClosestToPos(selection.ranges[0].$from, node => {\n return node.type.name === 'table'\n })\n\n table?.node.descendants(node => {\n if (node.type.name === 'table') {\n return false\n }\n\n if (['tableCell', 'tableHeader'].includes(node.type.name)) {\n cellCount += 1\n }\n })\n\n const allCellsSelected = cellCount === selection.ranges.length\n\n if (!allCellsSelected) {\n return false\n }\n\n editor.commands.deleteTable()\n\n return true\n}\n","import {\n callOrReturn, getExtensionField, mergeAttributes, Node, ParentConfig,\n} from '@tiptap/core'\nimport { DOMOutputSpec } from '@tiptap/pm/model'\nimport { TextSelection } from '@tiptap/pm/state'\nimport {\n addColumnAfter,\n addColumnBefore,\n addRowAfter,\n addRowBefore,\n CellSelection,\n columnResizing,\n deleteColumn,\n deleteRow,\n deleteTable,\n fixTables,\n goToNextCell,\n mergeCells,\n setCellAttr,\n splitCell,\n tableEditing,\n toggleHeader,\n toggleHeaderCell,\n} from '@tiptap/pm/tables'\nimport { NodeView } from '@tiptap/pm/view'\n\nimport { TableView } from './TableView.js'\nimport { createColGroup } from './utilities/createColGroup.js'\nimport { createTable } from './utilities/createTable.js'\nimport { deleteTableWhenAllCellsSelected } from './utilities/deleteTableWhenAllCellsSelected.js'\n\nexport interface TableOptions {\n /**\n * HTML attributes for the table element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Enables the resizing of tables.\n * @default false\n * @example true\n */\n resizable: boolean\n\n /**\n * The width of the resize handle.\n * @default 5\n * @example 10\n */\n handleWidth: number\n\n /**\n * The minimum width of a cell.\n * @default 25\n * @example 50\n */\n cellMinWidth: number\n\n /**\n * The node view to render the table.\n * @default TableView\n */\n View: NodeView\n\n /**\n * Enables the resizing of the last column.\n * @default true\n * @example false\n */\n lastColumnResizable: boolean\n\n /**\n * Allow table node selection.\n * @default false\n * @example true\n */\n allowTableNodeSelection: boolean\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n table: {\n /**\n * Insert a table\n * @param options The table attributes\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.insertTable({ rows: 3, cols: 3, withHeaderRow: true })\n */\n insertTable: (options?: {\n rows?: number\n cols?: number\n withHeaderRow?: boolean\n }) => ReturnType\n\n /**\n * Add a column before the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addColumnBefore()\n */\n addColumnBefore: () => ReturnType\n\n /**\n * Add a column after the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addColumnAfter()\n */\n addColumnAfter: () => ReturnType\n\n /**\n * Delete the current column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteColumn()\n */\n deleteColumn: () => ReturnType\n\n /**\n * Add a row before the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addRowBefore()\n */\n addRowBefore: () => ReturnType\n\n /**\n * Add a row after the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.addRowAfter()\n */\n addRowAfter: () => ReturnType\n\n /**\n * Delete the current row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteRow()\n */\n deleteRow: () => ReturnType\n\n /**\n * Delete the current table\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.deleteTable()\n */\n deleteTable: () => ReturnType\n\n /**\n * Merge the currently selected cells\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.mergeCells()\n */\n mergeCells: () => ReturnType\n\n /**\n * Split the currently selected cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.splitCell()\n */\n splitCell: () => ReturnType\n\n /**\n * Toggle the header column\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderColumn()\n */\n toggleHeaderColumn: () => ReturnType\n\n /**\n * Toggle the header row\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderRow()\n */\n toggleHeaderRow: () => ReturnType\n\n /**\n * Toggle the header cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.toggleHeaderCell()\n */\n toggleHeaderCell: () => ReturnType\n\n /**\n * Merge or split the currently selected cells\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.mergeOrSplit()\n */\n mergeOrSplit: () => ReturnType\n\n /**\n * Set a cell attribute\n * @param name The attribute name\n * @param value The attribute value\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.setCellAttribute('align', 'right')\n */\n setCellAttribute: (name: string, value: any) => ReturnType\n\n /**\n * Moves the selection to the next cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.goToNextCell()\n */\n goToNextCell: () => ReturnType\n\n /**\n * Moves the selection to the previous cell\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.goToPreviousCell()\n */\n goToPreviousCell: () => ReturnType\n\n /**\n * Try to fix the table structure if necessary\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.fixTables()\n */\n fixTables: () => ReturnType\n\n /**\n * Set a cell selection inside the current table\n * @param position The cell position\n * @returns True if the command was successful, otherwise false\n * @example editor.commands.setCellSelection({ anchorCell: 1, headCell: 2 })\n */\n setCellSelection: (position: { anchorCell: number; headCell?: number }) => ReturnType\n }\n }\n\n interface NodeConfig<Options, Storage> {\n /**\n * A string or function to determine the role of the table.\n * @default 'table'\n * @example () => 'table'\n */\n tableRole?:\n | string\n | ((this: {\n name: string\n options: Options\n storage: Storage\n parent: ParentConfig<NodeConfig<Options>>['tableRole']\n }) => string)\n }\n}\n\n/**\n * This extension allows you to create tables.\n * @see https://www.tiptap.dev/api/nodes/table\n */\nexport const Table = Node.create<TableOptions>({\n name: 'table',\n\n // @ts-ignore\n addOptions() {\n return {\n HTMLAttributes: {},\n resizable: false,\n handleWidth: 5,\n cellMinWidth: 25,\n // TODO: fix\n View: TableView,\n lastColumnResizable: true,\n allowTableNodeSelection: false,\n }\n },\n\n content: 'tableRow+',\n\n tableRole: 'table',\n\n isolating: true,\n\n group: 'block',\n\n parseHTML() {\n return [{ tag: 'table' }]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const { colgroup, tableWidth, tableMinWidth } = createColGroup(\n node,\n this.options.cellMinWidth,\n )\n\n const table: DOMOutputSpec = [\n 'table',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {\n style: tableWidth\n ? `width: ${tableWidth}`\n : `minWidth: ${tableMinWidth}`,\n }),\n colgroup,\n ['tbody', 0],\n ]\n\n return table\n },\n\n addCommands() {\n return {\n insertTable:\n ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => {\n const node = createTable(editor.schema, rows, cols, withHeaderRow)\n\n if (dispatch) {\n const offset = tr.selection.from + 1\n\n tr.replaceSelectionWith(node)\n .scrollIntoView()\n .setSelection(TextSelection.near(tr.doc.resolve(offset)))\n }\n\n return true\n },\n addColumnBefore:\n () => ({ state, dispatch }) => {\n return addColumnBefore(state, dispatch)\n },\n addColumnAfter:\n () => ({ state, dispatch }) => {\n return addColumnAfter(state, dispatch)\n },\n deleteColumn:\n () => ({ state, dispatch }) => {\n return deleteColumn(state, dispatch)\n },\n addRowBefore:\n () => ({ state, dispatch }) => {\n return addRowBefore(state, dispatch)\n },\n addRowAfter:\n () => ({ state, dispatch }) => {\n return addRowAfter(state, dispatch)\n },\n deleteRow:\n () => ({ state, dispatch }) => {\n return deleteRow(state, dispatch)\n },\n deleteTable:\n () => ({ state, dispatch }) => {\n return deleteTable(state, dispatch)\n },\n mergeCells:\n () => ({ state, dispatch }) => {\n return mergeCells(state, dispatch)\n },\n splitCell:\n () => ({ state, dispatch }) => {\n return splitCell(state, dispatch)\n },\n toggleHeaderColumn:\n () => ({ state, dispatch }) => {\n return toggleHeader('column')(state, dispatch)\n },\n toggleHeaderRow:\n () => ({ state, dispatch }) => {\n return toggleHeader('row')(state, dispatch)\n },\n toggleHeaderCell:\n () => ({ state, dispatch }) => {\n return toggleHeaderCell(state, dispatch)\n },\n mergeOrSplit:\n () => ({ state, dispatch }) => {\n if (mergeCells(state, dispatch)) {\n return true\n }\n\n return splitCell(state, dispatch)\n },\n setCellAttribute:\n (name, value) => ({ state, dispatch }) => {\n return setCellAttr(name, value)(state, dispatch)\n },\n goToNextCell:\n () => ({ state, dispatch }) => {\n return goToNextCell(1)(state, dispatch)\n },\n goToPreviousCell:\n () => ({ state, dispatch }) => {\n return goToNextCell(-1)(state, dispatch)\n },\n fixTables:\n () => ({ state, dispatch }) => {\n if (dispatch) {\n fixTables(state)\n }\n\n return true\n },\n setCellSelection:\n position => ({ tr, dispatch }) => {\n if (dispatch) {\n const selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell)\n\n // @ts-ignore\n tr.setSelection(selection)\n }\n\n return true\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Tab: () => {\n if (this.editor.commands.goToNextCell()) {\n return true\n }\n\n if (!this.editor.can().addRowAfter()) {\n return false\n }\n\n return this.editor.chain().addRowAfter().goToNextCell().run()\n },\n 'Shift-Tab': () => this.editor.commands.goToPreviousCell(),\n Backspace: deleteTableWhenAllCellsSelected,\n 'Mod-Backspace': deleteTableWhenAllCellsSelected,\n Delete: deleteTableWhenAllCellsSelected,\n 'Mod-Delete': deleteTableWhenAllCellsSelected,\n }\n },\n\n addProseMirrorPlugins() {\n const isResizable = this.options.resizable && this.editor.isEditable\n\n return [\n ...(isResizable\n ? [\n columnResizing({\n handleWidth: this.options.handleWidth,\n cellMinWidth: this.options.cellMinWidth,\n // @ts-ignore (incorrect type)\n View: this.options.View,\n // TODO: PR for @types/prosemirror-tables\n // @ts-ignore (incorrect type)\n lastColumnResizable: this.options.lastColumnResizable,\n }),\n ]\n : []),\n tableEditing({\n allowTableNodeSelection: this.options.allowTableNodeSelection,\n }),\n ]\n },\n\n extendNodeSchema(extension) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n }\n\n return {\n tableRole: callOrReturn(getExtensionField(extension, 'tableRole', context)),\n }\n },\n})\n"],"names":["CellSelection","findParentNodeClosestToPos","Node","mergeAttributes","TextSelection","addColumnBefore","addColumnAfter","deleteColumn","addRowBefore","addRowAfter","deleteRow","deleteTable","mergeCells","splitCell","toggleHeader","toggleHeaderCell","setCellAttr","goToNextCell","fixTables","columnResizing","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BAAmB;uBACtD,CAAC;EACH,iBAAA;oBACC,EAAE;EACN,YAAAC,mBAAY,CAAC;EACX,gBAAA,uBAAuB,EAAE,IAAI,CAAC,OAAO,CAAC,uBAAuB;eAC9D,CAAC;WACH,CAAA;OACF;EAED,IAAA,gBAAgB,CAAC,SAAS,EAAA;EACxB,QAAA,MAAM,OAAO,GAAG;cACd,IAAI,EAAE,SAAS,CAAC,IAAI;cACpB,OAAO,EAAE,SAAS,CAAC,OAAO;cAC1B,OAAO,EAAE,SAAS,CAAC,OAAO;WAC3B,CAAA;UAED,OAAO;cACL,SAAS,EAAEC,iBAAY,CAACC,sBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;WAC5E,CAAA;OACF;EACF,CAAA;;;;;;;;;;;;;"}
@@ -1,20 +0,0 @@
1
- import { EditorState, Transaction } from '@tiptap/pm/state';
2
- import { Editor } from './Editor.js';
3
- import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types.js';
4
- export declare class CommandManager {
5
- editor: Editor;
6
- rawCommands: AnyCommands;
7
- customState?: EditorState;
8
- constructor(props: {
9
- editor: Editor;
10
- state?: EditorState;
11
- });
12
- get hasCustomState(): boolean;
13
- get state(): EditorState;
14
- get commands(): SingleCommands;
15
- get chain(): () => ChainedCommands;
16
- get can(): () => CanCommands;
17
- createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
18
- createCan(startTr?: Transaction): CanCommands;
19
- buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
20
- }
@@ -1,161 +0,0 @@
1
- import { MarkType, NodeType, Schema } from '@tiptap/pm/model';
2
- import { EditorState, Plugin, PluginKey, Transaction } from '@tiptap/pm/state';
3
- import { EditorView } from '@tiptap/pm/view';
4
- import { EventEmitter } from './EventEmitter.js';
5
- import { ExtensionManager } from './ExtensionManager.js';
6
- import { NodePos } from './NodePos.js';
7
- import { CanCommands, ChainedCommands, EditorEvents, EditorOptions, JSONContent, SingleCommands, TextSerializer } from './types.js';
8
- export * as extensions from './extensions/index.js';
9
- declare global {
10
- interface HTMLElement {
11
- editor?: Editor;
12
- }
13
- }
14
- export declare class Editor extends EventEmitter<EditorEvents> {
15
- private commandManager;
16
- extensionManager: ExtensionManager;
17
- private css;
18
- schema: Schema;
19
- view: EditorView;
20
- isFocused: boolean;
21
- extensionStorage: Record<string, any>;
22
- options: EditorOptions;
23
- constructor(options?: Partial<EditorOptions>);
24
- /**
25
- * Returns the editor storage.
26
- */
27
- get storage(): Record<string, any>;
28
- /**
29
- * An object of all registered commands.
30
- */
31
- get commands(): SingleCommands;
32
- /**
33
- * Create a command chain to call multiple commands at once.
34
- */
35
- chain(): ChainedCommands;
36
- /**
37
- * Check if a command or a command chain can be executed. Without executing it.
38
- */
39
- can(): CanCommands;
40
- /**
41
- * Inject CSS styles.
42
- */
43
- private injectCSS;
44
- /**
45
- * Update editor options.
46
- *
47
- * @param options A list of options
48
- */
49
- setOptions(options?: Partial<EditorOptions>): void;
50
- /**
51
- * Update editable state of the editor.
52
- */
53
- setEditable(editable: boolean, emitUpdate?: boolean): void;
54
- /**
55
- * Returns whether the editor is editable.
56
- */
57
- get isEditable(): boolean;
58
- /**
59
- * Returns the editor state.
60
- */
61
- get state(): EditorState;
62
- /**
63
- * Register a ProseMirror plugin.
64
- *
65
- * @param plugin A ProseMirror plugin
66
- * @param handlePlugins Control how to merge the plugin into the existing plugins.
67
- */
68
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
69
- /**
70
- * Unregister a ProseMirror plugin.
71
- *
72
- * @param nameOrPluginKey The plugins name
73
- */
74
- unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
75
- /**
76
- * Creates an extension manager.
77
- */
78
- private createExtensionManager;
79
- /**
80
- * Creates an command manager.
81
- */
82
- private createCommandManager;
83
- /**
84
- * Creates a ProseMirror schema.
85
- */
86
- private createSchema;
87
- /**
88
- * Creates a ProseMirror view.
89
- */
90
- private createView;
91
- /**
92
- * Creates all node views.
93
- */
94
- createNodeViews(): void;
95
- /**
96
- * Prepend class name to element.
97
- */
98
- prependClass(): void;
99
- isCapturingTransaction: boolean;
100
- private capturedTransaction;
101
- captureTransaction(fn: Function): Transaction | null;
102
- /**
103
- * The callback over which to send transactions (state updates) produced by the view.
104
- *
105
- * @param transaction An editor state transaction
106
- */
107
- private dispatchTransaction;
108
- /**
109
- * Get attributes of the currently selected node or mark.
110
- */
111
- getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
112
- /**
113
- * Returns if the currently selected node or mark is active.
114
- *
115
- * @param name Name of the node or mark
116
- * @param attributes Attributes of the node or mark
117
- */
118
- isActive(name: string, attributes?: {}): boolean;
119
- isActive(attributes: {}): boolean;
120
- /**
121
- * Get the document as JSON.
122
- */
123
- getJSON(): JSONContent;
124
- /**
125
- * Get the document as HTML.
126
- */
127
- getHTML(): string;
128
- /**
129
- * Get the document as text.
130
- */
131
- getText(options?: {
132
- blockSeparator?: string;
133
- textSerializers?: Record<string, TextSerializer>;
134
- }): string;
135
- /**
136
- * Check if there is no content.
137
- */
138
- get isEmpty(): boolean;
139
- /**
140
- * Get the number of characters for the current document.
141
- *
142
- * @deprecated
143
- */
144
- getCharacterCount(): number;
145
- /**
146
- * Destroy the editor.
147
- */
148
- destroy(): void;
149
- /**
150
- * Check if the editor is already destroyed.
151
- */
152
- get isDestroyed(): boolean;
153
- $node(selector: string, attributes?: {
154
- [key: string]: any;
155
- }): NodePos | null;
156
- $nodes(selector: string, attributes?: {
157
- [key: string]: any;
158
- }): NodePos[] | null;
159
- $pos(pos: number): NodePos;
160
- get $doc(): NodePos;
161
- }
@@ -1,11 +0,0 @@
1
- type StringKeyOf<T> = Extract<keyof T, string>;
2
- type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
3
- type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
4
- export declare class EventEmitter<T extends Record<string, any>> {
5
- private callbacks;
6
- on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
7
- emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
8
- off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
9
- removeAllListeners(): void;
10
- }
11
- export {};