@kopexa/extension-table 17.0.46 → 17.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2NBDRVYL.mjs +428 -0
- package/dist/chunk-3SWV7BGP.mjs +638 -0
- package/dist/chunk-4QSZXHZO.mjs +276 -0
- package/dist/chunk-5B5XIL2G.mjs +457 -0
- package/dist/chunk-62B2LU2Q.mjs +603 -0
- package/dist/chunk-6FHFDGJO.mjs +251 -0
- package/dist/chunk-CD62W5C3.mjs +165 -0
- package/dist/chunk-CN73TYHV.mjs +190 -0
- package/dist/chunk-CPDSPBS6.mjs +276 -0
- package/dist/chunk-E7W2KRZG.mjs +49 -0
- package/dist/chunk-G6GHC2WO.mjs +276 -0
- package/dist/chunk-GBTQVIN5.mjs +174 -0
- package/dist/chunk-GDEXPEW5.mjs +52 -0
- package/dist/chunk-GQLZBIWF.mjs +198 -0
- package/dist/chunk-IRJ6RAVQ.mjs +116 -0
- package/dist/chunk-J4VOSZCZ.mjs +59 -0
- package/dist/chunk-KIYFW7MP.mjs +122 -0
- package/dist/chunk-KTRZVXJC.mjs +306 -0
- package/dist/chunk-LUA32VH4.mjs +35 -0
- package/dist/{chunk-2L3HZWWG.mjs → chunk-MB52MZQ4.mjs} +7 -8
- package/dist/chunk-PTX5UYV6.mjs +10 -0
- package/dist/chunk-TEGO6KUS.mjs +96 -0
- package/dist/chunk-VIBVRWS4.mjs +197 -0
- package/dist/chunk-VQV757EG.mjs +113 -0
- package/dist/chunk-XRNQXADK.mjs +149 -0
- package/dist/chunk-ZVPJDJBO.mjs +134 -0
- package/dist/{kit.d.mts → extensions/kit.d.mts} +1 -3
- package/dist/{kit.d.ts → extensions/kit.d.ts} +1 -3
- package/dist/extensions/kit.js +1041 -0
- package/dist/extensions/kit.mjs +15 -0
- package/dist/extensions/table-cell.d.mts +6 -0
- package/dist/extensions/table-cell.d.ts +6 -0
- package/dist/extensions/table-cell.js +70 -0
- package/dist/extensions/table-cell.mjs +8 -0
- package/dist/extensions/table-handle-plugin.d.mts +46 -0
- package/dist/extensions/table-handle-plugin.d.ts +46 -0
- package/dist/extensions/table-handle-plugin.js +1100 -0
- package/dist/extensions/table-handle-plugin.mjs +18 -0
- package/dist/extensions/table-handle.d.mts +19 -0
- package/dist/extensions/table-handle.d.ts +19 -0
- package/dist/extensions/table-handle.js +865 -0
- package/dist/extensions/table-handle.mjs +11 -0
- package/dist/{table → extensions}/table.d.mts +2 -2
- package/dist/{table → extensions}/table.d.ts +2 -2
- package/dist/extensions/table.js +138 -0
- package/dist/extensions/table.mjs +9 -0
- package/dist/hooks/use-resize-overlay.d.mts +5 -0
- package/dist/hooks/use-resize-overlay.d.ts +5 -0
- package/dist/hooks/use-resize-overlay.js +83 -0
- package/dist/hooks/use-resize-overlay.mjs +9 -0
- package/dist/hooks/use-table-add-row-column.d.mts +57 -0
- package/dist/hooks/use-table-add-row-column.d.ts +57 -0
- package/dist/hooks/use-table-add-row-column.js +551 -0
- package/dist/hooks/use-table-add-row-column.mjs +11 -0
- package/dist/hooks/use-table-align-cell.d.mts +148 -0
- package/dist/hooks/use-table-align-cell.d.ts +148 -0
- package/dist/hooks/use-table-align-cell.js +655 -0
- package/dist/hooks/use-table-align-cell.mjs +13 -0
- package/dist/hooks/use-table-clear-row-column-content.d.mts +103 -0
- package/dist/hooks/use-table-clear-row-column-content.d.ts +103 -0
- package/dist/hooks/use-table-clear-row-column-content.js +681 -0
- package/dist/hooks/use-table-clear-row-column-content.mjs +11 -0
- package/dist/hooks/use-table-delete-row-column.d.mts +87 -0
- package/dist/hooks/use-table-delete-row-column.d.ts +87 -0
- package/dist/hooks/use-table-delete-row-column.js +459 -0
- package/dist/hooks/use-table-delete-row-column.mjs +11 -0
- package/dist/hooks/use-table-duplicate-row-column.d.mts +49 -0
- package/dist/hooks/use-table-duplicate-row-column.d.ts +49 -0
- package/dist/hooks/use-table-duplicate-row-column.js +758 -0
- package/dist/hooks/use-table-duplicate-row-column.mjs +11 -0
- package/dist/hooks/use-table-handle-positioning.d.mts +42 -0
- package/dist/hooks/use-table-handle-positioning.d.ts +42 -0
- package/dist/hooks/use-table-handle-positioning.js +190 -0
- package/dist/hooks/use-table-handle-positioning.mjs +10 -0
- package/dist/hooks/use-table-handle-state.d.mts +28 -0
- package/dist/hooks/use-table-handle-state.d.ts +28 -0
- package/dist/hooks/use-table-handle-state.js +76 -0
- package/dist/hooks/use-table-handle-state.mjs +9 -0
- package/dist/hooks/use-table-header-row-column.d.mts +58 -0
- package/dist/hooks/use-table-header-row-column.d.ts +58 -0
- package/dist/hooks/use-table-header-row-column.js +603 -0
- package/dist/hooks/use-table-header-row-column.mjs +13 -0
- package/dist/hooks/use-table-merge-split-cell.d.mts +123 -0
- package/dist/hooks/use-table-merge-split-cell.d.ts +123 -0
- package/dist/hooks/use-table-merge-split-cell.js +331 -0
- package/dist/hooks/use-table-merge-split-cell.mjs +12 -0
- package/dist/hooks/use-table-move-row-column.d.mts +101 -0
- package/dist/hooks/use-table-move-row-column.d.ts +101 -0
- package/dist/hooks/use-table-move-row-column.js +621 -0
- package/dist/hooks/use-table-move-row-column.mjs +13 -0
- package/dist/hooks/use-table-sort-row-column.d.mts +118 -0
- package/dist/hooks/use-table-sort-row-column.d.ts +118 -0
- package/dist/hooks/use-table-sort-row-column.js +623 -0
- package/dist/hooks/use-table-sort-row-column.mjs +13 -0
- package/dist/index.d.mts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +4947 -660
- package/dist/index.mjs +43 -21
- package/dist/lib/constants.d.mts +4 -0
- package/dist/lib/constants.d.ts +4 -0
- package/dist/{table/lib/is-cell-selection.js → lib/constants.js} +10 -10
- package/dist/lib/constants.mjs +10 -0
- package/dist/lib/create-image.d.mts +12 -0
- package/dist/lib/create-image.d.ts +12 -0
- package/dist/lib/create-image.js +221 -0
- package/dist/lib/create-image.mjs +8 -0
- package/dist/lib/table-utils.d.mts +263 -0
- package/dist/lib/table-utils.d.ts +263 -0
- package/dist/lib/table-utils.js +488 -0
- package/dist/lib/table-utils.mjs +40 -0
- package/dist/messages.d.mts +174 -0
- package/dist/messages.d.ts +174 -0
- package/dist/messages.js +213 -0
- package/dist/{table-row.mjs → messages.mjs} +3 -3
- package/dist/ui/table-alignment-menu.d.mts +25 -0
- package/dist/ui/table-alignment-menu.d.ts +25 -0
- package/dist/ui/table-alignment-menu.js +758 -0
- package/dist/ui/table-alignment-menu.mjs +14 -0
- package/dist/ui/table-cell-handle-menu.d.mts +12 -0
- package/dist/ui/table-cell-handle-menu.d.ts +12 -0
- package/dist/ui/table-cell-handle-menu.js +1317 -0
- package/dist/ui/table-cell-handle-menu.mjs +17 -0
- package/dist/ui/table-handle-menu.d.mts +23 -0
- package/dist/ui/table-handle-menu.d.ts +23 -0
- package/dist/ui/table-handle-menu.js +2598 -0
- package/dist/ui/table-handle-menu.mjs +21 -0
- package/dist/ui/table-handle.d.mts +48 -0
- package/dist/ui/table-handle.d.ts +48 -0
- package/dist/ui/table-handle.js +3126 -0
- package/dist/ui/table-handle.mjs +22 -0
- package/dist/ui/table-selection-overlay.d.mts +14 -0
- package/dist/ui/table-selection-overlay.d.ts +14 -0
- package/dist/ui/table-selection-overlay.js +553 -0
- package/dist/ui/table-selection-overlay.mjs +11 -0
- package/package.json +12 -7
- package/dist/chunk-3XEOCAHB.mjs +0 -41
- package/dist/chunk-5W5ARI64.mjs +0 -11
- package/dist/chunk-BTJ3DCGC.mjs +0 -113
- package/dist/chunk-DR2GZJH6.mjs +0 -70
- package/dist/chunk-GHOJLOCF.mjs +0 -247
- package/dist/chunk-HWVA6DOK.mjs +0 -20
- package/dist/chunk-KLUH6EZS.mjs +0 -40
- package/dist/chunk-KNOMCS6F.mjs +0 -57
- package/dist/chunk-LPHCE6EI.mjs +0 -92
- package/dist/chunk-POJFNXG7.mjs +0 -44
- package/dist/chunk-QHD3QTD2.mjs +0 -61
- package/dist/chunk-RPPUD4R5.mjs +0 -1
- package/dist/kit.js +0 -764
- package/dist/kit.mjs +0 -19
- package/dist/table/index.d.mts +0 -6
- package/dist/table/index.d.ts +0 -6
- package/dist/table/index.js +0 -625
- package/dist/table/index.mjs +0 -18
- package/dist/table/lib/col-style.d.mts +0 -3
- package/dist/table/lib/col-style.d.ts +0 -3
- package/dist/table/lib/col-style.js +0 -36
- package/dist/table/lib/col-style.mjs +0 -13
- package/dist/table/lib/delete-table-when-all-cells-selected.d.mts +0 -5
- package/dist/table/lib/delete-table-when-all-cells-selected.d.ts +0 -5
- package/dist/table/lib/delete-table-when-all-cells-selected.js +0 -66
- package/dist/table/lib/delete-table-when-all-cells-selected.mjs +0 -40
- package/dist/table/lib/get-table-node-types.d.mts +0 -7
- package/dist/table/lib/get-table-node-types.d.ts +0 -7
- package/dist/table/lib/get-table-node-types.js +0 -44
- package/dist/table/lib/get-table-node-types.mjs +0 -21
- package/dist/table/lib/icons.d.mts +0 -13
- package/dist/table/lib/icons.d.ts +0 -13
- package/dist/table/lib/icons.js +0 -81
- package/dist/table/lib/icons.mjs +0 -58
- package/dist/table/lib/insert-line-above-table-action.d.mts +0 -5
- package/dist/table/lib/insert-line-above-table-action.d.ts +0 -5
- package/dist/table/lib/insert-line-above-table-action.js +0 -64
- package/dist/table/lib/insert-line-above-table-action.mjs +0 -8
- package/dist/table/lib/insert-line-below-table-action.d.mts +0 -5
- package/dist/table/lib/insert-line-below-table-action.d.ts +0 -5
- package/dist/table/lib/insert-line-below-table-action.js +0 -63
- package/dist/table/lib/insert-line-below-table-action.mjs +0 -8
- package/dist/table/lib/is-cell-selection.d.mts +0 -5
- package/dist/table/lib/is-cell-selection.d.ts +0 -5
- package/dist/table/lib/is-cell-selection.mjs +0 -8
- package/dist/table/lib/table-controls.d.mts +0 -15
- package/dist/table/lib/table-controls.d.ts +0 -15
- package/dist/table/lib/table-controls.js +0 -131
- package/dist/table/lib/table-controls.mjs +0 -8
- package/dist/table/table.js +0 -621
- package/dist/table/table.mjs +0 -14
- package/dist/table/views/table-column-menu.d.mts +0 -11
- package/dist/table/views/table-column-menu.d.ts +0 -11
- package/dist/table/views/table-column-menu.js +0 -84
- package/dist/table/views/table-column-menu.mjs +0 -8
- package/dist/table/views/table-node-view.d.mts +0 -25
- package/dist/table/views/table-node-view.d.ts +0 -25
- package/dist/table/views/table-node-view.js +0 -370
- package/dist/table/views/table-node-view.mjs +0 -10
- package/dist/table/views/table-row-menu.d.mts +0 -11
- package/dist/table/views/table-row-menu.d.ts +0 -11
- package/dist/table/views/table-row-menu.js +0 -80
- package/dist/table/views/table-row-menu.mjs +0 -8
- package/dist/table-cell.d.mts +0 -8
- package/dist/table-cell.d.ts +0 -8
- package/dist/table-cell.js +0 -93
- package/dist/table-cell.mjs +0 -8
- package/dist/table-header.d.mts +0 -6
- package/dist/table-header.d.ts +0 -6
- package/dist/table-header.js +0 -67
- package/dist/table-header.mjs +0 -8
- package/dist/table-row.d.mts +0 -6
- package/dist/table-row.d.ts +0 -6
- package/dist/table-row.js +0 -43
package/dist/index.mjs
CHANGED
|
@@ -1,34 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
TableHandle
|
|
4
|
+
} from "./chunk-TEGO6KUS.mjs";
|
|
5
|
+
import "./chunk-62B2LU2Q.mjs";
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
TableSelectionOverlay
|
|
8
|
+
} from "./chunk-2NBDRVYL.mjs";
|
|
9
|
+
import "./chunk-G6GHC2WO.mjs";
|
|
10
|
+
import "./chunk-6FHFDGJO.mjs";
|
|
11
|
+
import {
|
|
12
|
+
TableCellHandleMenu
|
|
13
|
+
} from "./chunk-XRNQXADK.mjs";
|
|
14
|
+
import "./chunk-KIYFW7MP.mjs";
|
|
15
|
+
import {
|
|
16
|
+
TableAlignMenuItems,
|
|
17
|
+
TableAlignSubMenu
|
|
18
|
+
} from "./chunk-VQV757EG.mjs";
|
|
19
|
+
import "./chunk-VIBVRWS4.mjs";
|
|
20
|
+
import "./chunk-KTRZVXJC.mjs";
|
|
21
|
+
import "./chunk-4QSZXHZO.mjs";
|
|
22
|
+
import "./chunk-ZVPJDJBO.mjs";
|
|
23
|
+
import "./chunk-CPDSPBS6.mjs";
|
|
24
|
+
import "./chunk-GBTQVIN5.mjs";
|
|
25
|
+
import "./chunk-GDEXPEW5.mjs";
|
|
26
|
+
import "./chunk-CD62W5C3.mjs";
|
|
8
27
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
28
|
+
messages
|
|
29
|
+
} from "./chunk-CN73TYHV.mjs";
|
|
11
30
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import
|
|
31
|
+
TableKit
|
|
32
|
+
} from "./chunk-MB52MZQ4.mjs";
|
|
33
|
+
import {
|
|
34
|
+
TableCell
|
|
35
|
+
} from "./chunk-E7W2KRZG.mjs";
|
|
36
|
+
import "./chunk-LUA32VH4.mjs";
|
|
37
|
+
import "./chunk-3SWV7BGP.mjs";
|
|
38
|
+
import "./chunk-GQLZBIWF.mjs";
|
|
39
|
+
import "./chunk-5B5XIL2G.mjs";
|
|
15
40
|
import {
|
|
16
41
|
Table
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
} from "./chunk-GHOJLOCF.mjs";
|
|
21
|
-
import "./chunk-KNOMCS6F.mjs";
|
|
22
|
-
import "./chunk-3XEOCAHB.mjs";
|
|
23
|
-
import "./chunk-KLUH6EZS.mjs";
|
|
24
|
-
import "./chunk-BTJ3DCGC.mjs";
|
|
25
|
-
import "./chunk-QHD3QTD2.mjs";
|
|
42
|
+
} from "./chunk-IRJ6RAVQ.mjs";
|
|
43
|
+
import "./chunk-PTX5UYV6.mjs";
|
|
44
|
+
import "./chunk-J4VOSZCZ.mjs";
|
|
26
45
|
import "./chunk-WKV76XOR.mjs";
|
|
27
46
|
export {
|
|
28
47
|
Table,
|
|
48
|
+
TableAlignMenuItems,
|
|
49
|
+
TableAlignSubMenu,
|
|
29
50
|
TableCell,
|
|
30
|
-
|
|
51
|
+
TableCellHandleMenu,
|
|
52
|
+
TableHandle,
|
|
31
53
|
TableKit,
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
TableSelectionOverlay,
|
|
55
|
+
messages as tableMessages
|
|
34
56
|
};
|
|
@@ -18,17 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
|
|
21
|
-
// src/
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
24
|
-
|
|
21
|
+
// src/lib/constants.ts
|
|
22
|
+
var constants_exports = {};
|
|
23
|
+
__export(constants_exports, {
|
|
24
|
+
EMPTY_CELL_WIDTH: () => EMPTY_CELL_WIDTH,
|
|
25
|
+
RESIZE_MIN_WIDTH: () => RESIZE_MIN_WIDTH
|
|
25
26
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
return value instanceof import_tables.CellSelection;
|
|
30
|
-
}
|
|
27
|
+
module.exports = __toCommonJS(constants_exports);
|
|
28
|
+
var EMPTY_CELL_WIDTH = 120;
|
|
29
|
+
var RESIZE_MIN_WIDTH = 35;
|
|
31
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
31
|
0 && (module.exports = {
|
|
33
|
-
|
|
32
|
+
EMPTY_CELL_WIDTH,
|
|
33
|
+
RESIZE_MIN_WIDTH
|
|
34
34
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public API
|
|
5
|
+
* Creates a polished drag image for a row/column from a TipTap/ProseMirror table.
|
|
6
|
+
* - Subtle rounded corners & shadow
|
|
7
|
+
* - Scales down if it exceeds editor width
|
|
8
|
+
* - Preserves computed styles to look 1:1 with the table
|
|
9
|
+
*/
|
|
10
|
+
declare function createTableDragImage(editor: Editor, orientation: "row" | "col", index: number, tablePos: number): HTMLElement;
|
|
11
|
+
|
|
12
|
+
export { createTableDragImage };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public API
|
|
5
|
+
* Creates a polished drag image for a row/column from a TipTap/ProseMirror table.
|
|
6
|
+
* - Subtle rounded corners & shadow
|
|
7
|
+
* - Scales down if it exceeds editor width
|
|
8
|
+
* - Preserves computed styles to look 1:1 with the table
|
|
9
|
+
*/
|
|
10
|
+
declare function createTableDragImage(editor: Editor, orientation: "row" | "col", index: number, tablePos: number): HTMLElement;
|
|
11
|
+
|
|
12
|
+
export { createTableDragImage };
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/lib/create-image.ts
|
|
22
|
+
var create_image_exports = {};
|
|
23
|
+
__export(create_image_exports, {
|
|
24
|
+
createTableDragImage: () => createTableDragImage
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(create_image_exports);
|
|
27
|
+
var STYLE_PROPS = [
|
|
28
|
+
// Box & border
|
|
29
|
+
"boxSizing",
|
|
30
|
+
"backgroundColor",
|
|
31
|
+
"borderTopColor",
|
|
32
|
+
"borderRightColor",
|
|
33
|
+
"borderBottomColor",
|
|
34
|
+
"borderLeftColor",
|
|
35
|
+
"borderTopStyle",
|
|
36
|
+
"borderRightStyle",
|
|
37
|
+
"borderBottomStyle",
|
|
38
|
+
"borderLeftStyle",
|
|
39
|
+
"borderTopWidth",
|
|
40
|
+
"borderRightWidth",
|
|
41
|
+
"borderBottomWidth",
|
|
42
|
+
"borderLeftWidth",
|
|
43
|
+
"borderRadius",
|
|
44
|
+
// Spacing
|
|
45
|
+
"paddingTop",
|
|
46
|
+
"paddingRight",
|
|
47
|
+
"paddingBottom",
|
|
48
|
+
"paddingLeft",
|
|
49
|
+
// Typography
|
|
50
|
+
"color",
|
|
51
|
+
"font",
|
|
52
|
+
"fontFamily",
|
|
53
|
+
"fontSize",
|
|
54
|
+
"fontWeight",
|
|
55
|
+
"fontStyle",
|
|
56
|
+
"lineHeight",
|
|
57
|
+
"letterSpacing",
|
|
58
|
+
"textTransform",
|
|
59
|
+
"textDecoration",
|
|
60
|
+
"textAlign",
|
|
61
|
+
"verticalAlign",
|
|
62
|
+
"whiteSpace",
|
|
63
|
+
// Sizing
|
|
64
|
+
"width",
|
|
65
|
+
"minWidth",
|
|
66
|
+
"maxWidth",
|
|
67
|
+
"height",
|
|
68
|
+
"minHeight",
|
|
69
|
+
"maxHeight",
|
|
70
|
+
// Table specifics
|
|
71
|
+
"backgroundClip"
|
|
72
|
+
];
|
|
73
|
+
var toDash = (p) => p.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
74
|
+
function copyComputedStyles(source, target) {
|
|
75
|
+
const cs = getComputedStyle(source);
|
|
76
|
+
for (const p of STYLE_PROPS) {
|
|
77
|
+
const prop = String(p);
|
|
78
|
+
const val = cs.getPropertyValue(toDash(prop));
|
|
79
|
+
if (val) target.style[prop] = val;
|
|
80
|
+
}
|
|
81
|
+
target.style.overflow = "hidden";
|
|
82
|
+
target.style.textOverflow = "ellipsis";
|
|
83
|
+
if (cs.whiteSpace === "" || cs.whiteSpace === "normal") {
|
|
84
|
+
target.style.whiteSpace = "nowrap";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function cloneWithStyles(root) {
|
|
88
|
+
const clone = root.cloneNode(true);
|
|
89
|
+
const q = [{ src: root, dst: clone }];
|
|
90
|
+
while (q.length) {
|
|
91
|
+
const { src, dst } = q.shift();
|
|
92
|
+
if (src instanceof HTMLElement && dst instanceof HTMLElement) {
|
|
93
|
+
copyComputedStyles(src, dst);
|
|
94
|
+
}
|
|
95
|
+
const srcChildren = Array.from(src.children);
|
|
96
|
+
const dstChildren = Array.from(dst.children);
|
|
97
|
+
const len = Math.min(srcChildren.length, dstChildren.length);
|
|
98
|
+
for (let i = 0; i < len; i++) {
|
|
99
|
+
const srcChild = srcChildren[i];
|
|
100
|
+
const dstChild = dstChildren[i];
|
|
101
|
+
if (srcChild && dstChild) {
|
|
102
|
+
q.push({ src: srcChild, dst: dstChild });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return clone;
|
|
107
|
+
}
|
|
108
|
+
function styleDragWrapper(el, maxWidth) {
|
|
109
|
+
Object.assign(el.style, {
|
|
110
|
+
position: "fixed",
|
|
111
|
+
top: "-10000px",
|
|
112
|
+
left: "-10000px",
|
|
113
|
+
pointerEvents: "none",
|
|
114
|
+
zIndex: "2147483647",
|
|
115
|
+
maxWidth: `${maxWidth}px`,
|
|
116
|
+
borderRadius: "12px",
|
|
117
|
+
background: "transparent",
|
|
118
|
+
filter: "drop-shadow(0 8px 24px rgba(0,0,0,0.18)) drop-shadow(0 2px 8px rgba(0,0,0,0.10))",
|
|
119
|
+
overflow: "hidden"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function scaleToFit(el, maxWidth) {
|
|
123
|
+
if (!el.isConnected) document.body.appendChild(el);
|
|
124
|
+
const rect = el.getBoundingClientRect();
|
|
125
|
+
if (rect.width > maxWidth && rect.width > 0) {
|
|
126
|
+
const scale = maxWidth / rect.width;
|
|
127
|
+
el.style.transformOrigin = "top left";
|
|
128
|
+
el.style.transform = `scale(${scale})`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function applyTableBoxStyles(srcTable, dstTable) {
|
|
132
|
+
const tcs = getComputedStyle(srcTable);
|
|
133
|
+
dstTable.style.borderCollapse = tcs.borderCollapse;
|
|
134
|
+
dstTable.style.borderSpacing = tcs.borderSpacing;
|
|
135
|
+
dstTable.style.tableLayout = "fixed";
|
|
136
|
+
dstTable.className = srcTable.className;
|
|
137
|
+
}
|
|
138
|
+
function lockCellWidth(fromCell, toCell) {
|
|
139
|
+
const rect = fromCell.getBoundingClientRect();
|
|
140
|
+
if (rect.width > 0) {
|
|
141
|
+
toCell.style.width = `${rect.width}px`;
|
|
142
|
+
toCell.style.maxWidth = `${rect.width}px`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function buildRowPreview(tableEl, rowIndex) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
const body = (_b = (_a = tableEl.tBodies) == null ? void 0 : _a[0]) != null ? _b : tableEl.querySelector("tbody");
|
|
148
|
+
if (!body) return null;
|
|
149
|
+
const row = (_c = body.rows) == null ? void 0 : _c[rowIndex];
|
|
150
|
+
if (!row) return null;
|
|
151
|
+
const tableClone = document.createElement("table");
|
|
152
|
+
const tbodyClone = document.createElement("tbody");
|
|
153
|
+
const rowClone = cloneWithStyles(row);
|
|
154
|
+
applyTableBoxStyles(tableEl, tableClone);
|
|
155
|
+
for (let i = 0; i < row.cells.length; i++) {
|
|
156
|
+
const src = row.cells[i];
|
|
157
|
+
const dst = rowClone.cells[i];
|
|
158
|
+
if (dst) lockCellWidth(src, dst);
|
|
159
|
+
}
|
|
160
|
+
tbodyClone.appendChild(rowClone);
|
|
161
|
+
tableClone.appendChild(tbodyClone);
|
|
162
|
+
return tableClone;
|
|
163
|
+
}
|
|
164
|
+
function buildColumnPreview(tableEl, colIndex) {
|
|
165
|
+
var _a, _b, _c;
|
|
166
|
+
const body = (_b = (_a = tableEl.tBodies) == null ? void 0 : _a[0]) != null ? _b : tableEl.querySelector("tbody");
|
|
167
|
+
if (!body) return null;
|
|
168
|
+
const tableClone = document.createElement("table");
|
|
169
|
+
const tbodyClone = document.createElement("tbody");
|
|
170
|
+
applyTableBoxStyles(tableEl, tableClone);
|
|
171
|
+
let firstCellWidth = 0;
|
|
172
|
+
for (let r = 0; r < body.rows.length; r++) {
|
|
173
|
+
const srcRow = body.rows[r];
|
|
174
|
+
if (!srcRow) continue;
|
|
175
|
+
const srcCell = (_c = srcRow.cells) == null ? void 0 : _c[colIndex];
|
|
176
|
+
if (!srcCell) continue;
|
|
177
|
+
const tr = document.createElement("tr");
|
|
178
|
+
const cellClone = cloneWithStyles(srcCell);
|
|
179
|
+
const rect = srcCell.getBoundingClientRect();
|
|
180
|
+
if (!firstCellWidth && rect.width > 0) firstCellWidth = rect.width;
|
|
181
|
+
lockCellWidth(srcCell, cellClone);
|
|
182
|
+
tr.appendChild(cellClone);
|
|
183
|
+
tbodyClone.appendChild(tr);
|
|
184
|
+
}
|
|
185
|
+
if (firstCellWidth > 0) {
|
|
186
|
+
tableClone.style.width = `${firstCellWidth}px`;
|
|
187
|
+
tableClone.style.maxWidth = `${firstCellWidth}px`;
|
|
188
|
+
}
|
|
189
|
+
tableClone.appendChild(tbodyClone);
|
|
190
|
+
return tableClone;
|
|
191
|
+
}
|
|
192
|
+
function createTableDragImage(editor, orientation, index, tablePos) {
|
|
193
|
+
const editorRect = editor.view.dom.getBoundingClientRect();
|
|
194
|
+
const maxWidth = Math.max(0, editorRect.width);
|
|
195
|
+
const wrapper = document.createElement("div");
|
|
196
|
+
styleDragWrapper(wrapper, maxWidth);
|
|
197
|
+
const tableEl = editor.view.nodeDOM(tablePos);
|
|
198
|
+
if (!tableEl) {
|
|
199
|
+
document.body.appendChild(wrapper);
|
|
200
|
+
return wrapper;
|
|
201
|
+
}
|
|
202
|
+
const tableRect = tableEl.getBoundingClientRect();
|
|
203
|
+
const dragWidth = Math.min(tableRect.width, editorRect.width);
|
|
204
|
+
wrapper.style.width = `${dragWidth}px`;
|
|
205
|
+
const preview = orientation === "row" ? buildRowPreview(tableEl, index) : buildColumnPreview(tableEl, index);
|
|
206
|
+
if (preview) {
|
|
207
|
+
const card = document.createElement("div");
|
|
208
|
+
Object.assign(card.style, {
|
|
209
|
+
background: "var(--drag-image-bg, transparent)",
|
|
210
|
+
overflow: "hidden"
|
|
211
|
+
});
|
|
212
|
+
card.appendChild(preview);
|
|
213
|
+
wrapper.appendChild(card);
|
|
214
|
+
}
|
|
215
|
+
scaleToFit(wrapper, maxWidth);
|
|
216
|
+
return wrapper;
|
|
217
|
+
}
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
createTableDragImage
|
|
221
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { Node } from '@tiptap/pm/model';
|
|
2
|
+
import { Transaction, EditorState, Command } from '@tiptap/pm/state';
|
|
3
|
+
import { TableMap, FindNodeResult, Rect } from '@tiptap/pm/tables';
|
|
4
|
+
import { Editor } from '@tiptap/react';
|
|
5
|
+
|
|
6
|
+
type Orientation = "row" | "column";
|
|
7
|
+
type TableInfo = {
|
|
8
|
+
map: TableMap;
|
|
9
|
+
} & FindNodeResult;
|
|
10
|
+
interface CellInfo extends FindNodeResult {
|
|
11
|
+
row: number;
|
|
12
|
+
column: number;
|
|
13
|
+
}
|
|
14
|
+
type DomCellAroundResult = {
|
|
15
|
+
type: "cell";
|
|
16
|
+
domNode: HTMLElement;
|
|
17
|
+
tbodyNode: HTMLTableSectionElement | null;
|
|
18
|
+
} | {
|
|
19
|
+
type: "wrapper";
|
|
20
|
+
domNode: HTMLElement;
|
|
21
|
+
tbodyNode: HTMLTableSectionElement | null;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Walk up from an element until we find a TD/TH or the table wrapper.
|
|
25
|
+
* Returns the found element plus its tbody (if present).
|
|
26
|
+
*/
|
|
27
|
+
declare function domCellAround(target: Element): DomCellAroundResult | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Given a DOM cell element, find its (row, col) indices within the table.
|
|
30
|
+
*
|
|
31
|
+
* This function:
|
|
32
|
+
* - Locates the nearest ancestor table element
|
|
33
|
+
* - Uses the editor's document model to resolve the cell's position
|
|
34
|
+
* - Traverses up the node hierarchy to find the corresponding table cell node
|
|
35
|
+
* - Uses `TableMap` to translate the cell's position into (row, col) indices
|
|
36
|
+
*
|
|
37
|
+
* Returns null if:
|
|
38
|
+
* - the table or cell cannot be found in the editor's document
|
|
39
|
+
* - any error occurs during position resolution
|
|
40
|
+
*
|
|
41
|
+
* @param cell The HTMLTableCellElement (td or th)
|
|
42
|
+
* @param tableNode The table node in the ProseMirror document
|
|
43
|
+
* @param editor The Tiptap editor instance
|
|
44
|
+
* @returns An object with { rowIndex, colIndex } or null if not found
|
|
45
|
+
*/
|
|
46
|
+
declare function getCellIndicesFromDOM(cell: HTMLTableCellElement, tableNode: Node | null, editor: Editor): {
|
|
47
|
+
rowIndex: number;
|
|
48
|
+
colIndex: number;
|
|
49
|
+
} | null;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a cell is merged (has colspan or rowspan > 1)
|
|
52
|
+
*/
|
|
53
|
+
declare function isCellMerged(node: Node | null): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Collect cells (and unique merged cells) from the current table.
|
|
56
|
+
* - If `columnIndex` is provided, scans that column.
|
|
57
|
+
* - If omitted, uses the first (leftmost) selected column based on the current selection.
|
|
58
|
+
*/
|
|
59
|
+
declare function getColumnCells(editor: Editor | null, columnIndex?: number, tablePos?: number): {
|
|
60
|
+
cells: CellInfo[];
|
|
61
|
+
mergedCells: CellInfo[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Get information about the table at the current selection or a specific position.
|
|
65
|
+
*
|
|
66
|
+
* If `tablePos` is provided, it looks for a table at that exact position.
|
|
67
|
+
* Otherwise, it finds the nearest table containing the current selection.
|
|
68
|
+
*
|
|
69
|
+
* Returns an object with:
|
|
70
|
+
* - `node`: the table node
|
|
71
|
+
* - `pos`: the position of the table in the document
|
|
72
|
+
* - `start`: the position just after the table node (where its content starts)
|
|
73
|
+
* - `map`: the `TableMap` for layout info (rows, columns, spans)
|
|
74
|
+
*
|
|
75
|
+
* If no table is found, returns null.
|
|
76
|
+
*/
|
|
77
|
+
declare function getTable(editor: Editor | null, tablePos?: number): {
|
|
78
|
+
map: TableMap;
|
|
79
|
+
node: Node;
|
|
80
|
+
pos: number;
|
|
81
|
+
start: number;
|
|
82
|
+
depth: number;
|
|
83
|
+
} | null;
|
|
84
|
+
/**
|
|
85
|
+
* Get all (row, col) coordinates for a given row or column index.
|
|
86
|
+
*
|
|
87
|
+
* - If `orientation` is "row", returns all columns in that row.
|
|
88
|
+
* - If `orientation` is "column", returns all rows in that column.
|
|
89
|
+
*
|
|
90
|
+
* Returns null if:
|
|
91
|
+
* - the editor or table is not found
|
|
92
|
+
* - the index is out of bounds
|
|
93
|
+
*
|
|
94
|
+
* @param editor The Tiptap editor instance
|
|
95
|
+
* @param index The row or column index (0-based)
|
|
96
|
+
* @param orientation "row" to get row coordinates, "column" for column coordinates
|
|
97
|
+
* @param tablePos Optional position of the table node in the document
|
|
98
|
+
* @returns Array of {row, col} objects or null if invalid
|
|
99
|
+
*/
|
|
100
|
+
declare function getIndexCoordinates({ editor, index, orientation, tablePos, }: {
|
|
101
|
+
editor: Editor | null;
|
|
102
|
+
index: number;
|
|
103
|
+
orientation?: Orientation;
|
|
104
|
+
tablePos?: number;
|
|
105
|
+
}): {
|
|
106
|
+
row: number;
|
|
107
|
+
col: number;
|
|
108
|
+
}[] | null;
|
|
109
|
+
/**
|
|
110
|
+
* Collect cells (and unique merged cells) from a specific row.
|
|
111
|
+
* - If `rowIndex` is provided, scans that row.
|
|
112
|
+
* - If omitted, uses the first (topmost) selected row based on the current selection.
|
|
113
|
+
*/
|
|
114
|
+
declare function getRowCells(editor: Editor | null, rowIndex?: number, tablePos?: number): {
|
|
115
|
+
cells: CellInfo[];
|
|
116
|
+
mergedCells: CellInfo[];
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Given a DOM element inside a table, find the corresponding table node and its position.
|
|
120
|
+
*
|
|
121
|
+
* This function:
|
|
122
|
+
* - Locates the nearest ancestor table element
|
|
123
|
+
* - Uses the editor's document model to resolve the table's position
|
|
124
|
+
* - Traverses up the node hierarchy to find the corresponding table node
|
|
125
|
+
*
|
|
126
|
+
* Returns null if:
|
|
127
|
+
* - the table cannot be found in the editor's document
|
|
128
|
+
* - any error occurs during position resolution
|
|
129
|
+
*
|
|
130
|
+
* @param tableElement The HTMLTableElement or an element inside it
|
|
131
|
+
* @param editor The Tiptap editor instance
|
|
132
|
+
* @returns An object with { node: tableNode, pos: tablePos } or null if not found
|
|
133
|
+
*/
|
|
134
|
+
declare function getTableFromDOM(tableElement: HTMLElement, editor: Editor): {
|
|
135
|
+
node: Node;
|
|
136
|
+
pos: number;
|
|
137
|
+
} | null;
|
|
138
|
+
/**
|
|
139
|
+
* Checks if a node is a table node
|
|
140
|
+
*/
|
|
141
|
+
declare function isTableNode(node: Node | null | undefined): node is Node;
|
|
142
|
+
type TransactionSelectionOptions = {
|
|
143
|
+
mode: "transaction";
|
|
144
|
+
};
|
|
145
|
+
type StateSelectionOptions = {
|
|
146
|
+
mode?: "state";
|
|
147
|
+
};
|
|
148
|
+
type SelectionReturnMode = "state" | "transaction" | "dispatch";
|
|
149
|
+
type DispatchSelectionOptions = {
|
|
150
|
+
mode: "dispatch";
|
|
151
|
+
dispatch: (tr: Transaction) => void;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Selects table cells by their (row, col) coordinates.
|
|
155
|
+
*
|
|
156
|
+
* This function can be used in three modes:
|
|
157
|
+
* - `"state"` (default) → Returns a new `EditorState` with the selection applied, or null if failed.
|
|
158
|
+
* - `"transaction"` → Returns a `Transaction` with the selection set, or null if failed.
|
|
159
|
+
* - `"dispatch"` → Immediately dispatches the selection and returns boolean success status.
|
|
160
|
+
*
|
|
161
|
+
* @param editor - The editor instance
|
|
162
|
+
* @param tablePos - Position of the table in the document
|
|
163
|
+
* @param coords - Array of {row, col} coordinates to select
|
|
164
|
+
* @param options - Mode and dispatch options
|
|
165
|
+
*/
|
|
166
|
+
declare function selectCellsByCoords(editor: Editor | null, tablePos: number, coords: {
|
|
167
|
+
row: number;
|
|
168
|
+
col: number;
|
|
169
|
+
}[], options?: StateSelectionOptions): EditorState;
|
|
170
|
+
declare function selectCellsByCoords(editor: Editor | null, tablePos: number, coords: {
|
|
171
|
+
row: number;
|
|
172
|
+
col: number;
|
|
173
|
+
}[], options: TransactionSelectionOptions): Transaction;
|
|
174
|
+
declare function selectCellsByCoords(editor: Editor | null, tablePos: number, coords: {
|
|
175
|
+
row: number;
|
|
176
|
+
col: number;
|
|
177
|
+
}[], options: DispatchSelectionOptions): void;
|
|
178
|
+
/**
|
|
179
|
+
* Determine if the current selection is a full row or column selection.
|
|
180
|
+
*
|
|
181
|
+
* If the selection is a `CellSelection` that spans an entire row or column,
|
|
182
|
+
* returns an object indicating the type and index:
|
|
183
|
+
* - `{ type: "row", index: number }` for full row selections
|
|
184
|
+
* - `{ type: "column", index: number }` for full column selections
|
|
185
|
+
*
|
|
186
|
+
* If the selection is not a full row/column, or if no table is found, returns null.
|
|
187
|
+
*/
|
|
188
|
+
declare function getTableSelectionType(editor: Editor | null, index?: number, orientation?: Orientation, tablePos?: number): {
|
|
189
|
+
orientation: Orientation;
|
|
190
|
+
index: number;
|
|
191
|
+
} | null;
|
|
192
|
+
/**
|
|
193
|
+
* Get all cells (and unique merged cells) in the selected row or column.
|
|
194
|
+
*
|
|
195
|
+
* - If `index` is provided, uses that row/column index.
|
|
196
|
+
* - If omitted, uses the first selected row/column based on current selection.
|
|
197
|
+
*
|
|
198
|
+
* Returns an object with:
|
|
199
|
+
* - `cells`: all cells in the row/column
|
|
200
|
+
* - `mergedCells`: only the unique cells that have rowspan/colspan > 1
|
|
201
|
+
*
|
|
202
|
+
* If no valid selection or index is found, returns empty arrays.
|
|
203
|
+
*/
|
|
204
|
+
declare function getRowOrColumnCells(editor: Editor | null, index?: number, orientation?: Orientation, tablePos?: number): {
|
|
205
|
+
cells: CellInfo[];
|
|
206
|
+
mergedCells: CellInfo[];
|
|
207
|
+
index?: number;
|
|
208
|
+
orientation?: Orientation;
|
|
209
|
+
tablePos?: number;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* After moving a row or column, update the selection to the moved item.
|
|
213
|
+
*
|
|
214
|
+
* This ensures that after a move operation, the selection remains on the
|
|
215
|
+
* moved row or column, providing better user feedback.
|
|
216
|
+
*
|
|
217
|
+
* @param editor - The editor instance
|
|
218
|
+
* @param orientation - "row" or "column" indicating what was moved
|
|
219
|
+
* @param newIndex - The new index of the moved row/column
|
|
220
|
+
* @param tablePos - Optional position of the table in the document
|
|
221
|
+
*/
|
|
222
|
+
declare function updateSelectionAfterAction(editor: Editor, orientation: Orientation, newIndex: number, tablePos?: number): void;
|
|
223
|
+
/**
|
|
224
|
+
* Determines whether a table cell is effectively empty.
|
|
225
|
+
*
|
|
226
|
+
* A cell is considered empty when:
|
|
227
|
+
* - it has no children, or
|
|
228
|
+
* - it contains only whitespace text, or
|
|
229
|
+
* - it contains no text and no non-text leaf nodes (images, embeds, etc.)
|
|
230
|
+
*
|
|
231
|
+
* Early-outs as soon as any meaningful content is found.
|
|
232
|
+
*
|
|
233
|
+
* @param cellNode - The table cell node to check
|
|
234
|
+
* @returns true if the cell is empty; false otherwise
|
|
235
|
+
*/
|
|
236
|
+
declare function isCellEmpty(cellNode: Node): boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Returns a command that sets the given attributes to the given values,
|
|
239
|
+
* and is only available when the currently selected cell doesn't
|
|
240
|
+
* already have those attributes set to those values.
|
|
241
|
+
*
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
declare function setCellAttr(attrs: Record<string, unknown>): Command;
|
|
245
|
+
declare function setCellAttr(name: string, value: unknown): Command;
|
|
246
|
+
/**
|
|
247
|
+
* Cells overlap a rectangle if any of the cells in the rectangle are merged
|
|
248
|
+
* with cells outside the rectangle.
|
|
249
|
+
*/
|
|
250
|
+
declare function cellsOverlapRectangle({ width, height, map }: TableMap, rect: Rect): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Compares two DOMRect objects for equality.
|
|
253
|
+
*
|
|
254
|
+
* Treats `undefined` as a valid state, where two `undefined` rects are equal,
|
|
255
|
+
* and `undefined` is not equal to any defined rect.
|
|
256
|
+
*
|
|
257
|
+
* @param a - The first DOMRect or undefined
|
|
258
|
+
* @param b - The second DOMRect or undefined
|
|
259
|
+
* @returns true if both rects are equal or both are undefined; false otherwise
|
|
260
|
+
*/
|
|
261
|
+
declare function rectEq(a?: DOMRect | null, b?: DOMRect | null): boolean;
|
|
262
|
+
|
|
263
|
+
export { type CellInfo, type DispatchSelectionOptions, type DomCellAroundResult, type Orientation, type SelectionReturnMode, type StateSelectionOptions, type TableInfo, type TransactionSelectionOptions, cellsOverlapRectangle, domCellAround, getCellIndicesFromDOM, getColumnCells, getIndexCoordinates, getRowCells, getRowOrColumnCells, getTable, getTableFromDOM, getTableSelectionType, isCellEmpty, isCellMerged, isTableNode, rectEq, selectCellsByCoords, setCellAttr, updateSelectionAfterAction };
|