@kopexa/extension-table 17.0.45 → 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-SNJF4UW6.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/{table/icons.mjs → extensions/table-cell.mjs} +3 -3
- 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 +18 -5
- package/dist/index.d.ts +18 -5
- package/dist/index.js +4939 -910
- package/dist/index.mjs +43 -18
- package/dist/lib/constants.d.mts +4 -0
- package/dist/lib/constants.d.ts +4 -0
- package/dist/{table-row.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 +16 -12
- package/dist/chunk-6NY5XWR7.mjs +0 -11
- package/dist/chunk-74O2ORPO.mjs +0 -81
- package/dist/chunk-7NEAULTF.mjs +0 -58
- package/dist/chunk-ARSGMUXM.mjs +0 -116
- package/dist/chunk-BAQU2YT5.mjs +0 -41
- package/dist/chunk-DF6ZMJLL.mjs +0 -40
- package/dist/chunk-FKOIW52J.mjs +0 -11
- package/dist/chunk-GMNNSVR3.mjs +0 -540
- package/dist/chunk-IMRHHVEF.mjs +0 -113
- package/dist/chunk-NTWXQSW6.mjs +0 -13
- package/dist/chunk-OPDSKEZR.mjs +0 -93
- package/dist/chunk-YSUOVRY4.mjs +0 -1
- package/dist/kit.js +0 -1024
- package/dist/kit.mjs +0 -19
- package/dist/table/icons.d.mts +0 -13
- package/dist/table/icons.d.ts +0 -13
- package/dist/table/icons.js +0 -81
- package/dist/table/index.d.mts +0 -3
- package/dist/table/index.d.ts +0 -3
- package/dist/table/index.js +0 -809
- package/dist/table/index.mjs +0 -15
- package/dist/table/table-controls.d.mts +0 -15
- package/dist/table/table-controls.d.ts +0 -15
- package/dist/table/table-controls.js +0 -131
- package/dist/table/table-controls.mjs +0 -8
- package/dist/table/table-view.d.mts +0 -43
- package/dist/table/table-view.d.ts +0 -43
- package/dist/table/table-view.js +0 -610
- package/dist/table/table-view.mjs +0 -12
- package/dist/table/table.js +0 -807
- package/dist/table/table.mjs +0 -14
- package/dist/table/utilities/col-style.d.mts +0 -3
- package/dist/table/utilities/col-style.d.ts +0 -3
- package/dist/table/utilities/col-style.js +0 -36
- package/dist/table/utilities/col-style.mjs +0 -8
- package/dist/table/utilities/delete-table-when-all-cells-selected.d.mts +0 -5
- package/dist/table/utilities/delete-table-when-all-cells-selected.d.ts +0 -5
- package/dist/table/utilities/delete-table-when-all-cells-selected.js +0 -66
- package/dist/table/utilities/delete-table-when-all-cells-selected.mjs +0 -40
- package/dist/table/utilities/get-table-node-types.d.mts +0 -7
- package/dist/table/utilities/get-table-node-types.d.ts +0 -7
- package/dist/table/utilities/get-table-node-types.js +0 -44
- package/dist/table/utilities/get-table-node-types.mjs +0 -21
- package/dist/table/utilities/insert-line-above-table-action.d.mts +0 -5
- package/dist/table/utilities/insert-line-above-table-action.d.ts +0 -5
- package/dist/table/utilities/insert-line-above-table-action.js +0 -64
- package/dist/table/utilities/insert-line-above-table-action.mjs +0 -8
- package/dist/table/utilities/insert-line-below-table-action.d.mts +0 -5
- package/dist/table/utilities/insert-line-below-table-action.d.ts +0 -5
- package/dist/table/utilities/insert-line-below-table-action.js +0 -63
- package/dist/table/utilities/insert-line-below-table-action.mjs +0 -8
- package/dist/table/utilities/is-cell-selection.d.mts +0 -5
- package/dist/table/utilities/is-cell-selection.d.ts +0 -5
- package/dist/table/utilities/is-cell-selection.js +0 -34
- package/dist/table/utilities/is-cell-selection.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 -139
- 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 -104
- 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/chunk-GMNNSVR3.mjs
DELETED
|
@@ -1,540 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
getColStyleDeclaration
|
|
4
|
-
} from "./chunk-NTWXQSW6.mjs";
|
|
5
|
-
import {
|
|
6
|
-
icons
|
|
7
|
-
} from "./chunk-7NEAULTF.mjs";
|
|
8
|
-
import {
|
|
9
|
-
__publicField
|
|
10
|
-
} from "./chunk-WKV76XOR.mjs";
|
|
11
|
-
|
|
12
|
-
// src/table/table-view.tsx
|
|
13
|
-
import {
|
|
14
|
-
autoUpdate,
|
|
15
|
-
computePosition,
|
|
16
|
-
flip,
|
|
17
|
-
offset,
|
|
18
|
-
shift
|
|
19
|
-
} from "@floating-ui/dom";
|
|
20
|
-
import {
|
|
21
|
-
CellSelection,
|
|
22
|
-
TableMap,
|
|
23
|
-
updateColumnsOnResize
|
|
24
|
-
} from "@tiptap/pm/tables";
|
|
25
|
-
import { h } from "jsx-dom-cjs";
|
|
26
|
-
var Popover = class {
|
|
27
|
-
constructor(content, opts) {
|
|
28
|
-
__publicField(this, "reference");
|
|
29
|
-
__publicField(this, "floating");
|
|
30
|
-
__publicField(this, "cleanupAutoUpdate", null);
|
|
31
|
-
__publicField(this, "onDocClick", (e) => {
|
|
32
|
-
if (!this.floating.contains(e.target) && !this.reference.contains(e.target)) {
|
|
33
|
-
this.hide();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
__publicField(this, "onEsc", (e) => {
|
|
37
|
-
if (e.key === "Escape") this.hide();
|
|
38
|
-
});
|
|
39
|
-
__publicField(this, "_placement");
|
|
40
|
-
__publicField(this, "_offsetPx");
|
|
41
|
-
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: backwards. will be used later
|
|
42
|
-
__publicField(this, "_interactive");
|
|
43
|
-
var _a, _b, _c, _d;
|
|
44
|
-
this.reference = opts.reference;
|
|
45
|
-
this.floating = document.createElement("div");
|
|
46
|
-
this.floating.setAttribute("role", "dialog");
|
|
47
|
-
this.floating.setAttribute("aria-modal", "false");
|
|
48
|
-
this.floating.style.position = "fixed";
|
|
49
|
-
this.floating.style.zIndex = "9999";
|
|
50
|
-
this.floating.style.display = "none";
|
|
51
|
-
this.floating.className = "rounded-md border bg-background px-2 py-2.5 text-xs shadow-sm min-w-[12rem] whitespace-nowrap";
|
|
52
|
-
this.floating.appendChild(content);
|
|
53
|
-
const host = (_a = opts.container) != null ? _a : document.body;
|
|
54
|
-
host.appendChild(this.floating);
|
|
55
|
-
this._placement = (_b = opts.placement) != null ? _b : "right";
|
|
56
|
-
this._offsetPx = (_c = opts.offsetPx) != null ? _c : 6;
|
|
57
|
-
this._interactive = (_d = opts.interactive) != null ? _d : true;
|
|
58
|
-
}
|
|
59
|
-
async _updatePosition() {
|
|
60
|
-
const { x, y } = await computePosition(this.reference, this.floating, {
|
|
61
|
-
placement: this._placement,
|
|
62
|
-
middleware: [offset(this._offsetPx), flip(), shift({ padding: 8 })]
|
|
63
|
-
});
|
|
64
|
-
Object.assign(this.floating.style, { left: `${x}px`, top: `${y}px` });
|
|
65
|
-
}
|
|
66
|
-
show() {
|
|
67
|
-
if (this.floating.style.display !== "none") return;
|
|
68
|
-
this.floating.style.display = "block";
|
|
69
|
-
this.cleanupAutoUpdate = autoUpdate(
|
|
70
|
-
this.reference,
|
|
71
|
-
this.floating,
|
|
72
|
-
() => this._updatePosition()
|
|
73
|
-
);
|
|
74
|
-
document.addEventListener("keydown", this.onEsc, { passive: true });
|
|
75
|
-
document.addEventListener("mousedown", this.onDocClick, { capture: true });
|
|
76
|
-
requestAnimationFrame(() => this._updatePosition());
|
|
77
|
-
}
|
|
78
|
-
hide() {
|
|
79
|
-
var _a;
|
|
80
|
-
if (this.floating.style.display === "none") return;
|
|
81
|
-
this.floating.style.display = "none";
|
|
82
|
-
(_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
|
|
83
|
-
this.cleanupAutoUpdate = null;
|
|
84
|
-
document.removeEventListener("keydown", this.onEsc);
|
|
85
|
-
document.removeEventListener("mousedown", this.onDocClick, {
|
|
86
|
-
capture: true
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
toggle() {
|
|
90
|
-
if (this.floating.style.display === "none") this.show();
|
|
91
|
-
else this.hide();
|
|
92
|
-
}
|
|
93
|
-
destroy() {
|
|
94
|
-
this.hide();
|
|
95
|
-
this.floating.remove();
|
|
96
|
-
}
|
|
97
|
-
get el() {
|
|
98
|
-
return this.floating;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
|
|
102
|
-
var _a;
|
|
103
|
-
let totalWidth = 0;
|
|
104
|
-
let fixedWidth = true;
|
|
105
|
-
let nextDOM = colgroup.firstChild;
|
|
106
|
-
const row = node.firstChild;
|
|
107
|
-
if (row !== null) {
|
|
108
|
-
for (let i = 0, col = 0; i < row.childCount; i += 1) {
|
|
109
|
-
const { colspan, colwidth } = row.child(i).attrs;
|
|
110
|
-
for (let j = 0; j < colspan; j += 1, col += 1) {
|
|
111
|
-
const hasWidth = overrideCol === col ? overrideValue : colwidth == null ? void 0 : colwidth[j];
|
|
112
|
-
const cssWidth = hasWidth ? `${hasWidth}px` : "";
|
|
113
|
-
totalWidth += hasWidth || cellMinWidth;
|
|
114
|
-
if (!hasWidth) fixedWidth = false;
|
|
115
|
-
if (!nextDOM) {
|
|
116
|
-
const colElement = document.createElement("col");
|
|
117
|
-
const [key, val] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
118
|
-
colElement.style.setProperty(key, val);
|
|
119
|
-
colgroup.appendChild(colElement);
|
|
120
|
-
} else {
|
|
121
|
-
const colEl = nextDOM;
|
|
122
|
-
if (colEl.style.width !== cssWidth) {
|
|
123
|
-
const [key, val] = getColStyleDeclaration(cellMinWidth, hasWidth);
|
|
124
|
-
colEl.style.setProperty(key, val);
|
|
125
|
-
}
|
|
126
|
-
nextDOM = nextDOM.nextSibling;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
while (nextDOM) {
|
|
132
|
-
const after = nextDOM.nextSibling;
|
|
133
|
-
(_a = nextDOM.parentNode) == null ? void 0 : _a.removeChild(nextDOM);
|
|
134
|
-
nextDOM = after;
|
|
135
|
-
}
|
|
136
|
-
if (fixedWidth) {
|
|
137
|
-
table.style.width = `${totalWidth}px`;
|
|
138
|
-
table.style.minWidth = "";
|
|
139
|
-
} else {
|
|
140
|
-
table.style.width = "";
|
|
141
|
-
table.style.minWidth = `${totalWidth}px`;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function setCellsBackgroundColor(editor, color) {
|
|
145
|
-
return editor.chain().focus().updateAttributes("tableCell", {
|
|
146
|
-
background: color.backgroundColor,
|
|
147
|
-
textColor: color.textColor
|
|
148
|
-
}).run();
|
|
149
|
-
}
|
|
150
|
-
function setTableRowBackgroundColor(editor, color) {
|
|
151
|
-
const { state, dispatch } = editor.view;
|
|
152
|
-
const { selection } = state;
|
|
153
|
-
if (!(selection instanceof CellSelection)) return false;
|
|
154
|
-
const hoveredCell = selection.$headCell || selection.$anchorCell;
|
|
155
|
-
let rowDepth = hoveredCell.depth;
|
|
156
|
-
while (rowDepth > 0 && hoveredCell.node(rowDepth).type.name !== "tableRow") {
|
|
157
|
-
rowDepth--;
|
|
158
|
-
}
|
|
159
|
-
if (hoveredCell.node(rowDepth).type.name !== "tableRow") return false;
|
|
160
|
-
const rowStartPos = hoveredCell.start(rowDepth);
|
|
161
|
-
const tr = state.tr.setNodeMarkup(rowStartPos - 1, null, {
|
|
162
|
-
...hoveredCell.node(rowDepth).attrs,
|
|
163
|
-
background: color.backgroundColor,
|
|
164
|
-
textColor: color.textColor
|
|
165
|
-
});
|
|
166
|
-
dispatch(tr);
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
var columnsToolboxItems = [
|
|
170
|
-
{
|
|
171
|
-
label: "Toggle column header",
|
|
172
|
-
icon: icons.toggleColumnHeader,
|
|
173
|
-
action: ({ editor }) => editor.chain().focus().toggleHeaderColumn().run()
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
label: "Add column before",
|
|
177
|
-
icon: icons.insertLeftTableIcon,
|
|
178
|
-
action: ({ editor }) => editor.chain().focus().addColumnBefore().run()
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
label: "Add column after",
|
|
182
|
-
icon: icons.insertRightTableIcon,
|
|
183
|
-
action: ({ editor }) => editor.chain().focus().addColumnAfter().run()
|
|
184
|
-
},
|
|
185
|
-
{ label: "Pick color", icon: "", action: () => {
|
|
186
|
-
} },
|
|
187
|
-
{
|
|
188
|
-
label: "Delete column",
|
|
189
|
-
icon: icons.deleteColumn,
|
|
190
|
-
action: ({ editor }) => editor.chain().focus().deleteColumn().run()
|
|
191
|
-
}
|
|
192
|
-
];
|
|
193
|
-
var rowsToolboxItems = [
|
|
194
|
-
{
|
|
195
|
-
label: "Toggle row header",
|
|
196
|
-
icon: icons.toggleRowHeader,
|
|
197
|
-
action: ({ editor }) => editor.chain().focus().toggleHeaderRow().run()
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
label: "Add row above",
|
|
201
|
-
icon: icons.insertTopTableIcon,
|
|
202
|
-
action: ({ editor }) => editor.chain().focus().addRowBefore().run()
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
label: "Add row below",
|
|
206
|
-
icon: icons.insertBottomTableIcon,
|
|
207
|
-
action: ({ editor }) => editor.chain().focus().addRowAfter().run()
|
|
208
|
-
},
|
|
209
|
-
{ label: "Pick color", icon: "", action: () => {
|
|
210
|
-
} },
|
|
211
|
-
{
|
|
212
|
-
label: "Delete row",
|
|
213
|
-
icon: icons.deleteRow,
|
|
214
|
-
action: ({ editor }) => editor.chain().focus().deleteRow().run()
|
|
215
|
-
}
|
|
216
|
-
];
|
|
217
|
-
function buildToolboxContent({
|
|
218
|
-
items,
|
|
219
|
-
onClickItem,
|
|
220
|
-
onSelectColor,
|
|
221
|
-
colors
|
|
222
|
-
}) {
|
|
223
|
-
return h(
|
|
224
|
-
"div",
|
|
225
|
-
{ className: "space-y-2" },
|
|
226
|
-
items.map((item) => {
|
|
227
|
-
if (item.label === "Pick color") {
|
|
228
|
-
return h("div", { className: "flex flex-col" }, [
|
|
229
|
-
h("hr", { className: "!my-2 border" }),
|
|
230
|
-
h("div", { className: "text-foreground text-sm" }, item.label),
|
|
231
|
-
h(
|
|
232
|
-
"div",
|
|
233
|
-
{ className: "grid grid-cols-6 gap-x-1 gap-y-2.5 mt-2" },
|
|
234
|
-
Object.entries(colors).map(
|
|
235
|
-
([_, colorValue]) => {
|
|
236
|
-
var _a;
|
|
237
|
-
return h("button", {
|
|
238
|
-
// @ts-expect-error JSX
|
|
239
|
-
type: "button",
|
|
240
|
-
className: "grid place-items-center size-6 rounded outline-none ring-offset-2 focus-visible:ring",
|
|
241
|
-
style: `background-color:${colorValue.backgroundColor};color:${colorValue.textColor || "inherit"};`,
|
|
242
|
-
innerHTML: (_a = colorValue.icon) != null ? _a : `<span class="text-md" style="color:${colorValue.textColor || "inherit"}">A</span>`,
|
|
243
|
-
onClick: (e) => {
|
|
244
|
-
e.stopPropagation();
|
|
245
|
-
onSelectColor(colorValue);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
)
|
|
250
|
-
),
|
|
251
|
-
h("hr", { className: "!my-2 border" })
|
|
252
|
-
]);
|
|
253
|
-
}
|
|
254
|
-
return h(
|
|
255
|
-
"button",
|
|
256
|
-
{
|
|
257
|
-
// @ts-expect-error JSX
|
|
258
|
-
type: "button",
|
|
259
|
-
className: "w-full flex items-center gap-2 px-1 py-1.5 bg-background hover:bg-muted text-sm text-foreground rounded",
|
|
260
|
-
onClick: (e) => {
|
|
261
|
-
e.stopPropagation();
|
|
262
|
-
onClickItem(item);
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
[
|
|
266
|
-
h("span", { className: "h-3 w-3 shrink-0", innerHTML: item.icon }),
|
|
267
|
-
h("div", { className: "label" }, item.label)
|
|
268
|
-
]
|
|
269
|
-
);
|
|
270
|
-
})
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
function createToolbox({
|
|
274
|
-
triggerButton,
|
|
275
|
-
items,
|
|
276
|
-
onSelectColor,
|
|
277
|
-
onClickItem,
|
|
278
|
-
colors,
|
|
279
|
-
appendTo
|
|
280
|
-
}) {
|
|
281
|
-
if (!triggerButton) {
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
const content = buildToolboxContent({
|
|
285
|
-
items,
|
|
286
|
-
onClickItem,
|
|
287
|
-
onSelectColor,
|
|
288
|
-
colors
|
|
289
|
-
});
|
|
290
|
-
const pop = new Popover(content, {
|
|
291
|
-
reference: triggerButton,
|
|
292
|
-
container: appendTo != null ? appendTo : void 0,
|
|
293
|
-
placement: "right",
|
|
294
|
-
offsetPx: 6,
|
|
295
|
-
interactive: true
|
|
296
|
-
});
|
|
297
|
-
const onTrigger = (e) => {
|
|
298
|
-
e.stopPropagation();
|
|
299
|
-
pop.toggle();
|
|
300
|
-
};
|
|
301
|
-
triggerButton.addEventListener("click", onTrigger);
|
|
302
|
-
return {
|
|
303
|
-
show: () => pop.show(),
|
|
304
|
-
hide: () => pop.hide(),
|
|
305
|
-
destroy: () => {
|
|
306
|
-
pop.destroy();
|
|
307
|
-
triggerButton.removeEventListener("click", onTrigger);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
var TableView = class {
|
|
312
|
-
constructor(node, cellMinWidth, decorations, editor, getPos) {
|
|
313
|
-
__publicField(this, "node");
|
|
314
|
-
__publicField(this, "cellMinWidth");
|
|
315
|
-
__publicField(this, "decorations");
|
|
316
|
-
__publicField(this, "editor");
|
|
317
|
-
__publicField(this, "getPos");
|
|
318
|
-
__publicField(this, "hoveredCell", null);
|
|
319
|
-
__publicField(this, "map");
|
|
320
|
-
__publicField(this, "root");
|
|
321
|
-
__publicField(this, "table");
|
|
322
|
-
__publicField(this, "colgroup");
|
|
323
|
-
__publicField(this, "tbody");
|
|
324
|
-
__publicField(this, "rowsControl");
|
|
325
|
-
__publicField(this, "columnsControl");
|
|
326
|
-
__publicField(this, "columnsToolbox");
|
|
327
|
-
__publicField(this, "rowsToolbox");
|
|
328
|
-
__publicField(this, "controls");
|
|
329
|
-
var _a, _b, _c, _d;
|
|
330
|
-
this.node = node;
|
|
331
|
-
this.cellMinWidth = cellMinWidth;
|
|
332
|
-
this.decorations = decorations.slice();
|
|
333
|
-
this.editor = editor;
|
|
334
|
-
this.getPos = getPos;
|
|
335
|
-
this.hoveredCell = null;
|
|
336
|
-
this.map = TableMap.get(node);
|
|
337
|
-
if (editor.isEditable) {
|
|
338
|
-
this.rowsControl = h(
|
|
339
|
-
"div",
|
|
340
|
-
{ className: "rows-control" },
|
|
341
|
-
h("button", {
|
|
342
|
-
// @ts-expect-error JSX
|
|
343
|
-
type: "button",
|
|
344
|
-
className: "rows-control-div",
|
|
345
|
-
onClick: () => this.selectRow(),
|
|
346
|
-
"aria-label": "Row actions"
|
|
347
|
-
})
|
|
348
|
-
);
|
|
349
|
-
this.columnsControl = h(
|
|
350
|
-
"div",
|
|
351
|
-
{ className: "columns-control" },
|
|
352
|
-
h("button", {
|
|
353
|
-
// @ts-expect-error JSX
|
|
354
|
-
type: "button",
|
|
355
|
-
className: "columns-control-div",
|
|
356
|
-
onClick: () => this.selectColumn(),
|
|
357
|
-
"aria-label": "Column actions"
|
|
358
|
-
})
|
|
359
|
-
);
|
|
360
|
-
this.controls = h(
|
|
361
|
-
"div",
|
|
362
|
-
{ className: "table-controls", contentEditable: "false" },
|
|
363
|
-
this.rowsControl,
|
|
364
|
-
this.columnsControl
|
|
365
|
-
);
|
|
366
|
-
const palette = {
|
|
367
|
-
Blue: { backgroundColor: "#D9E4FF", textColor: "#171717" },
|
|
368
|
-
Orange: { backgroundColor: "#FFEDD5", textColor: "#171717" },
|
|
369
|
-
Grey: { backgroundColor: "#F1F1F1", textColor: "#171717" },
|
|
370
|
-
Yellow: { backgroundColor: "#FEF3C7", textColor: "#171717" },
|
|
371
|
-
Green: { backgroundColor: "#DCFCE7", textColor: "#171717" },
|
|
372
|
-
Red: { backgroundColor: "#FFDDDD", textColor: "#171717" },
|
|
373
|
-
Pink: { backgroundColor: "#FFE8FA", textColor: "#171717" },
|
|
374
|
-
Purple: { backgroundColor: "#E8DAFB", textColor: "#171717" },
|
|
375
|
-
None: {
|
|
376
|
-
backgroundColor: "transparent",
|
|
377
|
-
textColor: "inherit",
|
|
378
|
-
icon: `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="gray" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-ban"><circle cx="12" cy="12" r="10"/><path d="m4.9 4.9 14.2 14.2"/></svg>`
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
this.columnsToolbox = createToolbox({
|
|
382
|
-
triggerButton: (_a = this.columnsControl) == null ? void 0 : _a.querySelector(
|
|
383
|
-
".columns-control-div"
|
|
384
|
-
),
|
|
385
|
-
items: columnsToolboxItems,
|
|
386
|
-
colors: palette,
|
|
387
|
-
appendTo: (_b = this.controls) != null ? _b : null,
|
|
388
|
-
onSelectColor: (color) => setCellsBackgroundColor(this.editor, color),
|
|
389
|
-
onClickItem: (item) => {
|
|
390
|
-
var _a2, _b2;
|
|
391
|
-
item.action({
|
|
392
|
-
editor: this.editor,
|
|
393
|
-
triggerButton: (_a2 = this.columnsControl) == null ? void 0 : _a2.firstElementChild,
|
|
394
|
-
controlsContainer: this.controls
|
|
395
|
-
});
|
|
396
|
-
(_b2 = this.columnsToolbox) == null ? void 0 : _b2.hide();
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
this.rowsToolbox = createToolbox({
|
|
400
|
-
triggerButton: (_c = this.rowsControl) == null ? void 0 : _c.querySelector(
|
|
401
|
-
".rows-control-div"
|
|
402
|
-
),
|
|
403
|
-
items: rowsToolboxItems,
|
|
404
|
-
colors: palette,
|
|
405
|
-
appendTo: (_d = this.controls) != null ? _d : null,
|
|
406
|
-
onSelectColor: (color) => setTableRowBackgroundColor(editor, color),
|
|
407
|
-
onClickItem: (item) => {
|
|
408
|
-
var _a2, _b2;
|
|
409
|
-
item.action({
|
|
410
|
-
editor: this.editor,
|
|
411
|
-
triggerButton: (_a2 = this.rowsControl) == null ? void 0 : _a2.firstElementChild,
|
|
412
|
-
controlsContainer: this.controls
|
|
413
|
-
});
|
|
414
|
-
(_b2 = this.rowsToolbox) == null ? void 0 : _b2.hide();
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
this.colgroup = h(
|
|
419
|
-
"colgroup",
|
|
420
|
-
null,
|
|
421
|
-
Array.from({ length: this.map.width }, () => 1).map(() => h("col"))
|
|
422
|
-
);
|
|
423
|
-
this.tbody = h("tbody");
|
|
424
|
-
this.table = h(
|
|
425
|
-
"table",
|
|
426
|
-
null,
|
|
427
|
-
this.colgroup,
|
|
428
|
-
this.tbody
|
|
429
|
-
);
|
|
430
|
-
this.root = h(
|
|
431
|
-
"div",
|
|
432
|
-
{
|
|
433
|
-
className: "table-wrapper horizontal-scrollbar scrollbar-md controls--disabled"
|
|
434
|
-
},
|
|
435
|
-
this.controls,
|
|
436
|
-
this.table
|
|
437
|
-
);
|
|
438
|
-
this.render();
|
|
439
|
-
}
|
|
440
|
-
get dom() {
|
|
441
|
-
return this.root;
|
|
442
|
-
}
|
|
443
|
-
get contentDOM() {
|
|
444
|
-
return this.tbody;
|
|
445
|
-
}
|
|
446
|
-
update(node, decorations) {
|
|
447
|
-
if (node.type !== this.node.type) return false;
|
|
448
|
-
this.node = node;
|
|
449
|
-
this.decorations = [...decorations];
|
|
450
|
-
this.map = TableMap.get(this.node);
|
|
451
|
-
if (this.editor.isEditable) this.updateControls();
|
|
452
|
-
this.render();
|
|
453
|
-
return true;
|
|
454
|
-
}
|
|
455
|
-
render() {
|
|
456
|
-
if (this.colgroup.children.length !== this.map.width) {
|
|
457
|
-
const cols = Array.from({ length: this.map.width }, () => 1).map(
|
|
458
|
-
() => h("col")
|
|
459
|
-
);
|
|
460
|
-
this.colgroup.replaceChildren(...cols);
|
|
461
|
-
}
|
|
462
|
-
updateColumnsOnResize(
|
|
463
|
-
this.node,
|
|
464
|
-
this.colgroup,
|
|
465
|
-
this.table,
|
|
466
|
-
this.cellMinWidth
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
ignoreMutation() {
|
|
470
|
-
return true;
|
|
471
|
-
}
|
|
472
|
-
updateControls() {
|
|
473
|
-
var _a;
|
|
474
|
-
const { hoveredTable: table, hoveredCell: cell } = Object.values(
|
|
475
|
-
this.decorations
|
|
476
|
-
).reduce(
|
|
477
|
-
(acc, curr) => {
|
|
478
|
-
if (curr.spec.hoveredCell !== void 0)
|
|
479
|
-
acc.hoveredCell = curr.spec.hoveredCell;
|
|
480
|
-
if (curr.spec.hoveredTable !== void 0)
|
|
481
|
-
acc.hoveredTable = curr.spec.hoveredTable;
|
|
482
|
-
return acc;
|
|
483
|
-
},
|
|
484
|
-
{}
|
|
485
|
-
);
|
|
486
|
-
if (table === void 0 || cell === void 0) {
|
|
487
|
-
this.root.classList.add("controls--disabled");
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
this.root.classList.remove("controls--disabled");
|
|
491
|
-
this.hoveredCell = cell;
|
|
492
|
-
const cellDom = this.editor.view.nodeDOM(cell.pos);
|
|
493
|
-
if (!this.table || !cellDom) return;
|
|
494
|
-
const tableRect = this.table.getBoundingClientRect();
|
|
495
|
-
const cellRect = cellDom.getBoundingClientRect();
|
|
496
|
-
if (this.columnsControl) {
|
|
497
|
-
this.columnsControl.style.left = `${cellRect.left - tableRect.left - (((_a = this.table.parentElement) == null ? void 0 : _a.scrollLeft) || 0)}px`;
|
|
498
|
-
this.columnsControl.style.width = `${cellRect.width}px`;
|
|
499
|
-
}
|
|
500
|
-
if (this.rowsControl) {
|
|
501
|
-
this.rowsControl.style.top = `${cellRect.top - tableRect.top}px`;
|
|
502
|
-
this.rowsControl.style.height = `${cellRect.height}px`;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
selectColumn() {
|
|
506
|
-
if (!this.hoveredCell) return;
|
|
507
|
-
const colIndex = this.map.colCount(
|
|
508
|
-
this.hoveredCell.pos - (this.getPos() + 1)
|
|
509
|
-
);
|
|
510
|
-
const anchorCellPos = this.hoveredCell.pos;
|
|
511
|
-
const headCellPos = this.map.map[colIndex + this.map.width * (this.map.height - 1)] + (this.getPos() + 1);
|
|
512
|
-
const cellSelection = CellSelection.create(
|
|
513
|
-
this.editor.view.state.doc,
|
|
514
|
-
anchorCellPos,
|
|
515
|
-
headCellPos
|
|
516
|
-
);
|
|
517
|
-
this.editor.view.dispatch(this.editor.state.tr.setSelection(cellSelection));
|
|
518
|
-
}
|
|
519
|
-
selectRow() {
|
|
520
|
-
if (!this.hoveredCell) return;
|
|
521
|
-
const anchorCellPos = this.hoveredCell.pos;
|
|
522
|
-
const anchorCellIndex = this.map.map.indexOf(
|
|
523
|
-
anchorCellPos - (this.getPos() + 1)
|
|
524
|
-
);
|
|
525
|
-
const headCellPos = this.map.map[anchorCellIndex + (this.map.width - 1)] + (this.getPos() + 1);
|
|
526
|
-
const cellSelection = CellSelection.create(
|
|
527
|
-
this.editor.state.doc,
|
|
528
|
-
anchorCellPos,
|
|
529
|
-
headCellPos
|
|
530
|
-
);
|
|
531
|
-
this.editor.view.dispatch(
|
|
532
|
-
this.editor.view.state.tr.setSelection(cellSelection)
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
export {
|
|
538
|
-
updateColumns,
|
|
539
|
-
TableView
|
|
540
|
-
};
|
package/dist/chunk-IMRHHVEF.mjs
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
__publicField
|
|
4
|
-
} from "./chunk-WKV76XOR.mjs";
|
|
5
|
-
|
|
6
|
-
// src/table/table-controls.ts
|
|
7
|
-
import { findParentNode } from "@tiptap/core";
|
|
8
|
-
import {
|
|
9
|
-
Plugin,
|
|
10
|
-
PluginKey,
|
|
11
|
-
TextSelection
|
|
12
|
-
} from "@tiptap/pm/state";
|
|
13
|
-
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
14
|
-
function tableControls() {
|
|
15
|
-
const key = new PluginKey("tableControls");
|
|
16
|
-
return new Plugin({
|
|
17
|
-
key,
|
|
18
|
-
state: {
|
|
19
|
-
init() {
|
|
20
|
-
return new TableControlsState(key);
|
|
21
|
-
},
|
|
22
|
-
apply(tr, prev) {
|
|
23
|
-
return prev.apply(tr);
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
props: {
|
|
27
|
-
handleDOMEvents: {
|
|
28
|
-
mousemove: (view, event) => {
|
|
29
|
-
var _a;
|
|
30
|
-
const pluginState = key.getState(view.state);
|
|
31
|
-
if (!event.target.closest(".table-wrapper") && pluginState.values.hoveredTable) {
|
|
32
|
-
return view.dispatch(
|
|
33
|
-
view.state.tr.setMeta(key, {
|
|
34
|
-
setHoveredTable: null,
|
|
35
|
-
setHoveredCell: null
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const pos = view.posAtCoords({
|
|
40
|
-
left: event.clientX,
|
|
41
|
-
top: event.clientY
|
|
42
|
-
});
|
|
43
|
-
if (!pos || pos.pos < 0 || pos.pos > view.state.doc.content.size)
|
|
44
|
-
return;
|
|
45
|
-
const table = findParentNode((node) => node.type.name === "table")(
|
|
46
|
-
TextSelection.create(view.state.doc, pos.pos)
|
|
47
|
-
);
|
|
48
|
-
const cell = findParentNode(
|
|
49
|
-
(node) => node.type.name === "tableCell" || node.type.name === "tableHeader"
|
|
50
|
-
)(TextSelection.create(view.state.doc, pos.pos));
|
|
51
|
-
if (!table || !cell) return;
|
|
52
|
-
if (((_a = pluginState.values.hoveredCell) == null ? void 0 : _a.pos) !== cell.pos) {
|
|
53
|
-
return view.dispatch(
|
|
54
|
-
view.state.tr.setMeta(key, {
|
|
55
|
-
setHoveredTable: table,
|
|
56
|
-
setHoveredCell: cell
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
decorations: (state) => {
|
|
63
|
-
const pluginState = key.getState(state);
|
|
64
|
-
if (!pluginState) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const { hoveredTable, hoveredCell } = pluginState.values;
|
|
68
|
-
const docSize = state.doc.content.size;
|
|
69
|
-
if (hoveredTable && hoveredCell && hoveredTable.pos < docSize && hoveredCell.pos < docSize) {
|
|
70
|
-
const decorations = [
|
|
71
|
-
Decoration.node(
|
|
72
|
-
hoveredTable.pos,
|
|
73
|
-
hoveredTable.pos + hoveredTable.node.nodeSize,
|
|
74
|
-
{},
|
|
75
|
-
{
|
|
76
|
-
hoveredTable,
|
|
77
|
-
hoveredCell
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
];
|
|
81
|
-
return DecorationSet.create(state.doc, decorations);
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
var TableControlsState = class {
|
|
89
|
-
constructor(key, props = {}) {
|
|
90
|
-
__publicField(this, "values");
|
|
91
|
-
__publicField(this, "key");
|
|
92
|
-
this.key = key;
|
|
93
|
-
this.values = {
|
|
94
|
-
hoveredTable: null,
|
|
95
|
-
hoveredCell: null,
|
|
96
|
-
...props
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
apply(tr) {
|
|
100
|
-
const actions = tr.getMeta(this.key);
|
|
101
|
-
if ((actions == null ? void 0 : actions.setHoveredTable) !== void 0) {
|
|
102
|
-
this.values.hoveredTable = actions.setHoveredTable;
|
|
103
|
-
}
|
|
104
|
-
if ((actions == null ? void 0 : actions.setHoveredCell) !== void 0) {
|
|
105
|
-
this.values.hoveredCell = actions.setHoveredCell;
|
|
106
|
-
}
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
tableControls
|
|
113
|
-
};
|
package/dist/chunk-NTWXQSW6.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// src/table/utilities/col-style.ts
|
|
4
|
-
function getColStyleDeclaration(minWidth, width) {
|
|
5
|
-
if (width) {
|
|
6
|
-
return ["width", `${Math.max(width, minWidth)}px`];
|
|
7
|
-
}
|
|
8
|
-
return ["min-width", `${minWidth}px`];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
getColStyleDeclaration
|
|
13
|
-
};
|