@kopexa/extension-table 17.0.44 → 17.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/{chunk-SNJF4UW6.mjs → chunk-2L3HZWWG.mjs} +4 -4
  2. package/dist/{chunk-BAQU2YT5.mjs → chunk-3XEOCAHB.mjs} +1 -1
  3. package/dist/{chunk-FKOIW52J.mjs → chunk-5W5ARI64.mjs} +1 -1
  4. package/dist/{chunk-IMRHHVEF.mjs → chunk-BTJ3DCGC.mjs} +2 -2
  5. package/dist/chunk-DR2GZJH6.mjs +70 -0
  6. package/dist/chunk-GHOJLOCF.mjs +247 -0
  7. package/dist/chunk-HWVA6DOK.mjs +20 -0
  8. package/dist/{chunk-DF6ZMJLL.mjs → chunk-KLUH6EZS.mjs} +1 -1
  9. package/dist/chunk-KNOMCS6F.mjs +57 -0
  10. package/dist/{chunk-OPDSKEZR.mjs → chunk-LPHCE6EI.mjs} +16 -17
  11. package/dist/chunk-POJFNXG7.mjs +44 -0
  12. package/dist/chunk-QHD3QTD2.mjs +61 -0
  13. package/dist/index.d.mts +2 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +456 -714
  16. package/dist/index.mjs +15 -12
  17. package/dist/kit.js +454 -714
  18. package/dist/kit.mjs +12 -12
  19. package/dist/table/index.d.mts +3 -0
  20. package/dist/table/index.d.ts +3 -0
  21. package/dist/table/index.js +411 -595
  22. package/dist/table/index.mjs +12 -9
  23. package/dist/table/{utilities → lib}/col-style.js +1 -1
  24. package/dist/{chunk-NTWXQSW6.mjs → table/lib/col-style.mjs} +2 -2
  25. package/dist/table/{utilities → lib}/delete-table-when-all-cells-selected.js +3 -3
  26. package/dist/table/{utilities → lib}/delete-table-when-all-cells-selected.mjs +2 -2
  27. package/dist/table/{utilities → lib}/get-table-node-types.js +1 -1
  28. package/dist/table/{utilities → lib}/get-table-node-types.mjs +1 -1
  29. package/dist/table/{icons.js → lib/icons.js} +1 -1
  30. package/dist/{chunk-7NEAULTF.mjs → table/lib/icons.mjs} +2 -2
  31. package/dist/table/{utilities → lib}/insert-line-above-table-action.js +1 -1
  32. package/dist/table/{utilities → lib}/insert-line-above-table-action.mjs +1 -1
  33. package/dist/table/{utilities → lib}/insert-line-below-table-action.js +1 -1
  34. package/dist/table/{utilities → lib}/insert-line-below-table-action.mjs +1 -1
  35. package/dist/table/{utilities → lib}/is-cell-selection.js +1 -1
  36. package/dist/table/{utilities → lib}/is-cell-selection.mjs +1 -1
  37. package/dist/table/{table-controls.js → lib/table-controls.js} +2 -2
  38. package/dist/table/lib/table-controls.mjs +8 -0
  39. package/dist/table/table.js +407 -593
  40. package/dist/table/table.mjs +7 -7
  41. package/dist/table/views/table-column-menu.d.mts +11 -0
  42. package/dist/table/views/table-column-menu.d.ts +11 -0
  43. package/dist/table/views/table-column-menu.js +84 -0
  44. package/dist/table/views/table-column-menu.mjs +8 -0
  45. package/dist/table/views/table-node-view.d.mts +25 -0
  46. package/dist/table/views/table-node-view.d.ts +25 -0
  47. package/dist/table/views/table-node-view.js +370 -0
  48. package/dist/table/views/table-node-view.mjs +10 -0
  49. package/dist/table/views/table-row-menu.d.mts +11 -0
  50. package/dist/table/views/table-row-menu.d.ts +11 -0
  51. package/dist/table/views/table-row-menu.js +80 -0
  52. package/dist/table/views/table-row-menu.mjs +8 -0
  53. package/dist/table-cell.js +18 -64
  54. package/dist/table-cell.mjs +1 -1
  55. package/dist/table-header.js +17 -54
  56. package/dist/table-header.mjs +1 -1
  57. package/dist/table-row.js +10 -1
  58. package/dist/table-row.mjs +1 -1
  59. package/package.json +10 -11
  60. package/dist/chunk-6NY5XWR7.mjs +0 -11
  61. package/dist/chunk-74O2ORPO.mjs +0 -81
  62. package/dist/chunk-ARSGMUXM.mjs +0 -116
  63. package/dist/chunk-GMNNSVR3.mjs +0 -540
  64. package/dist/table/icons.mjs +0 -8
  65. package/dist/table/table-controls.mjs +0 -8
  66. package/dist/table/table-view.d.mts +0 -43
  67. package/dist/table/table-view.d.ts +0 -43
  68. package/dist/table/table-view.js +0 -610
  69. package/dist/table/table-view.mjs +0 -12
  70. package/dist/table/utilities/col-style.mjs +0 -8
  71. /package/dist/{chunk-YSUOVRY4.mjs → chunk-RPPUD4R5.mjs} +0 -0
  72. /package/dist/table/{utilities → lib}/col-style.d.mts +0 -0
  73. /package/dist/table/{utilities → lib}/col-style.d.ts +0 -0
  74. /package/dist/table/{utilities → lib}/delete-table-when-all-cells-selected.d.mts +0 -0
  75. /package/dist/table/{utilities → lib}/delete-table-when-all-cells-selected.d.ts +0 -0
  76. /package/dist/table/{utilities → lib}/get-table-node-types.d.mts +0 -0
  77. /package/dist/table/{utilities → lib}/get-table-node-types.d.ts +0 -0
  78. /package/dist/table/{icons.d.mts → lib/icons.d.mts} +0 -0
  79. /package/dist/table/{icons.d.ts → lib/icons.d.ts} +0 -0
  80. /package/dist/table/{utilities → lib}/insert-line-above-table-action.d.mts +0 -0
  81. /package/dist/table/{utilities → lib}/insert-line-above-table-action.d.ts +0 -0
  82. /package/dist/table/{utilities → lib}/insert-line-below-table-action.d.mts +0 -0
  83. /package/dist/table/{utilities → lib}/insert-line-below-table-action.d.ts +0 -0
  84. /package/dist/table/{utilities → lib}/is-cell-selection.d.mts +0 -0
  85. /package/dist/table/{utilities → lib}/is-cell-selection.d.ts +0 -0
  86. /package/dist/table/{table-controls.d.mts → lib/table-controls.d.mts} +0 -0
  87. /package/dist/table/{table-controls.d.ts → lib/table-controls.d.ts} +0 -0
