@kopexa/tiptap 1.0.0 → 13.0.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 (213) hide show
  1. package/dist/{chunk-AASYBJDX.mjs → chunk-2SI7MRAE.mjs} +1 -1
  2. package/dist/{chunk-6W7J7PHZ.mjs → chunk-B2DHYFSH.mjs} +6 -7
  3. package/dist/{chunk-RQPJU4UB.mjs → chunk-B7WJOQ3X.mjs} +1 -1
  4. package/dist/{chunk-ACWAVTTK.mjs → chunk-BEV5U2DK.mjs} +6 -6
  5. package/dist/{chunk-TGQP45HH.mjs → chunk-EHY2NAW7.mjs} +1 -3
  6. package/dist/{chunk-O5P45H3I.mjs → chunk-GYIYX2JH.mjs} +1 -1
  7. package/dist/{chunk-QCULSZRZ.mjs → chunk-IOB3REX6.mjs} +1 -3
  8. package/dist/{chunk-ILPDDC4W.mjs → chunk-IQERE7KP.mjs} +1 -4
  9. package/dist/{chunk-6SS62RYU.mjs → chunk-JNL4KY45.mjs} +1 -3
  10. package/dist/{chunk-R2RRQUU5.mjs → chunk-LHXRE26G.mjs} +2 -2
  11. package/dist/{chunk-F2HHFSM4.mjs → chunk-LNVWG34E.mjs} +1 -4
  12. package/dist/chunk-NUCXXNTA.mjs +131 -0
  13. package/dist/{chunk-GLQRF7PR.mjs → chunk-OEVR5N7X.mjs} +2 -10
  14. package/dist/{chunk-YYHNT322.mjs → chunk-OZWCQMRA.mjs} +27 -19
  15. package/dist/{chunk-OX2A52WL.mjs → chunk-Q7DFJ5NI.mjs} +2 -4
  16. package/dist/{chunk-ODBSAQ5V.mjs → chunk-QF3YHPWM.mjs} +2 -4
  17. package/dist/{chunk-R5AMMJTQ.mjs → chunk-REJEJXOZ.mjs} +3 -3
  18. package/dist/chunk-TZQQ6C2Q.mjs +101 -0
  19. package/dist/{chunk-KI3YOPAA.mjs → chunk-UJ4BNZ63.mjs} +1 -4
  20. package/dist/{chunk-4LAWYE7B.mjs → chunk-V6TAZMQN.mjs} +2 -4
  21. package/dist/{chunk-QP2LCU5N.mjs → chunk-VX3HSJ76.mjs} +2 -2
  22. package/dist/{chunk-WCBSINO5.mjs → chunk-W2FLOOJ6.mjs} +1 -1
  23. package/dist/{chunk-JHMEXFB3.mjs → chunk-WHJ4B43N.mjs} +1 -1
  24. package/dist/{chunk-YD56B5SG.mjs → chunk-WPRDVMPN.mjs} +19 -18
  25. package/dist/{chunk-44V2Y6IU.mjs → chunk-XL5FS7LN.mjs} +3 -3
  26. package/dist/{chunk-ZSYXHD7D.mjs → chunk-YJAHZXLG.mjs} +1 -4
  27. package/dist/{chunk-T7LL5ZSR.mjs → chunk-ZVTJ6XD7.mjs} +1 -3
  28. package/dist/{chunk-I7WKP3OM.mjs → chunk-ZZ4OU46C.mjs} +6 -6
  29. package/dist/context/editor-context.d.mts +4 -4
  30. package/dist/context/editor-context.d.ts +4 -4
  31. package/dist/context/editor-context.js +5 -5
  32. package/dist/context/editor-context.mjs +5 -6
  33. package/dist/extensions/link/index.mjs +0 -1
  34. package/dist/extensions/selection/index.mjs +0 -1
  35. package/dist/extensions/trailing-node/index.mjs +0 -1
  36. package/dist/extensions/ui-state/index.mjs +0 -1
  37. package/dist/hooks/use-create-editor.d.mts +16 -5
  38. package/dist/hooks/use-create-editor.d.ts +16 -5
  39. package/dist/hooks/use-create-editor.js +84 -1062
  40. package/dist/hooks/use-create-editor.mjs +5 -18
  41. package/dist/hooks/use-cursor-visibility.mjs +0 -1
  42. package/dist/hooks/use-floating-element.mjs +0 -1
  43. package/dist/hooks/use-floating-toolbar-visibility.mjs +0 -1
  44. package/dist/hooks/use-menu-navigation.mjs +0 -1
  45. package/dist/hooks/use-tiptap-editor.mjs +0 -1
  46. package/dist/hooks/use-ui-editor-state.mjs +0 -1
  47. package/dist/hooks/use-window-size.mjs +0 -1
  48. package/dist/index.d.mts +6 -5
  49. package/dist/index.d.ts +6 -5
  50. package/dist/index.js +483 -1584
  51. package/dist/index.mjs +39 -60
  52. package/dist/presets/basic/editor-header.js +112 -167
  53. package/dist/presets/basic/editor-header.mjs +25 -25
  54. package/dist/presets/basic/index.d.mts +6 -3
  55. package/dist/presets/basic/index.d.ts +6 -3
  56. package/dist/presets/basic/index.js +386 -1468
  57. package/dist/presets/basic/index.mjs +32 -46
  58. package/dist/ui/blockquote-button/blockquote-button.js +12 -67
  59. package/dist/ui/blockquote-button/blockquote-button.mjs +2 -4
  60. package/dist/ui/blockquote-button/index.js +12 -67
  61. package/dist/ui/blockquote-button/index.mjs +2 -4
  62. package/dist/ui/blockquote-button/use-blockquote.js +12 -65
  63. package/dist/ui/blockquote-button/use-blockquote.mjs +1 -3
  64. package/dist/ui/codeblock-button/code-block-button.js +13 -76
  65. package/dist/ui/codeblock-button/code-block-button.mjs +2 -4
  66. package/dist/ui/codeblock-button/index.js +13 -76
  67. package/dist/ui/codeblock-button/index.mjs +2 -4
  68. package/dist/ui/codeblock-button/use-code-block.js +12 -65
  69. package/dist/ui/codeblock-button/use-code-block.mjs +1 -3
  70. package/dist/ui/color-highlight-button/color-highlight-button.js +3 -23
  71. package/dist/ui/color-highlight-button/color-highlight-button.mjs +2 -4
  72. package/dist/ui/color-highlight-button/index.js +3 -23
  73. package/dist/ui/color-highlight-button/index.mjs +2 -4
  74. package/dist/ui/color-highlight-button/use-color-highlight.js +3 -21
  75. package/dist/ui/color-highlight-button/use-color-highlight.mjs +1 -3
  76. package/dist/ui/color-highlight-popover/color-highlight-popover.js +4 -24
  77. package/dist/ui/color-highlight-popover/color-highlight-popover.mjs +3 -5
  78. package/dist/ui/color-highlight-popover/index.js +4 -24
  79. package/dist/ui/color-highlight-popover/index.mjs +3 -5
  80. package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.js +2 -18
  81. package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.mjs +1 -3
  82. package/dist/ui/heading-button/index.js +2 -9
  83. package/dist/ui/heading-button/index.mjs +1 -3
  84. package/dist/ui/heading-button/utils.mjs +0 -1
  85. package/dist/ui/heading-dropdown-menu/index.js +4 -10
  86. package/dist/ui/heading-dropdown-menu/index.mjs +2 -4
  87. package/dist/ui/link-popover/index.js +2 -6
  88. package/dist/ui/link-popover/index.mjs +3 -4
  89. package/dist/ui/link-popover/link-popover.js +2 -6
  90. package/dist/ui/link-popover/link-popover.mjs +3 -4
  91. package/dist/ui/link-popover/use-link-popover.js +2 -6
  92. package/dist/ui/link-popover/use-link-popover.mjs +2 -3
  93. package/dist/ui/list-button/index.js +2 -9
  94. package/dist/ui/list-button/index.mjs +1 -3
  95. package/dist/ui/list-dropdown-menu/index.js +4 -10
  96. package/dist/ui/list-dropdown-menu/index.mjs +2 -4
  97. package/dist/ui/mark-button/index.js +3 -21
  98. package/dist/ui/mark-button/index.mjs +1 -3
  99. package/dist/ui/reset-all-formatting-button/index.mjs +0 -1
  100. package/dist/ui/reset-all-formatting-button/reset-all-formatting-button.mjs +0 -1
  101. package/dist/ui/reset-all-formatting-button/use-reset-all-formatting.mjs +0 -1
  102. package/dist/ui/slash-dropdown-menu/index.js +27 -129
  103. package/dist/ui/slash-dropdown-menu/index.mjs +3 -5
  104. package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +27 -129
  105. package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +3 -5
  106. package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +23 -116
  107. package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.mjs +2 -4
  108. package/dist/ui/suggestion-menu/index.mjs +0 -1
  109. package/dist/ui/suggestion-menu/suggestion-menu-utils.mjs +0 -1
  110. package/dist/ui/suggestion-menu/suggestion-menu.mjs +0 -1
  111. package/dist/ui/table-button/index.js +4 -24
  112. package/dist/ui/table-button/index.mjs +2 -4
  113. package/dist/ui/table-button/use-table.js +3 -21
  114. package/dist/ui/table-button/use-table.mjs +1 -3
  115. package/dist/ui/text-align-button/index.js +3 -32
  116. package/dist/ui/text-align-button/index.mjs +2 -4
  117. package/dist/ui/text-align-button/text-align-button.js +3 -32
  118. package/dist/ui/text-align-button/text-align-button.mjs +2 -4
  119. package/dist/ui/text-align-button/use-text-align.js +3 -30
  120. package/dist/ui/text-align-button/use-text-align.mjs +1 -3
  121. package/dist/ui/undo-redo-button/index.js +2 -18
  122. package/dist/ui/undo-redo-button/index.mjs +2 -4
  123. package/dist/ui/undo-redo-button/undo-redo-button.js +2 -18
  124. package/dist/ui/undo-redo-button/undo-redo-button.mjs +2 -4
  125. package/dist/ui/undo-redo-button/use-undo-redo.js +2 -16
  126. package/dist/ui/undo-redo-button/use-undo-redo.mjs +1 -3
  127. package/dist/utils/index.d.mts +1 -101
  128. package/dist/utils/index.d.ts +1 -101
  129. package/dist/utils/index.js +0 -166
  130. package/dist/utils/index.mjs +1 -28
  131. package/dist/utils/safe-parse.mjs +0 -1
  132. package/package.json +40 -34
  133. package/dist/chunk-4HTILXJM.mjs +0 -104
  134. package/dist/chunk-4IIGLBTD.mjs +0 -81
  135. package/dist/chunk-574UV65T.mjs +0 -111
  136. package/dist/chunk-7HC7D256.mjs +0 -91
  137. package/dist/chunk-AC22DSDA.mjs +0 -540
  138. package/dist/chunk-AGOMESFC.mjs +0 -1
  139. package/dist/chunk-BXPGSCTT.mjs +0 -39
  140. package/dist/chunk-C6M3CDOK.mjs +0 -254
  141. package/dist/chunk-EN3J5AMF.mjs +0 -12
  142. package/dist/chunk-HYDS6H67.mjs +0 -58
  143. package/dist/chunk-KRLE4MMD.mjs +0 -116
  144. package/dist/chunk-LKOQAQPZ.mjs +0 -13
  145. package/dist/chunk-LXZ53XU7.mjs +0 -1
  146. package/dist/chunk-T6P7CS4F.mjs +0 -42
  147. package/dist/chunk-TVFWG7IC.mjs +0 -43
  148. package/dist/chunk-VULWMVYS.mjs +0 -11
  149. package/dist/chunk-WKV76XOR.mjs +0 -8
  150. package/dist/extensions/table/index.d.mts +0 -8
  151. package/dist/extensions/table/index.d.ts +0 -8
  152. package/dist/extensions/table/index.js +0 -1044
  153. package/dist/extensions/table/index.mjs +0 -33
  154. package/dist/extensions/table/kit.d.mts +0 -30
  155. package/dist/extensions/table/kit.d.ts +0 -30
  156. package/dist/extensions/table/kit.js +0 -1034
  157. package/dist/extensions/table/kit.mjs +0 -20
  158. package/dist/extensions/table/table/icons.d.mts +0 -13
  159. package/dist/extensions/table/table/icons.d.ts +0 -13
  160. package/dist/extensions/table/table/icons.js +0 -81
  161. package/dist/extensions/table/table/icons.mjs +0 -8
  162. package/dist/extensions/table/table/index.d.mts +0 -3
  163. package/dist/extensions/table/table/index.d.ts +0 -3
  164. package/dist/extensions/table/table/index.js +0 -818
  165. package/dist/extensions/table/table/index.mjs +0 -16
  166. package/dist/extensions/table/table/table-controls.d.mts +0 -10
  167. package/dist/extensions/table/table/table-controls.d.ts +0 -10
  168. package/dist/extensions/table/table/table-controls.js +0 -129
  169. package/dist/extensions/table/table/table-controls.mjs +0 -8
  170. package/dist/extensions/table/table/table-view.d.mts +0 -43
  171. package/dist/extensions/table/table/table-view.d.ts +0 -43
  172. package/dist/extensions/table/table/table-view.js +0 -610
  173. package/dist/extensions/table/table/table-view.mjs +0 -12
  174. package/dist/extensions/table/table/table.d.mts +0 -17
  175. package/dist/extensions/table/table/table.d.ts +0 -17
  176. package/dist/extensions/table/table/table.js +0 -816
  177. package/dist/extensions/table/table/table.mjs +0 -15
  178. package/dist/extensions/table/table/utilities/col-style.d.mts +0 -3
  179. package/dist/extensions/table/table/utilities/col-style.d.ts +0 -3
  180. package/dist/extensions/table/table/utilities/col-style.js +0 -36
  181. package/dist/extensions/table/table/utilities/col-style.mjs +0 -8
  182. package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.d.mts +0 -5
  183. package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.d.ts +0 -5
  184. package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.js +0 -66
  185. package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.mjs +0 -40
  186. package/dist/extensions/table/table/utilities/get-table-node-types.d.mts +0 -7
  187. package/dist/extensions/table/table/utilities/get-table-node-types.d.ts +0 -7
  188. package/dist/extensions/table/table/utilities/get-table-node-types.js +0 -44
  189. package/dist/extensions/table/table/utilities/get-table-node-types.mjs +0 -21
  190. package/dist/extensions/table/table/utilities/insert-line-above-table-action.d.mts +0 -5
  191. package/dist/extensions/table/table/utilities/insert-line-above-table-action.d.ts +0 -5
  192. package/dist/extensions/table/table/utilities/insert-line-above-table-action.js +0 -80
  193. package/dist/extensions/table/table/utilities/insert-line-above-table-action.mjs +0 -9
  194. package/dist/extensions/table/table/utilities/insert-line-below-table-action.d.mts +0 -5
  195. package/dist/extensions/table/table/utilities/insert-line-below-table-action.d.ts +0 -5
  196. package/dist/extensions/table/table/utilities/insert-line-below-table-action.js +0 -79
  197. package/dist/extensions/table/table/utilities/insert-line-below-table-action.mjs +0 -9
  198. package/dist/extensions/table/table/utilities/is-cell-selection.d.mts +0 -5
  199. package/dist/extensions/table/table/utilities/is-cell-selection.d.ts +0 -5
  200. package/dist/extensions/table/table/utilities/is-cell-selection.js +0 -34
  201. package/dist/extensions/table/table/utilities/is-cell-selection.mjs +0 -8
  202. package/dist/extensions/table/table-cell.d.mts +0 -8
  203. package/dist/extensions/table/table-cell.d.ts +0 -8
  204. package/dist/extensions/table/table-cell.js +0 -139
  205. package/dist/extensions/table/table-cell.mjs +0 -8
  206. package/dist/extensions/table/table-header.d.mts +0 -6
  207. package/dist/extensions/table/table-header.d.ts +0 -6
  208. package/dist/extensions/table/table-header.js +0 -104
  209. package/dist/extensions/table/table-header.mjs +0 -8
  210. package/dist/extensions/table/table-row.d.mts +0 -6
  211. package/dist/extensions/table/table-row.d.ts +0 -6
  212. package/dist/extensions/table/table-row.js +0 -35
  213. package/dist/extensions/table/table-row.mjs +0 -8
