@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.
Files changed (200) hide show
  1. package/dist/chunk-2NBDRVYL.mjs +428 -0
  2. package/dist/chunk-3SWV7BGP.mjs +638 -0
  3. package/dist/chunk-4QSZXHZO.mjs +276 -0
  4. package/dist/chunk-5B5XIL2G.mjs +457 -0
  5. package/dist/chunk-62B2LU2Q.mjs +603 -0
  6. package/dist/chunk-6FHFDGJO.mjs +251 -0
  7. package/dist/chunk-CD62W5C3.mjs +165 -0
  8. package/dist/chunk-CN73TYHV.mjs +190 -0
  9. package/dist/chunk-CPDSPBS6.mjs +276 -0
  10. package/dist/chunk-E7W2KRZG.mjs +49 -0
  11. package/dist/chunk-G6GHC2WO.mjs +276 -0
  12. package/dist/chunk-GBTQVIN5.mjs +174 -0
  13. package/dist/chunk-GDEXPEW5.mjs +52 -0
  14. package/dist/chunk-GQLZBIWF.mjs +198 -0
  15. package/dist/chunk-IRJ6RAVQ.mjs +116 -0
  16. package/dist/chunk-J4VOSZCZ.mjs +59 -0
  17. package/dist/chunk-KIYFW7MP.mjs +122 -0
  18. package/dist/chunk-KTRZVXJC.mjs +306 -0
  19. package/dist/chunk-LUA32VH4.mjs +35 -0
  20. package/dist/{chunk-SNJF4UW6.mjs → chunk-MB52MZQ4.mjs} +7 -8
  21. package/dist/chunk-PTX5UYV6.mjs +10 -0
  22. package/dist/chunk-TEGO6KUS.mjs +96 -0
  23. package/dist/chunk-VIBVRWS4.mjs +197 -0
  24. package/dist/chunk-VQV757EG.mjs +113 -0
  25. package/dist/chunk-XRNQXADK.mjs +149 -0
  26. package/dist/chunk-ZVPJDJBO.mjs +134 -0
  27. package/dist/{kit.d.mts → extensions/kit.d.mts} +1 -3
  28. package/dist/{kit.d.ts → extensions/kit.d.ts} +1 -3
  29. package/dist/extensions/kit.js +1041 -0
  30. package/dist/extensions/kit.mjs +15 -0
  31. package/dist/extensions/table-cell.d.mts +6 -0
  32. package/dist/extensions/table-cell.d.ts +6 -0
  33. package/dist/extensions/table-cell.js +70 -0
  34. package/dist/{table/icons.mjs → extensions/table-cell.mjs} +3 -3
  35. package/dist/extensions/table-handle-plugin.d.mts +46 -0
  36. package/dist/extensions/table-handle-plugin.d.ts +46 -0
  37. package/dist/extensions/table-handle-plugin.js +1100 -0
  38. package/dist/extensions/table-handle-plugin.mjs +18 -0
  39. package/dist/extensions/table-handle.d.mts +19 -0
  40. package/dist/extensions/table-handle.d.ts +19 -0
  41. package/dist/extensions/table-handle.js +865 -0
  42. package/dist/extensions/table-handle.mjs +11 -0
  43. package/dist/{table → extensions}/table.d.mts +2 -2
  44. package/dist/{table → extensions}/table.d.ts +2 -2
  45. package/dist/extensions/table.js +138 -0
  46. package/dist/extensions/table.mjs +9 -0
  47. package/dist/hooks/use-resize-overlay.d.mts +5 -0
  48. package/dist/hooks/use-resize-overlay.d.ts +5 -0
  49. package/dist/hooks/use-resize-overlay.js +83 -0
  50. package/dist/hooks/use-resize-overlay.mjs +9 -0
  51. package/dist/hooks/use-table-add-row-column.d.mts +57 -0
  52. package/dist/hooks/use-table-add-row-column.d.ts +57 -0
  53. package/dist/hooks/use-table-add-row-column.js +551 -0
  54. package/dist/hooks/use-table-add-row-column.mjs +11 -0
  55. package/dist/hooks/use-table-align-cell.d.mts +148 -0
  56. package/dist/hooks/use-table-align-cell.d.ts +148 -0
  57. package/dist/hooks/use-table-align-cell.js +655 -0
  58. package/dist/hooks/use-table-align-cell.mjs +13 -0
  59. package/dist/hooks/use-table-clear-row-column-content.d.mts +103 -0
  60. package/dist/hooks/use-table-clear-row-column-content.d.ts +103 -0
  61. package/dist/hooks/use-table-clear-row-column-content.js +681 -0
  62. package/dist/hooks/use-table-clear-row-column-content.mjs +11 -0
  63. package/dist/hooks/use-table-delete-row-column.d.mts +87 -0
  64. package/dist/hooks/use-table-delete-row-column.d.ts +87 -0
  65. package/dist/hooks/use-table-delete-row-column.js +459 -0
  66. package/dist/hooks/use-table-delete-row-column.mjs +11 -0
  67. package/dist/hooks/use-table-duplicate-row-column.d.mts +49 -0
  68. package/dist/hooks/use-table-duplicate-row-column.d.ts +49 -0
  69. package/dist/hooks/use-table-duplicate-row-column.js +758 -0
  70. package/dist/hooks/use-table-duplicate-row-column.mjs +11 -0
  71. package/dist/hooks/use-table-handle-positioning.d.mts +42 -0
  72. package/dist/hooks/use-table-handle-positioning.d.ts +42 -0
  73. package/dist/hooks/use-table-handle-positioning.js +190 -0
  74. package/dist/hooks/use-table-handle-positioning.mjs +10 -0
  75. package/dist/hooks/use-table-handle-state.d.mts +28 -0
  76. package/dist/hooks/use-table-handle-state.d.ts +28 -0
  77. package/dist/hooks/use-table-handle-state.js +76 -0
  78. package/dist/hooks/use-table-handle-state.mjs +9 -0
  79. package/dist/hooks/use-table-header-row-column.d.mts +58 -0
  80. package/dist/hooks/use-table-header-row-column.d.ts +58 -0
  81. package/dist/hooks/use-table-header-row-column.js +603 -0
  82. package/dist/hooks/use-table-header-row-column.mjs +13 -0
  83. package/dist/hooks/use-table-merge-split-cell.d.mts +123 -0
  84. package/dist/hooks/use-table-merge-split-cell.d.ts +123 -0
  85. package/dist/hooks/use-table-merge-split-cell.js +331 -0
  86. package/dist/hooks/use-table-merge-split-cell.mjs +12 -0
  87. package/dist/hooks/use-table-move-row-column.d.mts +101 -0
  88. package/dist/hooks/use-table-move-row-column.d.ts +101 -0
  89. package/dist/hooks/use-table-move-row-column.js +621 -0
  90. package/dist/hooks/use-table-move-row-column.mjs +13 -0
  91. package/dist/hooks/use-table-sort-row-column.d.mts +118 -0
  92. package/dist/hooks/use-table-sort-row-column.d.ts +118 -0
  93. package/dist/hooks/use-table-sort-row-column.js +623 -0
  94. package/dist/hooks/use-table-sort-row-column.mjs +13 -0
  95. package/dist/index.d.mts +18 -5
  96. package/dist/index.d.ts +18 -5
  97. package/dist/index.js +4939 -910
  98. package/dist/index.mjs +43 -18
  99. package/dist/lib/constants.d.mts +4 -0
  100. package/dist/lib/constants.d.ts +4 -0
  101. package/dist/{table-row.js → lib/constants.js} +10 -10
  102. package/dist/lib/constants.mjs +10 -0
  103. package/dist/lib/create-image.d.mts +12 -0
  104. package/dist/lib/create-image.d.ts +12 -0
  105. package/dist/lib/create-image.js +221 -0
  106. package/dist/lib/create-image.mjs +8 -0
  107. package/dist/lib/table-utils.d.mts +263 -0
  108. package/dist/lib/table-utils.d.ts +263 -0
  109. package/dist/lib/table-utils.js +488 -0
  110. package/dist/lib/table-utils.mjs +40 -0
  111. package/dist/messages.d.mts +174 -0
  112. package/dist/messages.d.ts +174 -0
  113. package/dist/messages.js +213 -0
  114. package/dist/{table-row.mjs → messages.mjs} +3 -3
  115. package/dist/ui/table-alignment-menu.d.mts +25 -0
  116. package/dist/ui/table-alignment-menu.d.ts +25 -0
  117. package/dist/ui/table-alignment-menu.js +758 -0
  118. package/dist/ui/table-alignment-menu.mjs +14 -0
  119. package/dist/ui/table-cell-handle-menu.d.mts +12 -0
  120. package/dist/ui/table-cell-handle-menu.d.ts +12 -0
  121. package/dist/ui/table-cell-handle-menu.js +1317 -0
  122. package/dist/ui/table-cell-handle-menu.mjs +17 -0
  123. package/dist/ui/table-handle-menu.d.mts +23 -0
  124. package/dist/ui/table-handle-menu.d.ts +23 -0
  125. package/dist/ui/table-handle-menu.js +2598 -0
  126. package/dist/ui/table-handle-menu.mjs +21 -0
  127. package/dist/ui/table-handle.d.mts +48 -0
  128. package/dist/ui/table-handle.d.ts +48 -0
  129. package/dist/ui/table-handle.js +3126 -0
  130. package/dist/ui/table-handle.mjs +22 -0
  131. package/dist/ui/table-selection-overlay.d.mts +14 -0
  132. package/dist/ui/table-selection-overlay.d.ts +14 -0
  133. package/dist/ui/table-selection-overlay.js +553 -0
  134. package/dist/ui/table-selection-overlay.mjs +11 -0
  135. package/package.json +16 -12
  136. package/dist/chunk-6NY5XWR7.mjs +0 -11
  137. package/dist/chunk-74O2ORPO.mjs +0 -81
  138. package/dist/chunk-7NEAULTF.mjs +0 -58
  139. package/dist/chunk-ARSGMUXM.mjs +0 -116
  140. package/dist/chunk-BAQU2YT5.mjs +0 -41
  141. package/dist/chunk-DF6ZMJLL.mjs +0 -40
  142. package/dist/chunk-FKOIW52J.mjs +0 -11
  143. package/dist/chunk-GMNNSVR3.mjs +0 -540
  144. package/dist/chunk-IMRHHVEF.mjs +0 -113
  145. package/dist/chunk-NTWXQSW6.mjs +0 -13
  146. package/dist/chunk-OPDSKEZR.mjs +0 -93
  147. package/dist/chunk-YSUOVRY4.mjs +0 -1
  148. package/dist/kit.js +0 -1024
  149. package/dist/kit.mjs +0 -19
  150. package/dist/table/icons.d.mts +0 -13
  151. package/dist/table/icons.d.ts +0 -13
  152. package/dist/table/icons.js +0 -81
  153. package/dist/table/index.d.mts +0 -3
  154. package/dist/table/index.d.ts +0 -3
  155. package/dist/table/index.js +0 -809
  156. package/dist/table/index.mjs +0 -15
  157. package/dist/table/table-controls.d.mts +0 -15
  158. package/dist/table/table-controls.d.ts +0 -15
  159. package/dist/table/table-controls.js +0 -131
  160. package/dist/table/table-controls.mjs +0 -8
  161. package/dist/table/table-view.d.mts +0 -43
  162. package/dist/table/table-view.d.ts +0 -43
  163. package/dist/table/table-view.js +0 -610
  164. package/dist/table/table-view.mjs +0 -12
  165. package/dist/table/table.js +0 -807
  166. package/dist/table/table.mjs +0 -14
  167. package/dist/table/utilities/col-style.d.mts +0 -3
  168. package/dist/table/utilities/col-style.d.ts +0 -3
  169. package/dist/table/utilities/col-style.js +0 -36
  170. package/dist/table/utilities/col-style.mjs +0 -8
  171. package/dist/table/utilities/delete-table-when-all-cells-selected.d.mts +0 -5
  172. package/dist/table/utilities/delete-table-when-all-cells-selected.d.ts +0 -5
  173. package/dist/table/utilities/delete-table-when-all-cells-selected.js +0 -66
  174. package/dist/table/utilities/delete-table-when-all-cells-selected.mjs +0 -40
  175. package/dist/table/utilities/get-table-node-types.d.mts +0 -7
  176. package/dist/table/utilities/get-table-node-types.d.ts +0 -7
  177. package/dist/table/utilities/get-table-node-types.js +0 -44
  178. package/dist/table/utilities/get-table-node-types.mjs +0 -21
  179. package/dist/table/utilities/insert-line-above-table-action.d.mts +0 -5
  180. package/dist/table/utilities/insert-line-above-table-action.d.ts +0 -5
  181. package/dist/table/utilities/insert-line-above-table-action.js +0 -64
  182. package/dist/table/utilities/insert-line-above-table-action.mjs +0 -8
  183. package/dist/table/utilities/insert-line-below-table-action.d.mts +0 -5
  184. package/dist/table/utilities/insert-line-below-table-action.d.ts +0 -5
  185. package/dist/table/utilities/insert-line-below-table-action.js +0 -63
  186. package/dist/table/utilities/insert-line-below-table-action.mjs +0 -8
  187. package/dist/table/utilities/is-cell-selection.d.mts +0 -5
  188. package/dist/table/utilities/is-cell-selection.d.ts +0 -5
  189. package/dist/table/utilities/is-cell-selection.js +0 -34
  190. package/dist/table/utilities/is-cell-selection.mjs +0 -8
  191. package/dist/table-cell.d.mts +0 -8
  192. package/dist/table-cell.d.ts +0 -8
  193. package/dist/table-cell.js +0 -139
  194. package/dist/table-cell.mjs +0 -8
  195. package/dist/table-header.d.mts +0 -6
  196. package/dist/table-header.d.ts +0 -6
  197. package/dist/table-header.js +0 -104
  198. package/dist/table-header.mjs +0 -8
  199. package/dist/table-row.d.mts +0 -6
  200. package/dist/table-row.d.ts +0 -6
