@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
@@ -66,25 +66,9 @@ function useTiptapEditor(providedEditor) {
66
66
  }
67
67
 
68
68
  // src/ui/undo-redo-button/use-undo-redo.ts
69
+ var import_editor_utils = require("@kopexa/editor-utils");
69
70
  var import_icons = require("@kopexa/icons");
70
71
  var import_react3 = require("react");
71
-
72
- // src/utils/index.ts
73
- var import_state = require("@tiptap/pm/state");
74
- var MAX_FILE_SIZE = 5 * 1024 * 1024;
75
- function isNodeTypeSelected(editor, types = []) {
76
- if (!editor || !editor.state.selection) return false;
77
- const { state } = editor;
78
- const { selection } = state;
79
- if (selection.empty) return false;
80
- if (selection instanceof import_state.NodeSelection) {
81
- const node = selection.node;
82
- return node ? types.includes(node.type.name) : false;
83
- }
84
- return false;
85
- }
86
-
87
- // src/ui/undo-redo-button/use-undo-redo.ts
88
72
  var UNDO_REDO_SHORTCUT_KEYS = {
89
73
  undo: "mod+z",
90
74
  redo: "mod+shift+z"
@@ -99,7 +83,7 @@ var historyIcons = {
99
83
  };
100
84
  function canExecuteUndoRedoAction(editor, action) {
101
85
  if (!editor || !editor.isEditable) return false;
102
- if (isNodeTypeSelected(editor, ["image"])) return false;
86
+ if ((0, import_editor_utils.isNodeTypeSelected)(editor, ["image"])) return false;
103
87
  return action === "undo" ? editor.can().undo() : editor.can().redo();
104
88
  }
105
89
  function executeUndoRedoAction(editor, action) {
@@ -2,7 +2,7 @@
2
2
  import "../../chunk-Y2KSWMG5.mjs";
3
3
  import {
4
4
  UndoRedoButton
5
- } from "../../chunk-AASYBJDX.mjs";
5
+ } from "../../chunk-2SI7MRAE.mjs";
6
6
  import {
7
7
  UNDO_REDO_SHORTCUT_KEYS,
8
8
  canExecuteUndoRedoAction,
@@ -11,10 +11,8 @@ import {
11
11
  historyIcons,
12
12
  shouldShowButton,
13
13
  useUndoRedo
14
- } from "../../chunk-T7LL5ZSR.mjs";
15
- import "../../chunk-C6M3CDOK.mjs";
14
+ } from "../../chunk-ZVTJ6XD7.mjs";
16
15
  import "../../chunk-P55PLOHR.mjs";
17
- import "../../chunk-WKV76XOR.mjs";
18
16
  export {
19
17
  UNDO_REDO_SHORTCUT_KEYS,
20
18
  UndoRedoButton,
@@ -58,25 +58,9 @@ function useTiptapEditor(providedEditor) {
58
58
  }
59
59
 
60
60
  // src/ui/undo-redo-button/use-undo-redo.ts
61
+ var import_editor_utils = require("@kopexa/editor-utils");
61
62
  var import_icons = require("@kopexa/icons");
62
63
  var import_react3 = require("react");
63
-
64
- // src/utils/index.ts
65
- var import_state = require("@tiptap/pm/state");
66
- var MAX_FILE_SIZE = 5 * 1024 * 1024;
67
- function isNodeTypeSelected(editor, types = []) {
68
- if (!editor || !editor.state.selection) return false;
69
- const { state } = editor;
70
- const { selection } = state;
71
- if (selection.empty) return false;
72
- if (selection instanceof import_state.NodeSelection) {
73
- const node = selection.node;
74
- return node ? types.includes(node.type.name) : false;
75
- }
76
- return false;
77
- }
78
-
79
- // src/ui/undo-redo-button/use-undo-redo.ts
80
64
  var UNDO_REDO_SHORTCUT_KEYS = {
81
65
  undo: "mod+z",
82
66
  redo: "mod+shift+z"
@@ -91,7 +75,7 @@ var historyIcons = {
91
75
  };
92
76
  function canExecuteUndoRedoAction(editor, action) {
93
77
  if (!editor || !editor.isEditable) return false;
94
- if (isNodeTypeSelected(editor, ["image"])) return false;
78
+ if ((0, import_editor_utils.isNodeTypeSelected)(editor, ["image"])) return false;
95
79
  return action === "undo" ? editor.can().undo() : editor.can().redo();
96
80
  }
97
81
  function executeUndoRedoAction(editor, action) {
@@ -2,11 +2,9 @@
2
2
  "use client";
3
3
  import {
4
4
  UndoRedoButton
5
- } from "../../chunk-AASYBJDX.mjs";
6
- import "../../chunk-T7LL5ZSR.mjs";
7
- import "../../chunk-C6M3CDOK.mjs";
5
+ } from "../../chunk-2SI7MRAE.mjs";
6
+ import "../../chunk-ZVTJ6XD7.mjs";
8
7
  import "../../chunk-P55PLOHR.mjs";
9
- import "../../chunk-WKV76XOR.mjs";
10
8
  export {
11
9
  UndoRedoButton
12
10
  };
@@ -31,6 +31,7 @@ __export(use_undo_redo_exports, {
31
31
  useUndoRedo: () => useUndoRedo
32
32
  });
33
33
  module.exports = __toCommonJS(use_undo_redo_exports);
34
+ var import_editor_utils = require("@kopexa/editor-utils");
34
35
  var import_icons = require("@kopexa/icons");
35
36
  var import_react3 = require("react");
36
37
 
@@ -63,21 +64,6 @@ function useTiptapEditor(providedEditor) {
63
64
  return editorState || { editor: null };
64
65
  }
65
66
 
66
- // src/utils/index.ts
67
- var import_state = require("@tiptap/pm/state");
68
- var MAX_FILE_SIZE = 5 * 1024 * 1024;
69
- function isNodeTypeSelected(editor, types = []) {
70
- if (!editor || !editor.state.selection) return false;
71
- const { state } = editor;
72
- const { selection } = state;
73
- if (selection.empty) return false;
74
- if (selection instanceof import_state.NodeSelection) {
75
- const node = selection.node;
76
- return node ? types.includes(node.type.name) : false;
77
- }
78
- return false;
79
- }
80
-
81
67
  // src/ui/undo-redo-button/use-undo-redo.ts
82
68
  var UNDO_REDO_SHORTCUT_KEYS = {
83
69
  undo: "mod+z",
@@ -93,7 +79,7 @@ var historyIcons = {
93
79
  };
94
80
  function canExecuteUndoRedoAction(editor, action) {
95
81
  if (!editor || !editor.isEditable) return false;
96
- if (isNodeTypeSelected(editor, ["image"])) return false;
82
+ if ((0, import_editor_utils.isNodeTypeSelected)(editor, ["image"])) return false;
97
83
  return action === "undo" ? editor.can().undo() : editor.can().redo();
98
84
  }
99
85
  function executeUndoRedoAction(editor, action) {
@@ -8,10 +8,8 @@ import {
8
8
  historyIcons,
9
9
  shouldShowButton,
10
10
  useUndoRedo
11
- } from "../../chunk-T7LL5ZSR.mjs";
12
- import "../../chunk-C6M3CDOK.mjs";
11
+ } from "../../chunk-ZVTJ6XD7.mjs";
13
12
  import "../../chunk-P55PLOHR.mjs";
14
- import "../../chunk-WKV76XOR.mjs";
15
13
  export {
16
14
  UNDO_REDO_SHORTCUT_KEYS,
17
15
  canExecuteUndoRedoAction,
@@ -1,52 +1,4 @@
1
- import * as _tiptap_core from '@tiptap/core';
2
- import { Node, Attrs } from '@tiptap/pm/model';
3
- import { Selection } from '@tiptap/pm/state';
4
- import { Editor } from '@tiptap/react';
5
-
6
- type OverflowPosition = "none" | "top" | "bottom" | "both";
7
1
  declare const MAX_FILE_SIZE: number;
8
- /**
9
- * Checks if a mark exists in the editor schema
10
- * @param markName - The name of the mark to check
11
- * @param editor - The editor instance
12
- * @returns boolean indicating if the mark exists in the schema
13
- */
14
- declare const isMarkInSchema: (markName: string, editor: Editor | null) => boolean;
15
- /**
16
- * Checks if a node exists in the editor schema
17
- * @param nodeName - The name of the node to check
18
- * @param editor - The editor instance
19
- * @returns boolean indicating if the node exists in the schema
20
- */
21
- declare const isNodeInSchema: (nodeName: string, editor: Editor | null) => boolean;
22
- /**
23
- * Gets the active attributes of a specific mark in the current editor selection.
24
- *
25
- * @param editor - The Tiptap editor instance.
26
- * @param markName - The name of the mark to look for (e.g., "highlight", "link").
27
- * @returns The attributes of the active mark, or `null` if the mark is not active.
28
- */
29
- declare function getActiveMarkAttrs(editor: Editor | null, markName: string): Attrs | null;
30
- /**
31
- * Checks if a node is empty
32
- */
33
- declare function isEmptyNode(node?: Node | null): boolean;
34
- /**
35
- * Finds the position and instance of a node in the document
36
- * @param props Object containing editor, node (optional), and nodePos (optional)
37
- * @param props.editor The TipTap editor instance
38
- * @param props.node The node to find (optional if nodePos is provided)
39
- * @param props.nodePos The position of the node to find (optional if node is provided)
40
- * @returns An object with the position and node, or null if not found
41
- */
42
- declare function findNodePosition(props: {
43
- editor: Editor | null;
44
- node?: Node | null;
45
- nodePos?: number | null;
46
- }): {
47
- pos: number;
48
- node: Node;
49
- } | null;
50
2
  /**
51
3
  * Handles image upload with progress tracking and abort capability
52
4
  * @param file The file to upload
@@ -82,57 +34,5 @@ type ProtocolOptions = {
82
34
  type ProtocolConfig = Array<ProtocolOptions | string>;
83
35
  declare function isAllowedUri(uri: string | undefined, protocols?: ProtocolConfig): true | RegExpMatchArray | null;
84
36
  declare function sanitizeUrl(inputUrl: string, baseUrl: string, protocols?: ProtocolConfig): string;
85
- /**
86
- * Checks if the current selection in the editor is a node selection of specified types
87
- * @param editor The Tiptap editor instance
88
- * @param types An array of node type names to check against
89
- * @returns boolean indicating if the selected node matches any of the specified types
90
- */
91
- declare function isNodeTypeSelected(editor: Editor | null, types?: string[]): boolean;
92
- /**
93
- * Checks if one or more extensions are registered in the Tiptap editor.
94
- * @param editor - The Tiptap editor instance
95
- * @param extensionNames - A single extension name or an array of names to check
96
- * @returns True if at least one of the extensions is available, false otherwise
97
- */
98
- declare function isExtensionAvailable(editor: Editor | null, extensionNames: string | string[]): boolean;
99
- /**
100
- * Retrieves a specific extension by name from the Tiptap editor.
101
- * @param editor - The Tiptap editor instance
102
- * @param extensionName - The name of the extension to retrieve
103
- * @returns The extension instance if found, otherwise null
104
- */
105
- declare function getEditorExtension(editor: Editor | null, extensionName: string): _tiptap_core.AnyExtension | null;
106
- /**
107
- * Helper function to check if there's content above the current position
108
- */
109
- declare function hasContentAbove(editor: Editor | null): {
110
- hasContent: boolean;
111
- content: string;
112
- };
113
- /**
114
- * Finds the position of a node in the editor selection
115
- * @param params Object containing editor, node (optional), and nodePos (optional)
116
- * @returns The position of the node in the selection or null if not found
117
- */
118
- declare function findSelectionPosition(params: {
119
- editor: Editor;
120
- node?: Node | null;
121
- nodePos?: number | null;
122
- }): number | null;
123
- /**
124
- * Checks if a value is a valid number (not null, undefined, or NaN)
125
- * @param value - The value to check
126
- * @returns boolean indicating if the value is a valid number
127
- */
128
- declare function isValidPosition(pos: number | null | undefined): pos is number;
129
- /**
130
- * Determines how a target element overflows relative to a container element
131
- */
132
- declare function getElementOverflowPosition(targetElement: Element, containerElement: HTMLElement): OverflowPosition;
133
- declare function findParentNodeOfType(selection: Selection, typeName: string): {
134
- node: Node;
135
- pos: number;
136
- } | null;
137
37
 
138
- export { MAX_FILE_SIZE, type OverflowPosition, convertFileToBase64, findNodePosition, findParentNodeOfType, findSelectionPosition, getActiveMarkAttrs, getEditorExtension, getElementOverflowPosition, handleImageUpload, hasContentAbove, isAllowedUri, isEmptyNode, isExtensionAvailable, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isValidPosition, sanitizeUrl };
38
+ export { MAX_FILE_SIZE, convertFileToBase64, handleImageUpload, isAllowedUri, sanitizeUrl };
@@ -1,52 +1,4 @@
1
- import * as _tiptap_core from '@tiptap/core';
2
- import { Node, Attrs } from '@tiptap/pm/model';
3
- import { Selection } from '@tiptap/pm/state';
4
- import { Editor } from '@tiptap/react';
5
-
6
- type OverflowPosition = "none" | "top" | "bottom" | "both";
7
1
  declare const MAX_FILE_SIZE: number;
8
- /**
9
- * Checks if a mark exists in the editor schema
10
- * @param markName - The name of the mark to check
11
- * @param editor - The editor instance
12
- * @returns boolean indicating if the mark exists in the schema
13
- */
14
- declare const isMarkInSchema: (markName: string, editor: Editor | null) => boolean;
15
- /**
16
- * Checks if a node exists in the editor schema
17
- * @param nodeName - The name of the node to check
18
- * @param editor - The editor instance
19
- * @returns boolean indicating if the node exists in the schema
20
- */
21
- declare const isNodeInSchema: (nodeName: string, editor: Editor | null) => boolean;
22
- /**
23
- * Gets the active attributes of a specific mark in the current editor selection.
24
- *
25
- * @param editor - The Tiptap editor instance.
26
- * @param markName - The name of the mark to look for (e.g., "highlight", "link").
27
- * @returns The attributes of the active mark, or `null` if the mark is not active.
28
- */
29
- declare function getActiveMarkAttrs(editor: Editor | null, markName: string): Attrs | null;
30
- /**
31
- * Checks if a node is empty
32
- */
33
- declare function isEmptyNode(node?: Node | null): boolean;
34
- /**
35
- * Finds the position and instance of a node in the document
36
- * @param props Object containing editor, node (optional), and nodePos (optional)
37
- * @param props.editor The TipTap editor instance
38
- * @param props.node The node to find (optional if nodePos is provided)
39
- * @param props.nodePos The position of the node to find (optional if node is provided)
40
- * @returns An object with the position and node, or null if not found
41
- */
42
- declare function findNodePosition(props: {
43
- editor: Editor | null;
44
- node?: Node | null;
45
- nodePos?: number | null;
46
- }): {
47
- pos: number;
48
- node: Node;
49
- } | null;
50
2
  /**
51
3
  * Handles image upload with progress tracking and abort capability
52
4
  * @param file The file to upload
@@ -82,57 +34,5 @@ type ProtocolOptions = {
82
34
  type ProtocolConfig = Array<ProtocolOptions | string>;
83
35
  declare function isAllowedUri(uri: string | undefined, protocols?: ProtocolConfig): true | RegExpMatchArray | null;
84
36
  declare function sanitizeUrl(inputUrl: string, baseUrl: string, protocols?: ProtocolConfig): string;
85
- /**
86
- * Checks if the current selection in the editor is a node selection of specified types
87
- * @param editor The Tiptap editor instance
88
- * @param types An array of node type names to check against
89
- * @returns boolean indicating if the selected node matches any of the specified types
90
- */
91
- declare function isNodeTypeSelected(editor: Editor | null, types?: string[]): boolean;
92
- /**
93
- * Checks if one or more extensions are registered in the Tiptap editor.
94
- * @param editor - The Tiptap editor instance
95
- * @param extensionNames - A single extension name or an array of names to check
96
- * @returns True if at least one of the extensions is available, false otherwise
97
- */
98
- declare function isExtensionAvailable(editor: Editor | null, extensionNames: string | string[]): boolean;
99
- /**
100
- * Retrieves a specific extension by name from the Tiptap editor.
101
- * @param editor - The Tiptap editor instance
102
- * @param extensionName - The name of the extension to retrieve
103
- * @returns The extension instance if found, otherwise null
104
- */
105
- declare function getEditorExtension(editor: Editor | null, extensionName: string): _tiptap_core.AnyExtension | null;
106
- /**
107
- * Helper function to check if there's content above the current position
108
- */
109
- declare function hasContentAbove(editor: Editor | null): {
110
- hasContent: boolean;
111
- content: string;
112
- };
113
- /**
114
- * Finds the position of a node in the editor selection
115
- * @param params Object containing editor, node (optional), and nodePos (optional)
116
- * @returns The position of the node in the selection or null if not found
117
- */
118
- declare function findSelectionPosition(params: {
119
- editor: Editor;
120
- node?: Node | null;
121
- nodePos?: number | null;
122
- }): number | null;
123
- /**
124
- * Checks if a value is a valid number (not null, undefined, or NaN)
125
- * @param value - The value to check
126
- * @returns boolean indicating if the value is a valid number
127
- */
128
- declare function isValidPosition(pos: number | null | undefined): pos is number;
129
- /**
130
- * Determines how a target element overflows relative to a container element
131
- */
132
- declare function getElementOverflowPosition(targetElement: Element, containerElement: HTMLElement): OverflowPosition;
133
- declare function findParentNodeOfType(selection: Selection, typeName: string): {
134
- node: Node;
135
- pos: number;
136
- } | null;
137
37
 
138
- export { MAX_FILE_SIZE, type OverflowPosition, convertFileToBase64, findNodePosition, findParentNodeOfType, findSelectionPosition, getActiveMarkAttrs, getEditorExtension, getElementOverflowPosition, handleImageUpload, hasContentAbove, isAllowedUri, isEmptyNode, isExtensionAvailable, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isValidPosition, sanitizeUrl };
38
+ export { MAX_FILE_SIZE, convertFileToBase64, handleImageUpload, isAllowedUri, sanitizeUrl };
@@ -23,77 +23,12 @@ var utils_exports = {};
23
23
  __export(utils_exports, {
24
24
  MAX_FILE_SIZE: () => MAX_FILE_SIZE,
25
25
  convertFileToBase64: () => convertFileToBase64,
26
- findNodePosition: () => findNodePosition,
27
- findParentNodeOfType: () => findParentNodeOfType,
28
- findSelectionPosition: () => findSelectionPosition,
29
- getActiveMarkAttrs: () => getActiveMarkAttrs,
30
- getEditorExtension: () => getEditorExtension,
31
- getElementOverflowPosition: () => getElementOverflowPosition,
32
26
  handleImageUpload: () => handleImageUpload,
33
- hasContentAbove: () => hasContentAbove,
34
27
  isAllowedUri: () => isAllowedUri,
35
- isEmptyNode: () => isEmptyNode,
36
- isExtensionAvailable: () => isExtensionAvailable,
37
- isMarkInSchema: () => isMarkInSchema,
38
- isNodeInSchema: () => isNodeInSchema,
39
- isNodeTypeSelected: () => isNodeTypeSelected,
40
- isValidPosition: () => isValidPosition,
41
28
  sanitizeUrl: () => sanitizeUrl
42
29
  });
43
30
  module.exports = __toCommonJS(utils_exports);
44
- var import_state = require("@tiptap/pm/state");
45
31
  var MAX_FILE_SIZE = 5 * 1024 * 1024;
46
- var isMarkInSchema = (markName, editor) => {
47
- if (!(editor == null ? void 0 : editor.schema)) return false;
48
- return editor.schema.spec.marks.get(markName) !== void 0;
49
- };
50
- var isNodeInSchema = (nodeName, editor) => {
51
- if (!(editor == null ? void 0 : editor.schema)) return false;
52
- return editor.schema.spec.nodes.get(nodeName) !== void 0;
53
- };
54
- function getActiveMarkAttrs(editor, markName) {
55
- var _a;
56
- if (!editor) return null;
57
- const { state } = editor;
58
- const marks = state.storedMarks || state.selection.$from.marks();
59
- const mark = marks.find((mark2) => mark2.type.name === markName);
60
- return (_a = mark == null ? void 0 : mark.attrs) != null ? _a : null;
61
- }
62
- function isEmptyNode(node) {
63
- return !!node && node.content.size === 0;
64
- }
65
- function findNodePosition(props) {
66
- var _a;
67
- const { editor, node, nodePos } = props;
68
- if (!editor || !((_a = editor.state) == null ? void 0 : _a.doc)) return null;
69
- const hasValidNode = node !== void 0 && node !== null;
70
- const hasValidPos = nodePos !== void 0 && nodePos !== null;
71
- if (!hasValidNode && !hasValidPos) {
72
- return null;
73
- }
74
- if (hasValidPos) {
75
- try {
76
- const nodeAtPos = editor.state.doc.nodeAt(nodePos);
77
- if (nodeAtPos) {
78
- return { pos: nodePos, node: nodeAtPos };
79
- }
80
- } catch (error) {
81
- console.error("Error checking node at position:", error);
82
- return null;
83
- }
84
- }
85
- let foundPos = -1;
86
- let foundNode = null;
87
- editor.state.doc.descendants((currentNode, pos) => {
88
- if (currentNode === node) {
89
- foundPos = pos;
90
- foundNode = currentNode;
91
- return false;
92
- }
93
- return true;
94
- });
95
- return foundPos !== -1 && foundNode !== null ? { pos: foundPos, node: foundNode } : null;
96
- }
97
32
  var handleImageUpload = async (file, onProgress, abortSignal) => {
98
33
  if (!file) {
99
34
  throw new Error("No file provided");
@@ -183,112 +118,11 @@ function sanitizeUrl(inputUrl, baseUrl, protocols) {
183
118
  }
184
119
  return "#";
185
120
  }
186
- function isNodeTypeSelected(editor, types = []) {
187
- if (!editor || !editor.state.selection) return false;
188
- const { state } = editor;
189
- const { selection } = state;
190
- if (selection.empty) return false;
191
- if (selection instanceof import_state.NodeSelection) {
192
- const node = selection.node;
193
- return node ? types.includes(node.type.name) : false;
194
- }
195
- return false;
196
- }
197
- function isExtensionAvailable(editor, extensionNames) {
198
- if (!editor) return false;
199
- const names = Array.isArray(extensionNames) ? extensionNames : [extensionNames];
200
- const found = names.some(
201
- (name) => editor.extensionManager.extensions.some((ext) => ext.name === name)
202
- );
203
- if (!found) {
204
- console.warn(
205
- `None of the extensions [${names.join(", ")}] were found in the editor schema. Ensure they are included in the editor configuration.`
206
- );
207
- }
208
- return found;
209
- }
210
- function getEditorExtension(editor, extensionName) {
211
- if (!editor) return null;
212
- const extension = editor.extensionManager.extensions.find(
213
- (ext) => ext.name === extensionName
214
- );
215
- if (!extension) {
216
- console.warn(
217
- `Extension "${extensionName}" not found in the editor schema. Ensure it is included in the editor configuration.`
218
- );
219
- return null;
220
- }
221
- return extension;
222
- }
223
- function hasContentAbove(editor) {
224
- if (!editor) return { hasContent: false, content: "" };
225
- const { state } = editor;
226
- const { $from } = state.selection;
227
- for (let i = $from.index(0) - 1; i >= 0; i--) {
228
- const node = state.doc.child(i);
229
- const content = node.textContent.trim();
230
- if (content) {
231
- return { hasContent: true, content };
232
- }
233
- }
234
- return { hasContent: false, content: "" };
235
- }
236
- function findSelectionPosition(params) {
237
- const { editor, node, nodePos } = params;
238
- if (isValidPosition(nodePos)) return nodePos;
239
- if (node) {
240
- const found = findNodePosition({ editor, node });
241
- if (found) return found.pos;
242
- }
243
- const { selection } = editor.state;
244
- if (!selection.empty) return null;
245
- const resolvedPos = selection.$anchor;
246
- const nodeDepth = 1;
247
- const selectedNode = resolvedPos.node(nodeDepth);
248
- return selectedNode ? resolvedPos.before(nodeDepth) : null;
249
- }
250
- function isValidPosition(pos) {
251
- return typeof pos === "number" && pos >= 0;
252
- }
253
- function getElementOverflowPosition(targetElement, containerElement) {
254
- const targetBounds = targetElement.getBoundingClientRect();
255
- const containerBounds = containerElement.getBoundingClientRect();
256
- const isOverflowingTop = targetBounds.top < containerBounds.top;
257
- const isOverflowingBottom = targetBounds.bottom > containerBounds.bottom;
258
- if (isOverflowingTop && isOverflowingBottom) return "both";
259
- if (isOverflowingTop) return "top";
260
- if (isOverflowingBottom) return "bottom";
261
- return "none";
262
- }
263
- function findParentNodeOfType(selection, typeName) {
264
- let depth = selection.$anchor.depth;
265
- while (depth > 0) {
266
- const node = selection.$anchor.node(depth);
267
- if (node.type.name === typeName) {
268
- return { node, pos: selection.$anchor.start(depth) - 1 };
269
- }
270
- depth--;
271
- }
272
- return null;
273
- }
274
121
  // Annotate the CommonJS export names for ESM import in node:
275
122
  0 && (module.exports = {
276
123
  MAX_FILE_SIZE,
277
124
  convertFileToBase64,
278
- findNodePosition,
279
- findParentNodeOfType,
280
- findSelectionPosition,
281
- getActiveMarkAttrs,
282
- getEditorExtension,
283
- getElementOverflowPosition,
284
125
  handleImageUpload,
285
- hasContentAbove,
286
126
  isAllowedUri,
287
- isEmptyNode,
288
- isExtensionAvailable,
289
- isMarkInSchema,
290
- isNodeInSchema,
291
- isNodeTypeSelected,
292
- isValidPosition,
293
127
  sanitizeUrl
294
128
  });
@@ -2,41 +2,14 @@
2
2
  import {
3
3
  MAX_FILE_SIZE,
4
4
  convertFileToBase64,
5
- findNodePosition,
6
- findParentNodeOfType,
7
- findSelectionPosition,
8
- getActiveMarkAttrs,
9
- getEditorExtension,
10
- getElementOverflowPosition,
11
5
  handleImageUpload,
12
- hasContentAbove,
13
6
  isAllowedUri,
14
- isEmptyNode,
15
- isExtensionAvailable,
16
- isMarkInSchema,
17
- isNodeInSchema,
18
- isNodeTypeSelected,
19
- isValidPosition,
20
7
  sanitizeUrl
21
- } from "../chunk-C6M3CDOK.mjs";
22
- import "../chunk-WKV76XOR.mjs";
8
+ } from "../chunk-TZQQ6C2Q.mjs";
23
9
  export {
24
10
  MAX_FILE_SIZE,
25
11
  convertFileToBase64,
26
- findNodePosition,
27
- findParentNodeOfType,
28
- findSelectionPosition,
29
- getActiveMarkAttrs,
30
- getEditorExtension,
31
- getElementOverflowPosition,
32
12
  handleImageUpload,
33
- hasContentAbove,
34
13
  isAllowedUri,
35
- isEmptyNode,
36
- isExtensionAvailable,
37
- isMarkInSchema,
38
- isNodeInSchema,
39
- isNodeTypeSelected,
40
- isValidPosition,
41
14
  sanitizeUrl
42
15
  };
@@ -3,7 +3,6 @@
3
3
  import {
4
4
  safeParseContent
5
5
  } from "../chunk-7LHOYNVF.mjs";
6
- import "../chunk-WKV76XOR.mjs";
7
6
  export {
8
7
  safeParseContent
9
8
  };