@tiptap/extension-table 3.0.0 → 3.0.2
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/LICENSE.md +21 -0
- package/README.md +5 -1
- package/dist/cell/index.cjs +68 -0
- package/dist/cell/index.cjs.map +1 -0
- package/dist/cell/index.d.cts +33 -0
- package/dist/cell/index.d.ts +33 -0
- package/dist/cell/index.js +41 -0
- package/dist/cell/index.js.map +1 -0
- package/dist/header/index.cjs +68 -0
- package/dist/header/index.cjs.map +1 -0
- package/dist/header/index.d.cts +33 -0
- package/dist/header/index.d.ts +33 -0
- package/dist/header/index.js +41 -0
- package/dist/header/index.js.map +1 -0
- package/dist/index.cjs +480 -321
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +305 -0
- package/dist/index.d.ts +305 -0
- package/dist/index.js +465 -316
- package/dist/index.js.map +1 -1
- package/dist/kit/index.cjs +497 -0
- package/dist/kit/index.cjs.map +1 -0
- package/dist/kit/index.d.cts +252 -0
- package/dist/kit/index.d.ts +252 -0
- package/dist/kit/index.js +490 -0
- package/dist/kit/index.js.map +1 -0
- package/dist/row/index.cjs +49 -0
- package/dist/row/index.cjs.map +1 -0
- package/dist/row/index.d.cts +33 -0
- package/dist/row/index.d.ts +33 -0
- package/dist/row/index.js +22 -0
- package/dist/row/index.js.map +1 -0
- package/dist/table/index.cjs +384 -0
- package/dist/table/index.cjs.map +1 -0
- package/dist/{packages/extension-table/src/table.d.ts → table/index.d.cts} +45 -19
- package/dist/table/index.d.ts +220 -0
- package/dist/table/index.js +373 -0
- package/dist/table/index.js.map +1 -0
- package/package.json +53 -11
- package/src/cell/index.ts +1 -0
- package/src/cell/table-cell.ts +60 -0
- package/src/header/index.ts +1 -0
- package/src/header/table-header.ts +60 -0
- package/src/index.ts +6 -7
- package/src/kit/index.ts +64 -0
- package/src/row/index.ts +1 -0
- package/src/row/table-row.ts +38 -0
- package/src/table/TableView.ts +108 -0
- package/src/table/index.ts +3 -0
- package/src/{table.ts → table/table.ts} +56 -64
- package/src/table/utilities/colStyle.ts +9 -0
- package/src/{utilities → table/utilities}/createCell.ts +1 -1
- package/src/{utilities → table/utilities}/createColGroup.ts +24 -6
- package/src/{utilities → table/utilities}/createTable.ts +1 -1
- package/src/{utilities → table/utilities}/deleteTableWhenAllCellsSelected.ts +2 -1
- package/src/{utilities → table/utilities}/getTableNodeTypes.ts +1 -1
- package/src/types.ts +19 -0
- package/dist/index.umd.js +0 -358
- package/dist/index.umd.js.map +0 -1
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -161
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -343
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -451
- package/dist/packages/core/src/Node.d.ts +0 -611
- package/dist/packages/core/src/NodePos.d.ts +0 -44
- package/dist/packages/core/src/NodeView.d.ts +0 -31
- package/dist/packages/core/src/PasteRule.d.ts +0 -50
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -13
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
- package/dist/packages/core/src/commands/command.d.ts +0 -18
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
- package/dist/packages/core/src/commands/cut.d.ts +0 -20
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
- package/dist/packages/core/src/commands/enter.d.ts +0 -13
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
- package/dist/packages/core/src/commands/first.d.ts +0 -14
- package/dist/packages/core/src/commands/focus.d.ts +0 -27
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -55
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
- package/dist/packages/core/src/commands/join.d.ts +0 -41
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
- package/dist/packages/core/src/commands/lift.d.ts +0 -17
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
- package/dist/packages/core/src/commands/setContent.d.ts +0 -40
- package/dist/packages/core/src/commands/setMark.d.ts +0 -15
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
- package/dist/packages/core/src/commands/setNode.d.ts +0 -16
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
- package/dist/packages/core/src/extensions/commands.d.ts +0 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getText.d.ts +0 -15
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
- package/dist/packages/core/src/helpers/index.d.ts +0 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -24
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -255
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/packages/extension-table/src/TableView.d.ts +0 -17
- package/dist/packages/extension-table/src/index.d.ts +0 -5
- package/dist/packages/extension-table/src/utilities/createCell.d.ts +0 -2
- package/dist/packages/extension-table/src/utilities/createColGroup.d.ts +0 -19
- package/dist/packages/extension-table/src/utilities/createTable.d.ts +0 -2
- package/dist/packages/extension-table/src/utilities/deleteTableWhenAllCellsSelected.d.ts +0 -2
- package/dist/packages/extension-table/src/utilities/getTableNodeTypes.d.ts +0 -4
- package/dist/packages/extension-table/src/utilities/isCellSelection.d.ts +0 -2
- package/src/TableView.ts +0 -100
- /package/src/{utilities → table/utilities}/isCellSelection.ts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,356 +1,515 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Table: () => Table,
|
|
24
|
+
TableCell: () => TableCell,
|
|
25
|
+
TableHeader: () => TableHeader,
|
|
26
|
+
TableKit: () => TableKit,
|
|
27
|
+
TableRow: () => TableRow,
|
|
28
|
+
TableView: () => TableView,
|
|
29
|
+
createColGroup: () => createColGroup,
|
|
30
|
+
createTable: () => createTable,
|
|
31
|
+
updateColumns: () => updateColumns
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/cell/table-cell.ts
|
|
36
|
+
var import_core = require("@tiptap/core");
|
|
37
|
+
var TableCell = import_core.Node.create({
|
|
38
|
+
name: "tableCell",
|
|
39
|
+
addOptions() {
|
|
40
|
+
return {
|
|
41
|
+
HTMLAttributes: {}
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
content: "block+",
|
|
45
|
+
addAttributes() {
|
|
46
|
+
return {
|
|
47
|
+
colspan: {
|
|
48
|
+
default: 1
|
|
49
|
+
},
|
|
50
|
+
rowspan: {
|
|
51
|
+
default: 1
|
|
52
|
+
},
|
|
53
|
+
colwidth: {
|
|
54
|
+
default: null,
|
|
55
|
+
parseHTML: (element) => {
|
|
56
|
+
const colwidth = element.getAttribute("colwidth");
|
|
57
|
+
const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
tableRole: "cell",
|
|
64
|
+
isolating: true,
|
|
65
|
+
parseHTML() {
|
|
66
|
+
return [{ tag: "td" }];
|
|
67
|
+
},
|
|
68
|
+
renderHTML({ HTMLAttributes }) {
|
|
69
|
+
return ["td", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// src/header/table-header.ts
|
|
74
|
+
var import_core2 = require("@tiptap/core");
|
|
75
|
+
var TableHeader = import_core2.Node.create({
|
|
76
|
+
name: "tableHeader",
|
|
77
|
+
addOptions() {
|
|
78
|
+
return {
|
|
79
|
+
HTMLAttributes: {}
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
content: "block+",
|
|
83
|
+
addAttributes() {
|
|
84
|
+
return {
|
|
85
|
+
colspan: {
|
|
86
|
+
default: 1
|
|
87
|
+
},
|
|
88
|
+
rowspan: {
|
|
89
|
+
default: 1
|
|
90
|
+
},
|
|
91
|
+
colwidth: {
|
|
92
|
+
default: null,
|
|
93
|
+
parseHTML: (element) => {
|
|
94
|
+
const colwidth = element.getAttribute("colwidth");
|
|
95
|
+
const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
tableRole: "header_cell",
|
|
102
|
+
isolating: true,
|
|
103
|
+
parseHTML() {
|
|
104
|
+
return [{ tag: "th" }];
|
|
105
|
+
},
|
|
106
|
+
renderHTML({ HTMLAttributes }) {
|
|
107
|
+
return ["th", (0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// src/kit/index.ts
|
|
112
|
+
var import_core6 = require("@tiptap/core");
|
|
113
|
+
|
|
114
|
+
// src/row/table-row.ts
|
|
115
|
+
var import_core3 = require("@tiptap/core");
|
|
116
|
+
var TableRow = import_core3.Node.create({
|
|
117
|
+
name: "tableRow",
|
|
118
|
+
addOptions() {
|
|
119
|
+
return {
|
|
120
|
+
HTMLAttributes: {}
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
content: "(tableCell | tableHeader)*",
|
|
124
|
+
tableRole: "row",
|
|
125
|
+
parseHTML() {
|
|
126
|
+
return [{ tag: "tr" }];
|
|
127
|
+
},
|
|
128
|
+
renderHTML({ HTMLAttributes }) {
|
|
129
|
+
return ["tr", (0, import_core3.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
2
132
|
|
|
3
|
-
|
|
133
|
+
// src/table/table.ts
|
|
134
|
+
var import_core5 = require("@tiptap/core");
|
|
135
|
+
var import_state = require("@tiptap/pm/state");
|
|
136
|
+
var import_tables2 = require("@tiptap/pm/tables");
|
|
4
137
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
138
|
+
// src/table/utilities/colStyle.ts
|
|
139
|
+
function getColStyleDeclaration(minWidth, width) {
|
|
140
|
+
if (width) {
|
|
141
|
+
return ["width", `${Math.max(width, minWidth)}px`];
|
|
142
|
+
}
|
|
143
|
+
return ["min-width", `${minWidth}px`];
|
|
144
|
+
}
|
|
8
145
|
|
|
146
|
+
// src/table/TableView.ts
|
|
9
147
|
function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
148
|
+
var _a;
|
|
149
|
+
let totalWidth = 0;
|
|
150
|
+
let fixedWidth = true;
|
|
151
|
+
let nextDOM = colgroup.firstChild;
|
|
152
|
+
const row = node.firstChild;
|
|
153
|
+
if (row !== null) {
|
|
14
154
|
for (let i = 0, col = 0; i < row.childCount; i += 1) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (!nextDOM) {
|
|
24
|
-
colgroup.appendChild(document.createElement('col')).style.width = cssWidth;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
if (nextDOM.style.width !== cssWidth) {
|
|
28
|
-
nextDOM.style.width = cssWidth;
|
|
29
|
-
}
|
|
30
|
-
nextDOM = nextDOM.nextSibling;
|
|
31
|
-
}
|
|
155
|
+
const { colspan, colwidth } = row.child(i).attrs;
|
|
156
|
+
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
157
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
158
|
+
const cssWidth = hasWidth ? `${hasWidth}px` : "";
|
|
159
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
160
|
+
if (!hasWidth) {
|
|
161
|
+
fixedWidth = false;
|
|
32
162
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
table.style.width = '';
|
|
45
|
-
table.style.minWidth = `${totalWidth}px`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
class TableView {
|
|
49
|
-
constructor(node, cellMinWidth) {
|
|
50
|
-
this.node = node;
|
|
51
|
-
this.cellMinWidth = cellMinWidth;
|
|
52
|
-
this.dom = document.createElement('div');
|
|
53
|
-
this.dom.className = 'tableWrapper';
|
|
54
|
-
this.table = this.dom.appendChild(document.createElement('table'));
|
|
55
|
-
this.colgroup = this.table.appendChild(document.createElement('colgroup'));
|
|
56
|
-
updateColumns(node, this.colgroup, this.table, cellMinWidth);
|
|
57
|
-
this.contentDOM = this.table.appendChild(document.createElement('tbody'));
|
|
58
|
-
}
|
|
59
|
-
update(node) {
|
|
60
|
-
if (node.type !== this.node.type) {
|
|
61
|
-
return false;
|
|
163
|
+
if (!nextDOM) {
|
|
164
|
+
const colElement = document.createElement("col");
|
|
165
|
+
const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
166
|
+
colElement.style.setProperty(propertyKey, propertyValue);
|
|
167
|
+
colgroup.appendChild(colElement);
|
|
168
|
+
} else {
|
|
169
|
+
if (nextDOM.style.width !== cssWidth) {
|
|
170
|
+
const [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
171
|
+
nextDOM.style.setProperty(propertyKey, propertyValue);
|
|
172
|
+
}
|
|
173
|
+
nextDOM = nextDOM.nextSibling;
|
|
62
174
|
}
|
|
63
|
-
|
|
64
|
-
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
ignoreMutation(mutation) {
|
|
68
|
-
return (mutation.type === 'attributes'
|
|
69
|
-
&& (mutation.target === this.table || this.colgroup.contains(mutation.target)));
|
|
175
|
+
}
|
|
70
176
|
}
|
|
177
|
+
}
|
|
178
|
+
while (nextDOM) {
|
|
179
|
+
const after = nextDOM.nextSibling;
|
|
180
|
+
(_a = nextDOM.parentNode) == null ? void 0 : _a.removeChild(nextDOM);
|
|
181
|
+
nextDOM = after;
|
|
182
|
+
}
|
|
183
|
+
if (fixedWidth) {
|
|
184
|
+
table.style.width = `${totalWidth}px`;
|
|
185
|
+
table.style.minWidth = "";
|
|
186
|
+
} else {
|
|
187
|
+
table.style.width = "";
|
|
188
|
+
table.style.minWidth = `${totalWidth}px`;
|
|
189
|
+
}
|
|
71
190
|
}
|
|
191
|
+
var TableView = class {
|
|
192
|
+
constructor(node, cellMinWidth) {
|
|
193
|
+
this.node = node;
|
|
194
|
+
this.cellMinWidth = cellMinWidth;
|
|
195
|
+
this.dom = document.createElement("div");
|
|
196
|
+
this.dom.className = "tableWrapper";
|
|
197
|
+
this.table = this.dom.appendChild(document.createElement("table"));
|
|
198
|
+
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
199
|
+
updateColumns(node, this.colgroup, this.table, cellMinWidth);
|
|
200
|
+
this.contentDOM = this.table.appendChild(document.createElement("tbody"));
|
|
201
|
+
}
|
|
202
|
+
update(node) {
|
|
203
|
+
if (node.type !== this.node.type) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
this.node = node;
|
|
207
|
+
updateColumns(node, this.colgroup, this.table, this.cellMinWidth);
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
ignoreMutation(mutation) {
|
|
211
|
+
return mutation.type === "attributes" && (mutation.target === this.table || this.colgroup.contains(mutation.target));
|
|
212
|
+
}
|
|
213
|
+
};
|
|
72
214
|
|
|
73
|
-
|
|
74
|
-
* Creates a colgroup element for a table node in ProseMirror.
|
|
75
|
-
*
|
|
76
|
-
* @param node - The ProseMirror node representing the table.
|
|
77
|
-
* @param cellMinWidth - The minimum width of a cell in the table.
|
|
78
|
-
* @param overrideCol - (Optional) The index of the column to override the width of.
|
|
79
|
-
* @param overrideValue - (Optional) The width value to use for the overridden column.
|
|
80
|
-
* @returns An object containing the colgroup element, the total width of the table, and the minimum width of the table.
|
|
81
|
-
*/
|
|
215
|
+
// src/table/utilities/createColGroup.ts
|
|
82
216
|
function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
217
|
+
let totalWidth = 0;
|
|
218
|
+
let fixedWidth = true;
|
|
219
|
+
const cols = [];
|
|
220
|
+
const row = node.firstChild;
|
|
221
|
+
if (!row) {
|
|
222
|
+
return {};
|
|
223
|
+
}
|
|
224
|
+
for (let i = 0, col = 0; i < row.childCount; i += 1) {
|
|
225
|
+
const { colspan, colwidth } = row.child(i).attrs;
|
|
226
|
+
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
227
|
+
const hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];
|
|
228
|
+
totalWidth += hasWidth || cellMinWidth;
|
|
229
|
+
if (!hasWidth) {
|
|
230
|
+
fixedWidth = false;
|
|
231
|
+
}
|
|
232
|
+
const [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
233
|
+
cols.push(["col", { style: `${property}: ${value}` }]);
|
|
89
234
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
totalWidth += hasWidth || cellMinWidth;
|
|
96
|
-
if (!hasWidth) {
|
|
97
|
-
fixedWidth = false;
|
|
98
|
-
}
|
|
99
|
-
cols.push(['col', cssWidth ? { style: `width: ${cssWidth}` } : {}]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const tableWidth = fixedWidth ? `${totalWidth}px` : '';
|
|
103
|
-
const tableMinWidth = fixedWidth ? '' : `${totalWidth}px`;
|
|
104
|
-
const colgroup = ['colgroup', {}, ...cols];
|
|
105
|
-
return { colgroup, tableWidth, tableMinWidth };
|
|
235
|
+
}
|
|
236
|
+
const tableWidth = fixedWidth ? `${totalWidth}px` : "";
|
|
237
|
+
const tableMinWidth = fixedWidth ? "" : `${totalWidth}px`;
|
|
238
|
+
const colgroup = ["colgroup", {}, ...cols];
|
|
239
|
+
return { colgroup, tableWidth, tableMinWidth };
|
|
106
240
|
}
|
|
107
241
|
|
|
242
|
+
// src/table/utilities/createCell.ts
|
|
108
243
|
function createCell(cellType, cellContent) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
244
|
+
if (cellContent) {
|
|
245
|
+
return cellType.createChecked(null, cellContent);
|
|
246
|
+
}
|
|
247
|
+
return cellType.createAndFill();
|
|
113
248
|
}
|
|
114
249
|
|
|
250
|
+
// src/table/utilities/getTableNodeTypes.ts
|
|
115
251
|
function getTableNodeTypes(schema) {
|
|
116
|
-
|
|
117
|
-
|
|
252
|
+
if (schema.cached.tableNodeTypes) {
|
|
253
|
+
return schema.cached.tableNodeTypes;
|
|
254
|
+
}
|
|
255
|
+
const roles = {};
|
|
256
|
+
Object.keys(schema.nodes).forEach((type) => {
|
|
257
|
+
const nodeType = schema.nodes[type];
|
|
258
|
+
if (nodeType.spec.tableRole) {
|
|
259
|
+
roles[nodeType.spec.tableRole] = nodeType;
|
|
118
260
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (nodeType.spec.tableRole) {
|
|
123
|
-
roles[nodeType.spec.tableRole] = nodeType;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
schema.cached.tableNodeTypes = roles;
|
|
127
|
-
return roles;
|
|
261
|
+
});
|
|
262
|
+
schema.cached.tableNodeTypes = roles;
|
|
263
|
+
return roles;
|
|
128
264
|
}
|
|
129
265
|
|
|
266
|
+
// src/table/utilities/createTable.ts
|
|
130
267
|
function createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
if (withHeaderRow) {
|
|
140
|
-
const headerCell = createCell(types.header_cell, cellContent);
|
|
141
|
-
if (headerCell) {
|
|
142
|
-
headerCells.push(headerCell);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
268
|
+
const types = getTableNodeTypes(schema);
|
|
269
|
+
const headerCells = [];
|
|
270
|
+
const cells = [];
|
|
271
|
+
for (let index = 0; index < colsCount; index += 1) {
|
|
272
|
+
const cell = createCell(types.cell, cellContent);
|
|
273
|
+
if (cell) {
|
|
274
|
+
cells.push(cell);
|
|
145
275
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
276
|
+
if (withHeaderRow) {
|
|
277
|
+
const headerCell = createCell(types.header_cell, cellContent);
|
|
278
|
+
if (headerCell) {
|
|
279
|
+
headerCells.push(headerCell);
|
|
280
|
+
}
|
|
149
281
|
}
|
|
150
|
-
|
|
282
|
+
}
|
|
283
|
+
const rows = [];
|
|
284
|
+
for (let index = 0; index < rowsCount; index += 1) {
|
|
285
|
+
rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells));
|
|
286
|
+
}
|
|
287
|
+
return types.table.createChecked(null, rows);
|
|
151
288
|
}
|
|
152
289
|
|
|
290
|
+
// src/table/utilities/deleteTableWhenAllCellsSelected.ts
|
|
291
|
+
var import_core4 = require("@tiptap/core");
|
|
292
|
+
|
|
293
|
+
// src/table/utilities/isCellSelection.ts
|
|
294
|
+
var import_tables = require("@tiptap/pm/tables");
|
|
153
295
|
function isCellSelection(value) {
|
|
154
|
-
|
|
296
|
+
return value instanceof import_tables.CellSelection;
|
|
155
297
|
}
|
|
156
298
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
299
|
+
// src/table/utilities/deleteTableWhenAllCellsSelected.ts
|
|
300
|
+
var deleteTableWhenAllCellsSelected = ({ editor }) => {
|
|
301
|
+
const { selection } = editor.state;
|
|
302
|
+
if (!isCellSelection(selection)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
let cellCount = 0;
|
|
306
|
+
const table = (0, import_core4.findParentNodeClosestToPos)(selection.ranges[0].$from, (node) => {
|
|
307
|
+
return node.type.name === "table";
|
|
308
|
+
});
|
|
309
|
+
table == null ? void 0 : table.node.descendants((node) => {
|
|
310
|
+
if (node.type.name === "table") {
|
|
311
|
+
return false;
|
|
161
312
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return node.type.name === 'table';
|
|
165
|
-
});
|
|
166
|
-
table === null || table === void 0 ? void 0 : table.node.descendants(node => {
|
|
167
|
-
if (node.type.name === 'table') {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
if (['tableCell', 'tableHeader'].includes(node.type.name)) {
|
|
171
|
-
cellCount += 1;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
const allCellsSelected = cellCount === selection.ranges.length;
|
|
175
|
-
if (!allCellsSelected) {
|
|
176
|
-
return false;
|
|
313
|
+
if (["tableCell", "tableHeader"].includes(node.type.name)) {
|
|
314
|
+
cellCount += 1;
|
|
177
315
|
}
|
|
178
|
-
|
|
179
|
-
|
|
316
|
+
});
|
|
317
|
+
const allCellsSelected = cellCount === selection.ranges.length;
|
|
318
|
+
if (!allCellsSelected) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
editor.commands.deleteTable();
|
|
322
|
+
return true;
|
|
180
323
|
};
|
|
181
324
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
];
|
|
339
|
-
},
|
|
340
|
-
extendNodeSchema(extension) {
|
|
341
|
-
const context = {
|
|
342
|
-
name: extension.name,
|
|
343
|
-
options: extension.options,
|
|
344
|
-
storage: extension.storage,
|
|
345
|
-
};
|
|
346
|
-
return {
|
|
347
|
-
tableRole: core.callOrReturn(core.getExtensionField(extension, 'tableRole', context)),
|
|
348
|
-
};
|
|
349
|
-
},
|
|
325
|
+
// src/table/table.ts
|
|
326
|
+
var Table = import_core5.Node.create({
|
|
327
|
+
name: "table",
|
|
328
|
+
// @ts-ignore
|
|
329
|
+
addOptions() {
|
|
330
|
+
return {
|
|
331
|
+
HTMLAttributes: {},
|
|
332
|
+
resizable: false,
|
|
333
|
+
handleWidth: 5,
|
|
334
|
+
cellMinWidth: 25,
|
|
335
|
+
// TODO: fix
|
|
336
|
+
View: TableView,
|
|
337
|
+
lastColumnResizable: true,
|
|
338
|
+
allowTableNodeSelection: false
|
|
339
|
+
};
|
|
340
|
+
},
|
|
341
|
+
content: "tableRow+",
|
|
342
|
+
tableRole: "table",
|
|
343
|
+
isolating: true,
|
|
344
|
+
group: "block",
|
|
345
|
+
parseHTML() {
|
|
346
|
+
return [{ tag: "table" }];
|
|
347
|
+
},
|
|
348
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
349
|
+
const { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth);
|
|
350
|
+
const table = [
|
|
351
|
+
"table",
|
|
352
|
+
(0, import_core5.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
|
|
353
|
+
style: tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`
|
|
354
|
+
}),
|
|
355
|
+
colgroup,
|
|
356
|
+
["tbody", 0]
|
|
357
|
+
];
|
|
358
|
+
return table;
|
|
359
|
+
},
|
|
360
|
+
addCommands() {
|
|
361
|
+
return {
|
|
362
|
+
insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => {
|
|
363
|
+
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
364
|
+
if (dispatch) {
|
|
365
|
+
const offset = tr.selection.from + 1;
|
|
366
|
+
tr.replaceSelectionWith(node).scrollIntoView().setSelection(import_state.TextSelection.near(tr.doc.resolve(offset)));
|
|
367
|
+
}
|
|
368
|
+
return true;
|
|
369
|
+
},
|
|
370
|
+
addColumnBefore: () => ({ state, dispatch }) => {
|
|
371
|
+
return (0, import_tables2.addColumnBefore)(state, dispatch);
|
|
372
|
+
},
|
|
373
|
+
addColumnAfter: () => ({ state, dispatch }) => {
|
|
374
|
+
return (0, import_tables2.addColumnAfter)(state, dispatch);
|
|
375
|
+
},
|
|
376
|
+
deleteColumn: () => ({ state, dispatch }) => {
|
|
377
|
+
return (0, import_tables2.deleteColumn)(state, dispatch);
|
|
378
|
+
},
|
|
379
|
+
addRowBefore: () => ({ state, dispatch }) => {
|
|
380
|
+
return (0, import_tables2.addRowBefore)(state, dispatch);
|
|
381
|
+
},
|
|
382
|
+
addRowAfter: () => ({ state, dispatch }) => {
|
|
383
|
+
return (0, import_tables2.addRowAfter)(state, dispatch);
|
|
384
|
+
},
|
|
385
|
+
deleteRow: () => ({ state, dispatch }) => {
|
|
386
|
+
return (0, import_tables2.deleteRow)(state, dispatch);
|
|
387
|
+
},
|
|
388
|
+
deleteTable: () => ({ state, dispatch }) => {
|
|
389
|
+
return (0, import_tables2.deleteTable)(state, dispatch);
|
|
390
|
+
},
|
|
391
|
+
mergeCells: () => ({ state, dispatch }) => {
|
|
392
|
+
return (0, import_tables2.mergeCells)(state, dispatch);
|
|
393
|
+
},
|
|
394
|
+
splitCell: () => ({ state, dispatch }) => {
|
|
395
|
+
return (0, import_tables2.splitCell)(state, dispatch);
|
|
396
|
+
},
|
|
397
|
+
toggleHeaderColumn: () => ({ state, dispatch }) => {
|
|
398
|
+
return (0, import_tables2.toggleHeader)("column")(state, dispatch);
|
|
399
|
+
},
|
|
400
|
+
toggleHeaderRow: () => ({ state, dispatch }) => {
|
|
401
|
+
return (0, import_tables2.toggleHeader)("row")(state, dispatch);
|
|
402
|
+
},
|
|
403
|
+
toggleHeaderCell: () => ({ state, dispatch }) => {
|
|
404
|
+
return (0, import_tables2.toggleHeaderCell)(state, dispatch);
|
|
405
|
+
},
|
|
406
|
+
mergeOrSplit: () => ({ state, dispatch }) => {
|
|
407
|
+
if ((0, import_tables2.mergeCells)(state, dispatch)) {
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
return (0, import_tables2.splitCell)(state, dispatch);
|
|
411
|
+
},
|
|
412
|
+
setCellAttribute: (name, value) => ({ state, dispatch }) => {
|
|
413
|
+
return (0, import_tables2.setCellAttr)(name, value)(state, dispatch);
|
|
414
|
+
},
|
|
415
|
+
goToNextCell: () => ({ state, dispatch }) => {
|
|
416
|
+
return (0, import_tables2.goToNextCell)(1)(state, dispatch);
|
|
417
|
+
},
|
|
418
|
+
goToPreviousCell: () => ({ state, dispatch }) => {
|
|
419
|
+
return (0, import_tables2.goToNextCell)(-1)(state, dispatch);
|
|
420
|
+
},
|
|
421
|
+
fixTables: () => ({ state, dispatch }) => {
|
|
422
|
+
if (dispatch) {
|
|
423
|
+
(0, import_tables2.fixTables)(state);
|
|
424
|
+
}
|
|
425
|
+
return true;
|
|
426
|
+
},
|
|
427
|
+
setCellSelection: (position) => ({ tr, dispatch }) => {
|
|
428
|
+
if (dispatch) {
|
|
429
|
+
const selection = import_tables2.CellSelection.create(tr.doc, position.anchorCell, position.headCell);
|
|
430
|
+
tr.setSelection(selection);
|
|
431
|
+
}
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
},
|
|
436
|
+
addKeyboardShortcuts() {
|
|
437
|
+
return {
|
|
438
|
+
Tab: () => {
|
|
439
|
+
if (this.editor.commands.goToNextCell()) {
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
if (!this.editor.can().addRowAfter()) {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
return this.editor.chain().addRowAfter().goToNextCell().run();
|
|
446
|
+
},
|
|
447
|
+
"Shift-Tab": () => this.editor.commands.goToPreviousCell(),
|
|
448
|
+
Backspace: deleteTableWhenAllCellsSelected,
|
|
449
|
+
"Mod-Backspace": deleteTableWhenAllCellsSelected,
|
|
450
|
+
Delete: deleteTableWhenAllCellsSelected,
|
|
451
|
+
"Mod-Delete": deleteTableWhenAllCellsSelected
|
|
452
|
+
};
|
|
453
|
+
},
|
|
454
|
+
addProseMirrorPlugins() {
|
|
455
|
+
const isResizable = this.options.resizable && this.editor.isEditable;
|
|
456
|
+
return [
|
|
457
|
+
...isResizable ? [
|
|
458
|
+
(0, import_tables2.columnResizing)({
|
|
459
|
+
handleWidth: this.options.handleWidth,
|
|
460
|
+
cellMinWidth: this.options.cellMinWidth,
|
|
461
|
+
defaultCellMinWidth: this.options.cellMinWidth,
|
|
462
|
+
View: this.options.View,
|
|
463
|
+
lastColumnResizable: this.options.lastColumnResizable
|
|
464
|
+
})
|
|
465
|
+
] : [],
|
|
466
|
+
(0, import_tables2.tableEditing)({
|
|
467
|
+
allowTableNodeSelection: this.options.allowTableNodeSelection
|
|
468
|
+
})
|
|
469
|
+
];
|
|
470
|
+
},
|
|
471
|
+
extendNodeSchema(extension) {
|
|
472
|
+
const context = {
|
|
473
|
+
name: extension.name,
|
|
474
|
+
options: extension.options,
|
|
475
|
+
storage: extension.storage
|
|
476
|
+
};
|
|
477
|
+
return {
|
|
478
|
+
tableRole: (0, import_core5.callOrReturn)((0, import_core5.getExtensionField)(extension, "tableRole", context))
|
|
479
|
+
};
|
|
480
|
+
}
|
|
350
481
|
});
|
|
351
482
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
483
|
+
// src/kit/index.ts
|
|
484
|
+
var TableKit = import_core6.Extension.create({
|
|
485
|
+
name: "tableKit",
|
|
486
|
+
addExtensions() {
|
|
487
|
+
const extensions = [];
|
|
488
|
+
if (this.options.table !== false) {
|
|
489
|
+
extensions.push(Table.configure(this.options.table));
|
|
490
|
+
}
|
|
491
|
+
if (this.options.tableCell !== false) {
|
|
492
|
+
extensions.push(TableCell.configure(this.options.tableCell));
|
|
493
|
+
}
|
|
494
|
+
if (this.options.tableHeader !== false) {
|
|
495
|
+
extensions.push(TableHeader.configure(this.options.tableHeader));
|
|
496
|
+
}
|
|
497
|
+
if (this.options.tableRow !== false) {
|
|
498
|
+
extensions.push(TableRow.configure(this.options.tableRow));
|
|
499
|
+
}
|
|
500
|
+
return extensions;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
504
|
+
0 && (module.exports = {
|
|
505
|
+
Table,
|
|
506
|
+
TableCell,
|
|
507
|
+
TableHeader,
|
|
508
|
+
TableKit,
|
|
509
|
+
TableRow,
|
|
510
|
+
TableView,
|
|
511
|
+
createColGroup,
|
|
512
|
+
createTable,
|
|
513
|
+
updateColumns
|
|
514
|
+
});
|
|
515
|
+
//# sourceMappingURL=index.cjs.map
|