@kopexa/tiptap 1.0.0 → 2.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 +36 -30
  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
@@ -7,16 +7,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
8
  var __getProtoOf = Object.getPrototypeOf;
9
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
11
10
  var __export = (target, all) => {
12
11
  for (var name in all)
13
12
  __defProp(target, name, { get: all[name], enumerable: true });
14
13
  };
15
14
  var __copyProps = (to, from, except, desc) => {
16
15
  if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key2 of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key2) && key2 !== except)
19
- __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
19
  }
21
20
  return to;
22
21
  };
@@ -29,7 +28,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
28
  mod
30
29
  ));
31
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
33
31
 
34
32
  // src/presets/basic/index.tsx
35
33
  var basic_exports = {};
@@ -38,25 +36,29 @@ __export(basic_exports, {
38
36
  });
39
37
  module.exports = __toCommonJS(basic_exports);
40
38
  var import_theme3 = require("@kopexa/theme");
41
- var import_react32 = require("@tiptap/react");
42
- var import_react33 = require("react");
39
+ var import_react31 = require("@tiptap/react");
40
+ var import_react32 = require("react");
43
41
 
44
42
  // src/context/editor-context.ts
45
43
  var import_react_utils = require("@kopexa/react-utils");
46
- var [EditorWrapperProvider, useEditorWrapper] = (0, import_react_utils.createContext)();
44
+ var [EditorUIProvider, useEditorUIContext] = (0, import_react_utils.createContext)();
47
45
 
48
46
  // src/hooks/use-create-editor.ts
47
+ var import_extension_code = require("@kopexa/extension-code");
49
48
  var import_extension_controlref = require("@kopexa/extension-controlref");
49
+ var import_extension_table = require("@kopexa/extension-table");
50
50
  var import_extension_highlight = require("@tiptap/extension-highlight");
51
+ var import_extension_invisible_characters = __toESM(require("@tiptap/extension-invisible-characters"));
52
+ var import_extension_list = require("@tiptap/extension-list");
51
53
  var import_extension_subscript = require("@tiptap/extension-subscript");
52
54
  var import_extension_superscript = require("@tiptap/extension-superscript");
53
- var import_extension_task_item = require("@tiptap/extension-task-item");
54
- var import_extension_task_list = require("@tiptap/extension-task-list");
55
+ var import_extension_table_of_contents = require("@tiptap/extension-table-of-contents");
55
56
  var import_extension_text_align = require("@tiptap/extension-text-align");
57
+ var import_extension_text_style = require("@tiptap/extension-text-style");
56
58
  var import_extension_typography = require("@tiptap/extension-typography");
57
59
  var import_extension_unique_id = require("@tiptap/extension-unique-id");
58
60
  var import_extensions = require("@tiptap/extensions");
59
- var import_react5 = require("@tiptap/react");
61
+ var import_react4 = require("@tiptap/react");
60
62
  var import_starter_kit = require("@tiptap/starter-kit");
61
63
 
62
64
  // src/extensions/link/index.ts
@@ -149,1174 +151,9 @@ var Selection = import_react2.Extension.create({
149
151
  }
150
152
  });
151
153
 