@@ -1,818 +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, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = 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 key2 of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key2) && key2 !== except)
16
- __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
- var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
22
-
23
- // src/extensions/table/table/index.ts
24
- var table_exports = {};
25
- __export(table_exports, {
26
- Table: () => Table
27
- });
28
- module.exports = __toCommonJS(table_exports);
29
-
30
- // src/extensions/table/table/table.ts
31
- var import_extension_table = require("@tiptap/extension-table");
32
- var import_tables2 = require("@tiptap/pm/tables");
33
-
34
- // src/extensions/table/table/table-controls.ts
35
- var import_core = require("@tiptap/core");
36
- var import_state = require("@tiptap/pm/state");
37
- var import_view = require("@tiptap/pm/view");
38
- var key = new import_state.PluginKey("tableControls");
39
- function tableControls() {
40
- return new import_state.Plugin({
41
- key,
42
- state: {
43
- init() {
44
- return new TableControlsState();
45
- },
46
- apply(tr, prev) {
47
- return prev.apply(tr);
48
- }
49
- },
50
- props: {
51
- handleDOMEvents: {
52
- mousemove: (view, event) => {
53
- var _a;
54
- const pluginState = key.getState(view.state);
55
- if (!event.target.closest(".table-wrapper") && pluginState.values.hoveredTable) {
56
- return view.dispatch(
57
- view.state.tr.setMeta(key, {
58
- setHoveredTable: null,
59
- setHoveredCell: null
60
- })
61
- );
62
- }
63
- const pos = view.posAtCoords({
64
- left: event.clientX,
65
- top: event.clientY
66
- });
67
- if (!pos || pos.pos < 0 || pos.pos > view.state.doc.content.size)
68
- return;
69
- const table = (0, import_core.findParentNode)((node) => node.type.name === "table")(
70
- import_state.TextSelection.create(view.state.doc, pos.pos)
71
- );
72
- const cell = (0, import_core.findParentNode)(
73
- (node) => node.type.name === "tableCell" || node.type.name === "tableHeader"
74
- )(import_state.TextSelection.create(view.state.doc, pos.pos));
75
- if (!table || !cell) return;
76
- if (((_a = pluginState.values.hoveredCell) == null ? void 0 : _a.pos) !== cell.pos) {
77
- return view.dispatch(
78
- view.state.tr.setMeta(key, {
79
- setHoveredTable: table,
80
- setHoveredCell: cell
81
- })
82
- );
83
- }
84
- }
85
- },
86
- decorations: (state) => {
87
- const pluginState = key.getState(state);
88
- if (!pluginState) {
89
- return null;
90
- }
91
- const { hoveredTable, hoveredCell } = pluginState.values;
92
- const docSize = state.doc.content.size;
93
- if (hoveredTable && hoveredCell && hoveredTable.pos < docSize && hoveredCell.pos < docSize) {
94
- const decorations = [
95
- import_view.Decoration.node(
96
- hoveredTable.pos,
97
- hoveredTable.pos + hoveredTable.node.nodeSize,
98
- {},
99
- {
100
- hoveredTable,
101
- hoveredCell
102
- }
103
- )
104
- ];
105
- return import_view.DecorationSet.create(state.doc, decorations);
106
- }
107
- return null;
108
- }
109
- }
110
- });
111
- }
112
- var TableControlsState = class {
113
- constructor(props = {}) {
114
- __publicField(this, "values");
115
- this.values = {
116
- hoveredTable: null,
117
- hoveredCell: null,
118
- ...props
119
- };
120
- }
121
- apply(tr) {
122
- const actions = tr.getMeta(key);
123
- if ((actions == null ? void 0 : actions.setHoveredTable) !== void 0) {
124
- this.values.hoveredTable = actions.setHoveredTable;
125
- }
126
- if ((actions == null ? void 0 : actions.setHoveredCell) !== void 0) {
127
- this.values.hoveredCell = actions.setHoveredCell;
128
- }
129
- return this;
130
- }
131
- };
132
-
133
- // src/extensions/table/table/table-view.tsx
134
- var import_dom = require("@floating-ui/dom");
135
- var import_tables = require("@tiptap/pm/tables");
136
- var import_jsx_dom_cjs = require("jsx-dom-cjs");
137
-
138
- // src/extensions/table/table/icons.ts
139
- var icons = {
140
- 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>`,
141
- 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>`,
142
- 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>`,
143
- insertLeftTableIcon: `<svg
144
- xmlns="http://www.w3.org/2000/svg"
145
- length={12}
146
- viewBox="0 -960 960 960"
147
- >
148
- <path
149
- 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"
150
- fill="rgb(var(--color-text-300))"
151
- />
152
- </svg>
153
- `,
154
- insertRightTableIcon: `<svg
155
- xmlns="http://www.w3.org/2000/svg"
156
- length={12}
157
- viewBox="0 -960 960 960"
158
- >
159
- <path
160
- 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"
161
- fill="rgb(var(--color-text-300))"
162
- />
163
- </svg>
164
- `,
165
- insertTopTableIcon: `<svg
166
- xmlns="http://www.w3.org/2000/svg"
167
- length={24}
168
- viewBox="0 -960 960 960"
169
- >
170
- <path
171
- 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"
172
- fill="rgb(var(--color-text-300))"
173
- />
174
- </svg>
175
- `,
176
- 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>`,
177
- 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>`,
178
- insertBottomTableIcon: `<svg
179
- xmlns="http://www.w3.org/2000/svg"
180
- length={24}
181
- viewBox="0 -960 960 960"
182
- >
183
- <path
184
- 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"
185
- fill="rgb(var(--color-text-300))"
186
- />
187
- </svg>
188
- `
189
- };
190
-
191
- // src/extensions/table/table/table-view.tsx
192
- var Popover = class {
193
- constructor(content, opts) {
194
- __publicField(this, "reference");
195
- __publicField(this, "floating");
196
- __publicField(this, "cleanupAutoUpdate", null);
197
- __publicField(this, "onDocClick", (e) => {
198
- if (!this.floating.contains(e.target) && !this.reference.contains(e.target)) {
199
- this.hide();
200
- }
201
- });
202
- __publicField(this, "onEsc", (e) => {
203
- if (e.key === "Escape") this.hide();
204
- });
205
- __publicField(this, "_placement");
206
- __publicField(this, "_offsetPx");
207
- // biome-ignore lint/correctness/noUnusedPrivateClassMembers: backwards. will be used later
208
- __publicField(this, "_interactive");
209
- var _a, _b, _c, _d;
210
- this.reference = opts.reference;
211
- this.floating = document.createElement("div");
212
- this.floating.setAttribute("role", "dialog");
213
- this.floating.setAttribute("aria-modal", "false");
214
- this.floating.style.position = "fixed";
215
- this.floating.style.zIndex = "9999";
216
- this.floating.style.display = "none";
217
- this.floating.className = "rounded-md border bg-background px-2 py-2.5 text-xs shadow-sm min-w-[12rem] whitespace-nowrap";
218
- this.floating.appendChild(content);
219
- const host = (_a = opts.container) != null ? _a : document.body;
220
- host.appendChild(this.floating);
221
- this._placement = (_b = opts.placement) != null ? _b : "right";
222
- this._offsetPx = (_c = opts.offsetPx) != null ? _c : 6;
223
- this._interactive = (_d = opts.interactive) != null ? _d : true;
224
- }
225
- async _updatePosition() {
226
- const { x, y } = await (0, import_dom.computePosition)(this.reference, this.floating, {
227
- placement: this._placement,
228
- middleware: [(0, import_dom.offset)(this._offsetPx), (0, import_dom.flip)(), (0, import_dom.shift)({ padding: 8 })]
229
- });
230
- Object.assign(this.floating.style, { left: `${x}px`, top: `${y}px` });
231
- }
232
- show() {
233
- if (this.floating.style.display !== "none") return;
234
- this.floating.style.display = "block";
235
- this.cleanupAutoUpdate = (0, import_dom.autoUpdate)(
236
- this.reference,
237
- this.floating,
238
- () => this._updatePosition()
239
- );
240
- document.addEventListener("keydown", this.onEsc, { passive: true });
241
- document.addEventListener("mousedown", this.onDocClick, { capture: true });
242
- requestAnimationFrame(() => this._updatePosition());
243
- }
244
- hide() {
245
- var _a;
246
- if (this.floating.style.display === "none") return;
247
- this.floating.style.display = "none";
248
- (_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
249
- this.cleanupAutoUpdate = null;
250
- document.removeEventListener("keydown", this.onEsc);
251
- document.removeEventListener("mousedown", this.onDocClick, {
252
- capture: true
253
- });
254
- }
255
- toggle() {
256
- if (this.floating.style.display === "none") this.show();
257
- else this.hide();
258
- }
259
- destroy() {
260
- this.hide();
261
- this.floating.remove();
262
- }
263
- get el() {
264
- return this.floating;
265
- }
266
- };
267
- function setCellsBackgroundColor(editor, color) {
268
- return editor.chain().focus().updateAttributes("tableCell", {
269
- background: color.backgroundColor,
270
- textColor: color.textColor
271
- }).run();
272
- }
273
- function setTableRowBackgroundColor(editor, color) {
274
- const { state, dispatch } = editor.view;
275
- const { selection } = state;
276
- if (!(selection instanceof import_tables.CellSelection)) return false;
277
- const hoveredCell = selection.$headCell || selection.$anchorCell;
278
- let rowDepth = hoveredCell.depth;
279
- while (rowDepth > 0 && hoveredCell.node(rowDepth).type.name !== "tableRow") {
280
- rowDepth--;
281
- }
282
- if (hoveredCell.node(rowDepth).type.name !== "tableRow") return false;
283
- const rowStartPos = hoveredCell.start(rowDepth);
284
- const tr = state.tr.setNodeMarkup(rowStartPos - 1, null, {
285
- ...hoveredCell.node(rowDepth).attrs,
286
- background: color.backgroundColor,
287
- textColor: color.textColor
288
- });
289
- dispatch(tr);
290
- return true;
291
- }
292
- var columnsToolboxItems = [
293
- {
294
- label: "Toggle column header",
295
- icon: icons.toggleColumnHeader,
296
- action: ({ editor }) => editor.chain().focus().toggleHeaderColumn().run()
297
- },
298
- {
299
- label: "Add column before",
300
- icon: icons.insertLeftTableIcon,
301
- action: ({ editor }) => editor.chain().focus().addColumnBefore().run()
302
- },
303
- {
304
- label: "Add column after",
305
- icon: icons.insertRightTableIcon,
306
- action: ({ editor }) => editor.chain().focus().addColumnAfter().run()
307
- },
308
- { label: "Pick color", icon: "", action: () => {
309
- } },
310
- {
311
- label: "Delete column",
312
- icon: icons.deleteColumn,
313
- action: ({ editor }) => editor.chain().focus().deleteColumn().run()
314
- }
315
- ];
316
- var rowsToolboxItems = [
317
- {
318
- label: "Toggle row header",
319
- icon: icons.toggleRowHeader,
320
- action: ({ editor }) => editor.chain().focus().toggleHeaderRow().run()
321
- },
322
- {
323
- label: "Add row above",
324
- icon: icons.insertTopTableIcon,
325
- action: ({ editor }) => editor.chain().focus().addRowBefore().run()
326
- },
327
- {
328
- label: "Add row below",
329
- icon: icons.insertBottomTableIcon,
330
- action: ({ editor }) => editor.chain().focus().addRowAfter().run()
331
- },
332
- { label: "Pick color", icon: "", action: () => {
333
- } },
334
- {
335
- label: "Delete row",
336
- icon: icons.deleteRow,
337
- action: ({ editor }) => editor.chain().focus().deleteRow().run()
338
- }
339
- ];
340
- function buildToolboxContent({
341
- items,
342
- onClickItem,
343
- onSelectColor,
344
- colors
345
- }) {
346
- return (0, import_jsx_dom_cjs.h)(
347
- "div",
348
- { className: "space-y-2" },
349
- items.map((item) => {
350
- if (item.label === "Pick color") {
351
- return (0, import_jsx_dom_cjs.h)("div", { className: "flex flex-col" }, [
352
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" }),
353
- (0, import_jsx_dom_cjs.h)("div", { className: "text-foreground text-sm" }, item.label),
354
- (0, import_jsx_dom_cjs.h)(
355
- "div",
356
- { className: "grid grid-cols-6 gap-x-1 gap-y-2.5 mt-2" },
357
- Object.entries(colors).map(
358
- ([_, colorValue]) => {
359
- var _a;
360
- return (0, import_jsx_dom_cjs.h)("button", {
361
- // @ts-expect-error JSX
362
- type: "button",
363
- className: "grid place-items-center size-6 rounded outline-none ring-offset-2 focus-visible:ring",
364
- style: `background-color:${colorValue.backgroundColor};color:${colorValue.textColor || "inherit"};`,
365
- innerHTML: (_a = colorValue.icon) != null ? _a : `<span class="text-md" style="color:${colorValue.textColor || "inherit"}">A</span>`,
366
- onClick: (e) => {
367
- e.stopPropagation();
368
- onSelectColor(colorValue);
369
- }
370
- });
371
- }
372
- )
373
- ),
374
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" })
375
- ]);
376
- }
377
- return (0, import_jsx_dom_cjs.h)(
378
- "button",
379
- {
380
- // @ts-expect-error JSX
381
- type: "button",
382
- className: "w-full flex items-center gap-2 px-1 py-1.5 bg-background hover:bg-muted text-sm text-foreground rounded",
383
- onClick: (e) => {
384
- e.stopPropagation();
385
- onClickItem(item);
386
- }
387
- },
388
- [
389
- (0, import_jsx_dom_cjs.h)("span", { className: "h-3 w-3 shrink-0", innerHTML: item.icon }),
390
- (0, import_jsx_dom_cjs.h)("div", { className: "label" }, item.label)
391
- ]
392
- );
393
- })
394
- );
395
- }
396
- function createToolbox({
397
- triggerButton,
398
- items,
399
- onSelectColor,
400
- onClickItem,
401
- colors,
402
- appendTo
403
- }) {
404
- if (!triggerButton) {
405
- return null;
406
- }
407
- const content = buildToolboxContent({
408
- items,
409
- onClickItem,
410
- onSelectColor,
411
- colors
412
- });
413
- const pop = new Popover(content, {
414
- reference: triggerButton,
415
- container: appendTo != null ? appendTo : void 0,
416
- placement: "right",
417
- offsetPx: 6,
418
- interactive: true
419
- });
420
- const onTrigger = (e) => {
421
- e.stopPropagation();
422
- pop.toggle();
423
- };
424
- triggerButton.addEventListener("click", onTrigger);
425
- return {
426
- show: () => pop.show(),
427
- hide: () => pop.hide(),
428
- destroy: () => {
429
- pop.destroy();
430
- triggerButton.removeEventListener("click", onTrigger);
431
- }
432
- };
433
- }
434
- var TableView = class {
435
- constructor(node, cellMinWidth, decorations, editor, getPos) {
436
- __publicField(this, "node");
437
- __publicField(this, "cellMinWidth");
438
- __publicField(this, "decorations");
439
- __publicField(this, "editor");
440
- __publicField(this, "getPos");
441
- __publicField(this, "hoveredCell", null);
442
- __publicField(this, "map");
443
- __publicField(this, "root");
444
- __publicField(this, "table");
445
- __publicField(this, "colgroup");
446
- __publicField(this, "tbody");
447
- __publicField(this, "rowsControl");
448
- __publicField(this, "columnsControl");
449
- __publicField(this, "columnsToolbox");
450
- __publicField(this, "rowsToolbox");
451
- __publicField(this, "controls");
452
- var _a, _b, _c, _d;
453
- this.node = node;
454
- this.cellMinWidth = cellMinWidth;
455
- this.decorations = decorations.slice();
456
- this.editor = editor;
457
- this.getPos = getPos;
458
- this.hoveredCell = null;
459
- this.map = import_tables.TableMap.get(node);
460
- if (editor.isEditable) {
461
- this.rowsControl = (0, import_jsx_dom_cjs.h)(
462
- "div",
463
- { className: "rows-control" },
464
- (0, import_jsx_dom_cjs.h)("button", {
465
- // @ts-expect-error JSX
466
- type: "button",
467
- className: "rows-control-div",
468
- onClick: () => this.selectRow(),
469
- "aria-label": "Row actions"
470
- })
471
- );
472
- this.columnsControl = (0, import_jsx_dom_cjs.h)(
473
- "div",
474
- { className: "columns-control" },
475
- (0, import_jsx_dom_cjs.h)("button", {
476
- // @ts-expect-error JSX
477
- type: "button",
478
- className: "columns-control-div",
479
- onClick: () => this.selectColumn(),
480
- "aria-label": "Column actions"
481
- })
482
- );
483
- this.controls = (0, import_jsx_dom_cjs.h)(
484
- "div",
485
- { className: "table-controls", contentEditable: "false" },
486
- this.rowsControl,
487
- this.columnsControl
488
- );
489
- const palette = {
490
- Blue: { backgroundColor: "#D9E4FF", textColor: "#171717" },
491
- Orange: { backgroundColor: "#FFEDD5", textColor: "#171717" },
492
- Grey: { backgroundColor: "#F1F1F1", textColor: "#171717" },
493
- Yellow: { backgroundColor: "#FEF3C7", textColor: "#171717" },
494
- Green: { backgroundColor: "#DCFCE7", textColor: "#171717" },
495
- Red: { backgroundColor: "#FFDDDD", textColor: "#171717" },
496
- Pink: { backgroundColor: "#FFE8FA", textColor: "#171717" },
497
- Purple: { backgroundColor: "#E8DAFB", textColor: "#171717" },
498
- None: {
499
- backgroundColor: "transparent",
500
- textColor: "inherit",
501
- 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>`
502
- }
503
- };
504
- this.columnsToolbox = createToolbox({
505
- triggerButton: (_a = this.columnsControl) == null ? void 0 : _a.querySelector(
506
- ".columns-control-div"
507
- ),
508
- items: columnsToolboxItems,
509
- colors: palette,
510
- appendTo: (_b = this.controls) != null ? _b : null,
511
- onSelectColor: (color) => setCellsBackgroundColor(this.editor, color),
512
- onClickItem: (item) => {
513
- var _a2, _b2;
514
- item.action({
515
- editor: this.editor,
516
- triggerButton: (_a2 = this.columnsControl) == null ? void 0 : _a2.firstElementChild,
517
- controlsContainer: this.controls
518
- });
519
- (_b2 = this.columnsToolbox) == null ? void 0 : _b2.hide();
520
- }
521
- });
522
- this.rowsToolbox = createToolbox({
523
- triggerButton: (_c = this.rowsControl) == null ? void 0 : _c.querySelector(
524
- ".rows-control-div"
525
- ),
526
- items: rowsToolboxItems,
527
- colors: palette,
528
- appendTo: (_d = this.controls) != null ? _d : null,
529
- onSelectColor: (color) => setTableRowBackgroundColor(editor, color),
530
- onClickItem: (item) => {
531
- var _a2, _b2;
532
- item.action({
533
- editor: this.editor,
534
- triggerButton: (_a2 = this.rowsControl) == null ? void 0 : _a2.firstElementChild,
535
- controlsContainer: this.controls
536
- });
537
- (_b2 = this.rowsToolbox) == null ? void 0 : _b2.hide();
538
- }
539
- });
540
- }
541
- this.colgroup = (0, import_jsx_dom_cjs.h)(
542
- "colgroup",
543
- null,
544
- Array.from({ length: this.map.width }, () => 1).map(() => (0, import_jsx_dom_cjs.h)("col"))
545
- );
546
- this.tbody = (0, import_jsx_dom_cjs.h)("tbody");
547
- this.table = (0, import_jsx_dom_cjs.h)(
548
- "table",
549
- null,
550
- this.colgroup,
551
- this.tbody
552
- );
553
- this.root = (0, import_jsx_dom_cjs.h)(
554
- "div",
555
- {
556
- className: "table-wrapper horizontal-scrollbar scrollbar-md controls--disabled"
557
- },
558
- this.controls,
559
- this.table
560
- );
561
- this.render();
562
- }
563
- get dom() {
564
- return this.root;
565
- }
566
- get contentDOM() {
567
- return this.tbody;
568
- }
569
- update(node, decorations) {
570
- if (node.type !== this.node.type) return false;
571
- this.node = node;
572
- this.decorations = [...decorations];
573
- this.map = import_tables.TableMap.get(this.node);
574
- if (this.editor.isEditable) this.updateControls();
575
- this.render();
576
- return true;
577
- }
578
- render() {
579
- if (this.colgroup.children.length !== this.map.width) {
580
- const cols = Array.from({ length: this.map.width }, () => 1).map(
581
- () => (0, import_jsx_dom_cjs.h)("col")
582
- );
583
- this.colgroup.replaceChildren(...cols);
584
- }
585
- (0, import_tables.updateColumnsOnResize)(
586
- this.node,
587
- this.colgroup,
588
- this.table,
589
- this.cellMinWidth
590
- );
591
- }
592
- ignoreMutation() {
593
- return true;
594
- }
595
- updateControls() {
596
- var _a;
597
- const { hoveredTable: table, hoveredCell: cell } = Object.values(
598
- this.decorations
599
- ).reduce(
600
- (acc, curr) => {
601
- if (curr.spec.hoveredCell !== void 0)
602
- acc.hoveredCell = curr.spec.hoveredCell;
603
- if (curr.spec.hoveredTable !== void 0)
604
- acc.hoveredTable = curr.spec.hoveredTable;
605
- return acc;
606
- },
607
- {}
608
- );
609
- if (table === void 0 || cell === void 0) {
610
- this.root.classList.add("controls--disabled");
611
- return;
612
- }
613
- this.root.classList.remove("controls--disabled");
614
- this.hoveredCell = cell;
615
- const cellDom = this.editor.view.nodeDOM(cell.pos);
616
- if (!this.table || !cellDom) return;
617
- const tableRect = this.table.getBoundingClientRect();
618
- const cellRect = cellDom.getBoundingClientRect();
619
- if (this.columnsControl) {
620
- this.columnsControl.style.left = `${cellRect.left - tableRect.left - (((_a = this.table.parentElement) == null ? void 0 : _a.scrollLeft) || 0)}px`;
621
- this.columnsControl.style.width = `${cellRect.width}px`;
622
- }
623
- if (this.rowsControl) {
624
- this.rowsControl.style.top = `${cellRect.top - tableRect.top}px`;
625
- this.rowsControl.style.height = `${cellRect.height}px`;
626
- }
627
- }
628
- selectColumn() {
629
- if (!this.hoveredCell) return;
630
- const colIndex = this.map.colCount(
631
- this.hoveredCell.pos - (this.getPos() + 1)
632
- );
633
- const anchorCellPos = this.hoveredCell.pos;
634
- const headCellPos = this.map.map[colIndex + this.map.width * (this.map.height - 1)] + (this.getPos() + 1);
635
- const cellSelection = import_tables.CellSelection.create(
636
- this.editor.view.state.doc,
637
- anchorCellPos,
638
- headCellPos
639
- );
640
- this.editor.view.dispatch(this.editor.state.tr.setSelection(cellSelection));
641
- }
642
- selectRow() {
643
- if (!this.hoveredCell) return;
644
- const anchorCellPos = this.hoveredCell.pos;
645
- const anchorCellIndex = this.map.map.indexOf(
646
- anchorCellPos - (this.getPos() + 1)
647
- );
648
- const headCellPos = this.map.map[anchorCellIndex + (this.map.width - 1)] + (this.getPos() + 1);
649
- const cellSelection = import_tables.CellSelection.create(
650
- this.editor.state.doc,
651
- anchorCellPos,
652
- headCellPos
653
- );
654
- this.editor.view.dispatch(
655
- this.editor.view.state.tr.setSelection(cellSelection)
656
- );
657
- }
658
- };
659
-
660
- // src/utils/index.ts
661
- var import_state2 = require("@tiptap/pm/state");
662
- var MAX_FILE_SIZE = 5 * 1024 * 1024;
663
- function findParentNodeOfType(selection, typeName) {
664
- let depth = selection.$anchor.depth;
665
- while (depth > 0) {
666
- const node = selection.$anchor.node(depth);
667
- if (node.type.name === typeName) {
668
- return { node, pos: selection.$anchor.start(depth) - 1 };
669
- }
670
- depth--;
671
- }
672
- return null;
673
- }
674
-
675
- // src/extensions/table/table/utilities/insert-line-above-table-action.ts
676
- var insertLineAboveTableAction = ({
677
- editor
678
- }) => {
679
- if (!editor.isActive("table")) return false;
680
- try {
681
- const { selection } = editor.state;
682
- const tableNode = findParentNodeOfType(selection, "table");
683
- if (!tableNode) return false;
684
- const tablePos = tableNode.pos;
685
- const firstRow = tableNode.node.child(0);
686
- const selectionPath = selection.$anchor.path;
687
- const selectionInFirstRow = selectionPath.includes(firstRow);
688
- if (!selectionInFirstRow) return false;
689
- if (tablePos === 0) {
690
- editor.chain().insertContentAt(tablePos, { type: "paragraph" }).run();
691
- editor.chain().setTextSelection(tablePos + 1).run();
692
- } else {
693
- const prevNodePos = tablePos - 1;
694
- if (prevNodePos <= 0) return false;
695
- const prevNode = editor.state.doc.nodeAt(prevNodePos - 1);
696
- if (prevNode && prevNode.type.name === "paragraph") {
697
- const endOfParagraphPos = tablePos - prevNode.nodeSize;
698
- editor.chain().setTextSelection(endOfParagraphPos).run();
699
- } else {
700
- return false;
701
- }
702
- }
703
- return true;
704
- } catch (e) {
705
- console.error("failed to insert line above table", e);
706
- return false;
707
- }
708
- };
709
-
710
- // src/extensions/table/table/utilities/insert-line-below-table-action.ts
711
- var insertLineBelowTableAction = ({
712
- editor
713
- }) => {
714
- if (!editor.isActive("table")) return false;
715
- try {
716
- const { selection } = editor.state;
717
- const tableNode = findParentNodeOfType(selection, "table");
718
- if (!tableNode) return false;
719
- const tablePos = tableNode.pos;
720
- const table = tableNode.node;
721
- const rowCount = table.childCount;
722
- const lastRow = table.child(rowCount - 1);
723
- const selectionPath = selection.$anchor.path;
724
- const selectionInLastRow = selectionPath.includes(lastRow);
725
- if (!selectionInLastRow) return false;
726
- const nextNodePos = tablePos + table.nodeSize;
727
- const nextNode = editor.state.doc.nodeAt(nextNodePos);
728
- if (nextNode && nextNode.type.name === "paragraph") {
729
- const endOfParagraphPos = nextNodePos + nextNode.nodeSize - 1;
730
- editor.chain().setTextSelection(endOfParagraphPos).run();
731
- } else if (!nextNode) {
732
- editor.chain().insertContentAt(nextNodePos, { type: "paragraph" }).run();
733
- editor.chain().setTextSelection(nextNodePos + 1).run();
734
- } else {
735
- return false;
736
- }
737
- return true;
738
- } catch (e) {
739
- console.error("failed to insert line above table", e);
740
- return false;
741
- }
742
- };
743
-
744
- // src/extensions/table/table/table.ts
745
- var Table = import_extension_table.Table.extend({
746
- addOptions() {
747
- var _a;
748
- return {
749
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
750
- HTMLAttributes: {},
751
- resizable: true,
752
- handleWidth: 5,
753
- cellMinWidth: 100,
754
- lastColumnResizable: true,
755
- allowTableNodeSelection: true
756
- };
757
- },
758
- addKeyboardShortcuts() {
759
- var _a;
760
- return {
761
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
762
- Tab: () => {
763
- if (this.editor.isActive("table")) {
764
- if (this.editor.isActive("listItem") || this.editor.isActive("taskItem")) {
765
- return false;
766
- }
767
- if (this.editor.commands.goToNextCell()) {
768
- return true;
769
- }
770
- if (!this.editor.can().addRowAfter()) {
771
- return false;
772
- }
773
- return this.editor.chain().addRowAfter().goToNextCell().run();
774
- }
775
- return false;
776
- },
777
- ArrowDown: insertLineBelowTableAction,
778
- ArrowUp: insertLineAboveTableAction
779
- };
780
- },
781
- addNodeView() {
782
- return ({ editor, getPos, node, decorations }) => {
783
- const { cellMinWidth } = this.options;
784
- return new TableView(
785
- node,
786
- cellMinWidth,
787
- // biome-ignore lint/suspicious/noExplicitAny: prosemirror
788
- decorations,
789
- editor,
790
- getPos
791
- );
792
- };
793
- },
794
- addProseMirrorPlugins() {
795
- const isResizable = this.options.resizable && this.editor.isEditable;
796
- const plugins = [
797
- (0, import_tables2.tableEditing)({
798
- allowTableNodeSelection: this.options.allowTableNodeSelection
799
- }),
800
- tableControls()
801
- ];
802
- if (isResizable) {
803
- plugins.unshift(
804
- (0, import_tables2.columnResizing)({
805
- handleWidth: this.options.handleWidth,
806
- cellMinWidth: this.options.cellMinWidth,
807
- // View: TableView,
808
- lastColumnResizable: this.options.lastColumnResizable
809
- })
810
- );
811
- }
812
- return plugins;
813
- }
814
- });
815
- // Annotate the CommonJS export names for ESM import in node:
816
- 0 && (module.exports = {
817
- Table
818
- });