package/dist/kit.js DELETED
@@ -1,1024 +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/kit.ts
24
- var kit_exports = {};
25
- __export(kit_exports, {
26
- TableKit: () => TableKit
27
- });
28
- module.exports = __toCommonJS(kit_exports);
29
- var import_react = require("@tiptap/react");
30
-
31
- // src/table/table.ts
32
- var import_extension_table = require("@tiptap/extension-table");
33
- var import_tables2 = require("@tiptap/pm/tables");
34
-
35
- // src/table/table-controls.ts
36
- var import_core = require("@tiptap/core");
37
- var import_state = require("@tiptap/pm/state");
38
- var import_view = require("@tiptap/pm/view");
39
- function tableControls() {
40
- const key = new import_state.PluginKey("tableControls");
41
- return new import_state.Plugin({
42
- key,
43
- state: {
44
- init() {
45
- return new TableControlsState(key);
46
- },
47
- apply(tr, prev) {
48
- return prev.apply(tr);
49
- }
50
- },
51
- props: {
52
- handleDOMEvents: {
53
- mousemove: (view, event) => {
54
- var _a;
55
- const pluginState = key.getState(view.state);
56
- if (!event.target.closest(".table-wrapper") && pluginState.values.hoveredTable) {
57
- return view.dispatch(
58
- view.state.tr.setMeta(key, {
59
- setHoveredTable: null,
60
- setHoveredCell: null
61
- })
62
- );
63
- }
64
- const pos = view.posAtCoords({
65
- left: event.clientX,
66
- top: event.clientY
67
- });
68
- if (!pos || pos.pos < 0 || pos.pos > view.state.doc.content.size)
69
- return;
70
- const table = (0, import_core.findParentNode)((node) => node.type.name === "table")(
71
- import_state.TextSelection.create(view.state.doc, pos.pos)
72
- );
73
- const cell = (0, import_core.findParentNode)(
74
- (node) => node.type.name === "tableCell" || node.type.name === "tableHeader"
75
- )(import_state.TextSelection.create(view.state.doc, pos.pos));
76
- if (!table || !cell) return;
77
- if (((_a = pluginState.values.hoveredCell) == null ? void 0 : _a.pos) !== cell.pos) {
78
- return view.dispatch(
79
- view.state.tr.setMeta(key, {
80
- setHoveredTable: table,
81
- setHoveredCell: cell
82
- })
83
- );
84
- }
85
- }
86
- },
87
- decorations: (state) => {
88
- const pluginState = key.getState(state);
89
- if (!pluginState) {
90
- return null;
91
- }
92
- const { hoveredTable, hoveredCell } = pluginState.values;
93
- const docSize = state.doc.content.size;
94
- if (hoveredTable && hoveredCell && hoveredTable.pos < docSize && hoveredCell.pos < docSize) {
95
- const decorations = [
96
- import_view.Decoration.node(
97
- hoveredTable.pos,
98
- hoveredTable.pos + hoveredTable.node.nodeSize,
99
- {},
100
- {
101
- hoveredTable,
102
- hoveredCell
103
- }
104
- )
105
- ];
106
- return import_view.DecorationSet.create(state.doc, decorations);
107
- }
108
- return null;
109
- }
110
- }
111
- });
112
- }
113
- var TableControlsState = class {
114
- constructor(key, props = {}) {
115
- __publicField(this, "values");
116
- __publicField(this, "key");
117
- this.key = key;
118
- this.values = {
119
- hoveredTable: null,
120
- hoveredCell: null,
121
- ...props
122
- };
123
- }
124
- apply(tr) {
125
- const actions = tr.getMeta(this.key);
126
- if ((actions == null ? void 0 : actions.setHoveredTable) !== void 0) {
127
- this.values.hoveredTable = actions.setHoveredTable;
128
- }
129
- if ((actions == null ? void 0 : actions.setHoveredCell) !== void 0) {
130
- this.values.hoveredCell = actions.setHoveredCell;
131
- }
132
- return this;
133
- }
134
- };
135
-
136
- // src/table/table-view.tsx
137
- var import_dom = require("@floating-ui/dom");
138
- var import_tables = require("@tiptap/pm/tables");
139
- var import_jsx_dom_cjs = require("jsx-dom-cjs");
140
-
141
- // src/table/icons.ts
142
- var icons = {
143
- 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>`,
144
- 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>`,
145
- 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>`,
146
- insertLeftTableIcon: `<svg
147
- xmlns="http://www.w3.org/2000/svg"
148
- length={12}
149
- viewBox="0 -960 960 960"
150
- >
151
- <path
152
- 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"
153
- fill="rgb(var(--color-text-300))"
154
- />
155
- </svg>
156
- `,
157
- insertRightTableIcon: `<svg
158
- xmlns="http://www.w3.org/2000/svg"
159
- length={12}
160
- viewBox="0 -960 960 960"
161
- >
162
- <path
163
- 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"
164
- fill="rgb(var(--color-text-300))"
165
- />
166
- </svg>
167
- `,
168
- insertTopTableIcon: `<svg
169
- xmlns="http://www.w3.org/2000/svg"
170
- length={24}
171
- viewBox="0 -960 960 960"
172
- >
173
- <path
174
- 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"
175
- fill="rgb(var(--color-text-300))"
176
- />
177
- </svg>
178
- `,
179
- 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>`,
180
- 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>`,
181
- insertBottomTableIcon: `<svg
182
- xmlns="http://www.w3.org/2000/svg"
183
- length={24}
184
- viewBox="0 -960 960 960"
185
- >
186
- <path
187
- 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"
188
- fill="rgb(var(--color-text-300))"
189
- />
190
- </svg>
191
- `
192
- };
193
-
194
- // src/table/table-view.tsx
195
- var Popover = class {
196
- constructor(content, opts) {
197
- __publicField(this, "reference");
198
- __publicField(this, "floating");
199
- __publicField(this, "cleanupAutoUpdate", null);
200
- __publicField(this, "onDocClick", (e) => {
201
- if (!this.floating.contains(e.target) && !this.reference.contains(e.target)) {
202
- this.hide();
203
- }
204
- });
205
- __publicField(this, "onEsc", (e) => {
206
- if (e.key === "Escape") this.hide();
207
- });
208
- __publicField(this, "_placement");
209
- __publicField(this, "_offsetPx");
210
- // biome-ignore lint/correctness/noUnusedPrivateClassMembers: backwards. will be used later
211
- __publicField(this, "_interactive");
212
- var _a, _b, _c, _d;
213
- this.reference = opts.reference;
214
- this.floating = document.createElement("div");
215
- this.floating.setAttribute("role", "dialog");
216
- this.floating.setAttribute("aria-modal", "false");
217
- this.floating.style.position = "fixed";
218
- this.floating.style.zIndex = "9999";
219
- this.floating.style.display = "none";
220
- this.floating.className = "rounded-md border bg-background px-2 py-2.5 text-xs shadow-sm min-w-[12rem] whitespace-nowrap";
221
- this.floating.appendChild(content);
222
- const host = (_a = opts.container) != null ? _a : document.body;
223
- host.appendChild(this.floating);
224
- this._placement = (_b = opts.placement) != null ? _b : "right";
225
- this._offsetPx = (_c = opts.offsetPx) != null ? _c : 6;
226
- this._interactive = (_d = opts.interactive) != null ? _d : true;
227
- }
228
- async _updatePosition() {
229
- const { x, y } = await (0, import_dom.computePosition)(this.reference, this.floating, {
230
- placement: this._placement,
231
- middleware: [(0, import_dom.offset)(this._offsetPx), (0, import_dom.flip)(), (0, import_dom.shift)({ padding: 8 })]
232
- });
233
- Object.assign(this.floating.style, { left: `${x}px`, top: `${y}px` });
234
- }
235
- show() {
236
- if (this.floating.style.display !== "none") return;
237
- this.floating.style.display = "block";
238
- this.cleanupAutoUpdate = (0, import_dom.autoUpdate)(
239
- this.reference,
240
- this.floating,
241
- () => this._updatePosition()
242
- );
243
- document.addEventListener("keydown", this.onEsc, { passive: true });
244
- document.addEventListener("mousedown", this.onDocClick, { capture: true });
245
- requestAnimationFrame(() => this._updatePosition());
246
- }
247
- hide() {
248
- var _a;
249
- if (this.floating.style.display === "none") return;
250
- this.floating.style.display = "none";
251
- (_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
252
- this.cleanupAutoUpdate = null;
253
- document.removeEventListener("keydown", this.onEsc);
254
- document.removeEventListener("mousedown", this.onDocClick, {
255
- capture: true
256
- });
257
- }
258
- toggle() {
259
- if (this.floating.style.display === "none") this.show();
260
- else this.hide();
261
- }
262
- destroy() {
263
- this.hide();
264
- this.floating.remove();
265
- }
266
- get el() {
267
- return this.floating;
268
- }
269
- };
270
- function setCellsBackgroundColor(editor, color) {
271
- return editor.chain().focus().updateAttributes("tableCell", {
272
- background: color.backgroundColor,
273
- textColor: color.textColor
274
- }).run();
275
- }
276
- function setTableRowBackgroundColor(editor, color) {
277
- const { state, dispatch } = editor.view;
278
- const { selection } = state;
279
- if (!(selection instanceof import_tables.CellSelection)) return false;
280
- const hoveredCell = selection.$headCell || selection.$anchorCell;
281
- let rowDepth = hoveredCell.depth;
282
- while (rowDepth > 0 && hoveredCell.node(rowDepth).type.name !== "tableRow") {
283
- rowDepth--;
284
- }
285
- if (hoveredCell.node(rowDepth).type.name !== "tableRow") return false;
286
- const rowStartPos = hoveredCell.start(rowDepth);
287
- const tr = state.tr.setNodeMarkup(rowStartPos - 1, null, {
288
- ...hoveredCell.node(rowDepth).attrs,
289
- background: color.backgroundColor,
290
- textColor: color.textColor
291
- });
292
- dispatch(tr);
293
- return true;
294
- }
295
- var columnsToolboxItems = [
296
- {
297
- label: "Toggle column header",
298
- icon: icons.toggleColumnHeader,
299
- action: ({ editor }) => editor.chain().focus().toggleHeaderColumn().run()
300
- },
301
- {
302
- label: "Add column before",
303
- icon: icons.insertLeftTableIcon,
304
- action: ({ editor }) => editor.chain().focus().addColumnBefore().run()
305
- },
306
- {
307
- label: "Add column after",
308
- icon: icons.insertRightTableIcon,
309
- action: ({ editor }) => editor.chain().focus().addColumnAfter().run()
310
- },
311
- { label: "Pick color", icon: "", action: () => {
312
- } },
313
- {
314
- label: "Delete column",
315
- icon: icons.deleteColumn,
316
- action: ({ editor }) => editor.chain().focus().deleteColumn().run()
317
- }
318
- ];
319
- var rowsToolboxItems = [
320
- {
321
- label: "Toggle row header",
322
- icon: icons.toggleRowHeader,
323
- action: ({ editor }) => editor.chain().focus().toggleHeaderRow().run()
324
- },
325
- {
326
- label: "Add row above",
327
- icon: icons.insertTopTableIcon,
328
- action: ({ editor }) => editor.chain().focus().addRowBefore().run()
329
- },
330
- {
331
- label: "Add row below",
332
- icon: icons.insertBottomTableIcon,
333
- action: ({ editor }) => editor.chain().focus().addRowAfter().run()
334
- },
335
- { label: "Pick color", icon: "", action: () => {
336
- } },
337
- {
338
- label: "Delete row",
339
- icon: icons.deleteRow,
340
- action: ({ editor }) => editor.chain().focus().deleteRow().run()
341
- }
342
- ];
343
- function buildToolboxContent({
344
- items,
345
- onClickItem,
346
- onSelectColor,
347
- colors
348
- }) {
349
- return (0, import_jsx_dom_cjs.h)(
350
- "div",
351
- { className: "space-y-2" },
352
- items.map((item) => {
353
- if (item.label === "Pick color") {
354
- return (0, import_jsx_dom_cjs.h)("div", { className: "flex flex-col" }, [
355
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" }),
356
- (0, import_jsx_dom_cjs.h)("div", { className: "text-foreground text-sm" }, item.label),
357
- (0, import_jsx_dom_cjs.h)(
358
- "div",
359
- { className: "grid grid-cols-6 gap-x-1 gap-y-2.5 mt-2" },
360
- Object.entries(colors).map(
361
- ([_, colorValue]) => {
362
- var _a;
363
- return (0, import_jsx_dom_cjs.h)("button", {
364
- // @ts-expect-error JSX
365
- type: "button",
366
- className: "grid place-items-center size-6 rounded outline-none ring-offset-2 focus-visible:ring",
367
- style: `background-color:${colorValue.backgroundColor};color:${colorValue.textColor || "inherit"};`,
368
- innerHTML: (_a = colorValue.icon) != null ? _a : `<span class="text-md" style="color:${colorValue.textColor || "inherit"}">A</span>`,
369
- onClick: (e) => {
370
- e.stopPropagation();
371
- onSelectColor(colorValue);
372
- }
373
- });
374
- }
375
- )
376
- ),
377
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" })
378
- ]);
379
- }
380
- return (0, import_jsx_dom_cjs.h)(
381
- "button",
382
- {
383
- // @ts-expect-error JSX
384
- type: "button",
385
- className: "w-full flex items-center gap-2 px-1 py-1.5 bg-background hover:bg-muted text-sm text-foreground rounded",
386
- onClick: (e) => {
387
- e.stopPropagation();
388
- onClickItem(item);
389
- }
390
- },
391
- [
392
- (0, import_jsx_dom_cjs.h)("span", { className: "h-3 w-3 shrink-0", innerHTML: item.icon }),
393
- (0, import_jsx_dom_cjs.h)("div", { className: "label" }, item.label)
394
- ]
395
- );
396
- })
397
- );
398
- }
399
- function createToolbox({
400
- triggerButton,
401
- items,
402
- onSelectColor,
403
- onClickItem,
404
- colors,
405
- appendTo
406
- }) {
407
- if (!triggerButton) {
408
- return null;
409
- }
410
- const content = buildToolboxContent({
411
- items,
412
- onClickItem,
413
- onSelectColor,
414
- colors
415
- });
416
- const pop = new Popover(content, {
417
- reference: triggerButton,
418
- container: appendTo != null ? appendTo : void 0,
419
- placement: "right",
420
- offsetPx: 6,
421
- interactive: true
422
- });
423
- const onTrigger = (e) => {
424
- e.stopPropagation();
425
- pop.toggle();
426
- };
427
- triggerButton.addEventListener("click", onTrigger);
428
- return {
429
- show: () => pop.show(),
430
- hide: () => pop.hide(),
431
- destroy: () => {
432
- pop.destroy();
433
- triggerButton.removeEventListener("click", onTrigger);
434
- }
435
- };
436
- }
437
- var TableView = class {
438
- constructor(node, cellMinWidth, decorations, editor, getPos) {
439
- __publicField(this, "node");
440
- __publicField(this, "cellMinWidth");
441
- __publicField(this, "decorations");
442
- __publicField(this, "editor");
443
- __publicField(this, "getPos");
444
- __publicField(this, "hoveredCell", null);
445
- __publicField(this, "map");
446
- __publicField(this, "root");
447
- __publicField(this, "table");
448
- __publicField(this, "colgroup");
449
- __publicField(this, "tbody");
450
- __publicField(this, "rowsControl");
451
- __publicField(this, "columnsControl");
452
- __publicField(this, "columnsToolbox");
453
- __publicField(this, "rowsToolbox");
454
- __publicField(this, "controls");
455
- var _a, _b, _c, _d;
456
- this.node = node;
457
- this.cellMinWidth = cellMinWidth;
458
- this.decorations = decorations.slice();
459
- this.editor = editor;
460
- this.getPos = getPos;
461
- this.hoveredCell = null;
462
- this.map = import_tables.TableMap.get(node);
463
- if (editor.isEditable) {
464
- this.rowsControl = (0, import_jsx_dom_cjs.h)(
465
- "div",
466
- { className: "rows-control" },
467
- (0, import_jsx_dom_cjs.h)("button", {
468
- // @ts-expect-error JSX
469
- type: "button",
470
- className: "rows-control-div",
471
- onClick: () => this.selectRow(),
472
- "aria-label": "Row actions"
473
- })
474
- );
475
- this.columnsControl = (0, import_jsx_dom_cjs.h)(
476
- "div",
477
- { className: "columns-control" },
478
- (0, import_jsx_dom_cjs.h)("button", {
479
- // @ts-expect-error JSX
480
- type: "button",
481
- className: "columns-control-div",
482
- onClick: () => this.selectColumn(),
483
- "aria-label": "Column actions"
484
- })
485
- );
486
- this.controls = (0, import_jsx_dom_cjs.h)(
487
- "div",
488
- { className: "table-controls", contentEditable: "false" },
489
- this.rowsControl,
490
- this.columnsControl
491
- );
492
- const palette = {
493
- Blue: { backgroundColor: "#D9E4FF", textColor: "#171717" },
494
- Orange: { backgroundColor: "#FFEDD5", textColor: "#171717" },
495
- Grey: { backgroundColor: "#F1F1F1", textColor: "#171717" },
496
- Yellow: { backgroundColor: "#FEF3C7", textColor: "#171717" },
497
- Green: { backgroundColor: "#DCFCE7", textColor: "#171717" },
498
- Red: { backgroundColor: "#FFDDDD", textColor: "#171717" },
499
- Pink: { backgroundColor: "#FFE8FA", textColor: "#171717" },
500
- Purple: { backgroundColor: "#E8DAFB", textColor: "#171717" },
501
- None: {
502
- backgroundColor: "transparent",
503
- textColor: "inherit",
504
- 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>`
505
- }
506
- };
507
- this.columnsToolbox = createToolbox({
508
- triggerButton: (_a = this.columnsControl) == null ? void 0 : _a.querySelector(
509
- ".columns-control-div"
510
- ),
511
- items: columnsToolboxItems,
512
- colors: palette,
513
- appendTo: (_b = this.controls) != null ? _b : null,
514
- onSelectColor: (color) => setCellsBackgroundColor(this.editor, color),
515
- onClickItem: (item) => {
516
- var _a2, _b2;
517
- item.action({
518
- editor: this.editor,
519
- triggerButton: (_a2 = this.columnsControl) == null ? void 0 : _a2.firstElementChild,
520
- controlsContainer: this.controls
521
- });
522
- (_b2 = this.columnsToolbox) == null ? void 0 : _b2.hide();
523
- }
524
- });
525
- this.rowsToolbox = createToolbox({
526
- triggerButton: (_c = this.rowsControl) == null ? void 0 : _c.querySelector(
527
- ".rows-control-div"
528
- ),
529
- items: rowsToolboxItems,
530
- colors: palette,
531
- appendTo: (_d = this.controls) != null ? _d : null,
532
- onSelectColor: (color) => setTableRowBackgroundColor(editor, color),
533
- onClickItem: (item) => {
534
- var _a2, _b2;
535
- item.action({
536
- editor: this.editor,
537
- triggerButton: (_a2 = this.rowsControl) == null ? void 0 : _a2.firstElementChild,
538
- controlsContainer: this.controls
539
- });
540
- (_b2 = this.rowsToolbox) == null ? void 0 : _b2.hide();
541
- }
542
- });
543
- }
544
- this.colgroup = (0, import_jsx_dom_cjs.h)(
545
- "colgroup",
546
- null,
547
- Array.from({ length: this.map.width }, () => 1).map(() => (0, import_jsx_dom_cjs.h)("col"))
548
- );
549
- this.tbody = (0, import_jsx_dom_cjs.h)("tbody");
550
- this.table = (0, import_jsx_dom_cjs.h)(
551
- "table",
552
- null,
553
- this.colgroup,
554
- this.tbody
555
- );
556
- this.root = (0, import_jsx_dom_cjs.h)(
557
- "div",
558
- {
559
- className: "table-wrapper horizontal-scrollbar scrollbar-md controls--disabled"
560
- },
561
- this.controls,
562
- this.table
563
- );
564
- this.render();
565
- }
566
- get dom() {
567
- return this.root;
568
- }
569
- get contentDOM() {
570
- return this.tbody;
571
- }
572
- update(node, decorations) {
573
- if (node.type !== this.node.type) return false;
574
- this.node = node;
575
- this.decorations = [...decorations];
576
- this.map = import_tables.TableMap.get(this.node);
577
- if (this.editor.isEditable) this.updateControls();
578
- this.render();
579
- return true;
580
- }
581
- render() {
582
- if (this.colgroup.children.length !== this.map.width) {
583
- const cols = Array.from({ length: this.map.width }, () => 1).map(
584
- () => (0, import_jsx_dom_cjs.h)("col")
585
- );
586
- this.colgroup.replaceChildren(...cols);
587
- }
588
- (0, import_tables.updateColumnsOnResize)(
589
- this.node,
590
- this.colgroup,
591
- this.table,
592
- this.cellMinWidth
593
- );
594
- }
595
- ignoreMutation() {
596
- return true;
597
- }
598
- updateControls() {
599
- var _a;
600
- const { hoveredTable: table, hoveredCell: cell } = Object.values(
601
- this.decorations
602
- ).reduce(
603
- (acc, curr) => {
604
- if (curr.spec.hoveredCell !== void 0)
605
- acc.hoveredCell = curr.spec.hoveredCell;
606
- if (curr.spec.hoveredTable !== void 0)
607
- acc.hoveredTable = curr.spec.hoveredTable;
608
- return acc;
609
- },
610
- {}
611
- );
612
- if (table === void 0 || cell === void 0) {
613
- this.root.classList.add("controls--disabled");
614
- return;
615
- }
616
- this.root.classList.remove("controls--disabled");
617
- this.hoveredCell = cell;
618
- const cellDom = this.editor.view.nodeDOM(cell.pos);
619
- if (!this.table || !cellDom) return;
620
- const tableRect = this.table.getBoundingClientRect();
621
- const cellRect = cellDom.getBoundingClientRect();
622
- if (this.columnsControl) {
623
- this.columnsControl.style.left = `${cellRect.left - tableRect.left - (((_a = this.table.parentElement) == null ? void 0 : _a.scrollLeft) || 0)}px`;
624
- this.columnsControl.style.width = `${cellRect.width}px`;
625
- }
626
- if (this.rowsControl) {
627
- this.rowsControl.style.top = `${cellRect.top - tableRect.top}px`;
628
- this.rowsControl.style.height = `${cellRect.height}px`;
629
- }
630
- }
631
- selectColumn() {
632
- if (!this.hoveredCell) return;
633
- const colIndex = this.map.colCount(
634
- this.hoveredCell.pos - (this.getPos() + 1)
635
- );
636
- const anchorCellPos = this.hoveredCell.pos;
637
- const headCellPos = this.map.map[colIndex + this.map.width * (this.map.height - 1)] + (this.getPos() + 1);
638
- const cellSelection = import_tables.CellSelection.create(
639
- this.editor.view.state.doc,
640
- anchorCellPos,
641
- headCellPos
642
- );
643
- this.editor.view.dispatch(this.editor.state.tr.setSelection(cellSelection));
644
- }
645
- selectRow() {
646
- if (!this.hoveredCell) return;
647
- const anchorCellPos = this.hoveredCell.pos;
648
- const anchorCellIndex = this.map.map.indexOf(
649
- anchorCellPos - (this.getPos() + 1)
650
- );
651
- const headCellPos = this.map.map[anchorCellIndex + (this.map.width - 1)] + (this.getPos() + 1);
652
- const cellSelection = import_tables.CellSelection.create(
653
- this.editor.state.doc,
654
- anchorCellPos,
655
- headCellPos
656
- );
657
- this.editor.view.dispatch(
658
- this.editor.view.state.tr.setSelection(cellSelection)
659
- );
660
- }
661
- };
662
-
663
- // src/table/utilities/insert-line-above-table-action.ts
664
- var import_editor_utils = require("@kopexa/editor-utils");
665
- var insertLineAboveTableAction = ({
666
- editor
667
- }) => {
668
- if (!editor.isActive("table")) return false;
669
- try {
670
- const { selection } = editor.state;
671
- const tableNode = (0, import_editor_utils.findParentNodeOfType)(selection, "table");
672
- if (!tableNode) return false;
673
- const tablePos = tableNode.pos;
674
- const firstRow = tableNode.node.child(0);
675
- const selectionPath = selection.$anchor.path;
676
- const selectionInFirstRow = selectionPath.includes(firstRow);
677
- if (!selectionInFirstRow) return false;
678
- if (tablePos === 0) {
679
- editor.chain().insertContentAt(tablePos, { type: "paragraph" }).run();
680
- editor.chain().setTextSelection(tablePos + 1).run();
681
- } else {
682
- const prevNodePos = tablePos - 1;
683
- if (prevNodePos <= 0) return false;
684
- const prevNode = editor.state.doc.nodeAt(prevNodePos - 1);
685
- if (prevNode && prevNode.type.name === "paragraph") {
686
- const endOfParagraphPos = tablePos - prevNode.nodeSize;
687
- editor.chain().setTextSelection(endOfParagraphPos).run();
688
- } else {
689
- return false;
690
- }
691
- }
692
- return true;
693
- } catch (e) {
694
- console.error("failed to insert line above table", e);
695
- return false;
696
- }
697
- };
698
-
699
- // src/table/utilities/insert-line-below-table-action.ts
700
- var import_editor_utils2 = require("@kopexa/editor-utils");
701
- var insertLineBelowTableAction = ({
702
- editor
703
- }) => {
704
- if (!editor.isActive("table")) return false;
705
- try {
706
- const { selection } = editor.state;
707
- const tableNode = (0, import_editor_utils2.findParentNodeOfType)(selection, "table");
708
- if (!tableNode) return false;
709
- const tablePos = tableNode.pos;
710
- const table = tableNode.node;
711
- const rowCount = table.childCount;
712
- const lastRow = table.child(rowCount - 1);
713
- const selectionPath = selection.$anchor.path;
714
- const selectionInLastRow = selectionPath.includes(lastRow);
715
- if (!selectionInLastRow) return false;
716
- const nextNodePos = tablePos + table.nodeSize;
717
- const nextNode = editor.state.doc.nodeAt(nextNodePos);
718
- if (nextNode && nextNode.type.name === "paragraph") {
719
- const endOfParagraphPos = nextNodePos + nextNode.nodeSize - 1;
720
- editor.chain().setTextSelection(endOfParagraphPos).run();
721
- } else if (!nextNode) {
722
- editor.chain().insertContentAt(nextNodePos, { type: "paragraph" }).run();
723
- editor.chain().setTextSelection(nextNodePos + 1).run();
724
- } else {
725
- return false;
726
- }
727
- return true;
728
- } catch (e) {
729
- console.error("failed to insert line above table", e);
730
- return false;
731
- }
732
- };
733
-
734
- // src/table/table.ts
735
- var Table = import_extension_table.Table.extend({
736
- addOptions() {
737
- var _a;
738
- return {
739
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
740
- HTMLAttributes: {},
741
- resizable: true,
742
- handleWidth: 5,
743
- cellMinWidth: 100,
744
- lastColumnResizable: true,
745
- allowTableNodeSelection: true,
746
- renderWrapper: true,
747
- View: null
748
- };
749
- },
750
- addKeyboardShortcuts() {
751
- var _a;
752
- return {
753
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
754
- Tab: () => {
755
- if (this.editor.isActive("table")) {
756
- if (this.editor.isActive("listItem") || this.editor.isActive("taskItem")) {
757
- return false;
758
- }
759
- if (this.editor.commands.goToNextCell()) {
760
- return true;
761
- }
762
- if (!this.editor.can().addRowAfter()) {
763
- return false;
764
- }
765
- return this.editor.chain().addRowAfter().goToNextCell().run();
766
- }
767
- return false;
768
- },
769
- ArrowDown: insertLineBelowTableAction,
770
- ArrowUp: insertLineAboveTableAction
771
- };
772
- },
773
- addNodeView() {
774
- return ({ editor, getPos, node, decorations }) => {
775
- const { cellMinWidth } = this.options;
776
- return new TableView(
777
- node,
778
- cellMinWidth,
779
- // biome-ignore lint/suspicious/noExplicitAny: prosemirror
780
- decorations,
781
- editor,
782
- getPos
783
- );
784
- };
785
- },
786
- addProseMirrorPlugins() {
787
- const isResizable = this.options.resizable && this.editor.isEditable;
788
- const plugins = [
789
- (0, import_tables2.tableEditing)({
790
- allowTableNodeSelection: this.options.allowTableNodeSelection
791
- }),
792
- tableControls()
793
- ];
794
- if (isResizable) {
795
- plugins.unshift(
796
- (0, import_tables2.columnResizing)({
797
- handleWidth: this.options.handleWidth,
798
- cellMinWidth: this.options.cellMinWidth,
799
- // View: TableView,
800
- lastColumnResizable: this.options.lastColumnResizable
801
- })
802
- );
803
- }
804
- return plugins;
805
- }
806
- });
807
-
808
- // src/table-cell.ts
809
- var import_core2 = require("@tiptap/core");
810
- var TableCell = import_core2.Node.create({
811
- name: "tableCell",
812
- content: "block+",
813
- // DONT allow table in table.
814
- tableRole: "cell",
815
- isolating: true,
816
- addOptions() {
817
- return {
818
- HTMLAttributes: {}
819
- };
820
- },
821
- parseHTML() {
822
- return [{ tag: "td" }];
823
- },
824
- renderHTML({ node, HTMLAttributes }) {
825
- return [
826
- "td",
827
- (0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
828
- style: `background-color: ${node.attrs.background}; color: ${node.attrs.textColor}`
829
- }),
830
- 0
831
- ];
832
- },
833
- addAttributes() {
834
- return {
835
- colspan: {
836
- default: 1,
837
- parseHTML: (element) => {
838
- const colspan = element.getAttribute("colspan");
839
- const value = colspan ? Number.parseInt(colspan, 10) : 1;
840
- return value;
841
- }
842
- },
843
- rowspan: {
844
- default: 1,
845
- parseHTML: (element) => {
846
- const rowspan = element.getAttribute("rowspan");
847
- const value = rowspan ? Number.parseInt(rowspan, 10) : 1;
848
- return value;
849
- }
850
- },
851
- colwidth: {
852
- default: null,
853
- parseHTML: (element) => {
854
- const colwidth = element.getAttribute("colwidth");
855
- const value = colwidth ? [Number.parseInt(colwidth, 10)] : null;
856
- return value;
857
- }
858
- },
859
- background: {
860
- default: null
861
- },
862
- textColor: {
863
- default: null
864
- },
865
- style: {
866
- default: null
867
- }
868
- };
869
- }
870
- // addProseMirrorPlugins() {
871
- // return [
872
- // new Plugin({
873
- // props: {
874
- // decorations: (state) => {
875
- // const { isEditable } = this.editor;
876
- // if (!isEditable) {
877
- // return DecorationSet.empty;
878
- // }
879
- // const { doc, selection } = state;
880
- // const decorations: Decoration[] = [];
881
- // const cells = getCellsInColumn(0)(selection);
882
- // if (cells) {
883
- // cells.forEach(({ pos }: { pos: number }, index: number) => {
884
- // decorations.push(
885
- // Decoration.widget(pos + 1, () => {
886
- // const rowSelected = isRowSelected(index)(selection);
887
- // let className = "grip-row";
888
- // if (rowSelected) {
889
- // className += " selected";
890
- // }
891
- // if (index === 0) {
892
- // className += " first";
893
- // }
894
- // if (index === cells.length - 1) {
895
- // className += " last";
896
- // }
897
- // const grip = document.createElement("a");
898
- // grip.className = className;
899
- // grip.addEventListener("mousedown", (event) => {
900
- // event.preventDefault();
901
- // event.stopImmediatePropagation();
902
- // this.editor.view.dispatch(
903
- // selectRow(index)(this.editor.state.tr),
904
- // );
905
- // });
906
- // return grip;
907
- // }),
908
- // );
909
- // });
910
- // }
911
- // return DecorationSet.create(doc, decorations);
912
- // },
913
- // },
914
- // }),
915
- // ];
916
- // },
917
- });
918
-
919
- // src/table-header.ts
920
- var import_extension_table2 = require("@tiptap/extension-table");
921
- var TableHeader = import_extension_table2.TableHeader.extend({
922
- addAttributes() {
923
- return {
924
- colspan: {
925
- default: 1
926
- },
927
- rowspan: {
928
- default: 1
929
- },
930
- colwidth: {
931
- default: null,
932
- parseHTML: (element) => {
933
- const colwidth = element.getAttribute("colwidth");
934
- const value = colwidth ? [Number.parseInt(colwidth, 10)] : null;
935
- return value;
936
- }
937
- },
938
- background: {
939
- default: "none"
940
- },
941
- style: {
942
- default: null
943
- }
944
- };
945
- }
946
- // addProseMirrorPlugins() {
947
- // return [
948
- // new Plugin({
949
- // props: {
950
- // decorations: (state) => {
951
- // const { isEditable } = this.editor;
952
- // if (!isEditable) {
953
- // return DecorationSet.empty;
954
- // }
955
- // const { doc, selection } = state;
956
- // const decorations: Decoration[] = [];
957
- // const cells = getCellsInRow(0)(selection);
958
- // if (cells) {
959
- // cells.forEach(({ pos }, index) => {
960
- // decorations.push(
961
- // Decoration.widget(pos + 1, () => {
962
- // const colSelected = isColumnSelected(index)(selection);
963
- // let className = "grip-column";
964
- // if (colSelected) {
965
- // className += " selected";
966
- // }
967
- // if (index === 0) {
968
- // className += " first";
969
- // }
970
- // if (index === cells.length - 1) {
971
- // className += " last";
972
- // }
973
- // const grip = document.createElement("a");
974
- // grip.className = className;
975
- // grip.addEventListener("mousedown", (event) => {
976
- // event.preventDefault();
977
- // event.stopImmediatePropagation();
978
- // this.editor.view.dispatch(
979
- // selectColumn(index)(this.editor.state.tr),
980
- // );
981
- // });
982
- // return grip;
983
- // }),
984
- // );
985
- // });
986
- // }
987
- // return DecorationSet.create(doc, decorations);
988
- // },
989
- // },
990
- // }),
991
- // ];
992
- // },
993
- });
994
-
995
- // src/table-row.ts
996
- var import_extension_table3 = require("@tiptap/extension-table");
997
- var TableRow = import_extension_table3.TableRow.extend({
998
- content: "(tableCell | tableHeader)*"
999
- });
1000
-
1001
- // src/kit.ts
1002
- var TableKit = import_react.Extension.create({
1003
- name: "tableKit",
1004
- addExtensions() {
1005
- const extensions = [];
1006
- if (this.options.table !== false) {
1007
- extensions.push(Table.configure(this.options.table));
1008
- }
1009
- if (this.options.tableCell !== false) {
1010
- extensions.push(TableCell.configure(this.options.tableCell));
1011
- }
1012
- if (this.options.tableHeader !== false) {
1013
- extensions.push(TableHeader.configure(this.options.tableHeader));
1014
- }
1015
- if (this.options.tableRow !== false) {
1016
- extensions.push(TableRow.configure(this.options.tableRow));
1017
- }
1018
- return extensions;
1019
- }
1020
- });
1021
- // Annotate the CommonJS export names for ESM import in node:
1022
- 0 && (module.exports = {
1023
- TableKit
1024
- });