152
- // src/extensions/table/kit.ts
153
- var import_react3 = require("@tiptap/react");
154
-
155
- // src/extensions/table/table/table.ts
156
- var import_extension_table = require("@tiptap/extension-table");
157
- var import_tables2 = require("@tiptap/pm/tables");
158
-
159
- // src/extensions/table/table/table-controls.ts
160
- var import_core = require("@tiptap/core");
161
- var import_state3 = require("@tiptap/pm/state");
162
- var import_view2 = require("@tiptap/pm/view");
163
- var key = new import_state3.PluginKey("tableControls");
164
- function tableControls() {
165
- return new import_state3.Plugin({
166
- key,
167
- state: {
168
- init() {
169
- return new TableControlsState();
170
- },
171
- apply(tr, prev) {
172
- return prev.apply(tr);
173
- }
174
- },
175
- props: {
176
- handleDOMEvents: {
177
- mousemove: (view, event) => {
178
- var _a;
179
- const pluginState = key.getState(view.state);
180
- if (!event.target.closest(".table-wrapper") && pluginState.values.hoveredTable) {
181
- return view.dispatch(
182
- view.state.tr.setMeta(key, {
183
- setHoveredTable: null,
184
- setHoveredCell: null
185
- })
186
- );
187
- }
188
- const pos = view.posAtCoords({
189
- left: event.clientX,
190
- top: event.clientY
191
- });
192
- if (!pos || pos.pos < 0 || pos.pos > view.state.doc.content.size)
193
- return;
194
- const table = (0, import_core.findParentNode)((node) => node.type.name === "table")(
195
- import_state3.TextSelection.create(view.state.doc, pos.pos)
196
- );
197
- const cell = (0, import_core.findParentNode)(
198
- (node) => node.type.name === "tableCell" || node.type.name === "tableHeader"
199
- )(import_state3.TextSelection.create(view.state.doc, pos.pos));
200
- if (!table || !cell) return;
201
- if (((_a = pluginState.values.hoveredCell) == null ? void 0 : _a.pos) !== cell.pos) {
202
- return view.dispatch(
203
- view.state.tr.setMeta(key, {
204
- setHoveredTable: table,
205
- setHoveredCell: cell
206
- })
207
- );
208
- }
209
- }
210
- },
211
- decorations: (state) => {
212
- const pluginState = key.getState(state);
213
- if (!pluginState) {
214
- return null;
215
- }
216
- const { hoveredTable, hoveredCell } = pluginState.values;
217
- const docSize = state.doc.content.size;
218
- if (hoveredTable && hoveredCell && hoveredTable.pos < docSize && hoveredCell.pos < docSize) {
219
- const decorations = [
220
- import_view2.Decoration.node(
221
- hoveredTable.pos,
222
- hoveredTable.pos + hoveredTable.node.nodeSize,
223
- {},
224
- {
225
- hoveredTable,
226
- hoveredCell
227
- }
228
- )
229
- ];
230
- return import_view2.DecorationSet.create(state.doc, decorations);
231
- }
232
- return null;
233
- }
234
- }
235
- });
236
- }
237
- var TableControlsState = class {
238
- constructor(props = {}) {
239
- __publicField(this, "values");
240
- this.values = {
241
- hoveredTable: null,
242
- hoveredCell: null,
243
- ...props
244
- };
245
- }
246
- apply(tr) {
247
- const actions = tr.getMeta(key);
248
- if ((actions == null ? void 0 : actions.setHoveredTable) !== void 0) {
249
- this.values.hoveredTable = actions.setHoveredTable;
250
- }
251
- if ((actions == null ? void 0 : actions.setHoveredCell) !== void 0) {
252
- this.values.hoveredCell = actions.setHoveredCell;
253
- }
254
- return this;
255
- }
256
- };
257
-
258
- // src/extensions/table/table/table-view.tsx
259
- var import_dom = require("@floating-ui/dom");
260
- var import_tables = require("@tiptap/pm/tables");
261
- var import_jsx_dom_cjs = require("jsx-dom-cjs");
262
-
263
- // src/extensions/table/table/icons.ts
264
- var icons = {
265
- 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>`,
266
- 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>`,
267
- 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>`,
268
- insertLeftTableIcon: `<svg
269
- xmlns="http://www.w3.org/2000/svg"
270
- length={12}
271
- viewBox="0 -960 960 960"
272
- >
273
- <path
274
- 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"
275
- fill="rgb(var(--color-text-300))"
276
- />
277
- </svg>
278
- `,
279
- insertRightTableIcon: `<svg
280
- xmlns="http://www.w3.org/2000/svg"
281
- length={12}
282
- viewBox="0 -960 960 960"
283
- >
284
- <path
285
- 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"
286
- fill="rgb(var(--color-text-300))"
287
- />
288
- </svg>
289
- `,
290
- insertTopTableIcon: `<svg
291
- xmlns="http://www.w3.org/2000/svg"
292
- length={24}
293
- viewBox="0 -960 960 960"
294
- >
295
- <path
296
- 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"
297
- fill="rgb(var(--color-text-300))"
298
- />
299
- </svg>
300
- `,
301
- 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>`,
302
- 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>`,
303
- insertBottomTableIcon: `<svg
304
- xmlns="http://www.w3.org/2000/svg"
305
- length={24}
306
- viewBox="0 -960 960 960"
307
- >
308
- <path
309
- 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"
310
- fill="rgb(var(--color-text-300))"
311
- />
312
- </svg>
313
- `
314
- };
315
-
316
- // src/extensions/table/table/table-view.tsx
317
- var Popover = class {
318
- constructor(content, opts) {
319
- __publicField(this, "reference");
320
- __publicField(this, "floating");
321
- __publicField(this, "cleanupAutoUpdate", null);
322
- __publicField(this, "onDocClick", (e) => {
323
- if (!this.floating.contains(e.target) && !this.reference.contains(e.target)) {
324
- this.hide();
325
- }
326
- });
327
- __publicField(this, "onEsc", (e) => {
328
- if (e.key === "Escape") this.hide();
329
- });
330
- __publicField(this, "_placement");
331
- __publicField(this, "_offsetPx");
332
- // biome-ignore lint/correctness/noUnusedPrivateClassMembers: backwards. will be used later
333
- __publicField(this, "_interactive");
334
- var _a, _b, _c, _d;
335
- this.reference = opts.reference;
336
- this.floating = document.createElement("div");
337
- this.floating.setAttribute("role", "dialog");
338
- this.floating.setAttribute("aria-modal", "false");
339
- this.floating.style.position = "fixed";
340
- this.floating.style.zIndex = "9999";
341
- this.floating.style.display = "none";
342
- this.floating.className = "rounded-md border bg-background px-2 py-2.5 text-xs shadow-sm min-w-[12rem] whitespace-nowrap";
343
- this.floating.appendChild(content);
344
- const host = (_a = opts.container) != null ? _a : document.body;
345
- host.appendChild(this.floating);
346
- this._placement = (_b = opts.placement) != null ? _b : "right";
347
- this._offsetPx = (_c = opts.offsetPx) != null ? _c : 6;
348
- this._interactive = (_d = opts.interactive) != null ? _d : true;
349
- }
350
- async _updatePosition() {
351
- const { x, y } = await (0, import_dom.computePosition)(this.reference, this.floating, {
352
- placement: this._placement,
353
- middleware: [(0, import_dom.offset)(this._offsetPx), (0, import_dom.flip)(), (0, import_dom.shift)({ padding: 8 })]
354
- });
355
- Object.assign(this.floating.style, { left: `${x}px`, top: `${y}px` });
356
- }
357
- show() {
358
- if (this.floating.style.display !== "none") return;
359
- this.floating.style.display = "block";
360
- this.cleanupAutoUpdate = (0, import_dom.autoUpdate)(
361
- this.reference,
362
- this.floating,
363
- () => this._updatePosition()
364
- );
365
- document.addEventListener("keydown", this.onEsc, { passive: true });
366
- document.addEventListener("mousedown", this.onDocClick, { capture: true });
367
- requestAnimationFrame(() => this._updatePosition());
368
- }
369
- hide() {
370
- var _a;
371
- if (this.floating.style.display === "none") return;
372
- this.floating.style.display = "none";
373
- (_a = this.cleanupAutoUpdate) == null ? void 0 : _a.call(this);
374
- this.cleanupAutoUpdate = null;
375
- document.removeEventListener("keydown", this.onEsc);
376
- document.removeEventListener("mousedown", this.onDocClick, {
377
- capture: true
378
- });
379
- }
380
- toggle() {
381
- if (this.floating.style.display === "none") this.show();
382
- else this.hide();
383
- }
384
- destroy() {
385
- this.hide();
386
- this.floating.remove();
387
- }
388
- get el() {
389
- return this.floating;
390
- }
391
- };
392
- function setCellsBackgroundColor(editor, color) {
393
- return editor.chain().focus().updateAttributes("tableCell", {
394
- background: color.backgroundColor,
395
- textColor: color.textColor
396
- }).run();
397
- }
398
- function setTableRowBackgroundColor(editor, color) {
399
- const { state, dispatch } = editor.view;
400
- const { selection } = state;
401
- if (!(selection instanceof import_tables.CellSelection)) return false;
402
- const hoveredCell = selection.$headCell || selection.$anchorCell;
403
- let rowDepth = hoveredCell.depth;
404
- while (rowDepth > 0 && hoveredCell.node(rowDepth).type.name !== "tableRow") {
405
- rowDepth--;
406
- }
407
- if (hoveredCell.node(rowDepth).type.name !== "tableRow") return false;
408
- const rowStartPos = hoveredCell.start(rowDepth);
409
- const tr = state.tr.setNodeMarkup(rowStartPos - 1, null, {
410
- ...hoveredCell.node(rowDepth).attrs,
411
- background: color.backgroundColor,
412
- textColor: color.textColor
413
- });
414
- dispatch(tr);
415
- return true;
416
- }
417
- var columnsToolboxItems = [
418
- {
419
- label: "Toggle column header",
420
- icon: icons.toggleColumnHeader,
421
- action: ({ editor }) => editor.chain().focus().toggleHeaderColumn().run()
422
- },
423
- {
424
- label: "Add column before",
425
- icon: icons.insertLeftTableIcon,
426
- action: ({ editor }) => editor.chain().focus().addColumnBefore().run()
427
- },
428
- {
429
- label: "Add column after",
430
- icon: icons.insertRightTableIcon,
431
- action: ({ editor }) => editor.chain().focus().addColumnAfter().run()
432
- },
433
- { label: "Pick color", icon: "", action: () => {
434
- } },
435
- {
436
- label: "Delete column",
437
- icon: icons.deleteColumn,
438
- action: ({ editor }) => editor.chain().focus().deleteColumn().run()
439
- }
440
- ];
441
- var rowsToolboxItems = [
442
- {
443
- label: "Toggle row header",
444
- icon: icons.toggleRowHeader,
445
- action: ({ editor }) => editor.chain().focus().toggleHeaderRow().run()
446
- },
447
- {
448
- label: "Add row above",
449
- icon: icons.insertTopTableIcon,
450
- action: ({ editor }) => editor.chain().focus().addRowBefore().run()
451
- },
452
- {
453
- label: "Add row below",
454
- icon: icons.insertBottomTableIcon,
455
- action: ({ editor }) => editor.chain().focus().addRowAfter().run()
456
- },
457
- { label: "Pick color", icon: "", action: () => {
458
- } },
459
- {
460
- label: "Delete row",
461
- icon: icons.deleteRow,
462
- action: ({ editor }) => editor.chain().focus().deleteRow().run()
463
- }
464
- ];
465
- function buildToolboxContent({
466
- items,
467
- onClickItem,
468
- onSelectColor,
469
- colors
470
- }) {
471
- return (0, import_jsx_dom_cjs.h)(
472
- "div",
473
- { className: "space-y-2" },
474
- items.map((item) => {
475
- if (item.label === "Pick color") {
476
- return (0, import_jsx_dom_cjs.h)("div", { className: "flex flex-col" }, [
477
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" }),
478
- (0, import_jsx_dom_cjs.h)("div", { className: "text-foreground text-sm" }, item.label),
479
- (0, import_jsx_dom_cjs.h)(
480
- "div",
481
- { className: "grid grid-cols-6 gap-x-1 gap-y-2.5 mt-2" },
482
- Object.entries(colors).map(
483
- ([_, colorValue]) => {
484
- var _a;
485
- return (0, import_jsx_dom_cjs.h)("button", {
486
- // @ts-expect-error JSX
487
- type: "button",
488
- className: "grid place-items-center size-6 rounded outline-none ring-offset-2 focus-visible:ring",
489
- style: `background-color:${colorValue.backgroundColor};color:${colorValue.textColor || "inherit"};`,
490
- innerHTML: (_a = colorValue.icon) != null ? _a : `<span class="text-md" style="color:${colorValue.textColor || "inherit"}">A</span>`,
491
- onClick: (e) => {
492
- e.stopPropagation();
493
- onSelectColor(colorValue);
494
- }
495
- });
496
- }
497
- )
498
- ),
499
- (0, import_jsx_dom_cjs.h)("hr", { className: "!my-2 border" })
500
- ]);
501
- }
502
- return (0, import_jsx_dom_cjs.h)(
503
- "button",
504
- {
505
- // @ts-expect-error JSX
506
- type: "button",
507
- className: "w-full flex items-center gap-2 px-1 py-1.5 bg-background hover:bg-muted text-sm text-foreground rounded",
508
- onClick: (e) => {
509
- e.stopPropagation();
510
- onClickItem(item);
511
- }
512
- },
513
- [
514
- (0, import_jsx_dom_cjs.h)("span", { className: "h-3 w-3 shrink-0", innerHTML: item.icon }),
515
- (0, import_jsx_dom_cjs.h)("div", { className: "label" }, item.label)
516
- ]
517
- );
518
- })
519
- );
520
- }
521
- function createToolbox({
522
- triggerButton,
523
- items,
524
- onSelectColor,
525
- onClickItem,
526
- colors,
527
- appendTo
528
- }) {
529
- if (!triggerButton) {
530
- return null;
531
- }
532
- const content = buildToolboxContent({
533
- items,
534
- onClickItem,
535
- onSelectColor,
536
- colors
537
- });
538
- const pop = new Popover(content, {
539
- reference: triggerButton,
540
- container: appendTo != null ? appendTo : void 0,
541
- placement: "right",
542
- offsetPx: 6,
543
- interactive: true
544
- });
545
- const onTrigger = (e) => {
546
- e.stopPropagation();
547
- pop.toggle();
548
- };
549
- triggerButton.addEventListener("click", onTrigger);
550
- return {
551
- show: () => pop.show(),
552
- hide: () => pop.hide(),
553
- destroy: () => {
554
- pop.destroy();
555
- triggerButton.removeEventListener("click", onTrigger);
556
- }
557
- };
558
- }
559
- var TableView = class {
560
- constructor(node, cellMinWidth, decorations, editor, getPos) {
561
- __publicField(this, "node");
562
- __publicField(this, "cellMinWidth");
563
- __publicField(this, "decorations");
564
- __publicField(this, "editor");
565
- __publicField(this, "getPos");
566
- __publicField(this, "hoveredCell", null);
567
- __publicField(this, "map");
568
- __publicField(this, "root");
569
- __publicField(this, "table");
570
- __publicField(this, "colgroup");
571
- __publicField(this, "tbody");
572
- __publicField(this, "rowsControl");
573
- __publicField(this, "columnsControl");
574
- __publicField(this, "columnsToolbox");
575
- __publicField(this, "rowsToolbox");
576
- __publicField(this, "controls");
577
- var _a, _b, _c, _d;
578
- this.node = node;
579
- this.cellMinWidth = cellMinWidth;
580
- this.decorations = decorations.slice();
581
- this.editor = editor;
582
- this.getPos = getPos;
583
- this.hoveredCell = null;
584
- this.map = import_tables.TableMap.get(node);
585
- if (editor.isEditable) {
586
- this.rowsControl = (0, import_jsx_dom_cjs.h)(
587
- "div",
588
- { className: "rows-control" },
589
- (0, import_jsx_dom_cjs.h)("button", {
590
- // @ts-expect-error JSX
591
- type: "button",
592
- className: "rows-control-div",
593
- onClick: () => this.selectRow(),
594
- "aria-label": "Row actions"
595
- })
596
- );
597
- this.columnsControl = (0, import_jsx_dom_cjs.h)(
598
- "div",
599
- { className: "columns-control" },
600
- (0, import_jsx_dom_cjs.h)("button", {
601
- // @ts-expect-error JSX
602
- type: "button",
603
- className: "columns-control-div",
604
- onClick: () => this.selectColumn(),
605
- "aria-label": "Column actions"
606
- })
607
- );
608
- this.controls = (0, import_jsx_dom_cjs.h)(
609
- "div",
610
- { className: "table-controls", contentEditable: "false" },
611
- this.rowsControl,
612
- this.columnsControl
613
- );
614
- const palette = {
615
- Blue: { backgroundColor: "#D9E4FF", textColor: "#171717" },
616
- Orange: { backgroundColor: "#FFEDD5", textColor: "#171717" },
617
- Grey: { backgroundColor: "#F1F1F1", textColor: "#171717" },
618
- Yellow: { backgroundColor: "#FEF3C7", textColor: "#171717" },
619
- Green: { backgroundColor: "#DCFCE7", textColor: "#171717" },
620
- Red: { backgroundColor: "#FFDDDD", textColor: "#171717" },
621
- Pink: { backgroundColor: "#FFE8FA", textColor: "#171717" },
622
- Purple: { backgroundColor: "#E8DAFB", textColor: "#171717" },
623
- None: {
624
- backgroundColor: "transparent",
625
- textColor: "inherit",
626
- 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>`
627
- }
628
- };
629
- this.columnsToolbox = createToolbox({
630
- triggerButton: (_a = this.columnsControl) == null ? void 0 : _a.querySelector(
631
- ".columns-control-div"
632
- ),
633
- items: columnsToolboxItems,
634
- colors: palette,
635
- appendTo: (_b = this.controls) != null ? _b : null,
636
- onSelectColor: (color) => setCellsBackgroundColor(this.editor, color),
637
- onClickItem: (item) => {
638
- var _a2, _b2;
639
- item.action({
640
- editor: this.editor,
641
- triggerButton: (_a2 = this.columnsControl) == null ? void 0 : _a2.firstElementChild,
642
- controlsContainer: this.controls
643
- });
644
- (_b2 = this.columnsToolbox) == null ? void 0 : _b2.hide();
645
- }
646
- });
647
- this.rowsToolbox = createToolbox({
648
- triggerButton: (_c = this.rowsControl) == null ? void 0 : _c.querySelector(
649
- ".rows-control-div"
650
- ),
651
- items: rowsToolboxItems,
652
- colors: palette,
653
- appendTo: (_d = this.controls) != null ? _d : null,
654
- onSelectColor: (color) => setTableRowBackgroundColor(editor, color),
655
- onClickItem: (item) => {
656
- var _a2, _b2;
657
- item.action({
658
- editor: this.editor,
659
- triggerButton: (_a2 = this.rowsControl) == null ? void 0 : _a2.firstElementChild,
660
- controlsContainer: this.controls
661
- });
662
- (_b2 = this.rowsToolbox) == null ? void 0 : _b2.hide();
663
- }
664
- });
665
- }
666
- this.colgroup = (0, import_jsx_dom_cjs.h)(
667
- "colgroup",
668
- null,
669
- Array.from({ length: this.map.width }, () => 1).map(() => (0, import_jsx_dom_cjs.h)("col"))
670
- );
671
- this.tbody = (0, import_jsx_dom_cjs.h)("tbody");
672
- this.table = (0, import_jsx_dom_cjs.h)(
673
- "table",
674
- null,
675
- this.colgroup,
676
- this.tbody
677
- );
678
- this.root = (0, import_jsx_dom_cjs.h)(
679
- "div",
680
- {
681
- className: "table-wrapper horizontal-scrollbar scrollbar-md controls--disabled"
682
- },
683
- this.controls,
684
- this.table
685
- );
686
- this.render();
687
- }
688
- get dom() {
689
- return this.root;
690
- }
691
- get contentDOM() {
692
- return this.tbody;
693
- }
694
- update(node, decorations) {
695
- if (node.type !== this.node.type) return false;
696
- this.node = node;
697
- this.decorations = [...decorations];
698
- this.map = import_tables.TableMap.get(this.node);
699
- if (this.editor.isEditable) this.updateControls();
700
- this.render();
701
- return true;
702
- }
703
- render() {
704
- if (this.colgroup.children.length !== this.map.width) {
705
- const cols = Array.from({ length: this.map.width }, () => 1).map(
706
- () => (0, import_jsx_dom_cjs.h)("col")
707
- );
708
- this.colgroup.replaceChildren(...cols);
709
- }
710
- (0, import_tables.updateColumnsOnResize)(
711
- this.node,
712
- this.colgroup,
713
- this.table,
714
- this.cellMinWidth
715
- );
716
- }
717
- ignoreMutation() {
718
- return true;
719
- }
720
- updateControls() {
721
- var _a;
722
- const { hoveredTable: table, hoveredCell: cell } = Object.values(
723
- this.decorations
724
- ).reduce(
725
- (acc, curr) => {
726
- if (curr.spec.hoveredCell !== void 0)
727
- acc.hoveredCell = curr.spec.hoveredCell;
728
- if (curr.spec.hoveredTable !== void 0)
729
- acc.hoveredTable = curr.spec.hoveredTable;
730
- return acc;
731
- },
732
- {}
733
- );
734
- if (table === void 0 || cell === void 0) {
735
- this.root.classList.add("controls--disabled");
736
- return;
737
- }
738
- this.root.classList.remove("controls--disabled");
739
- this.hoveredCell = cell;
740
- const cellDom = this.editor.view.nodeDOM(cell.pos);
741
- if (!this.table || !cellDom) return;
742
- const tableRect = this.table.getBoundingClientRect();
743
- const cellRect = cellDom.getBoundingClientRect();
744
- if (this.columnsControl) {
745
- this.columnsControl.style.left = `${cellRect.left - tableRect.left - (((_a = this.table.parentElement) == null ? void 0 : _a.scrollLeft) || 0)}px`;
746
- this.columnsControl.style.width = `${cellRect.width}px`;
747
- }
748
- if (this.rowsControl) {
749
- this.rowsControl.style.top = `${cellRect.top - tableRect.top}px`;
750
- this.rowsControl.style.height = `${cellRect.height}px`;
751
- }
752
- }
753
- selectColumn() {
754
- if (!this.hoveredCell) return;
755
- const colIndex = this.map.colCount(
756
- this.hoveredCell.pos - (this.getPos() + 1)
757
- );
758
- const anchorCellPos = this.hoveredCell.pos;
759
- const headCellPos = this.map.map[colIndex + this.map.width * (this.map.height - 1)] + (this.getPos() + 1);
760
- const cellSelection = import_tables.CellSelection.create(
761
- this.editor.view.state.doc,
762
- anchorCellPos,
763
- headCellPos
764
- );
765
- this.editor.view.dispatch(this.editor.state.tr.setSelection(cellSelection));
766
- }
767
- selectRow() {
768
- if (!this.hoveredCell) return;
769
- const anchorCellPos = this.hoveredCell.pos;
770
- const anchorCellIndex = this.map.map.indexOf(
771
- anchorCellPos - (this.getPos() + 1)
772
- );
773
- const headCellPos = this.map.map[anchorCellIndex + (this.map.width - 1)] + (this.getPos() + 1);
774
- const cellSelection = import_tables.CellSelection.create(
775
- this.editor.state.doc,
776
- anchorCellPos,
777
- headCellPos
778
- );
779
- this.editor.view.dispatch(
780
- this.editor.view.state.tr.setSelection(cellSelection)
781
- );
782
- }
783
- };
784
-
785
- // src/utils/index.ts
786
- var import_state4 = require("@tiptap/pm/state");
787
- var MAX_FILE_SIZE = 5 * 1024 * 1024;
788
- var isMarkInSchema = (markName, editor) => {
789
- if (!(editor == null ? void 0 : editor.schema)) return false;
790
- return editor.schema.spec.marks.get(markName) !== void 0;
791
- };
792
- var isNodeInSchema = (nodeName, editor) => {
793
- if (!(editor == null ? void 0 : editor.schema)) return false;
794
- return editor.schema.spec.nodes.get(nodeName) !== void 0;
795
- };
796
- function findNodePosition(props) {
797
- var _a;
798
- const { editor, node, nodePos } = props;
799
- if (!editor || !((_a = editor.state) == null ? void 0 : _a.doc)) return null;
800
- const hasValidNode = node !== void 0 && node !== null;
801
- const hasValidPos = nodePos !== void 0 && nodePos !== null;
802
- if (!hasValidNode && !hasValidPos) {
803
- return null;
804
- }
805
- if (hasValidPos) {
806
- try {
807
- const nodeAtPos = editor.state.doc.nodeAt(nodePos);
808
- if (nodeAtPos) {
809
- return { pos: nodePos, node: nodeAtPos };
810
- }
811
- } catch (error) {
812
- console.error("Error checking node at position:", error);
813
- return null;
814
- }
815
- }
816
- let foundPos = -1;
817
- let foundNode = null;
818
- editor.state.doc.descendants((currentNode, pos) => {
819
- if (currentNode === node) {
820
- foundPos = pos;
821
- foundNode = currentNode;
822
- return false;
823
- }
824
- return true;
825
- });
826
- return foundPos !== -1 && foundNode !== null ? { pos: foundPos, node: foundNode } : null;
827
- }
828
- var ATTR_WHITESPACE = (
829
- // eslint-disable-next-line no-control-regex
830
- // biome-ignore lint/suspicious/noControlCharactersInRegex: we can do this yay
831
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
832
- );
833
- function isAllowedUri(uri, protocols) {
834
- const allowedProtocols = [
835
- "http",
836
- "https",
837
- "ftp",
838
- "ftps",
839
- "mailto",
840
- "tel",
841
- "callto",
842
- "sms",
843
- "cid",
844
- "xmpp"
845
- ];
846
- if (protocols) {
847
- for (const protocol of protocols) {
848
- const nextProtocol = typeof protocol === "string" ? protocol : protocol.scheme;
849
- if (nextProtocol) {
850
- allowedProtocols.push(nextProtocol);
851
- }
852
- }
853
- }
854
- return !uri || uri.replace(ATTR_WHITESPACE, "").match(
855
- new RegExp(
856
- // eslint-disable-next-line no-useless-escape
857
- `^(?:(?:${allowedProtocols.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
858
- "i"
859
- )
860
- );
861
- }
862
- function sanitizeUrl(inputUrl, baseUrl, protocols) {
863
- try {
864
- const url = new URL(inputUrl, baseUrl);
865
- if (isAllowedUri(url.href, protocols)) {
866
- return url.href;
867
- }
868
- } catch {
869
- }
870
- return "#";
871
- }
872
- function isNodeTypeSelected(editor, types = []) {
873
- if (!editor || !editor.state.selection) return false;
874
- const { state } = editor;
875
- const { selection } = state;
876
- if (selection.empty) return false;
877
- if (selection instanceof import_state4.NodeSelection) {
878
- const node = selection.node;
879
- return node ? types.includes(node.type.name) : false;
880
- }
881
- return false;
882
- }
883
- function isExtensionAvailable(editor, extensionNames) {
884
- if (!editor) return false;
885
- const names = Array.isArray(extensionNames) ? extensionNames : [extensionNames];
886
- const found = names.some(
887
- (name) => editor.extensionManager.extensions.some((ext) => ext.name === name)
888
- );
889
- if (!found) {
890
- console.warn(
891
- `None of the extensions [${names.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`
892
- );
893
- }
894
- return found;
895
- }
896
- function getEditorExtension(editor, extensionName) {
897
- if (!editor) return null;
898
- const extension = editor.extensionManager.extensions.find(
899
- (ext) => ext.name === extensionName
900
- );
901
- if (!extension) {
902
- console.warn(
903
- `Extension "${extensionName}" not found in the editor schema. Ensure it is included in the editor configuration.`
904
- );
905
- return null;
906
- }
907
- return extension;
908
- }
909
- function hasContentAbove(editor) {
910
- if (!editor) return { hasContent: false, content: "" };
911
- const { state } = editor;
912
- const { $from } = state.selection;
913
- for (let i = $from.index(0) - 1; i >= 0; i--) {
914
- const node = state.doc.child(i);
915
- const content = node.textContent.trim();
916
- if (content) {
917
- return { hasContent: true, content };
918
- }
919
- }
920
- return { hasContent: false, content: "" };
921
- }
922
- function findSelectionPosition(params) {
923
- const { editor, node, nodePos } = params;
924
- if (isValidPosition(nodePos)) return nodePos;
925
- if (node) {
926
- const found = findNodePosition({ editor, node });
927
- if (found) return found.pos;
928
- }
929
- const { selection } = editor.state;
930
- if (!selection.empty) return null;
931
- const resolvedPos = selection.$anchor;
932
- const nodeDepth = 1;
933
- const selectedNode = resolvedPos.node(nodeDepth);
934
- return selectedNode ? resolvedPos.before(nodeDepth) : null;
935
- }
936
- function isValidPosition(pos) {
937
- return typeof pos === "number" && pos >= 0;
938
- }
939
- function getElementOverflowPosition(targetElement, containerElement) {
940
- const targetBounds = targetElement.getBoundingClientRect();
941
- const containerBounds = containerElement.getBoundingClientRect();
942
- const isOverflowingTop = targetBounds.top < containerBounds.top;
943
- const isOverflowingBottom = targetBounds.bottom > containerBounds.bottom;
944
- if (isOverflowingTop && isOverflowingBottom) return "both";
945
- if (isOverflowingTop) return "top";
946
- if (isOverflowingBottom) return "bottom";
947
- return "none";
948
- }
949
- function findParentNodeOfType(selection, typeName) {
950
- let depth = selection.$anchor.depth;
951
- while (depth > 0) {
952
- const node = selection.$anchor.node(depth);
953
- if (node.type.name === typeName) {
954
- return { node, pos: selection.$anchor.start(depth) - 1 };
955
- }
956
- depth--;
957
- }
958
- return null;
959
- }
960
-
961
- // src/extensions/table/table/utilities/insert-line-above-table-action.ts
962
- var insertLineAboveTableAction = ({
963
- editor
964
- }) => {
965
- if (!editor.isActive("table")) return false;
966
- try {
967
- const { selection } = editor.state;
968
- const tableNode = findParentNodeOfType(selection, "table");
969
- if (!tableNode) return false;
970
- const tablePos = tableNode.pos;
971
- const firstRow = tableNode.node.child(0);
972
- const selectionPath = selection.$anchor.path;
973
- const selectionInFirstRow = selectionPath.includes(firstRow);
974
- if (!selectionInFirstRow) return false;
975
- if (tablePos === 0) {
976
- editor.chain().insertContentAt(tablePos, { type: "paragraph" }).run();
977
- editor.chain().setTextSelection(tablePos + 1).run();
978
- } else {
979
- const prevNodePos = tablePos - 1;
980
- if (prevNodePos <= 0) return false;
981
- const prevNode = editor.state.doc.nodeAt(prevNodePos - 1);
982
- if (prevNode && prevNode.type.name === "paragraph") {
983
- const endOfParagraphPos = tablePos - prevNode.nodeSize;
984
- editor.chain().setTextSelection(endOfParagraphPos).run();
985
- } else {
986
- return false;
987
- }
988
- }
989
- return true;
990
- } catch (e) {
991
- console.error("failed to insert line above table", e);
992
- return false;
993
- }
994
- };
995
-
996
- // src/extensions/table/table/utilities/insert-line-below-table-action.ts
997
- var insertLineBelowTableAction = ({
998
- editor
999
- }) => {
1000
- if (!editor.isActive("table")) return false;
1001
- try {
1002
- const { selection } = editor.state;
1003
- const tableNode = findParentNodeOfType(selection, "table");
1004
- if (!tableNode) return false;
1005
- const tablePos = tableNode.pos;
1006
- const table = tableNode.node;
1007
- const rowCount = table.childCount;
1008
- const lastRow = table.child(rowCount - 1);
1009
- const selectionPath = selection.$anchor.path;
1010
- const selectionInLastRow = selectionPath.includes(lastRow);
1011
- if (!selectionInLastRow) return false;
1012
- const nextNodePos = tablePos + table.nodeSize;
1013
- const nextNode = editor.state.doc.nodeAt(nextNodePos);
1014
- if (nextNode && nextNode.type.name === "paragraph") {
1015
- const endOfParagraphPos = nextNodePos + nextNode.nodeSize - 1;
1016
- editor.chain().setTextSelection(endOfParagraphPos).run();
1017
- } else if (!nextNode) {
1018
- editor.chain().insertContentAt(nextNodePos, { type: "paragraph" }).run();
1019
- editor.chain().setTextSelection(nextNodePos + 1).run();
1020
- } else {
1021
- return false;
1022
- }
1023
- return true;
1024
- } catch (e) {
1025
- console.error("failed to insert line above table", e);
1026
- return false;
1027
- }
1028
- };
1029
-
1030
- // src/extensions/table/table/table.ts
1031
- var Table = import_extension_table.Table.extend({
1032
- addOptions() {
1033
- var _a;
1034
- return {
1035
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
1036
- HTMLAttributes: {},
1037
- resizable: true,
1038
- handleWidth: 5,
1039
- cellMinWidth: 100,
1040
- lastColumnResizable: true,
1041
- allowTableNodeSelection: true
1042
- };
1043
- },
1044
- addKeyboardShortcuts() {
1045
- var _a;
1046
- return {
1047
- ...(_a = this.parent) == null ? void 0 : _a.call(this),
1048
- Tab: () => {
1049
- if (this.editor.isActive("table")) {
1050
- if (this.editor.isActive("listItem") || this.editor.isActive("taskItem")) {
1051
- return false;
1052
- }
1053
- if (this.editor.commands.goToNextCell()) {
1054
- return true;
1055
- }
1056
- if (!this.editor.can().addRowAfter()) {
1057
- return false;
1058
- }
1059
- return this.editor.chain().addRowAfter().goToNextCell().run();
1060
- }
1061
- return false;
1062
- },
1063
- ArrowDown: insertLineBelowTableAction,
1064
- ArrowUp: insertLineAboveTableAction
1065
- };
1066
- },
1067
- addNodeView() {
1068
- return ({ editor, getPos, node, decorations }) => {
1069
- const { cellMinWidth } = this.options;
1070
- return new TableView(
1071
- node,
1072
- cellMinWidth,
1073
- // biome-ignore lint/suspicious/noExplicitAny: prosemirror
1074
- decorations,
1075
- editor,
1076
- getPos
1077
- );
1078
- };
1079
- },
1080
- addProseMirrorPlugins() {
1081
- const isResizable = this.options.resizable && this.editor.isEditable;
1082
- const plugins = [
1083
- (0, import_tables2.tableEditing)({
1084
- allowTableNodeSelection: this.options.allowTableNodeSelection
1085
- }),
1086
- tableControls()
1087
- ];
1088
- if (isResizable) {
1089
- plugins.unshift(
1090
- (0, import_tables2.columnResizing)({
1091
- handleWidth: this.options.handleWidth,
1092
- cellMinWidth: this.options.cellMinWidth,
1093
- // View: TableView,
1094
- lastColumnResizable: this.options.lastColumnResizable
1095
- })
1096
- );
1097
- }
1098
- return plugins;
1099
- }
1100
- });
1101
-
1102
- // src/extensions/table/table-cell.ts
1103
- var import_core2 = require("@tiptap/core");
1104
- var TableCell = import_core2.Node.create({
1105
- name: "tableCell",
1106
- content: "block+",
1107
- // DONT allow table in table.
1108
- tableRole: "cell",
1109
- isolating: true,
1110
- addOptions() {
1111
- return {
1112
- HTMLAttributes: {}
1113
- };
1114
- },
1115
- parseHTML() {
1116
- return [{ tag: "td" }];
1117
- },
1118
- renderHTML({ node, HTMLAttributes }) {
1119
- return [
1120
- "td",
1121
- (0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
1122
- style: `background-color: ${node.attrs.background}; color: ${node.attrs.textColor}`
1123
- }),
1124
- 0
1125
- ];
1126
- },
1127
- addAttributes() {
1128
- return {
1129
- colspan: {
1130
- default: 1,
1131
- parseHTML: (element) => {
1132
- const colspan = element.getAttribute("colspan");
1133
- const value = colspan ? Number.parseInt(colspan, 10) : 1;
1134
- return value;
1135
- }
1136
- },
1137
- rowspan: {
1138
- default: 1,
1139
- parseHTML: (element) => {
1140
- const rowspan = element.getAttribute("rowspan");
1141
- const value = rowspan ? Number.parseInt(rowspan, 10) : 1;
1142
- return value;
1143
- }
1144
- },
1145
- colwidth: {
1146
- default: null,
1147
- parseHTML: (element) => {
1148
- const colwidth = element.getAttribute("colwidth");
1149
- const value = colwidth ? [Number.parseInt(colwidth, 10)] : null;
1150
- return value;
1151
- }
1152
- },
1153
- background: {
1154
- default: null
1155
- },
1156
- textColor: {
1157
- default: null
1158
- },
1159
- style: {
1160
- default: null
1161
- }
1162
- };
1163
- }
1164
- // addProseMirrorPlugins() {
1165
- // return [
1166
- // new Plugin({
1167
- // props: {
1168
- // decorations: (state) => {
1169
- // const { isEditable } = this.editor;
1170
- // if (!isEditable) {
1171
- // return DecorationSet.empty;
1172
- // }
1173
- // const { doc, selection } = state;
1174
- // const decorations: Decoration[] = [];
1175
- // const cells = getCellsInColumn(0)(selection);
1176
- // if (cells) {
1177
- // cells.forEach(({ pos }: { pos: number }, index: number) => {
1178
- // decorations.push(
1179
- // Decoration.widget(pos + 1, () => {
1180
- // const rowSelected = isRowSelected(index)(selection);
1181
- // let className = "grip-row";
1182
- // if (rowSelected) {
1183
- // className += " selected";
1184
- // }
1185
- // if (index === 0) {
1186
- // className += " first";
1187
- // }
1188
- // if (index === cells.length - 1) {
1189
- // className += " last";
1190
- // }
1191
- // const grip = document.createElement("a");
1192
- // grip.className = className;
1193
- // grip.addEventListener("mousedown", (event) => {
1194
- // event.preventDefault();
1195
- // event.stopImmediatePropagation();
1196
- // this.editor.view.dispatch(
1197
- // selectRow(index)(this.editor.state.tr),
1198
- // );
1199
- // });
1200
- // return grip;
1201
- // }),
1202
- // );
1203
- // });
1204
- // }
1205
- // return DecorationSet.create(doc, decorations);
1206
- // },
1207
- // },
1208
- // }),
1209
- // ];
1210
- // },
1211
- });
1212
-
1213
- // src/extensions/table/table-header.ts
1214
- var import_extension_table2 = require("@tiptap/extension-table");
1215
- var TableHeader = import_extension_table2.TableHeader.extend({
1216
- addAttributes() {
1217
- return {
1218
- colspan: {
1219
- default: 1
1220
- },
1221
- rowspan: {
1222
- default: 1
1223
- },
1224
- colwidth: {
1225
- default: null,
1226
- parseHTML: (element) => {
1227
- const colwidth = element.getAttribute("colwidth");
1228
- const value = colwidth ? [Number.parseInt(colwidth, 10)] : null;
1229
- return value;
1230
- }
1231
- },
1232
- background: {
1233
- default: "none"
1234
- },
1235
- style: {
1236
- default: null
1237
- }
1238
- };
1239
- }
1240
- // addProseMirrorPlugins() {
1241
- // return [
1242
- // new Plugin({
1243
- // props: {
1244
- // decorations: (state) => {
1245
- // const { isEditable } = this.editor;
1246
- // if (!isEditable) {
1247
- // return DecorationSet.empty;
1248
- // }
1249
- // const { doc, selection } = state;
1250
- // const decorations: Decoration[] = [];
1251
- // const cells = getCellsInRow(0)(selection);
1252
- // if (cells) {
1253
- // cells.forEach(({ pos }, index) => {
1254
- // decorations.push(
1255
- // Decoration.widget(pos + 1, () => {
1256
- // const colSelected = isColumnSelected(index)(selection);
1257
- // let className = "grip-column";
1258
- // if (colSelected) {
1259
- // className += " selected";
1260
- // }
1261
- // if (index === 0) {
1262
- // className += " first";
1263
- // }
1264
- // if (index === cells.length - 1) {
1265
- // className += " last";
1266
- // }
1267
- // const grip = document.createElement("a");
1268
- // grip.className = className;
1269
- // grip.addEventListener("mousedown", (event) => {
1270
- // event.preventDefault();
1271
- // event.stopImmediatePropagation();
1272
- // this.editor.view.dispatch(
1273
- // selectColumn(index)(this.editor.state.tr),
1274
- // );
1275
- // });
1276
- // return grip;
1277
- // }),
1278
- // );
1279
- // });
1280
- // }
1281
- // return DecorationSet.create(doc, decorations);
1282
- // },
1283
- // },
1284
- // }),
1285
- // ];
1286
- // },
1287
- });
1288
-
1289
- // src/extensions/table/table-row.ts
1290
- var import_extension_table3 = require("@tiptap/extension-table");
1291
- var TableRow = import_extension_table3.TableRow.extend({
1292
- allowGapCursor: false,
1293
- content: "(tableCell | tableHeader)*"
1294
- });
1295
-
1296
- // src/extensions/table/kit.ts
1297
- var TableKit = import_react3.Extension.create({
1298
- name: "tableKit",
1299
- addExtensions() {
1300
- const extensions = [];
1301
- if (this.options.table !== false) {
1302
- extensions.push(Table.configure(this.options.table));
1303
- }
1304
- if (this.options.tableCell !== false) {
1305
- extensions.push(TableCell.configure(this.options.tableCell));
1306
- }
1307
- if (this.options.tableHeader !== false) {
1308
- extensions.push(TableHeader.configure(this.options.tableHeader));
1309
- }
1310
- if (this.options.tableRow !== false) {
1311
- extensions.push(TableRow.configure(this.options.tableRow));
1312
- }
1313
- return extensions;
1314
- }
1315
- });
1316
-
1317
154
  // src/extensions/trailing-node/index.ts
1318
- var import_state5 = require("@tiptap/pm/state");
1319
- var import_react4 = require("@tiptap/react");
155
+ var import_state3 = require("@tiptap/pm/state");
156
+ var import_react3 = require("@tiptap/react");
1320
157
  function nodeEqualsType({
1321
158
  types,
1322
159
  node
@@ -1327,7 +164,7 @@ function nodeEqualsType({
1327
164
  }
1328
165
  return node.type === types;
1329
166
  }
1330
- var TrailingNode = import_react4.Extension.create({
167
+ var TrailingNode = import_react3.Extension.create({
1331
168
  name: "trailingNode",
1332
169
  addOptions() {
1333
170
  return {
@@ -1336,10 +173,10 @@ var TrailingNode = import_react4.Extension.create({
1336
173
  };
1337
174
  },
1338
175
  addProseMirrorPlugins() {
1339
- const plugin = new import_state5.PluginKey(this.name);
176
+ const plugin = new import_state3.PluginKey(this.name);
1340
177
  const disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => this.options.notAfter.includes(node.name));
1341
178
  return [
1342
- new import_state5.Plugin({
179
+ new import_state3.Plugin({
1343
180
  key: plugin,
1344
181
  appendTransaction: (_, __, state) => {
1345
182
  const { doc, tr, schema } = state;
@@ -1373,7 +210,7 @@ var TrailingNode = import_react4.Extension.create({
1373
210
  });
1374
211
 
1375
212
  // src/extensions/ui-state/index.ts
1376
- var import_core3 = require("@tiptap/core");
213
+ var import_core = require("@tiptap/core");
1377
214
  var defaultUiState = {
1378
215
  aiGenerationIsSelection: false,
1379
216
  aiGenerationIsLoading: false,
@@ -1383,7 +220,7 @@ var defaultUiState = {
1383
220
  lockDragHandle: false,
1384
221
  isDragging: false
1385
222
  };
1386
- var UiState = import_core3.Extension.create({
223
+ var UiState = import_core.Extension.create({
1387
224
  name: "uiState",
1388
225
  addStorage() {
1389
226
  return {
@@ -1391,12 +228,12 @@ var UiState = import_core3.Extension.create({
1391
228
  };
1392
229
  },
1393
230
  addCommands() {
1394
- const createBooleanSetter = (key2) => (value) => () => {
1395
- this.storage[key2] = value;
231
+ const createBooleanSetter = (key) => (value) => () => {
232
+ this.storage[key] = value;
1396
233
  return true;
1397
234
  };
1398
- const createToggle = (key2, value) => () => () => {
1399
- this.storage[key2] = value;
235
+ const createToggle = (key, value) => () => () => {
236
+ this.storage[key] = value;
1400
237
  return true;
1401
238
  };
1402
239
  return {
@@ -1487,9 +324,10 @@ var useCreateEditor = ({
1487
324
  editable = true,
1488
325
  placeholder = "Write, type '/' for commands\u2026",
1489
326
  onChange,
327
+ controlResolver,
1490
328
  ...options
1491
329
  }) => {
1492
- const editor = (0, import_react5.useEditor)({
330
+ const editor = (0, import_react4.useEditor)({
1493
331
  editorProps: {
1494
332
  attributes: {
1495
333
  autocomplete: "off",
@@ -1500,44 +338,7 @@ var useCreateEditor = ({
1500
338
  },
1501
339
  immediatelyRender: false,
1502
340
  shouldRerenderOnTransaction: false,
1503
- extensions: [
1504
- import_starter_kit.StarterKit.configure({
1505
- trailingNode: false,
1506
- // we use our custom trailing node extension
1507
- link: false
1508
- // we use our custom link extension
1509
- }),
1510
- import_extension_text_align.TextAlign.configure({ types: ["heading", "paragraph"] }),
1511
- import_extension_task_list.TaskList,
1512
- import_extension_task_item.TaskItem.configure({ nested: true }),
1513
- import_extension_highlight.Highlight.configure({ multicolor: true }),
1514
- import_extension_typography.Typography,
1515
- import_extension_superscript.Superscript,
1516
- import_extension_subscript.Subscript,
1517
- Selection,
1518
- TrailingNode,
1519
- Link.configure({ openOnClick: !editable }),
1520
- // disable link click when editing
1521
- import_extension_unique_id.UniqueID.configure({
1522
- types: [
1523
- "paragraph",
1524
- "bulletList",
1525
- "orderedList",
1526
- "taskList",
1527
- "heading",
1528
- "blockquote",
1529
- "codeBlock"
1530
- ]
1531
- // filterTransaction: (transaction) => !isChangeOrigin(transaction),
1532
- }),
1533
- UiState,
1534
- TableKit,
1535
- import_extensions.Placeholder.configure({
1536
- placeholder,
1537
- emptyNodeClass: "is-empty with-slash"
1538
- }),
1539
- import_extension_controlref.ControlKit
1540
- ],
341
+ extensions: getExtensions({ editable, placeholder, controlResolver }),
1541
342
  editable,
1542
343
  onUpdate: ({ editor: editor2 }) => {
1543
344
  onChange == null ? void 0 : onChange(editor2.getJSON());
@@ -1547,12 +348,70 @@ var useCreateEditor = ({
1547
348
  });
1548
349
  return editor;
1549
350
  };
351
+ function getExtensions({
352
+ editable,
353
+ placeholder,
354
+ controlResolver
355
+ }) {
356
+ return [
357
+ import_starter_kit.StarterKit.configure({
358
+ trailingNode: false,
359
+ // we use our custom trailing node extension
360
+ link: false,
361
+ // we use our custom link extension
362
+ code: false,
363
+ // we use our own
364
+ codeBlock: false
365
+ // we use our own
366
+ // undoRedo should be dynamic based on collaboration, later.^
367
+ }),
368
+ import_extension_text_align.TextAlign.configure({ types: ["heading", "paragraph"] }),
369
+ import_extension_list.TaskList,
370
+ import_extension_list.TaskItem.configure({ nested: true }),
371
+ import_extension_invisible_characters.default.configure({
372
+ visible: false
373
+ }),
374
+ import_extension_table_of_contents.TableOfContents.configure({
375
+ getIndex: import_extension_table_of_contents.getHierarchicalIndexes
376
+ }),
377
+ Selection,
378
+ Link.configure({ openOnClick: !editable }),
379
+ // disable link click when editing
380
+ import_extension_text_style.TextStyleKit,
381
+ import_extension_highlight.Highlight.configure({ multicolor: true }),
382
+ import_extensions.CharacterCount,
383
+ import_extension_typography.Typography,
384
+ import_extension_superscript.Superscript,
385
+ import_extension_subscript.Subscript,
386
+ import_extension_code.CodeKit,
387
+ TrailingNode,
388
+ import_extension_unique_id.UniqueID.configure({
389
+ types: [
390
+ "paragraph",
391
+ "bulletList",
392
+ "orderedList",
393
+ "taskList",
394
+ "heading",
395
+ "blockquote",
396
+ "codeBlock"
397
+ ]
398
+ // filterTransaction: (transaction) => !isChangeOrigin(transaction),
399
+ }),
400
+ UiState,
401
+ import_extension_table.TableKit,
402
+ import_extensions.Placeholder.configure({
403
+ placeholder,
404
+ emptyNodeClass: "is-empty with-slash"
405
+ }),
406
+ import_extension_controlref.ControlKit.configure({ resolver: controlResolver })
407
+ ];
408
+ }
1550
409
 
1551
410
  // src/hooks/use-ui-editor-state.ts
1552
- var import_react6 = require("@tiptap/react");
411
+ var import_react5 = require("@tiptap/react");
1553
412
  function useUiEditorState(editor) {
1554
413
  var _a;
1555
- return (_a = (0, import_react6.useEditorState)({
414
+ return (_a = (0, import_react5.useEditorState)({
1556
415
  editor,
1557
416
  selector: ({ editor: editor2 }) => {
1558
417
  if (!editor2) return defaultUiState;
@@ -1569,31 +428,32 @@ function useUiEditorState(editor) {
1569
428
  }
1570
429
 
1571
430
  // src/ui/copy-anchor-link-button/use-scroll-to-hash.ts
431
+ var import_editor_utils = require("@kopexa/editor-utils");
1572
432
  var React2 = __toESM(require("react"));
1573
433
 
1574
434
  // src/hooks/use-floating-toolbar-visibility.ts
1575
- var import_state6 = require("@tiptap/pm/state");
1576
- var import_react7 = require("@tiptap/react");
435
+ var import_state4 = require("@tiptap/pm/state");
436
+ var import_react6 = require("@tiptap/react");
1577
437
  var React = __toESM(require("react"));
1578
438
  var HIDE_FLOATING_META = "hideFloatingToolbar";
1579
439
  var selectNodeAndHideFloating = (editor, pos) => {
1580
440
  if (!editor) return;
1581
441
  const { state, view } = editor;
1582
442
  view.dispatch(
1583
- state.tr.setSelection(import_state6.NodeSelection.create(state.doc, pos)).setMeta(HIDE_FLOATING_META, true)
443
+ state.tr.setSelection(import_state4.NodeSelection.create(state.doc, pos)).setMeta(HIDE_FLOATING_META, true)
1584
444
  );
1585
445
  };
1586
446
 
1587
447
  // src/hooks/use-tiptap-editor.ts
1588
- var import_react8 = require("@tiptap/react");
1589
- var import_react9 = require("react");
448
+ var import_react7 = require("@tiptap/react");
449
+ var import_react8 = require("react");
1590
450
  function useTiptapEditor(providedEditor) {
1591
- const { editor: coreEditor } = (0, import_react8.useCurrentEditor)();
1592
- const mainEditor = (0, import_react9.useMemo)(
451
+ const { editor: coreEditor } = (0, import_react7.useCurrentEditor)();
452
+ const mainEditor = (0, import_react8.useMemo)(
1593
453
  () => providedEditor || coreEditor,
1594
454
  [providedEditor, coreEditor]
1595
455
  );
1596
- const editorState = (0, import_react8.useEditorState)({
456
+ const editorState = (0, import_react7.useEditorState)({
1597
457
  editor: mainEditor,
1598
458
  selector(context) {
1599
459
  if (!context.editor) {
@@ -1627,7 +487,7 @@ function useScrollToHash(config = {}) {
1627
487
  (id) => {
1628
488
  var _a, _b, _c;
1629
489
  if (!editor) return false;
1630
- const attributeName = (_c = (_b = (_a = getEditorExtension(editor, "uniqueID")) == null ? void 0 : _a.options) == null ? void 0 : _b.attributeName) != null ? _c : "data-id";
490
+ const attributeName = (_c = (_b = (_a = (0, import_editor_utils.getEditorExtension)(editor, "uniqueID")) == null ? void 0 : _a.options) == null ? void 0 : _b.attributeName) != null ? _c : "data-id";
1631
491
  let position = null;
1632
492
  editor.state.doc.descendants((node, pos) => {
1633
493
  var _a2;
@@ -1701,28 +561,29 @@ function useScrollToHash(config = {}) {
1701
561
 
1702
562
  // src/ui/slash-dropdown-menu/slash-dropdown-menu.tsx
1703
563
  var import_button = require("@kopexa/button");
564
+ var import_editor_utils4 = require("@kopexa/editor-utils");
1704
565
  var import_separator = require("@kopexa/separator");
1705
566
  var import_theme = require("@kopexa/theme");
1706
567
  var React7 = __toESM(require("react"));
1707
568
 
1708
569
  // src/ui/suggestion-menu/suggestion-menu.tsx
1709
- var import_react11 = require("@floating-ui/react");
1710
- var import_state7 = require("@tiptap/pm/state");
570
+ var import_react10 = require("@floating-ui/react");
571
+ var import_state5 = require("@tiptap/pm/state");
1711
572
  var import_suggestion = require("@tiptap/suggestion");
1712
573
  var React5 = __toESM(require("react"));
1713
574
 
1714
575
  // src/hooks/use-floating-element.ts
1715
- var import_react10 = require("@floating-ui/react");
576
+ var import_react9 = require("@floating-ui/react");
1716
577
  var React3 = __toESM(require("react"));
1717
578
  function useFloatingElement(show, referencePos, zIndex, options) {
1718
579
  const { dismissOptions, ...floatingOptions } = options || {};
1719
- const { refs, update, context, floatingStyles } = (0, import_react10.useFloating)({
580
+ const { refs, update, context, floatingStyles } = (0, import_react9.useFloating)({
1720
581
  open: show,
1721
582
  ...floatingOptions
1722
583
  });
1723
- const { isMounted, styles } = (0, import_react10.useTransitionStyles)(context);
1724
- const dismiss = (0, import_react10.useDismiss)(context, dismissOptions);
1725
- const { getReferenceProps, getFloatingProps } = (0, import_react10.useInteractions)([dismiss]);
584
+ const { isMounted, styles } = (0, import_react9.useTransitionStyles)(context);
585
+ const dismiss = (0, import_react9.useDismiss)(context, dismissOptions);
586
+ const { getReferenceProps, getFloatingProps } = (0, import_react9.useInteractions)([dismiss]);
1726
587
  React3.useEffect(() => {
1727
588
  update();
1728
589
  }, [referencePos, update]);
@@ -1956,13 +817,13 @@ var SuggestionMenu = ({
1956
817
  {
1957
818
  placement: "bottom-start",
1958
819
  middleware: [
1959
- (0, import_react11.offset)(10),
1960
- (0, import_react11.flip)({
820
+ (0, import_react10.offset)(10),
821
+ (0, import_react10.flip)({
1961
822
  mainAxis: true,
1962
823
  crossAxis: false
1963
824
  }),
1964
- (0, import_react11.shift)(),
1965
- (0, import_react11.size)({
825
+ (0, import_react10.shift)(),
826
+ (0, import_react10.size)({
1966
827
  apply({ availableHeight, elements }) {
1967
828
  if (elements.floating) {
1968
829
  const maxHeightValue = maxHeight ? Math.min(maxHeight, availableHeight) : availableHeight;
@@ -2000,7 +861,7 @@ var SuggestionMenu = ({
2000
861
  editor.unregisterPlugin(pluginKey);
2001
862
  }
2002
863
  const suggestion = (0, import_suggestion.Suggestion)({
2003
- pluginKey: pluginKey instanceof import_state7.PluginKey ? pluginKey : new import_state7.PluginKey(pluginKey),
864
+ pluginKey: pluginKey instanceof import_state5.PluginKey ? pluginKey : new import_state5.PluginKey(pluginKey),
2004
865
  editor,
2005
866
  command({ editor: editor2, range, props }) {
2006
867
  var _a, _b;
@@ -2122,16 +983,18 @@ var SuggestionMenu = ({
2122
983
  };
2123
984
 
2124
985
  // src/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts
2125
- var import_icons3 = require("@kopexa/icons");
986
+ var import_editor_utils3 = require("@kopexa/editor-utils");
987
+ var import_icons2 = require("@kopexa/icons");
2126
988
  var React6 = __toESM(require("react"));
2127
989
 
2128
990
  // src/ui/table-button/use-table.ts
2129
- var import_icons2 = require("@kopexa/icons");
2130
- var import_react12 = require("@tiptap/react");
2131
- var import_react13 = require("react");
991
+ var import_editor_utils2 = require("@kopexa/editor-utils");
992
+ var import_icons = require("@kopexa/icons");
993
+ var import_react11 = require("@tiptap/react");
994
+ var import_react12 = require("react");
2132
995
  function canToggle(editor) {
2133
996
  if (!editor || !editor.isEditable) return false;
2134
- if (!isNodeInSchema("table", editor) || isNodeTypeSelected(editor, ["image"])) {
997
+ if (!(0, import_editor_utils2.isNodeInSchema)("table", editor) || (0, import_editor_utils2.isNodeTypeSelected)(editor, ["image"])) {
2135
998
  return false;
2136
999
  }
2137
1000
  try {
@@ -2157,9 +1020,9 @@ function toggleTable(editor, config) {
2157
1020
  function shouldShowButton(props) {
2158
1021
  const { editor, hideWhenUnavailable } = props;
2159
1022
  if (!editor || !editor.isEditable) return false;
2160
- if (!isNodeInSchema("table", editor)) return false;
1023
+ if (!(0, import_editor_utils2.isNodeInSchema)("table", editor)) return false;
2161
1024
  if (hideWhenUnavailable) {
2162
- if ((0, import_react12.isNodeSelection)(editor.state.selection) || !canToggle) {
1025
+ if ((0, import_react11.isNodeSelection)(editor.state.selection) || !canToggle) {
2163
1026
  return false;
2164
1027
  }
2165
1028
  }
@@ -2172,10 +1035,10 @@ function useTableBlock(config) {
2172
1035
  onToggled
2173
1036
  } = config || {};
2174
1037
  const { editor } = useTiptapEditor(providedEditor);
2175
- const [isVisible, setIsVisible] = (0, import_react13.useState)(true);
1038
+ const [isVisible, setIsVisible] = (0, import_react12.useState)(true);
2176
1039
  const canToggleState = canToggle(editor);
2177
1040
  const isActive = (editor == null ? void 0 : editor.isActive("table")) || false;
2178
- (0, import_react13.useEffect)(() => {
1041
+ (0, import_react12.useEffect)(() => {
2179
1042
  if (!editor) return;
2180
1043
  const handleSelectionUpdate = () => {
2181
1044
  setIsVisible(shouldShowButton({ editor, hideWhenUnavailable }));
@@ -2186,7 +1049,7 @@ function useTableBlock(config) {
2186
1049
  editor.off("selectionUpdate", handleSelectionUpdate);
2187
1050
  };
2188
1051
  }, [editor, hideWhenUnavailable]);
2189
- const handleToggle = (0, import_react13.useCallback)(() => {
1052
+ const handleToggle = (0, import_react12.useCallback)(() => {
2190
1053
  if (!editor) return false;
2191
1054
  const success = toggleTable(editor);
2192
1055
  if (success) {
@@ -2201,7 +1064,7 @@ function useTableBlock(config) {
2201
1064
  canToggle: canToggleState,
2202
1065
  label: "Table",
2203
1066
  // shortcutKeys: CODE_BLOCK_SHORTCUT_KEY,
2204
- Icon: import_icons2.TableIcon
1067
+ Icon: import_icons.TableIcon
2205
1068
  };
2206
1069
  }
2207
1070
 
@@ -2212,14 +1075,14 @@ var texts = {
2212
1075
  title: "Continue Writing",
2213
1076
  subtext: "Continue writing from the current position",
2214
1077
  keywords: ["continue", "write", "continue writing", "ai"],
2215
- badge: import_icons3.AiSparklesIcon,
1078
+ badge: import_icons2.AiSparklesIcon,
2216
1079
  group: "AI"
2217
1080
  },
2218
1081
  ai_ask_button: {
2219
1082
  title: "Ask AI",
2220
1083
  subtext: "Ask AI to generate content",
2221
1084
  keywords: ["ai", "ask", "generate"],
2222
- badge: import_icons3.AiSparklesIcon,
1085
+ badge: import_icons2.AiSparklesIcon,
2223
1086
  group: "AI"
2224
1087
  },
2225
1088
  // Style
@@ -2227,63 +1090,63 @@ var texts = {
2227
1090
  title: "Text",
2228
1091
  subtext: "Regular text paragraph",
2229
1092
  keywords: ["p", "paragraph", "text"],
2230
- badge: import_icons3.TypeIcon,
1093
+ badge: import_icons2.TypeIcon,
2231
1094
  group: "Style"
2232
1095
  },
2233
1096
  heading_1: {
2234
1097
  title: "Heading 1",
2235
1098
  subtext: "Top-level heading",
2236
1099
  keywords: ["h", "heading1", "h1"],
2237
- badge: import_icons3.HeadingOneIcon,
1100
+ badge: import_icons2.HeadingOneIcon,
2238
1101
  group: "Style"
2239
1102
  },
2240
1103
  heading_2: {
2241
1104
  title: "Heading 2",
2242
1105
  subtext: "Key section heading",
2243
1106
  keywords: ["h2", "heading2", "subheading"],
2244
- badge: import_icons3.HeadingTwoIcon,
1107
+ badge: import_icons2.HeadingTwoIcon,
2245
1108
  group: "Style"
2246
1109
  },
2247
1110
  heading_3: {
2248
1111
  title: "Heading 3",
2249
1112
  subtext: "Subsection and group heading",
2250
1113
  keywords: ["h3", "heading3", "subheading"],
2251
- badge: import_icons3.HeadingThreeIcon,
1114
+ badge: import_icons2.HeadingThreeIcon,
2252
1115
  group: "Style"
2253
1116
  },
2254
1117
  bullet_list: {
2255
1118
  title: "Bullet List",
2256
1119
  subtext: "List with unordered items",
2257
1120
  keywords: ["ul", "li", "list", "bulletlist", "bullet list"],
2258
- badge: import_icons3.ListIcon,
1121
+ badge: import_icons2.ListIcon,
2259
1122
  group: "Style"
2260
1123
  },
2261
1124
  ordered_list: {
2262
1125
  title: "Numbered List",
2263
1126
  subtext: "List with ordered items",
2264
1127
  keywords: ["ol", "li", "list", "numberedlist", "numbered list"],
2265
- badge: import_icons3.ListOrderedIcon,
1128
+ badge: import_icons2.ListOrderedIcon,
2266
1129
  group: "Style"
2267
1130
  },
2268
1131
  task_list: {
2269
1132
  title: "To-do list",
2270
1133
  subtext: "List with tasks",
2271
1134
  keywords: ["tasklist", "task list", "todo", "checklist"],
2272
- badge: import_icons3.ListTodoIcon,
1135
+ badge: import_icons2.ListTodoIcon,
2273
1136
  group: "Style"
2274
1137
  },
2275
1138
  quote: {
2276
1139
  title: "Blockquote",
2277
1140
  subtext: "Blockquote block",
2278
1141
  keywords: ["quote", "blockquote"],
2279
- badge: import_icons3.BlockquoteIcon,
1142
+ badge: import_icons2.BlockquoteIcon,
2280
1143
  group: "Style"
2281
1144
  },
2282
1145
  code_block: {
2283
1146
  title: "Code Block",
2284
1147
  subtext: "Code block with syntax highlighting",
2285
1148
  keywords: ["code", "pre"],
2286
- badge: import_icons3.CodeBlockIcon,
1149
+ badge: import_icons2.CodeBlockIcon,
2287
1150
  group: "Style"
2288
1151
  },
2289
1152
  // Insert
@@ -2305,21 +1168,21 @@ var texts = {
2305
1168
  title: "Control",
2306
1169
  subtext: "Insert a control block",
2307
1170
  keywords: ["control"],
2308
- badge: import_icons3.ControlsIcon,
1171
+ badge: import_icons2.ControlsIcon,
2309
1172
  group: "Insert"
2310
1173
  },
2311
1174
  divider: {
2312
1175
  title: "Separator",
2313
1176
  subtext: "Horizontal line to separate content",
2314
1177
  keywords: ["hr", "horizontalRule", "line", "separator"],
2315
- badge: import_icons3.MinusIcon,
1178
+ badge: import_icons2.MinusIcon,
2316
1179
  group: "Insert"
2317
1180
  },
2318
1181
  table: {
2319
1182
  title: "Table",
2320
1183
  subtext: "Insert a table",
2321
1184
  keywords: ["table", "grid", "spreadsheet"],
2322
- badge: import_icons3.TableIcon,
1185
+ badge: import_icons2.TableIcon,
2323
1186
  group: "Insert"
2324
1187
  },
2325
1188
  // Upload
@@ -2335,7 +1198,7 @@ var texts = {
2335
1198
  "media",
2336
1199
  "url"
2337
1200
  ],
2338
- badge: import_icons3.ImageIcon,
1201
+ badge: import_icons2.ImageIcon,
2339
1202
  group: "Upload"
2340
1203
  }
2341
1204
  };
@@ -2344,8 +1207,8 @@ var getItemImplementations = () => {
2344
1207
  // AI
2345
1208
  continue_writing: {
2346
1209
  check: (editor) => {
2347
- const { hasContent } = hasContentAbove(editor);
2348
- const extensionsReady = isExtensionAvailable(editor, [
1210
+ const { hasContent } = (0, import_editor_utils3.hasContentAbove)(editor);
1211
+ const extensionsReady = (0, import_editor_utils3.isExtensionAvailable)(editor, [
2349
1212
  "ai",
2350
1213
  "aiAdvanced"
2351
1214
  ]);
@@ -2353,14 +1216,14 @@ var getItemImplementations = () => {
2353
1216
  },
2354
1217
  action: ({ editor }) => {
2355
1218
  const editorChain = editor.chain().focus();
2356
- const nodeSelectionPosition = findSelectionPosition({ editor });
1219
+ const nodeSelectionPosition = (0, import_editor_utils3.findSelectionPosition)({ editor });
2357
1220
  if (nodeSelectionPosition !== null) {
2358
1221
  editorChain.setNodeSelection(nodeSelectionPosition);
2359
1222
  }
2360
1223
  editorChain.run();
2361
1224
  editor.chain().focus().aiGenerationShow().run();
2362
1225
  requestAnimationFrame(() => {
2363
- const { hasContent, content } = hasContentAbove(editor);
1226
+ const { hasContent, content } = (0, import_editor_utils3.hasContentAbove)(editor);
2364
1227
  const snippet = content.length > 500 ? `...${content.slice(-500)}` : content;
2365
1228
  const prompt = hasContent ? `Context: ${snippet}
2366
1229
 
@@ -2374,10 +1237,10 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
2374
1237
  }
2375
1238
  },
2376
1239
  ai_ask_button: {
2377
- check: (editor) => isExtensionAvailable(editor, ["ai", "aiAdvanced"]),
1240
+ check: (editor) => (0, import_editor_utils3.isExtensionAvailable)(editor, ["ai", "aiAdvanced"]),
2378
1241
  action: ({ editor }) => {
2379
1242
  const editorChain = editor.chain().focus();
2380
- const nodeSelectionPosition = findSelectionPosition({ editor });
1243
+ const nodeSelectionPosition = (0, import_editor_utils3.findSelectionPosition)({ editor });
2381
1244
  if (nodeSelectionPosition !== null) {
2382
1245
  editorChain.setNodeSelection(nodeSelectionPosition);
2383
1246
  }
@@ -2387,55 +1250,55 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
2387
1250
  },
2388
1251
  // Style
2389
1252
  text: {
2390
- check: (editor) => isNodeInSchema("paragraph", editor),
1253
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("paragraph", editor),
2391
1254
  action: ({ editor }) => {
2392
1255
  editor.chain().focus().setParagraph().run();
2393
1256
  }
2394
1257
  },
2395
1258
  heading_1: {
2396
- check: (editor) => isNodeInSchema("heading", editor),
1259
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("heading", editor),
2397
1260
  action: ({ editor }) => {
2398
1261
  editor.chain().focus().toggleHeading({ level: 1 }).run();
2399
1262
  }
2400
1263
  },
2401
1264
  heading_2: {
2402
- check: (editor) => isNodeInSchema("heading", editor),
1265
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("heading", editor),
2403
1266
  action: ({ editor }) => {
2404
1267
  editor.chain().focus().toggleHeading({ level: 2 }).run();
2405
1268
  }
2406
1269
  },
2407
1270
  heading_3: {
2408
- check: (editor) => isNodeInSchema("heading", editor),
1271
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("heading", editor),
2409
1272
  action: ({ editor }) => {
2410
1273
  editor.chain().focus().toggleHeading({ level: 3 }).run();
2411
1274
  }
2412
1275
  },
2413
1276
  bullet_list: {
2414
- check: (editor) => isNodeInSchema("bulletList", editor),
1277
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("bulletList", editor),
2415
1278
  action: ({ editor }) => {
2416
1279
  editor.chain().focus().toggleBulletList().run();
2417
1280
  }
2418
1281
  },
2419
1282
  ordered_list: {
2420
- check: (editor) => isNodeInSchema("orderedList", editor),
1283
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("orderedList", editor),
2421
1284
  action: ({ editor }) => {
2422
1285
  editor.chain().focus().toggleOrderedList().run();
2423
1286
  }
2424
1287
  },
2425
1288
  task_list: {
2426
- check: (editor) => isNodeInSchema("taskList", editor),
1289
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("taskList", editor),
2427
1290
  action: ({ editor }) => {
2428
1291
  editor.chain().focus().toggleTaskList().run();
2429
1292
  }
2430
1293
  },
2431
1294
  quote: {
2432
- check: (editor) => isNodeInSchema("blockquote", editor),
1295
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("blockquote", editor),
2433
1296
  action: ({ editor }) => {
2434
1297
  editor.chain().focus().toggleBlockquote().run();
2435
1298
  }
2436
1299
  },
2437
1300
  code_block: {
2438
- check: (editor) => isNodeInSchema("codeBlock", editor),
1301
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("codeBlock", editor),
2439
1302
  action: ({ editor }) => {
2440
1303
  editor.chain().focus().toggleNode("codeBlock", "paragraph").run();
2441
1304
  }
@@ -2452,21 +1315,20 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
2452
1315
  // action: ({ editor }: { editor: Editor }) => addEmojiTrigger(editor),
2453
1316
  // },
2454
1317
  divider: {
2455
- check: (editor) => isNodeInSchema("horizontalRule", editor),
1318
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("horizontalRule", editor),
2456
1319
  action: ({ editor }) => {
2457
1320
  editor.chain().focus().setHorizontalRule().run();
2458
1321
  }
2459
1322
  },
2460
1323
  table: {
2461
- check: (editor) => isNodeInSchema("table", editor),
1324
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("table", editor),
2462
1325
  action: ({ editor }) => toggleTable(editor, { rows: 3, cols: 3, withHeaderRow: true })
2463
1326
  },
2464
1327
  control: {
2465
- check: (editor) => isNodeInSchema("controlRef", editor),
1328
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("controlBlock", editor),
2466
1329
  action: ({ editor }) => {
2467
- console.log("hoho");
2468
1330
  try {
2469
- return editor.chain().focus().insertControlRef().run();
1331
+ return editor.chain().focus().insertControlBlock().run();
2470
1332
  } catch (e) {
2471
1333
  console.error(e);
2472
1334
  }
@@ -2474,7 +1336,7 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
2474
1336
  },
2475
1337
  // Upload
2476
1338
  image: {
2477
- check: (editor) => isNodeInSchema("image", editor),
1339
+ check: (editor) => (0, import_editor_utils3.isNodeInSchema)("image", editor),
2478
1340
  action: ({ editor }) => {
2479
1341
  editor.chain().focus().insertContent({
2480
1342
  type: "imageUpload"
@@ -2565,7 +1427,7 @@ var Item = (props) => {
2565
1427
  '[data-selector="tiptap-slash-dropdown-menu"]'
2566
1428
  );
2567
1429
  if (!itemRef.current || !isSelected || !selector) return;
2568
- const overflow = getElementOverflowPosition(itemRef.current, selector);
1430
+ const overflow = (0, import_editor_utils4.getElementOverflowPosition)(itemRef.current, selector);
2569
1431
  if (overflow === "top") {
2570
1432
  itemRef.current.scrollIntoView(true);
2571
1433
  } else if (overflow === "bottom") {
@@ -2683,11 +1545,11 @@ var List = ({
2683
1545
  };
2684
1546
 
2685
1547
  // src/presets/basic/editor-header.tsx
2686
- var import_icons18 = require("@kopexa/icons");
1548
+ var import_icons17 = require("@kopexa/icons");
2687
1549
  var import_popover3 = require("@kopexa/popover");
2688
1550
  var import_toolbar9 = require("@kopexa/toolbar");
2689
1551
  var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
2690
- var import_react31 = require("react");
1552
+ var import_react30 = require("react");
2691
1553
 
2692
1554
  // src/hooks/use-cursor-visibility.ts
2693
1555
  var React9 = __toESM(require("react"));
@@ -2796,14 +1658,15 @@ var import_toolbar = require("@kopexa/toolbar");
2796
1658
  var React11 = __toESM(require("react"));
2797
1659
 
2798
1660
  // src/ui/blockquote-button/use-blockquote.ts
2799
- var import_icons4 = require("@kopexa/icons");
2800
- var import_state8 = require("@tiptap/pm/state");
1661
+ var import_editor_utils5 = require("@kopexa/editor-utils");
1662
+ var import_icons3 = require("@kopexa/icons");
1663
+ var import_state6 = require("@tiptap/pm/state");
2801
1664
  var React10 = __toESM(require("react"));
2802
1665
  var BLOCKQUOTE_SHORTCUT_KEY = "mod+shift+b";
2803
1666
  function canToggleBlockquote(editor, turnInto = true) {
2804
1667
  var _a;
2805
1668
  if (!editor || !editor.isEditable) return false;
2806
- if (!isNodeInSchema("blockquote", editor) || isNodeTypeSelected(editor, ["image"]))
1669
+ if (!(0, import_editor_utils5.isNodeInSchema)("blockquote", editor) || (0, import_editor_utils5.isNodeTypeSelected)(editor, ["image"]))
2807
1670
  return false;
2808
1671
  if (!turnInto) {
2809
1672
  return editor.can().toggleWrap("blockquote");
@@ -2812,12 +1675,12 @@ function canToggleBlockquote(editor, turnInto = true) {
2812
1675
  const view = editor.view;
2813
1676
  const state = view.state;
2814
1677
  const selection = state.selection;
2815
- if (selection.empty || selection instanceof import_state8.TextSelection) {
2816
- const pos = (_a = findNodePosition({
1678
+ if (selection.empty || selection instanceof import_state6.TextSelection) {
1679
+ const pos = (_a = (0, import_editor_utils5.findNodePosition)({
2817
1680
  editor,
2818
1681
  node: state.selection.$anchor.node(1)
2819
1682
  })) == null ? void 0 : _a.pos;
2820
- if (!isValidPosition(pos)) return false;
1683
+ if (!(0, import_editor_utils5.isValidPosition)(pos)) return false;
2821
1684
  }
2822
1685
  return true;
2823
1686
  } catch {
@@ -2832,19 +1695,19 @@ function toggleBlockquote(editor) {
2832
1695
  const view = editor.view;
2833
1696
  let state = view.state;
2834
1697
  let tr = state.tr;
2835
- if (state.selection.empty || state.selection instanceof import_state8.TextSelection) {
2836
- const pos = (_a = findNodePosition({
1698
+ if (state.selection.empty || state.selection instanceof import_state6.TextSelection) {
1699
+ const pos = (_a = (0, import_editor_utils5.findNodePosition)({
2837
1700
  editor,
2838
1701
  node: state.selection.$anchor.node(1)
2839
1702
  })) == null ? void 0 : _a.pos;
2840
- if (!isValidPosition(pos)) return false;
2841
- tr = tr.setSelection(import_state8.NodeSelection.create(state.doc, pos));
1703
+ if (!(0, import_editor_utils5.isValidPosition)(pos)) return false;
1704
+ tr = tr.setSelection(import_state6.NodeSelection.create(state.doc, pos));
2842
1705
  view.dispatch(tr);
2843
1706
  state = view.state;
2844
1707
  }
2845
1708
  const selection = state.selection;
2846
1709
  let chain = editor.chain().focus();
2847
- if (selection instanceof import_state8.NodeSelection) {
1710
+ if (selection instanceof import_state6.NodeSelection) {
2848
1711
  const firstChild = (_b = selection.node.firstChild) == null ? void 0 : _b.firstChild;
2849
1712
  const lastChild = (_c = selection.node.lastChild) == null ? void 0 : _c.lastChild;
2850
1713
  const from = firstChild ? selection.from + firstChild.nodeSize : selection.from + 1;
@@ -2862,7 +1725,7 @@ function toggleBlockquote(editor) {
2862
1725
  function shouldShowButton2(props) {
2863
1726
  const { editor, hideWhenUnavailable } = props;
2864
1727
  if (!editor || !editor.isEditable) return false;
2865
- if (!isNodeInSchema("blockquote", editor)) return false;
1728
+ if (!(0, import_editor_utils5.isNodeInSchema)("blockquote", editor)) return false;
2866
1729
  if (hideWhenUnavailable && !editor.isActive("code")) {
2867
1730
  return canToggleBlockquote(editor);
2868
1731
  }
@@ -2904,7 +1767,7 @@ function useBlockquote(config) {
2904
1767
  canToggle: canToggle3,
2905
1768
  label: "Blockquote",
2906
1769
  shortcutKeys: BLOCKQUOTE_SHORTCUT_KEY,
2907
- Icon: import_icons4.BlockquoteIcon
1770
+ Icon: import_icons3.BlockquoteIcon
2908
1771
  };
2909
1772
  }
2910
1773
 
@@ -2971,19 +1834,20 @@ var BlockquoteButton = ({
2971
1834
  };
2972
1835
 
2973
1836
  // src/ui/codeblock-button/code-block-button.tsx
2974
- var import_icons6 = require("@kopexa/icons");
1837
+ var import_icons5 = require("@kopexa/icons");
2975
1838
  var import_toolbar2 = require("@kopexa/toolbar");
2976
- var import_react14 = require("react");
1839
+ var import_react13 = require("react");
2977
1840
 
2978
1841
  // src/ui/codeblock-button/use-code-block.ts
2979
- var import_icons5 = require("@kopexa/icons");
2980
- var import_state9 = require("@tiptap/pm/state");
1842
+ var import_editor_utils6 = require("@kopexa/editor-utils");
1843
+ var import_icons4 = require("@kopexa/icons");
1844
+ var import_state7 = require("@tiptap/pm/state");
2981
1845
  var React12 = __toESM(require("react"));
2982
1846
  var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
2983
1847
  function canToggle2(editor, turnInto = true) {
2984
1848
  var _a;
2985
1849
  if (!editor || !editor.isEditable) return false;
2986
- if (!isNodeInSchema("codeBlock", editor) || isNodeTypeSelected(editor, ["image"]))
1850
+ if (!(0, import_editor_utils6.isNodeInSchema)("codeBlock", editor) || (0, import_editor_utils6.isNodeTypeSelected)(editor, ["image"]))
2987
1851
  return false;
2988
1852
  if (!turnInto) {
2989
1853
  return editor.can().toggleNode("codeBlock", "paragraph");
@@ -2992,12 +1856,12 @@ function canToggle2(editor, turnInto = true) {
2992
1856
  const view = editor.view;
2993
1857
  const state = view.state;
2994
1858
  const selection = state.selection;
2995
- if (selection.empty || selection instanceof import_state9.TextSelection) {
2996
- const pos = (_a = findNodePosition({
1859
+ if (selection.empty || selection instanceof import_state7.TextSelection) {
1860
+ const pos = (_a = (0, import_editor_utils6.findNodePosition)({
2997
1861
  editor,
2998
1862
  node: state.selection.$anchor.node(1)
2999
1863
  })) == null ? void 0 : _a.pos;
3000
- if (!isValidPosition(pos)) return false;
1864
+ if (!(0, import_editor_utils6.isValidPosition)(pos)) return false;
3001
1865
  }
3002
1866
  return true;
3003
1867
  } catch {
@@ -3012,19 +1876,19 @@ function toggleCodeBlock(editor) {
3012
1876
  const view = editor.view;
3013
1877
  let state = view.state;
3014
1878
  let tr = state.tr;
3015
- if (state.selection.empty || state.selection instanceof import_state9.TextSelection) {
3016
- const pos = (_a = findNodePosition({
1879
+ if (state.selection.empty || state.selection instanceof import_state7.TextSelection) {
1880
+ const pos = (_a = (0, import_editor_utils6.findNodePosition)({
3017
1881
  editor,
3018
1882
  node: state.selection.$anchor.node(1)
3019
1883
  })) == null ? void 0 : _a.pos;
3020
- if (!isValidPosition(pos)) return false;
3021
- tr = tr.setSelection(import_state9.NodeSelection.create(state.doc, pos));
1884
+ if (!(0, import_editor_utils6.isValidPosition)(pos)) return false;
1885
+ tr = tr.setSelection(import_state7.NodeSelection.create(state.doc, pos));
3022
1886
  view.dispatch(tr);
3023
1887
  state = view.state;
3024
1888
  }
3025
1889
  const selection = state.selection;
3026
1890
  let chain = editor.chain().focus();
3027
- if (selection instanceof import_state9.NodeSelection) {
1891
+ if (selection instanceof import_state7.NodeSelection) {
3028
1892
  const firstChild = (_b = selection.node.firstChild) == null ? void 0 : _b.firstChild;
3029
1893
  const lastChild = (_c = selection.node.lastChild) == null ? void 0 : _c.lastChild;
3030
1894
  const from = firstChild ? selection.from + firstChild.nodeSize : selection.from + 1;
@@ -3042,7 +1906,7 @@ function toggleCodeBlock(editor) {
3042
1906
  function shouldShowButton3(props) {
3043
1907
  const { editor, hideWhenUnavailable } = props;
3044
1908
  if (!editor || !editor.isEditable) return false;
3045
- if (!isNodeInSchema("codeBlock", editor)) return false;
1909
+ if (!(0, import_editor_utils6.isNodeInSchema)("codeBlock", editor)) return false;
3046
1910
  if (hideWhenUnavailable && !editor.isActive("code")) {
3047
1911
  return canToggle2(editor);
3048
1912
  }
@@ -3084,7 +1948,7 @@ function useCodeBlock(config) {
3084
1948
  canToggle: canToggleState,
3085
1949
  label: "Code Block",
3086
1950
  shortcutKeys: CODE_BLOCK_SHORTCUT_KEY,
3087
- Icon: import_icons5.CodeblockIcon
1951
+ Icon: import_icons4.CodeblockIcon
3088
1952
  };
3089
1953
  }
3090
1954
 
@@ -3101,20 +1965,12 @@ var CodeBlockButton = ({
3101
1965
  ...buttonProps
3102
1966
  }) => {
3103
1967
  const { editor } = useTiptapEditor(providedEditor);
3104
- const {
3105
- isVisible,
3106
- canToggle: canToggle3,
3107
- isActive,
3108
- handleToggle,
3109
- label,
3110
- shortcutKeys,
3111
- Icon
3112
- } = useCodeBlock({
1968
+ const { isVisible, canToggle: canToggle3, isActive, handleToggle, label, shortcutKeys } = useCodeBlock({
3113
1969
  editor,
3114
1970
  hideWhenUnavailable,
3115
1971
  onToggled
3116
1972
  });
3117
- const handleClick = (0, import_react14.useCallback)(
1973
+ const handleClick = (0, import_react13.useCallback)(
3118
1974
  (event) => {
3119
1975
  onClick == null ? void 0 : onClick(event);
3120
1976
  if (event.defaultPrevented) return;
@@ -3142,25 +1998,26 @@ var CodeBlockButton = ({
3142
1998
  onClick: handleClick,
3143
1999
  isIconOnly: true,
3144
2000
  ...buttonProps,
3145
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons6.CodeblockIcon, {})
2001
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons5.CodeblockIcon, {})
3146
2002
  }
3147
2003
  );
3148
2004
  };
3149
2005
 
3150
2006
  // src/ui/color-highlight-popover/color-highlight-popover.tsx
3151
2007
  var import_button2 = require("@kopexa/button");
3152
- var import_icons8 = require("@kopexa/icons");
2008
+ var import_icons7 = require("@kopexa/icons");
3153
2009
  var import_popover = require("@kopexa/popover");
3154
2010
  var import_toolbar4 = require("@kopexa/toolbar");
3155
- var import_react16 = require("react");
2011
+ var import_react15 = require("react");
3156
2012
 
3157
2013
  // src/ui/color-highlight-button/color-highlight-button.tsx
3158
2014
  var import_theme2 = require("@kopexa/theme");
3159
2015
  var import_toolbar3 = require("@kopexa/toolbar");
3160
- var import_react15 = require("react");
2016
+ var import_react14 = require("react");
3161
2017
 
3162
2018
  // src/ui/color-highlight-button/use-color-highlight.ts
3163
- var import_icons7 = require("@kopexa/icons");
2019
+ var import_editor_utils7 = require("@kopexa/editor-utils");
2020
+ var import_icons6 = require("@kopexa/icons");
3164
2021
  var import_use_is_mobile = require("@kopexa/use-is-mobile");
3165
2022
  var React13 = __toESM(require("react"));
3166
2023
  var import_react_hotkeys_hook = require("react-hotkeys-hook");
@@ -3225,7 +2082,7 @@ function pickHighlightColorsByValue(values) {
3225
2082
  }
3226
2083
  function canColorHighlight(editor) {
3227
2084
  if (!editor || !editor.isEditable) return false;
3228
- if (!isMarkInSchema("highlight", editor) || isNodeTypeSelected(editor, ["image"]))
2085
+ if (!(0, import_editor_utils7.isMarkInSchema)("highlight", editor) || (0, import_editor_utils7.isNodeTypeSelected)(editor, ["image"]))
3229
2086
  return false;
3230
2087
  return editor.can().setMark("highlight");
3231
2088
  }
@@ -3241,7 +2098,7 @@ function removeHighlight(editor) {
3241
2098
  function shouldShowButton4(props) {
3242
2099
  const { editor, hideWhenUnavailable } = props;
3243
2100
  if (!editor || !editor.isEditable) return false;
3244
- if (!isMarkInSchema("highlight", editor)) return false;
2101
+ if (!(0, import_editor_utils7.isMarkInSchema)("highlight", editor)) return false;
3245
2102
  if (hideWhenUnavailable && !editor.isActive("code")) {
3246
2103
  return canColorHighlight(editor);
3247
2104
  }
@@ -3317,7 +2174,7 @@ function useColorHighlight(config) {
3317
2174
  canColorHighlight: canColorHighlightState,
3318
2175
  label: label || `Highlight`,
3319
2176
  shortcutKeys: COLOR_HIGHLIGHT_SHORTCUT_KEY,
3320
- Icon: import_icons7.HighlighterIcon
2177
+ Icon: import_icons6.HighlighterIcon
3321
2178
  };
3322
2179
  }
3323
2180
 
@@ -3351,7 +2208,7 @@ var ColorHighlightButton = ({
3351
2208
  hideWhenUnavailable,
3352
2209
  onApplied
3353
2210
  });
3354
- const handleClick = (0, import_react15.useCallback)(
2211
+ const handleClick = (0, import_react14.useCallback)(
3355
2212
  (event) => {
3356
2213
  onClick == null ? void 0 : onClick(event);
3357
2214
  if (event.defaultPrevented) return;
@@ -3359,7 +2216,7 @@ var ColorHighlightButton = ({
3359
2216
  },
3360
2217
  [handleColorHighlight, onClick]
3361
2218
  );
3362
- const buttonStyle = (0, import_react15.useMemo)(
2219
+ const buttonStyle = (0, import_react14.useMemo)(
3363
2220
  () => ({
3364
2221
  ...style,
3365
2222
  "--highlight-color": highlightColor
@@ -3428,7 +2285,7 @@ var ColorHighlightPopoverButton = ({
3428
2285
  tooltip: "Highlight",
3429
2286
  isIconOnly: !children,
3430
2287
  ...props,
3431
- children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons8.HighlighterIcon, {})
2288
+ children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons7.HighlighterIcon, {})
3432
2289
  }
3433
2290
  );
3434
2291
  function ColorHighlightPopoverContent({
@@ -3442,8 +2299,8 @@ function ColorHighlightPopoverContent({
3442
2299
  ])
3443
2300
  }) {
3444
2301
  const { handleRemoveHighlight } = useColorHighlight({ editor });
3445
- const containerRef = (0, import_react16.useRef)(null);
3446
- const menuItems = (0, import_react16.useMemo)(
2302
+ const containerRef = (0, import_react15.useRef)(null);
2303
+ const menuItems = (0, import_react15.useMemo)(
3447
2304
  () => [...colors, { label: "Remove highlight", value: "none" }],
3448
2305
  [colors]
3449
2306
  );
@@ -3492,7 +2349,7 @@ function ColorHighlightPopoverContent({
3492
2349
  variant: "ghost",
3493
2350
  color: "default",
3494
2351
  "data-highlighted": selectedIndex === colors.length,
3495
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons8.BanIcon, {})
2352
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons7.BanIcon, {})
3496
2353
  }
3497
2354
  ) })
3498
2355
  ] });
@@ -3511,8 +2368,8 @@ function ColorHighlightPopover({
3511
2368
  ...props
3512
2369
  }) {
3513
2370
  const { editor } = useTiptapEditor(providedEditor);
3514
- const [isOpen, setIsOpen] = (0, import_react16.useState)(false);
3515
- const { isVisible, canColorHighlight: canColorHighlight2, isActive, label, Icon } = useColorHighlight({
2371
+ const [isOpen, setIsOpen] = (0, import_react15.useState)(false);
2372
+ const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
3516
2373
  editor,
3517
2374
  hideWhenUnavailable,
3518
2375
  onApplied
@@ -3543,17 +2400,19 @@ function ColorHighlightPopover({
3543
2400
  // src/ui/heading-dropdown-menu/index.tsx
3544
2401
  var import_button4 = require("@kopexa/button");
3545
2402
  var import_dropdown_menu = require("@kopexa/dropdown-menu");
3546
- var import_icons10 = require("@kopexa/icons");
3547
- var import_react18 = require("@tiptap/react");
2403
+ var import_editor_utils9 = require("@kopexa/editor-utils");
2404
+ var import_icons9 = require("@kopexa/icons");
2405
+ var import_react17 = require("@tiptap/react");
3548
2406
  var React15 = __toESM(require("react"));
3549
2407
 
3550
2408
  // src/ui/heading-button/index.tsx
3551
2409
  var import_button3 = require("@kopexa/button");
3552
- var import_icons9 = require("@kopexa/icons");
2410
+ var import_editor_utils8 = require("@kopexa/editor-utils");
2411
+ var import_icons8 = require("@kopexa/icons");
3553
2412
  var React14 = __toESM(require("react"));
3554
2413
 
3555
2414
  // src/ui/heading-button/utils.ts
3556
- var import_react17 = require("@tiptap/react");
2415
+ var import_react16 = require("@tiptap/react");
3557
2416
  var headingShortcutKeys = {
3558
2417
  1: "Ctrl-Alt-1",
3559
2418
  2: "Ctrl-Alt-2",
@@ -3594,7 +2453,7 @@ function shouldShowHeadingButton(params) {
3594
2453
  return false;
3595
2454
  }
3596
2455
  if (hideWhenUnavailable) {
3597
- if ((0, import_react17.isNodeSelection)(editor.state.selection)) {
2456
+ if ((0, import_react16.isNodeSelection)(editor.state.selection)) {
3598
2457
  return false;
3599
2458
  }
3600
2459
  }
@@ -3607,15 +2466,15 @@ function getFormattedHeadingName(level) {
3607
2466
  // src/ui/heading-button/index.tsx
3608
2467
  var import_jsx_runtime7 = require("react/jsx-runtime");
3609
2468
  var headingIcons = {
3610
- 1: import_icons9.HeadingOneIcon,
3611
- 2: import_icons9.HeadingTwoIcon,
3612
- 3: import_icons9.HeadingThreeIcon,
3613
- 4: import_icons9.HeadingFourIcon,
3614
- 5: import_icons9.HeadingFiveIcon,
3615
- 6: import_icons9.HeadingSixIcon
2469
+ 1: import_icons8.HeadingOneIcon,
2470
+ 2: import_icons8.HeadingTwoIcon,
2471
+ 3: import_icons8.HeadingThreeIcon,
2472
+ 4: import_icons8.HeadingFourIcon,
2473
+ 5: import_icons8.HeadingFiveIcon,
2474
+ 6: import_icons8.HeadingSixIcon
3616
2475
  };
3617
2476
  function useHeadingState(editor, level, disabled = false) {
3618
- const headingInSchema = isNodeInSchema("heading", editor);
2477
+ const headingInSchema = (0, import_editor_utils8.isNodeInSchema)("heading", editor);
3619
2478
  const isDisabled = isHeadingButtonDisabled(editor, level, disabled);
3620
2479
  const isActive = isHeadingActive(editor, level);
3621
2480
  const Icon = headingIcons[level];
@@ -3707,7 +2566,7 @@ function HeadingDropdownMenu({
3707
2566
  var _a;
3708
2567
  const [isOpen, setIsOpen] = React15.useState(false);
3709
2568
  const { editor } = useTiptapEditor(providedEditor);
3710
- const headingInSchema = isNodeInSchema("heading", editor);
2569
+ const headingInSchema = (0, import_editor_utils9.isNodeInSchema)("heading", editor);
3711
2570
  const handleOnOpenChange = React15.useCallback(
3712
2571
  (open) => {
3713
2572
  setIsOpen(open);
@@ -3716,11 +2575,11 @@ function HeadingDropdownMenu({
3716
2575
  [onOpenChange]
3717
2576
  );
3718
2577
  const getActiveIcon = React15.useCallback(() => {
3719
- if (!editor) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons10.HeadingIcon, {});
2578
+ if (!editor) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons9.HeadingIcon, {});
3720
2579
  const activeLevel = levels.find(
3721
2580
  (level) => editor.isActive("heading", { level })
3722
2581
  );
3723
- if (!activeLevel) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons10.HeadingIcon, {});
2582
+ if (!activeLevel) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons9.HeadingIcon, {});
3724
2583
  const ActiveIcon = headingIcons[activeLevel];
3725
2584
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ActiveIcon, {});
3726
2585
  }, [editor, levels]);
@@ -3737,7 +2596,7 @@ function HeadingDropdownMenu({
3737
2596
  return false;
3738
2597
  }
3739
2598
  if (hideWhenUnavailable) {
3740
- if ((0, import_react18.isNodeSelection)(editor.state.selection) || !canToggleAnyHeading()) {
2599
+ if ((0, import_react17.isNodeSelection)(editor.state.selection) || !canToggleAnyHeading()) {
3741
2600
  return false;
3742
2601
  }
3743
2602
  }
@@ -3760,7 +2619,7 @@ function HeadingDropdownMenu({
3760
2619
  "aria-label": "Format text as heading",
3761
2620
  "aria-pressed": isAnyHeadingActive,
3762
2621
  tooltip: "Heading",
3763
- endContent: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons10.ChevronDownIcon, {}),
2622
+ endContent: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons9.ChevronDownIcon, {}),
3764
2623
  ...props,
3765
2624
  children: getActiveIcon()
3766
2625
  }
@@ -3781,16 +2640,66 @@ function HeadingDropdownMenu({
3781
2640
 
3782
2641
  // src/ui/link-popover/link-popover.tsx
3783
2642
  var import_button5 = require("@kopexa/button");
3784
- var import_icons12 = require("@kopexa/icons");
2643
+ var import_icons11 = require("@kopexa/icons");
3785
2644
  var import_input = require("@kopexa/input");
3786
2645
  var import_popover2 = require("@kopexa/popover");
3787
2646
  var import_separator2 = require("@kopexa/separator");
3788
2647
  var import_toolbar5 = require("@kopexa/toolbar");
3789
- var import_react19 = require("react");
2648
+ var import_react18 = require("react");
3790
2649
 
3791
2650
  // src/ui/link-popover/use-link-popover.ts
3792
- var import_icons11 = require("@kopexa/icons");
2651
+ var import_editor_utils10 = require("@kopexa/editor-utils");
2652
+ var import_icons10 = require("@kopexa/icons");
3793
2653
  var React16 = __toESM(require("react"));
2654
+
2655
+ // src/utils/index.ts
2656
+ var MAX_FILE_SIZE = 5 * 1024 * 1024;
2657
+ var ATTR_WHITESPACE = (
2658
+ // eslint-disable-next-line no-control-regex
2659
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: we can do this yay
2660
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2661
+ );
2662
+ function isAllowedUri(uri, protocols) {
2663
+ const allowedProtocols = [
2664
+ "http",
2665
+ "https",
2666
+ "ftp",
2667
+ "ftps",
2668
+ "mailto",
2669
+ "tel",
2670
+ "callto",
2671
+ "sms",
2672
+ "cid",
2673
+ "xmpp"
2674
+ ];
2675
+ if (protocols) {
2676
+ for (const protocol of protocols) {
2677
+ const nextProtocol = typeof protocol === "string" ? protocol : protocol.scheme;
2678
+ if (nextProtocol) {
2679
+ allowedProtocols.push(nextProtocol);
2680
+ }
2681
+ }
2682
+ }
2683
+ return !uri || uri.replace(ATTR_WHITESPACE, "").match(
2684
+ new RegExp(
2685
+ // eslint-disable-next-line no-useless-escape
2686
+ `^(?:(?:${allowedProtocols.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
2687
+ "i"
2688
+ )
2689
+ );
2690
+ }
2691
+ function sanitizeUrl(inputUrl, baseUrl, protocols) {
2692
+ try {
2693
+ const url = new URL(inputUrl, baseUrl);
2694
+ if (isAllowedUri(url.href, protocols)) {
2695
+ return url.href;
2696
+ }
2697
+ } catch {
2698
+ }
2699
+ return "#";
2700
+ }
2701
+
2702
+ // src/ui/link-popover/use-link-popover.ts
3794
2703
  function canSetLink(editor) {
3795
2704
  if (!editor || !editor.isEditable) return false;
3796
2705
  return editor.can().setMark("link");
@@ -3801,7 +2710,7 @@ function isLinkActive(editor) {
3801
2710
  }
3802
2711
  function shouldShowLinkButton(props) {
3803
2712
  const { editor, hideWhenUnavailable } = props;
3804
- const linkInSchema = isMarkInSchema("link", editor);
2713
+ const linkInSchema = (0, import_editor_utils10.isMarkInSchema)("link", editor);
3805
2714
  if (!linkInSchema || !editor) {
3806
2715
  return false;
3807
2716
  }
@@ -3914,7 +2823,7 @@ function useLinkPopover(config) {
3914
2823
  canSet,
3915
2824
  isActive,
3916
2825
  label: "Link",
3917
- Icon: import_icons11.LinkIcon,
2826
+ Icon: import_icons10.LinkIcon,
3918
2827
  ...linkHandler
3919
2828
  };
3920
2829
  }
@@ -3934,7 +2843,7 @@ var LinkButton = ({ className, children, ...props }) => {
3934
2843
  title: "Link",
3935
2844
  isIconOnly: !children,
3936
2845
  ...props,
3937
- children: children || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons12.LinkIcon, {})
2846
+ children: children || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons11.LinkIcon, {})
3938
2847
  }
3939
2848
  );
3940
2849
  };
@@ -3977,7 +2886,7 @@ var LinkMain = ({
3977
2886
  disabled: !url && !isActive,
3978
2887
  variant: "ghost",
3979
2888
  color: "default",
3980
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons12.CornerDownLeftIcon, {})
2889
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons11.CornerDownLeftIcon, {})
3981
2890
  }
3982
2891
  )
3983
2892
  ] }),
@@ -3992,7 +2901,7 @@ var LinkMain = ({
3992
2901
  disabled: !url && !isActive,
3993
2902
  variant: "ghost",
3994
2903
  color: "default",
3995
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons12.ExternalLinkIcon, {})
2904
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons11.ExternalLinkIcon, {})
3996
2905
  }
3997
2906
  ),
3998
2907
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -4004,7 +2913,7 @@ var LinkMain = ({
4004
2913
  disabled: !url && !isActive,
4005
2914
  variant: "ghost",
4006
2915
  color: "default",
4007
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons12.TrashIcon, {})
2916
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons11.TrashIcon, {})
4008
2917
  }
4009
2918
  )
4010
2919
  ] })
@@ -4021,7 +2930,7 @@ function LinkPopover({
4021
2930
  ...buttonProps
4022
2931
  }) {
4023
2932
  const { editor } = useTiptapEditor(providedEditor);
4024
- const [isOpen, setIsOpen] = (0, import_react19.useState)(false);
2933
+ const [isOpen, setIsOpen] = (0, import_react18.useState)(false);
4025
2934
  const {
4026
2935
  isVisible,
4027
2936
  canSet,
@@ -4037,18 +2946,18 @@ function LinkPopover({
4037
2946
  hideWhenUnavailable,
4038
2947
  onSetLink
4039
2948
  });
4040
- const handleOnOpenChange = (0, import_react19.useCallback)(
2949
+ const handleOnOpenChange = (0, import_react18.useCallback)(
4041
2950
  (nextIsOpen) => {
4042
2951
  setIsOpen(nextIsOpen);
4043
2952
  onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
4044
2953
  },
4045
2954
  [onOpenChange]
4046
2955
  );
4047
- const handleSetLink = (0, import_react19.useCallback)(() => {
2956
+ const handleSetLink = (0, import_react18.useCallback)(() => {
4048
2957
  setLink();
4049
2958
  setIsOpen(false);
4050
2959
  }, [setLink]);
4051
- const handleClick = (0, import_react19.useCallback)(
2960
+ const handleClick = (0, import_react18.useCallback)(
4052
2961
  (event) => {
4053
2962
  onClick == null ? void 0 : onClick(event);
4054
2963
  if (event.defaultPrevented) return;
@@ -4056,7 +2965,7 @@ function LinkPopover({
4056
2965
  },
4057
2966
  [onClick, isOpen]
4058
2967
  );
4059
- (0, import_react19.useEffect)(() => {
2968
+ (0, import_react18.useEffect)(() => {
4060
2969
  if (autoOpenOnLinkActive && isActive) {
4061
2970
  setIsOpen(true);
4062
2971
  }
@@ -4108,31 +3017,33 @@ LinkButton.displayName = "LinkButton";
4108
3017
  // src/ui/list-dropdown-menu/index.tsx
4109
3018
  var import_button7 = require("@kopexa/button");
4110
3019
  var import_dropdown_menu2 = require("@kopexa/dropdown-menu");
4111
- var import_icons14 = require("@kopexa/icons");
4112
- var import_react22 = require("@tiptap/react");
4113
- var import_react23 = require("react");
3020
+ var import_editor_utils12 = require("@kopexa/editor-utils");
3021
+ var import_icons13 = require("@kopexa/icons");
3022
+ var import_react21 = require("@tiptap/react");
3023
+ var import_react22 = require("react");
4114
3024
 
4115
3025
  // src/ui/list-button/index.tsx
4116
3026
  var import_button6 = require("@kopexa/button");
4117
- var import_icons13 = require("@kopexa/icons");
4118
- var import_react20 = require("@tiptap/react");
4119
- var import_react21 = require("react");
3027
+ var import_editor_utils11 = require("@kopexa/editor-utils");
3028
+ var import_icons12 = require("@kopexa/icons");
3029
+ var import_react19 = require("@tiptap/react");
3030
+ var import_react20 = require("react");
4120
3031
  var import_jsx_runtime10 = require("react/jsx-runtime");
4121
3032
  var listOptions = [
4122
3033
  {
4123
3034
  label: "Bullet List",
4124
3035
  type: "bulletList",
4125
- icon: import_icons13.ListIcon
3036
+ icon: import_icons12.ListIcon
4126
3037
  },
4127
3038
  {
4128
3039
  label: "Ordered List",
4129
3040
  type: "orderedList",
4130
- icon: import_icons13.ListOrderedIcon
3041
+ icon: import_icons12.ListOrderedIcon
4131
3042
  },
4132
3043
  {
4133
3044
  label: "Task List",
4134
3045
  type: "taskList",
4135
- icon: import_icons13.ListTodoIcon
3046
+ icon: import_icons12.ListTodoIcon
4136
3047
  }
4137
3048
  ];
4138
3049
  var listShortcutKeys = {
@@ -4191,14 +3102,14 @@ function shouldShowListButton(params) {
4191
3102
  return false;
4192
3103
  }
4193
3104
  if (hideWhenUnavailable) {
4194
- if ((0, import_react20.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
3105
+ if ((0, import_react19.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
4195
3106
  return false;
4196
3107
  }
4197
3108
  }
4198
3109
  return true;
4199
3110
  }
4200
3111
  function useListState(editor, type) {
4201
- const listInSchema = isNodeInSchema(type, editor);
3112
+ const listInSchema = (0, import_editor_utils11.isNodeInSchema)(type, editor);
4202
3113
  const listOption = getListOption(type);
4203
3114
  const isActive = isListActive(editor, type);
4204
3115
  const shortcutKey = listShortcutKeys[type];
@@ -4225,8 +3136,8 @@ var ListButton = ({
4225
3136
  editor,
4226
3137
  type
4227
3138
  );
4228
- const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons13.ListIcon;
4229
- const handleClick = (0, import_react21.useCallback)(
3139
+ const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons12.ListIcon;
3140
+ const handleClick = (0, import_react20.useCallback)(
4230
3141
  (e) => {
4231
3142
  onClick == null ? void 0 : onClick(e);
4232
3143
  if (!e.defaultPrevented && editor) {
@@ -4235,7 +3146,7 @@ var ListButton = ({
4235
3146
  },
4236
3147
  [onClick, editor, type]
4237
3148
  );
4238
- const show = (0, import_react21.useMemo)(() => {
3149
+ const show = (0, import_react20.useMemo)(() => {
4239
3150
  return shouldShowListButton({
4240
3151
  editor,
4241
3152
  type,
@@ -4289,24 +3200,24 @@ function shouldShowListDropdown(params) {
4289
3200
  return false;
4290
3201
  }
4291
3202
  if (hideWhenUnavailable) {
4292
- if ((0, import_react22.isNodeSelection)(editor.state.selection) || !canToggleAny) {
3203
+ if ((0, import_react21.isNodeSelection)(editor.state.selection) || !canToggleAny) {
4293
3204
  return false;
4294
3205
  }
4295
3206
  }
4296
3207
  return true;
4297
3208
  }
4298
3209
  function useListDropdownState(editor, availableTypes) {
4299
- const [isOpen, setIsOpen] = (0, import_react23.useState)(false);
3210
+ const [isOpen, setIsOpen] = (0, import_react22.useState)(false);
4300
3211
  const listInSchema = availableTypes.some(
4301
- (type) => isNodeInSchema(type, editor)
3212
+ (type) => (0, import_editor_utils12.isNodeInSchema)(type, editor)
4302
3213
  );
4303
- const filteredLists = (0, import_react23.useMemo)(
3214
+ const filteredLists = (0, import_react22.useMemo)(
4304
3215
  () => getFilteredListOptions(availableTypes),
4305
3216
  [availableTypes]
4306
3217
  );
4307
3218
  const canToggleAny = canToggleAnyList(editor, availableTypes);
4308
3219
  const isAnyActive = isAnyListActive(editor, availableTypes);
4309
- const handleOpenChange = (0, import_react23.useCallback)(
3220
+ const handleOpenChange = (0, import_react22.useCallback)(
4310
3221
  (open, callback) => {
4311
3222
  setIsOpen(open);
4312
3223
  callback == null ? void 0 : callback(open);
@@ -4324,11 +3235,11 @@ function useListDropdownState(editor, availableTypes) {
4324
3235
  };
4325
3236
  }
4326
3237
  function useActiveListIcon(editor, filteredLists) {
4327
- return (0, import_react23.useCallback)(() => {
3238
+ return (0, import_react22.useCallback)(() => {
4328
3239
  const activeOption = filteredLists.find(
4329
3240
  (option) => isListActive(editor, option.type)
4330
3241
  );
4331
- return activeOption ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(activeOption.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons14.ListIcon, {});
3242
+ return activeOption ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(activeOption.icon, {}) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons13.ListIcon, {});
4332
3243
  }, [editor, filteredLists]);
4333
3244
  }
4334
3245
  function ListDropdownMenu({
@@ -4348,7 +3259,7 @@ function ListDropdownMenu({
4348
3259
  handleOpenChange
4349
3260
  } = useListDropdownState(editor, types);
4350
3261
  const getActiveIcon = useActiveListIcon(editor, filteredLists);
4351
- const show = (0, import_react23.useMemo)(() => {
3262
+ const show = (0, import_react22.useMemo)(() => {
4352
3263
  return shouldShowListDropdown({
4353
3264
  editor,
4354
3265
  listTypes: types,
@@ -4357,7 +3268,7 @@ function ListDropdownMenu({
4357
3268
  canToggleAny
4358
3269
  });
4359
3270
  }, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
4360
- const handleOnOpenChange = (0, import_react23.useCallback)(
3271
+ const handleOnOpenChange = (0, import_react22.useCallback)(
4361
3272
  (open) => handleOpenChange(open, onOpenChange),
4362
3273
  [handleOpenChange, onOpenChange]
4363
3274
  );
@@ -4375,7 +3286,7 @@ function ListDropdownMenu({
4375
3286
  tabIndex: -1,
4376
3287
  "aria-label": "List options",
4377
3288
  tooltip: "List",
4378
- endContent: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons14.ChevronDownIcon, {}),
3289
+ endContent: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons13.ChevronDownIcon, {}),
4379
3290
  ...props,
4380
3291
  children: getActiveIcon()
4381
3292
  }
@@ -4396,19 +3307,20 @@ function ListDropdownMenu({
4396
3307
  }
4397
3308
 
4398
3309
  // src/ui/mark-button/index.tsx
4399
- var import_icons15 = require("@kopexa/icons");
3310
+ var import_editor_utils13 = require("@kopexa/editor-utils");
3311
+ var import_icons14 = require("@kopexa/icons");
4400
3312
  var import_toolbar6 = require("@kopexa/toolbar");
4401
- var import_react24 = require("@tiptap/react");
4402
- var import_react25 = require("react");
3313
+ var import_react23 = require("@tiptap/react");
3314
+ var import_react24 = require("react");
4403
3315
  var import_jsx_runtime12 = require("react/jsx-runtime");
4404
3316
  var markIcons = {
4405
- bold: import_icons15.BoldIcon,
4406
- italic: import_icons15.ItalicIcon,
4407
- underline: import_icons15.UnderlineIcon,
4408
- strike: import_icons15.StrikeIcon,
4409
- code: import_icons15.CodeIcon,
4410
- superscript: import_icons15.SuperscriptIcon,
4411
- subscript: import_icons15.SubscriptIcon
3317
+ bold: import_icons14.BoldIcon,
3318
+ italic: import_icons14.ItalicIcon,
3319
+ underline: import_icons14.UnderlineIcon,
3320
+ strike: import_icons14.StrikeIcon,
3321
+ code: import_icons14.CodeIcon,
3322
+ superscript: import_icons14.SuperscriptIcon,
3323
+ subscript: import_icons14.SubscriptIcon
4412
3324
  };
4413
3325
  var markShortcutKeys = {
4414
3326
  bold: "mod+b",
@@ -4421,7 +3333,7 @@ var markShortcutKeys = {
4421
3333
  };
4422
3334
  function canToggleMark(editor, type) {
4423
3335
  if (!editor || !editor.isEditable) return false;
4424
- if (!isMarkInSchema(type, editor) || isNodeTypeSelected(editor, ["image"]))
3336
+ if (!(0, import_editor_utils13.isMarkInSchema)(type, editor) || (0, import_editor_utils13.isNodeTypeSelected)(editor, ["image"]))
4425
3337
  return false;
4426
3338
  return editor.can().toggleMark(type);
4427
3339
  }
@@ -4446,7 +3358,7 @@ function shouldShowMarkButton(params) {
4446
3358
  return false;
4447
3359
  }
4448
3360
  if (hideWhenUnavailable) {
4449
- if ((0, import_react24.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
3361
+ if ((0, import_react23.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
4450
3362
  return false;
4451
3363
  }
4452
3364
  }
@@ -4456,7 +3368,7 @@ function getFormattedMarkName(type) {
4456
3368
  return type.charAt(0).toUpperCase() + type.slice(1);
4457
3369
  }
4458
3370
  function useMarkState(editor, type, disabled = false) {
4459
- const markInSchema = isMarkInSchema(type, editor);
3371
+ const markInSchema = (0, import_editor_utils13.isMarkInSchema)(type, editor);
4460
3372
  const isDisabled = isMarkButtonDisabled(editor, type, disabled);
4461
3373
  const isActive = isMarkActive(editor, type);
4462
3374
  const Icon = markIcons[type];
@@ -4491,7 +3403,7 @@ var MarkButton = ({
4491
3403
  shortcutKey,
4492
3404
  formattedName
4493
3405
  } = useMarkState(editor, type, disabled);
4494
- const handleClick = (0, import_react25.useCallback)(
3406
+ const handleClick = (0, import_react24.useCallback)(
4495
3407
  (e) => {
4496
3408
  onClick == null ? void 0 : onClick(e);
4497
3409
  if (!e.defaultPrevented && !isDisabled && editor) {
@@ -4500,7 +3412,7 @@ var MarkButton = ({
4500
3412
  },
4501
3413
  [onClick, isDisabled, editor, type]
4502
3414
  );
4503
- const show = (0, import_react25.useMemo)(() => {
3415
+ const show = (0, import_react24.useMemo)(() => {
4504
3416
  return shouldShowMarkButton({
4505
3417
  editor,
4506
3418
  type,
@@ -4536,7 +3448,7 @@ var MarkButton = ({
4536
3448
 
4537
3449
  // src/ui/table-button/index.tsx
4538
3450
  var import_toolbar7 = require("@kopexa/toolbar");
4539
- var import_react26 = require("react");
3451
+ var import_react25 = require("react");
4540
3452
  var import_jsx_runtime13 = require("react/jsx-runtime");
4541
3453
  var TableButton = ({
4542
3454
  editor: providedEditor,
@@ -4561,7 +3473,7 @@ var TableButton = ({
4561
3473
  hideWhenUnavailable,
4562
3474
  onToggled
4563
3475
  });
4564
- const handleClick = (0, import_react26.useCallback)(
3476
+ const handleClick = (0, import_react25.useCallback)(
4565
3477
  (event) => {
4566
3478
  onClick == null ? void 0 : onClick(event);
4567
3479
  if (event.defaultPrevented) return;
@@ -4584,7 +3496,7 @@ var TableButton = ({
4584
3496
  tabIndex: -1,
4585
3497
  "aria-label": label,
4586
3498
  "aria-pressed": isActive,
4587
- tooltip: label,
3499
+ title: label,
4588
3500
  onClick: handleClick,
4589
3501
  isIconOnly: !text && !children,
4590
3502
  ...buttonProps,
@@ -4598,11 +3510,12 @@ var TableButton = ({
4598
3510
 
4599
3511
  // src/ui/text-align-button/text-align-button.tsx
4600
3512
  var import_button8 = require("@kopexa/button");
4601
- var import_react28 = require("react");
3513
+ var import_react27 = require("react");
4602
3514
 
4603
3515
  // src/ui/text-align-button/use-text-align.ts
4604
- var import_icons16 = require("@kopexa/icons");
4605
- var import_react27 = require("react");
3516
+ var import_editor_utils14 = require("@kopexa/editor-utils");
3517
+ var import_icons15 = require("@kopexa/icons");
3518
+ var import_react26 = require("react");
4606
3519
  var TEXT_ALIGN_SHORTCUT_KEYS = {
4607
3520
  left: "mod+shift+l",
4608
3521
  center: "mod+shift+e",
@@ -4610,10 +3523,10 @@ var TEXT_ALIGN_SHORTCUT_KEYS = {
4610
3523
  justify: "mod+shift+j"
4611
3524
  };
4612
3525
  var textAlignIcons = {
4613
- left: import_icons16.AlignLeftIcon,
4614
- center: import_icons16.AlignCenterIcon,
4615
- right: import_icons16.AlignRightIcon,
4616
- justify: import_icons16.AlignJustifyIcon
3526
+ left: import_icons15.AlignLeftIcon,
3527
+ center: import_icons15.AlignCenterIcon,
3528
+ right: import_icons15.AlignRightIcon,
3529
+ justify: import_icons15.AlignJustifyIcon
4617
3530
  };
4618
3531
  var textAlignLabels = {
4619
3532
  left: "Align left",
@@ -4623,7 +3536,7 @@ var textAlignLabels = {
4623
3536
  };
4624
3537
  function canSetTextAlign(editor, align) {
4625
3538
  if (!editor || !editor.isEditable) return false;
4626
- if (!isExtensionAvailable(editor, "textAlign") || isNodeTypeSelected(editor, ["image"]))
3539
+ if (!(0, import_editor_utils14.isExtensionAvailable)(editor, "textAlign") || (0, import_editor_utils14.isNodeTypeSelected)(editor, ["image"]))
4627
3540
  return false;
4628
3541
  return editor.can().setTextAlign(align);
4629
3542
  }
@@ -4646,7 +3559,7 @@ function setTextAlign(editor, align) {
4646
3559
  function shouldShowButton5(props) {
4647
3560
  const { editor, hideWhenUnavailable, align } = props;
4648
3561
  if (!editor || !editor.isEditable) return false;
4649
- if (!isExtensionAvailable(editor, "textAlign")) return false;
3562
+ if (!(0, import_editor_utils14.isExtensionAvailable)(editor, "textAlign")) return false;
4650
3563
  if (hideWhenUnavailable && !editor.isActive("code")) {
4651
3564
  return canSetTextAlign(editor, align);
4652
3565
  }
@@ -4660,10 +3573,10 @@ function useTextAlign(config) {
4660
3573
  onAligned
4661
3574
  } = config;
4662
3575
  const { editor } = useTiptapEditor(providedEditor);
4663
- const [isVisible, setIsVisible] = (0, import_react27.useState)(true);
3576
+ const [isVisible, setIsVisible] = (0, import_react26.useState)(true);
4664
3577
  const canAlign = canSetTextAlign(editor, align);
4665
3578
  const isActive = isTextAlignActive(editor, align);
4666
- (0, import_react27.useEffect)(() => {
3579
+ (0, import_react26.useEffect)(() => {
4667
3580
  if (!editor) return;
4668
3581
  const handleSelectionUpdate = () => {
4669
3582
  setIsVisible(shouldShowButton5({ editor, align, hideWhenUnavailable }));
@@ -4674,7 +3587,7 @@ function useTextAlign(config) {
4674
3587
  editor.off("selectionUpdate", handleSelectionUpdate);
4675
3588
  };
4676
3589
  }, [editor, hideWhenUnavailable, align]);
4677
- const handleTextAlign = (0, import_react27.useCallback)(() => {
3590
+ const handleTextAlign = (0, import_react26.useCallback)(() => {
4678
3591
  if (!editor) return false;
4679
3592
  const success = setTextAlign(editor, align);
4680
3593
  if (success) {
@@ -4721,7 +3634,7 @@ var TextAlignButton = ({
4721
3634
  hideWhenUnavailable,
4722
3635
  onAligned
4723
3636
  });
4724
- const handleClick = (0, import_react28.useCallback)(
3637
+ const handleClick = (0, import_react27.useCallback)(
4725
3638
  (e) => {
4726
3639
  onClick == null ? void 0 : onClick(e);
4727
3640
  if (e.defaultPrevented) return;
@@ -4755,11 +3668,12 @@ var TextAlignButton = ({
4755
3668
 
4756
3669
  // src/ui/undo-redo-button/undo-redo-button.tsx
4757
3670
  var import_toolbar8 = require("@kopexa/toolbar");
4758
- var import_react30 = require("react");
3671
+ var import_react29 = require("react");
4759
3672
 
4760
3673
  // src/ui/undo-redo-button/use-undo-redo.ts
4761
- var import_icons17 = require("@kopexa/icons");
4762
- var import_react29 = require("react");
3674
+ var import_editor_utils15 = require("@kopexa/editor-utils");
3675
+ var import_icons16 = require("@kopexa/icons");
3676
+ var import_react28 = require("react");
4763
3677
  var UNDO_REDO_SHORTCUT_KEYS = {
4764
3678
  undo: "mod+z",
4765
3679
  redo: "mod+shift+z"
@@ -4769,12 +3683,12 @@ var historyActionLabels = {
4769
3683
  redo: "Redo"
4770
3684
  };
4771
3685
  var historyIcons = {
4772
- undo: import_icons17.UndoIcon,
4773
- redo: import_icons17.RedoIcon
3686
+ undo: import_icons16.UndoIcon,
3687
+ redo: import_icons16.RedoIcon
4774
3688
  };
4775
3689
  function canExecuteUndoRedoAction(editor, action) {
4776
3690
  if (!editor || !editor.isEditable) return false;
4777
- if (isNodeTypeSelected(editor, ["image"])) return false;
3691
+ if ((0, import_editor_utils15.isNodeTypeSelected)(editor, ["image"])) return false;
4778
3692
  return action === "undo" ? editor.can().undo() : editor.can().redo();
4779
3693
  }
4780
3694
  function executeUndoRedoAction(editor, action) {
@@ -4799,9 +3713,9 @@ function useUndoRedo(config) {
4799
3713
  onExecuted
4800
3714
  } = config;
4801
3715
  const { editor } = useTiptapEditor(providedEditor);
4802
- const [isVisible, setIsVisible] = (0, import_react29.useState)(true);
3716
+ const [isVisible, setIsVisible] = (0, import_react28.useState)(true);
4803
3717
  const canExecute = canExecuteUndoRedoAction(editor, action);
4804
- (0, import_react29.useEffect)(() => {
3718
+ (0, import_react28.useEffect)(() => {
4805
3719
  if (!editor) return;
4806
3720
  const handleUpdate = () => {
4807
3721
  setIsVisible(shouldShowButton6({ editor, hideWhenUnavailable, action }));
@@ -4812,7 +3726,7 @@ function useUndoRedo(config) {
4812
3726
  editor.off("transaction", handleUpdate);
4813
3727
  };
4814
3728
  }, [editor, hideWhenUnavailable, action]);
4815
- const handleAction = (0, import_react29.useCallback)(() => {
3729
+ const handleAction = (0, import_react28.useCallback)(() => {
4816
3730
  if (!editor) return false;
4817
3731
  const success = executeUndoRedoAction(editor, action);
4818
3732
  if (success) {
@@ -4850,7 +3764,7 @@ var UndoRedoButton = ({
4850
3764
  hideWhenUnavailable,
4851
3765
  onExecuted
4852
3766
  });
4853
- const handleClick = (0, import_react30.useCallback)(
3767
+ const handleClick = (0, import_react29.useCallback)(
4854
3768
  (event) => {
4855
3769
  onClick == null ? void 0 : onClick(event);
4856
3770
  if (event.defaultPrevented) return;
@@ -4888,7 +3802,8 @@ var EditorHeader = ({ editor: providedEditor }) => {
4888
3802
  const { editor } = useTiptapEditor(providedEditor);
4889
3803
  const isMobile = (0, import_use_is_mobile2.useIsMobile)();
4890
3804
  const windowSize = useWindowSize();
4891
- const toolbarRef = (0, import_react31.useRef)(null);
3805
+ const { styles } = useEditorUIContext();
3806
+ const toolbarRef = (0, import_react30.useRef)(null);
4892
3807
  const bodyRect = useCursorVisibility({
4893
3808
  editor,
4894
3809
  overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
@@ -4896,15 +3811,18 @@ var EditorHeader = ({ editor: providedEditor }) => {
4896
3811
  if (!(editor == null ? void 0 : editor.isEditable)) {
4897
3812
  return null;
4898
3813
  }
4899
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3814
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: styles.toolbar(), "data-slot": "editor-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4900
3815
  import_toolbar9.Toolbar,
4901
3816
  {
3817
+ sticky: true,
3818
+ radius: "none",
3819
+ border: "none",
4902
3820
  style: isMobile ? {
4903
3821
  bottom: `calc(100% - ${windowSize.height - bodyRect.y}px)`
4904
3822
  } : {},
4905
3823
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MainToolbarContent, {})
4906
3824
  }
4907
- );
3825
+ ) });
4908
3826
  };
4909
3827
  var MainToolbarContent = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
4910
3828
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_toolbar9.ToolbarGroup, { children: [
@@ -4938,8 +3856,8 @@ function MoreOptions({
4938
3856
  ...props
4939
3857
  }) {
4940
3858
  const { editor } = useTiptapEditor(providedEditor);
4941
- const [show, setShow] = (0, import_react31.useState)(false);
4942
- (0, import_react31.useEffect)(() => {
3859
+ const [show, setShow] = (0, import_react30.useState)(false);
3860
+ (0, import_react30.useEffect)(() => {
4943
3861
  if (!editor) return;
4944
3862
  const handleSelectionUpdate = () => {
4945
3863
  setShow(
@@ -4971,11 +3889,12 @@ function MoreOptions({
4971
3889
  variant: "ghost",
4972
3890
  color: "default",
4973
3891
  tabIndex: -1,
3892
+ size: "md",
4974
3893
  "aria-label": "More options",
4975
3894
  title: "More options",
4976
3895
  isIconOnly: true,
4977
3896
  ...props,
4978
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons18.MoreVerticalIcon, {})
3897
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons17.MoreVerticalIcon, {})
4979
3898
  }
4980
3899
  )
4981
3900
  }
@@ -4987,7 +3906,7 @@ function MoreOptions({
4987
3906
  align: "end",
4988
3907
  alignOffset: 4,
4989
3908
  sideOffset: 4,
4990
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_toolbar9.Toolbar, { tabIndex: 0, children: [
3909
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_toolbar9.Toolbar, { children: [
4991
3910
  /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_toolbar9.ToolbarGroup, { children: [
4992
3911
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MarkButton, { type: "superscript" }),
4993
3912
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(MarkButton, { type: "subscript" })
@@ -5031,31 +3950,30 @@ function shouldShowMoreOptions(params) {
5031
3950
  // src/presets/basic/index.tsx
5032
3951
  var import_jsx_runtime17 = require("react/jsx-runtime");
5033
3952
  var BasicEditor = ({
3953
+ variant,
5034
3954
  content,
5035
- editable,
5036
- onChange,
5037
- locale
3955
+ ...options
5038
3956
  }) => {
5039
- const styles = (0, import_theme3.editorBasic)();
5040
- const editor = useCreateEditor({ content, editable, onChange });
3957
+ const editor = useCreateEditor({ content, ...options });
3958
+ const styles = (0, import_theme3.editorBasic)({ variant });
5041
3959
  if (!editor) {
5042
3960
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LoadingSpinner, {});
5043
3961
  }
5044
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EditorWrapperProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react32.EditorContext.Provider, { value: { editor }, children: [
3962
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react31.EditorContext.Provider, { value: { editor }, children: [
5045
3963
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EditorHeader, { editor }),
5046
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EditorContentArea, {})
5047
- ] }) });
3964
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EditorContentArea, { variant })
3965
+ ] }) }) });
5048
3966
  };
5049
- var EditorContentArea = () => {
5050
- const { styles } = useEditorWrapper();
5051
- const { editor } = (0, import_react33.useContext)(import_react32.EditorContext);
3967
+ var EditorContentArea = ({ variant }) => {
3968
+ const styles = (0, import_theme3.editorBasic)({ variant });
3969
+ const { editor } = (0, import_react32.useContext)(import_react31.EditorContext);
5052
3970
  const { isDragging } = useUiEditorState(editor);
5053
3971
  useScrollToHash();
5054
3972
  if (!editor) {
5055
3973
  return null;
5056
3974
  }
5057
3975
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: styles.wrapper(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5058
- import_react32.EditorContent,
3976
+ import_react31.EditorContent,
5059
3977
  {
5060
3978
  editor,
5061
3979
  role: "presentation",