@@ -1,610 +0,0 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
-
23
- // src/table/table-view.tsx
24
- var table_view_exports = {};
25
- __export(table_view_exports, {
26
- TableView: () => TableView,
27
- updateColumns: () => updateColumns
28
- });
29
- module.exports = __toCommonJS(table_view_exports);
30
- var import_dom = require("@floating-ui/dom");
31
- var import_tables = require("@tiptap/pm/tables");
32
- var import_jsx_dom_cjs = require("jsx-dom-cjs");
33
-
34
- // src/table/icons.ts
35
- var icons = {
36
- colorPicker: `<svg xmlns="http://www.w3.org/2000/svg" length="24" viewBox="0 0 24 24" style="transform: ;msFilter:;"><path fill="rgb(var(--color-text-300))" d="M20 14c-.092.064-2 2.083-2 3.5 0 1.494.949 2.448 2 2.5.906.044 2-.891 2-2.5 0-1.5-1.908-3.436-2-3.5zM9.586 20c.378.378.88.586 1.414.586s1.036-.208 1.414-.586l7-7-.707-.707L11 4.586 8.707 2.293 7.293 3.707 9.586 6 4 11.586c-.378.378-.586.88-.586 1.414s.208 1.036.586 1.414L9.586 20zM11 7.414 16.586 13H5.414L11 7.414z"></path></svg>`,
37
- deleteColumn: `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>`,
38
- deleteRow: `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-trash-2"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/></svg>`,
39
- insertLeftTableIcon: `<svg
40
- xmlns="http://www.w3.org/2000/svg"
41
- length={12}
42
- viewBox="0 -960 960 960"
43
- >
44
- <path
45
- d="M224.617-140.001q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21H360q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H224.617Zm375.383 0q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21h135.383q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H600Zm147.691-607.69q0-4.616-3.846-8.463-3.846-3.846-8.462-3.846H600q-4.616 0-8.462 3.846-3.847 3.847-3.847 8.463v535.382q0 4.616 3.847 8.463Q595.384-200 600-200h135.383q4.616 0 8.462-3.846 3.846-3.847 3.846-8.463v-535.382ZM587.691-200h160-160Z"
46
- fill="rgb(var(--color-text-300))"
47
- />
48
- </svg>
49
- `,
50
- insertRightTableIcon: `<svg
51
- xmlns="http://www.w3.org/2000/svg"
52
- length={12}
53
- viewBox="0 -960 960 960"
54
- >
55
- <path
56
- d="M600-140.001q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21h135.383q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H600Zm-375.383 0q-30.307 0-51.307-21-21-21-21-51.308v-535.382q0-30.308 21-51.308t51.307-21H360q30.307 0 51.307 21 21 21 21 51.308v535.382q0 30.308-21 51.308t-51.307 21H224.617Zm-12.308-607.69v535.382q0 4.616 3.846 8.463 3.846 3.846 8.462 3.846H360q4.616 0 8.462-3.846 3.847-3.847 3.847-8.463v-535.382q0-4.616-3.847-8.463Q364.616-760 360-760H224.617q-4.616 0-8.462 3.846-3.846 3.847-3.846 8.463Zm160 547.691h-160 160Z"
57
- fill="rgb(var(--color-text-300))"
58
- />
59
- </svg>
60
- `,
61
- insertTopTableIcon: `<svg
62
- xmlns="http://www.w3.org/2000/svg"
63
- length={24}
64
- viewBox="0 -960 960 960"
65
- >
66
- <path
67
- d="M212.309-527.693q-30.308 0-51.308-21t-21-51.307v-135.383q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307V-600q0 30.307-21 51.307-21 21-51.308 21H212.309Zm0 375.383q-30.308 0-51.308-21t-21-51.307V-360q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307v135.383q0 30.307-21 51.307-21 21-51.308 21H212.309Zm0-59.999h535.382q4.616 0 8.463-3.846 3.846-3.846 3.846-8.462V-360q0-4.616-3.846-8.462-3.847-3.847-8.463-3.847H212.309q-4.616 0-8.463 3.847Q200-364.616 200-360v135.383q0 4.616 3.846 8.462 3.847 3.846 8.463 3.846Zm-12.309-160v160-160Z"
68
- fill="rgb(var(--color-text-300))"
69
- />
70
- </svg>
71
- `,
72
- toggleColumnHeader: `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-toggle-right"><rect width="20" height="12" x="2" y="6" rx="6" ry="6"/><circle cx="16" cy="12" r="2"/></svg>`,
73
- toggleRowHeader: `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-toggle-right"><rect width="20" height="12" x="2" y="6" rx="6" ry="6"/><circle cx="16" cy="12" r="2"/></svg>`,
74
- insertBottomTableIcon: `<svg
75
- xmlns="http://www.w3.org/2000/svg"
76
- length={24}
77
- viewBox="0 -960 960 960"
78
- >
79
- <path
80
- d="M212.309-152.31q-30.308 0-51.308-21t-21-51.307V-360q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307v135.383q0 30.307-21 51.307-21 21-51.308 21H212.309Zm0-375.383q-30.308 0-51.308-21t-21-51.307v-135.383q0-30.307 21-51.307 21-21 51.308-21h535.382q30.308 0 51.308 21t21 51.307V-600q0 30.307-21 51.307-21 21-51.308 21H212.309Zm535.382-219.998H212.309q-4.616 0-8.463 3.846-3.846 3.846-3.846 8.462V-600q0 4.616 3.846 8.462 3.847 3.847 8.463 3.847h535.382q4.616 0 8.463-3.847Q760-595.384 760-600v-135.383q0-4.616-3.846-8.462-3.847-3.846-8.463-3.846ZM200-587.691v-160 160Z"
81
- fill="rgb(var(--color-text-300))"
82
- />
83
- </svg>
84
- `
85
- };
86
-
87
- // src/table/utilities/col-style.ts
88
- function getColStyleDeclaration(minWidth, width) {
89
- if (width) {
90
- return ["width", `${Math.max(width, minWidth)}px`];
91
- }
92
- return ["min-width", `${minWidth}px`];
93
- }
94
-
95
- // src/table/table-view.tsx
96
- var Popover = class {
97
- constructor(content, opts) {
98
- __publicField(this, "reference");
99
- __publicField(this, "floating");
100
- __publicField(this, "cleanupAutoUpdate", null);
101
- __publicField(this, "onDocClick", (e) => {
102
- if (!this.floating.contains(e.target) && !this.reference.contains(e.target)) {
103
- this.hide();
104
- }
105
- });
106
- __publicField(this, "onEsc", (e) => {
107
- if (e.key === "Escape") this.hide();
108
- });
109
- __publicField(this, "_placement");
110
- __publicField(this, "_offsetPx");
111
- // biome-ignore lint/correctness/noUnusedPrivateClassMembers: backwards. will be used later
112
- __publicField(this, "_interactive");
113
- var _a, _b, _c, _d;
114
- this.reference = opts.reference;
115
- this.floating = document.createElement("div");
116
- this.floating.setAttribute("role", "dialog");
117
- this.floating.setAttribute("aria-modal", "false");
118
- this.floating.style.position = "fixed";
119
- this.floating.style.zIndex = "9999";
120
- this.floating.style.display = "none";
121
- this.floating.className = "rounded-md border bg-background px-2 py-2.5 text-xs shadow-sm min-w-[12rem] whitespace-nowrap";
122
- this.floating.appendChild(content);
123
- const host = (_a = opts.container) != null ? _a : document.body;
124
- host.appendChild(this.floating);
125
- this._placement = (_b = opts.placement) != null ? _b : "right";
126
- this._offsetPx = (_c = opts.offsetPx) != null ? _c : 6;
127
- this._interactive = (_d = opts.interactive) != null ? _d : true;
128
- }
129
- async _updatePosition() {
130
- const { x, y } = await (0, import_dom.computePosition)(this.reference, this.floating, {
131
- placement: this._placement,
132
- middleware: [(0, import_dom.offset)(this._offsetPx), (0, import_dom.flip)(), (0, import_dom.shift)({ padding: 8 })]
133
- });
134
- Object.assign(this.floating.style, { left: `${x}px`, top: `${y}px` });
135
- }
136
- show() {
137
- if (this.floating.style.display !== "none") return;
138
- this.floating.style.display = "block";
139
- this.cleanupAutoUpdate = (0, import_dom.autoUpdate)(
140
- this.reference,
141
- this.floating,
142
- () => this._updatePosition()
143
- );
144
- document.addEventListener("keydown", this.onEsc, { passive: true });
145
- document.addEventListener("mousedown", this.onDocClick, { capture: true });
146
- requestAnimationFrame(() => this._updatePosition());
147
- }
148
- hide() {
149
- var _a;
150
- if (this.floating.style.display === "none") return;
151
- this.floating.style.display = "none";
152
- (_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
153
- this.cleanupAutoUpdate = null;
154
- document.removeEventListener("keydown", this.onEsc);
155
- document.removeEventListener("mousedown", this.onDocClick, {
156
- capture: true
157
- });
158
- }
159
- toggle() {
160
- if (this.floating.style.display === "none") this.show();
161
- else this.hide();
162
- }
163
- destroy() {
164
- this.hide();
165
- this.floating.remove();
166
- }
167
- get el() {
168
- return this.floating;
169
- }
170
- };
171
- function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
172
- var _a;
173
- let totalWidth = 0;
174
- let fixedWidth = true;
175
- let nextDOM = colgroup.firstChild;
176
- const row = node.firstChild;
177
- if (row !== null) {
178
- for (let i = 0, col = 0; i < row.childCount; i += 1) {
179
- const { colspan, colwidth } = row.child(i).attrs;
180
- for (let j = 0; j < colspan; j += 1, col += 1) {
181
- const hasWidth = overrideCol === col ? overrideValue : colwidth == null ? void 0 : colwidth[j];
182
- const cssWidth = hasWidth ? `${hasWidth}px` : "";
183
- totalWidth += hasWidth || cellMinWidth;
184
- if (!hasWidth) fixedWidth = false;
185
- if (!nextDOM) {
186
- const colElement = document.createElement("col");
187
- const [key, val] = getColStyleDeclaration(cellMinWidth, hasWidth);
188
- colElement.style.setProperty(key, val);
189
- colgroup.appendChild(colElement);
190
- } else {
191
- const colEl = nextDOM;
192
- if (colEl.style.width !== cssWidth) {
193
- const [key, val] = getColStyleDeclaration(cellMinWidth, hasWidth);
194
- colEl.style.setProperty(key, val);
195
- }
196
- nextDOM = nextDOM.nextSibling;
197
- }
198
- }
199
- }
200
- }
201
- while (nextDOM) {
202
- const after = nextDOM.nextSibling;
203
- (_a = nextDOM.parentNode) == null ? void 0 : _a.removeChild(nextDOM);
204
- nextDOM = after;
205
- }
206
- if (fixedWidth) {
207
- table.style.width = `${totalWidth}px`;
208
- table.style.minWidth = "";
209
- } else {
210
- table.style.width = "";
211
- table.style.minWidth = `${totalWidth}px`;
212
- }
213
- }
214
- function setCellsBackgroundColor(editor, color) {
215
- return editor.chain().focus().updateAttributes("tableCell", {
216
- background: color.backgroundColor,
217
- textColor: color.textColor
218
- }).run();
219
- }
220
- function setTableRowBackgroundColor(editor, color) {
221
- const { state, dispatch } = editor.view;
222
- const { selection } = state;
223
- if (!(selection instanceof import_tables.CellSelection)) return false;
224
- const hoveredCell = selection.$headCell || selection.$anchorCell;
225
- let rowDepth = hoveredCell.depth;
226
- while (rowDepth > 0 && hoveredCell.node(rowDepth).type.name !== "tableRow") {
227
- rowDepth--;
228
- }
229
- if (hoveredCell.node(rowDepth).type.name !== "tableRow") return false;
230
- const rowStartPos = hoveredCell.start(rowDepth);
231
- const tr = state.tr.setNodeMarkup(rowStartPos - 1, null, {
232
- ...hoveredCell.node(rowDepth).attrs,
233
- background: color.backgroundColor,
234
- textColor: color.textColor
235
- });
236
- dispatch(tr);
237
- return true;
238
- }
239
- var columnsToolboxItems = [
240
- {
241
- label: "Toggle column header",
242
- icon: icons.toggleColumnHeader,
243
- action: ({ editor }) => editor.chain().focus().toggleHeaderColumn().run()
244
- },
245
- {
246
- label: "Add column before",
247
- icon: icons.insertLeftTableIcon,
248
- action: ({ editor }) => editor.chain().focus().addColumnBefore().run()
249
- },
250
- {
251
- label: "Add column after",
252
- icon: icons.insertRightTableIcon,
253
- action: ({ editor }) => editor.chain().focus().addColumnAfter().run()
254
- },
255
- { label: "Pick color", icon: "", action: () => {
256
- } },
257
- {
258
- label: "Delete column",
259
- icon: icons.deleteColumn,
260
- action: ({ editor }) => editor.chain().focus().deleteColumn().run()
261
- }
262
- ];
263
- var rowsToolboxItems = [
264
- {
265
- label: "Toggle row header",
266
- icon: icons.toggleRowHeader,
267
- action: ({ editor }) => editor.chain().focus().toggleHeaderRow().run()
268
- },
269
- {
270
- label: "Add row above",
271
- icon: icons.insertTopTableIcon,
272
- action: ({ editor }) => editor.chain().focus().addRowBefore().run()
273
- },
274
- {
275
- label: "Add row below",
276
- icon: icons.insertBottomTableIcon,
277
- action: ({ editor }) => editor.chain().focus().addRowAfter().run()
278
- },
279
- { label: "Pick color", icon: "", action: () => {
280
- } },
281
- {
282
- label: "Delete row",
283
- icon: icons.deleteRow,
284
- action: ({ editor }) => editor.chain().focus().deleteRow().run()
285
- }
286
- ];
287
- function buildToolboxContent({
288
- items,
289
- onClickItem,
290
- onSelectColor,
291
- colors
292
- }) {
293
- return (0, import_jsx_dom_cjs.h)(
294
- "div",
295
- { className: "space-y-2" },
296
- items.map((item) => {
297
- if (item.label === "Pick color") {
298
- return (0, import_jsx_dom_cjs.h)("div", { className: "flex flex-col" }, [
299
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" }),
300
- (0, import_jsx_dom_cjs.h)("div", { className: "text-foreground text-sm" }, item.label),
301
- (0, import_jsx_dom_cjs.h)(
302
- "div",
303
- { className: "grid grid-cols-6 gap-x-1 gap-y-2.5 mt-2" },
304
- Object.entries(colors).map(
305
- ([_, colorValue]) => {
306
- var _a;
307
- return (0, import_jsx_dom_cjs.h)("button", {
308
- // @ts-expect-error JSX
309
- type: "button",
310
- className: "grid place-items-center size-6 rounded outline-none ring-offset-2 focus-visible:ring",
311
- style: `background-color:${colorValue.backgroundColor};color:${colorValue.textColor || "inherit"};`,
312
- innerHTML: (_a = colorValue.icon) != null ? _a : `<span class="text-md" style="color:${colorValue.textColor || "inherit"}">A</span>`,
313
- onClick: (e) => {
314
- e.stopPropagation();
315
- onSelectColor(colorValue);
316
- }
317
- });
318
- }
319
- )
320
- ),
321
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" })
322
- ]);
323
- }
324
- return (0, import_jsx_dom_cjs.h)(
325
- "button",
326
- {
327
- // @ts-expect-error JSX
328
- type: "button",
329
- className: "w-full flex items-center gap-2 px-1 py-1.5 bg-background hover:bg-muted text-sm text-foreground rounded",
330
- onClick: (e) => {
331
- e.stopPropagation();
332
- onClickItem(item);
333
- }
334
- },
335
- [
336
- (0, import_jsx_dom_cjs.h)("span", { className: "h-3 w-3 shrink-0", innerHTML: item.icon }),
337
- (0, import_jsx_dom_cjs.h)("div", { className: "label" }, item.label)
338
- ]
339
- );
340
- })
341
- );
342
- }
343
- function createToolbox({
344
- triggerButton,
345
- items,
346
- onSelectColor,
347
- onClickItem,
348
- colors,
349
- appendTo
350
- }) {
351
- if (!triggerButton) {
352
- return null;
353
- }
354
- const content = buildToolboxContent({
355
- items,
356
- onClickItem,
357
- onSelectColor,
358
- colors
359
- });
360
- const pop = new Popover(content, {
361
- reference: triggerButton,
362
- container: appendTo != null ? appendTo : void 0,
363
- placement: "right",
364
- offsetPx: 6,
365
- interactive: true
366
- });
367
- const onTrigger = (e) => {
368
- e.stopPropagation();
369
- pop.toggle();
370
- };
371
- triggerButton.addEventListener("click", onTrigger);
372
- return {
373
- show: () => pop.show(),
374
- hide: () => pop.hide(),
375
- destroy: () => {
376
- pop.destroy();
377
- triggerButton.removeEventListener("click", onTrigger);
378
- }
379
- };
380
- }
381
- var TableView = class {
382
- constructor(node, cellMinWidth, decorations, editor, getPos) {
383
- __publicField(this, "node");
384
- __publicField(this, "cellMinWidth");
385
- __publicField(this, "decorations");
386
- __publicField(this, "editor");
387
- __publicField(this, "getPos");
388
- __publicField(this, "hoveredCell", null);
389
- __publicField(this, "map");
390
- __publicField(this, "root");
391
- __publicField(this, "table");
392
- __publicField(this, "colgroup");
393
- __publicField(this, "tbody");
394
- __publicField(this, "rowsControl");
395
- __publicField(this, "columnsControl");
396
- __publicField(this, "columnsToolbox");
397
- __publicField(this, "rowsToolbox");
398
- __publicField(this, "controls");
399
- var _a, _b, _c, _d;
400
- this.node = node;
401
- this.cellMinWidth = cellMinWidth;
402
- this.decorations = decorations.slice();
403
- this.editor = editor;
404
- this.getPos = getPos;
405
- this.hoveredCell = null;
406
- this.map = import_tables.TableMap.get(node);
407
- if (editor.isEditable) {
408
- this.rowsControl = (0, import_jsx_dom_cjs.h)(
409
- "div",
410
- { className: "rows-control" },
411
- (0, import_jsx_dom_cjs.h)("button", {
412
- // @ts-expect-error JSX
413
- type: "button",
414
- className: "rows-control-div",
415
- onClick: () => this.selectRow(),
416
- "aria-label": "Row actions"
417
- })
418
- );
419
- this.columnsControl = (0, import_jsx_dom_cjs.h)(
420
- "div",
421
- { className: "columns-control" },
422
- (0, import_jsx_dom_cjs.h)("button", {
423
- // @ts-expect-error JSX
424
- type: "button",
425
- className: "columns-control-div",
426
- onClick: () => this.selectColumn(),
427
- "aria-label": "Column actions"
428
- })
429
- );
430
- this.controls = (0, import_jsx_dom_cjs.h)(
431
- "div",
432
- { className: "table-controls", contentEditable: "false" },
433
- this.rowsControl,
434
- this.columnsControl
435
- );
436
- const palette = {
437
- Blue: { backgroundColor: "#D9E4FF", textColor: "#171717" },
438
- Orange: { backgroundColor: "#FFEDD5", textColor: "#171717" },
439
- Grey: { backgroundColor: "#F1F1F1", textColor: "#171717" },
440
- Yellow: { backgroundColor: "#FEF3C7", textColor: "#171717" },
441
- Green: { backgroundColor: "#DCFCE7", textColor: "#171717" },
442
- Red: { backgroundColor: "#FFDDDD", textColor: "#171717" },
443
- Pink: { backgroundColor: "#FFE8FA", textColor: "#171717" },
444
- Purple: { backgroundColor: "#E8DAFB", textColor: "#171717" },
445
- None: {
446
- backgroundColor: "transparent",
447
- textColor: "inherit",
448
- 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>`
449
- }
450
- };
451
- this.columnsToolbox = createToolbox({
452
- triggerButton: (_a = this.columnsControl) == null ? void 0 : _a.querySelector(
453
- ".columns-control-div"
454
- ),
455
- items: columnsToolboxItems,
456
- colors: palette,
457
- appendTo: (_b = this.controls) != null ? _b : null,
458
- onSelectColor: (color) => setCellsBackgroundColor(this.editor, color),
459
- onClickItem: (item) => {
460
- var _a2, _b2;
461
- item.action({
462
- editor: this.editor,
463
- triggerButton: (_a2 = this.columnsControl) == null ? void 0 : _a2.firstElementChild,
464
- controlsContainer: this.controls
465
- });
466
- (_b2 = this.columnsToolbox) == null ? void 0 : _b2.hide();
467
- }
468
- });
469
- this.rowsToolbox = createToolbox({
470
- triggerButton: (_c = this.rowsControl) == null ? void 0 : _c.querySelector(
471
- ".rows-control-div"
472
- ),
473
- items: rowsToolboxItems,
474
- colors: palette,
475
- appendTo: (_d = this.controls) != null ? _d : null,
476
- onSelectColor: (color) => setTableRowBackgroundColor(editor, color),
477
- onClickItem: (item) => {
478
- var _a2, _b2;
479
- item.action({
480
- editor: this.editor,
481
- triggerButton: (_a2 = this.rowsControl) == null ? void 0 : _a2.firstElementChild,
482
- controlsContainer: this.controls
483
- });
484
- (_b2 = this.rowsToolbox) == null ? void 0 : _b2.hide();
485
- }
486
- });
487
- }
488
- this.colgroup = (0, import_jsx_dom_cjs.h)(
489
- "colgroup",
490
- null,
491
- Array.from({ length: this.map.width }, () => 1).map(() => (0, import_jsx_dom_cjs.h)("col"))
492
- );
493
- this.tbody = (0, import_jsx_dom_cjs.h)("tbody");
494
- this.table = (0, import_jsx_dom_cjs.h)(
495
- "table",
496
- null,
497
- this.colgroup,
498
- this.tbody
499
- );
500
- this.root = (0, import_jsx_dom_cjs.h)(
501
- "div",
502
- {
503
- className: "table-wrapper horizontal-scrollbar scrollbar-md controls--disabled"
504
- },
505
- this.controls,
506
- this.table
507
- );
508
- this.render();
509
- }
510
- get dom() {
511
- return this.root;
512
- }
513
- get contentDOM() {
514
- return this.tbody;
515
- }
516
- update(node, decorations) {
517
- if (node.type !== this.node.type) return false;
518
- this.node = node;
519
- this.decorations = [...decorations];
520
- this.map = import_tables.TableMap.get(this.node);
521
- if (this.editor.isEditable) this.updateControls();
522
- this.render();
523
- return true;
524
- }
525
- render() {
526
- if (this.colgroup.children.length !== this.map.width) {
527
- const cols = Array.from({ length: this.map.width }, () => 1).map(
528
- () => (0, import_jsx_dom_cjs.h)("col")
529
- );
530
- this.colgroup.replaceChildren(...cols);
531
- }
532
- (0, import_tables.updateColumnsOnResize)(
533
- this.node,
534
- this.colgroup,
535
- this.table,
536
- this.cellMinWidth
537
- );
538
- }
539
- ignoreMutation() {
540
- return true;
541
- }
542
- updateControls() {
543
- var _a;
544
- const { hoveredTable: table, hoveredCell: cell } = Object.values(
545
- this.decorations
546
- ).reduce(
547
- (acc, curr) => {
548
- if (curr.spec.hoveredCell !== void 0)
549
- acc.hoveredCell = curr.spec.hoveredCell;
550
- if (curr.spec.hoveredTable !== void 0)
551
- acc.hoveredTable = curr.spec.hoveredTable;
552
- return acc;
553
- },
554
- {}
555
- );
556
- if (table === void 0 || cell === void 0) {
557
- this.root.classList.add("controls--disabled");
558
- return;
559
- }
560
- this.root.classList.remove("controls--disabled");
561
- this.hoveredCell = cell;
562
- const cellDom = this.editor.view.nodeDOM(cell.pos);
563
- if (!this.table || !cellDom) return;
564
- const tableRect = this.table.getBoundingClientRect();
565
- const cellRect = cellDom.getBoundingClientRect();
566
- if (this.columnsControl) {
567
- this.columnsControl.style.left = `${cellRect.left - tableRect.left - (((_a = this.table.parentElement) == null ? void 0 : _a.scrollLeft) || 0)}px`;
568
- this.columnsControl.style.width = `${cellRect.width}px`;
569
- }
570
- if (this.rowsControl) {
571
- this.rowsControl.style.top = `${cellRect.top - tableRect.top}px`;
572
- this.rowsControl.style.height = `${cellRect.height}px`;
573
- }
574
- }
575
- selectColumn() {
576
- if (!this.hoveredCell) return;
577
- const colIndex = this.map.colCount(
578
- this.hoveredCell.pos - (this.getPos() + 1)
579
- );
580
- const anchorCellPos = this.hoveredCell.pos;
581
- const headCellPos = this.map.map[colIndex + this.map.width * (this.map.height - 1)] + (this.getPos() + 1);
582
- const cellSelection = import_tables.CellSelection.create(
583
- this.editor.view.state.doc,
584
- anchorCellPos,
585
- headCellPos
586
- );
587
- this.editor.view.dispatch(this.editor.state.tr.setSelection(cellSelection));
588
- }
589
- selectRow() {
590
- if (!this.hoveredCell) return;
591
- const anchorCellPos = this.hoveredCell.pos;
592
- const anchorCellIndex = this.map.map.indexOf(
593
- anchorCellPos - (this.getPos() + 1)
594
- );
595
- const headCellPos = this.map.map[anchorCellIndex + (this.map.width - 1)] + (this.getPos() + 1);
596
- const cellSelection = import_tables.CellSelection.create(
597
- this.editor.state.doc,
598
- anchorCellPos,
599
- headCellPos
600
- );
601
- this.editor.view.dispatch(
602
- this.editor.view.state.tr.setSelection(cellSelection)
603
- );
604
- }
605
- };
606
- // Annotate the CommonJS export names for ESM import in node:
607
- 0 && (module.exports = {
608
- TableView,
609
- updateColumns
610
- });
@@ -1,12 +0,0 @@
1
- "use client";
2
- import {
3
- TableView,
4
- updateColumns
5
- } from "../chunk-GMNNSVR3.mjs";
6
- import "../chunk-NTWXQSW6.mjs";
7
- import "../chunk-7NEAULTF.mjs";
8
- import "../chunk-WKV76XOR.mjs";
9
- export {
10
- TableView,
11
- updateColumns
12
- };
@@ -1,8 +0,0 @@
1
- "use client";
2
- import {
3
- getColStyleDeclaration
4
- } from "../../chunk-NTWXQSW6.mjs";
5
- import "../../chunk-WKV76XOR.mjs";
6
- export {
7
- getColStyleDeclaration
8
- };
File without changes
File without changes
File without changes
File without changes
File without changes