@kopexa/tiptap 17.7.0 → 17.7.2

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 (3) hide show
  1. package/dist/index.js +505 -226
  2. package/dist/index.mjs +387 -86
  3. package/package.json +24 -24
package/dist/index.js CHANGED
@@ -2751,13 +2751,14 @@ function VariableFillerDialog({
2751
2751
  }
2752
2752
 
2753
2753
  // src/extensions/variable/variable-suggestion.tsx
2754
- var import_editor_utils = require("@kopexa/editor-utils");
2754
+ var import_editor_utils2 = require("@kopexa/editor-utils");
2755
2755
  var import_theme6 = require("@kopexa/theme");
2756
2756
  var import_state2 = require("@tiptap/pm/state");
2757
2757
  var React6 = __toESM(require("react"));
2758
2758
 
2759
2759
  // src/ui/suggestion-menu/suggestion-menu.tsx
2760
- var import_react30 = require("@floating-ui/react");
2760
+ var import_react28 = require("@floating-ui/react");
2761
+ var import_editor_utils = require("@kopexa/editor-utils");
2761
2762
  var import_state = require("@tiptap/pm/state");
2762
2763
  var import_suggestion = require("@tiptap/suggestion");
2763
2764
  var React5 = __toESM(require("react"));
@@ -2935,35 +2936,6 @@ function useMenuNavigation({
2935
2936
  };
2936
2937
  }
2937
2938
 
2938
- // src/hooks/use-tiptap-editor.ts
2939
- var import_react28 = require("@tiptap/react");
2940
- var import_react29 = require("react");
2941
- function useTiptapEditor(providedEditor) {
2942
- const { editor: coreEditor } = (0, import_react28.useCurrentEditor)();
2943
- const mainEditor = (0, import_react29.useMemo)(
2944
- () => providedEditor || coreEditor,
2945
- [providedEditor, coreEditor]
2946
- );
2947
- const editorState = (0, import_react28.useEditorState)({
2948
- editor: mainEditor,
2949
- selector(context) {
2950
- if (!context.editor) {
2951
- return {
2952
- editor: null,
2953
- editorState: void 0,
2954
- canCommand: void 0
2955
- };
2956
- }
2957
- return {
2958
- editor: context.editor,
2959
- editorState: context.editor.state,
2960
- canCommand: context.editor.can
2961
- };
2962
- }
2963
- });
2964
- return editorState || { editor: null };
2965
- }
2966
-
2967
2939
  // src/ui/suggestion-menu/suggestion-menu-utils.ts
2968
2940
  function calculateStartPosition(cursorPosition, previousNode, triggerChar) {
2969
2941
  if (!(previousNode == null ? void 0 : previousNode.text) || !triggerChar) {
@@ -3020,7 +2992,7 @@ var SuggestionMenu = ({
3020
2992
  pluginKey = import_suggestion.SuggestionPluginKey,
3021
2993
  ...internalSuggestionProps
3022
2994
  }) => {
3023
- const { editor } = useTiptapEditor(providedEditor);
2995
+ const { editor } = (0, import_editor_utils.useTiptapEditor)(providedEditor);
3024
2996
  const [show, setShow] = React5.useState(false);
3025
2997
  const [internalClientRect, setInternalClientRect] = React5.useState(null);
3026
2998
  const [internalCommand, setInternalCommand] = React5.useState(null);
@@ -3036,13 +3008,13 @@ var SuggestionMenu = ({
3036
3008
  {
3037
3009
  placement: "bottom-start",
3038
3010
  middleware: [
3039
- (0, import_react30.offset)(10),
3040
- (0, import_react30.flip)({
3011
+ (0, import_react28.offset)(10),
3012
+ (0, import_react28.flip)({
3041
3013
  mainAxis: true,
3042
3014
  crossAxis: false
3043
3015
  }),
3044
- (0, import_react30.shift)(),
3045
- (0, import_react30.size)({
3016
+ (0, import_react28.shift)(),
3017
+ (0, import_react28.size)({
3046
3018
  apply({ availableHeight, elements }) {
3047
3019
  if (elements.floating) {
3048
3020
  const maxHeightValue = maxHeight ? Math.min(maxHeight, availableHeight) : availableHeight;
@@ -3181,7 +3153,7 @@ var SuggestionMenu = ({
3181
3153
  if (!isMounted || !show || !editor) {
3182
3154
  return null;
3183
3155
  }
3184
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react30.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3156
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react28.FloatingPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3185
3157
  "div",
3186
3158
  {
3187
3159
  ref,
@@ -3276,7 +3248,7 @@ var VariableItem = ({
3276
3248
  '[data-selector="tiptap-variable-suggestion-menu"]'
3277
3249
  );
3278
3250
  if (!itemRef.current || !isSelected || !selector) return;
3279
- const overflow = (0, import_editor_utils.getElementOverflowPosition)(itemRef.current, selector);
3251
+ const overflow = (0, import_editor_utils2.getElementOverflowPosition)(itemRef.current, selector);
3280
3252
  if (overflow === "top") {
3281
3253
  itemRef.current.scrollIntoView(true);
3282
3254
  } else if (overflow === "bottom") {
@@ -3376,14 +3348,14 @@ var import_extension_text_style = require("@tiptap/extension-text-style");
3376
3348
  var import_extension_typography = require("@tiptap/extension-typography");
3377
3349
  var import_extension_unique_id = require("@tiptap/extension-unique-id");
3378
3350
  var import_extensions = require("@tiptap/extensions");
3379
- var import_react34 = require("@tiptap/react");
3351
+ var import_react32 = require("@tiptap/react");
3380
3352
  var import_starter_kit = require("@tiptap/starter-kit");
3381
- var import_react35 = require("react");
3353
+ var import_react33 = require("react");
3382
3354
 
3383
3355
  // src/extensions/link/index.ts
3384
3356
  var import_extension_link = __toESM(require("@tiptap/extension-link"));
3385
3357
  var import_state3 = require("@tiptap/pm/state");
3386
- var import_react31 = require("@tiptap/react");
3358
+ var import_react29 = require("@tiptap/react");
3387
3359
  var Link = import_extension_link.default.extend({
3388
3360
  inclusive: false,
3389
3361
  parseHTML() {
@@ -3412,7 +3384,7 @@ var Link = import_extension_link.default.extend({
3412
3384
  const { schema, doc, tr } = view.state;
3413
3385
  let range;
3414
3386
  if (schema.marks.link) {
3415
- range = (0, import_react31.getMarkRange)(doc.resolve(pos), schema.marks.link);
3387
+ range = (0, import_react29.getMarkRange)(doc.resolve(pos), schema.marks.link);
3416
3388
  }
3417
3389
  if (!range) {
3418
3390
  return;
@@ -3436,11 +3408,290 @@ var Link = import_extension_link.default.extend({
3436
3408
  }
3437
3409
  });
3438
3410
 
3411
+ // src/extensions/node-alignment/index.ts
3412
+ var import_editor_utils3 = require("@kopexa/editor-utils");
3413
+ var import_core7 = require("@tiptap/core");
3414
+ function getToggleValue(targets, attributeName, inputValue) {
3415
+ var _a, _b;
3416
+ if (targets.length === 0) return null;
3417
+ for (const target of targets) {
3418
+ const currentValue = (_b = (_a = target.node.attrs) == null ? void 0 : _a[attributeName]) != null ? _b : null;
3419
+ if (currentValue !== inputValue) {
3420
+ return inputValue;
3421
+ }
3422
+ }
3423
+ return null;
3424
+ }
3425
+ var NodeAlignment = import_core7.Extension.create({
3426
+ name: "nodeAlignment",
3427
+ addOptions() {
3428
+ return {
3429
+ types: ["paragraph", "heading", "blockquote", "tableCell", "tableHeader"],
3430
+ useStyle: true,
3431
+ textAlignValues: ["left", "center", "right", "justify"],
3432
+ verticalAlignValues: ["top", "middle", "bottom"]
3433
+ };
3434
+ },
3435
+ addGlobalAttributes() {
3436
+ return [
3437
+ {
3438
+ types: this.options.types,
3439
+ attributes: {
3440
+ nodeTextAlign: {
3441
+ default: null,
3442
+ parseHTML: (element) => {
3443
+ var _a;
3444
+ const styleAlign = (_a = element.style) == null ? void 0 : _a.textAlign;
3445
+ if (styleAlign && this.options.textAlignValues.includes(styleAlign)) {
3446
+ return styleAlign;
3447
+ }
3448
+ const dataAlign = element.getAttribute("data-node-text-align");
3449
+ if (dataAlign && this.options.textAlignValues.includes(dataAlign)) {
3450
+ return dataAlign;
3451
+ }
3452
+ return null;
3453
+ },
3454
+ renderHTML: (attributes) => {
3455
+ const align = attributes.nodeTextAlign;
3456
+ if (!align || !this.options.textAlignValues.includes(align))
3457
+ return {};
3458
+ if (this.options.useStyle) {
3459
+ return { style: `text-align: ${align}` };
3460
+ } else {
3461
+ return { "data-node-text-align": align };
3462
+ }
3463
+ }
3464
+ },
3465
+ nodeVerticalAlign: {
3466
+ default: null,
3467
+ parseHTML: (element) => {
3468
+ var _a;
3469
+ const styleVAlign = (_a = element.style) == null ? void 0 : _a.verticalAlign;
3470
+ if (styleVAlign && this.options.verticalAlignValues.includes(styleVAlign)) {
3471
+ return styleVAlign;
3472
+ }
3473
+ const dataVAlign = element.getAttribute(
3474
+ "data-node-vertical-align"
3475
+ );
3476
+ if (dataVAlign && this.options.verticalAlignValues.includes(dataVAlign)) {
3477
+ return dataVAlign;
3478
+ }
3479
+ return null;
3480
+ },
3481
+ renderHTML: (attributes) => {
3482
+ const vAlign = attributes.nodeVerticalAlign;
3483
+ if (!vAlign || !this.options.verticalAlignValues.includes(vAlign))
3484
+ return {};
3485
+ if (this.options.useStyle) {
3486
+ return { style: `vertical-align: ${vAlign}` };
3487
+ } else {
3488
+ return { "data-node-vertical-align": vAlign };
3489
+ }
3490
+ }
3491
+ }
3492
+ }
3493
+ }
3494
+ ];
3495
+ },
3496
+ addCommands() {
3497
+ const executeAlignmentCommand = (attributeName, getTargetValue) => {
3498
+ return (inputValue) => ({ state, tr }) => {
3499
+ const targets = (0, import_editor_utils3.getSelectedNodesOfType)(
3500
+ state.selection,
3501
+ this.options.types
3502
+ );
3503
+ if (targets.length === 0) return false;
3504
+ const targetValue = getTargetValue(targets, inputValue);
3505
+ return (0, import_editor_utils3.updateNodesAttr)(tr, targets, attributeName, targetValue);
3506
+ };
3507
+ };
3508
+ return {
3509
+ // TEXT ALIGN
3510
+ setNodeTextAlign: executeAlignmentCommand(
3511
+ "nodeTextAlign",
3512
+ (_, inputValue) => {
3513
+ if (!inputValue || !this.options.textAlignValues.includes(inputValue))
3514
+ return null;
3515
+ return inputValue;
3516
+ }
3517
+ ),
3518
+ unsetNodeTextAlign: executeAlignmentCommand("nodeTextAlign", () => null),
3519
+ toggleNodeTextAlign: executeAlignmentCommand(
3520
+ "nodeTextAlign",
3521
+ (targets, inputValue) => {
3522
+ if (!inputValue || !this.options.textAlignValues.includes(inputValue))
3523
+ return null;
3524
+ return getToggleValue(targets, "nodeTextAlign", inputValue);
3525
+ }
3526
+ ),
3527
+ // VERTICAL ALIGN
3528
+ setNodeVAlign: executeAlignmentCommand(
3529
+ "nodeVerticalAlign",
3530
+ (_, inputValue) => {
3531
+ if (!inputValue || !this.options.verticalAlignValues.includes(inputValue))
3532
+ return null;
3533
+ return inputValue;
3534
+ }
3535
+ ),
3536
+ unsetNodeVAlign: executeAlignmentCommand("nodeVerticalAlign", () => null),
3537
+ toggleNodeVAlign: executeAlignmentCommand(
3538
+ "nodeVerticalAlign",
3539
+ (targets, inputValue) => {
3540
+ if (!inputValue || !this.options.verticalAlignValues.includes(inputValue))
3541
+ return null;
3542
+ return getToggleValue(targets, "nodeVerticalAlign", inputValue);
3543
+ }
3544
+ ),
3545
+ // BOTH
3546
+ setNodeAlignment: (textAlign, verticalAlign) => ({ state, tr }) => {
3547
+ const targets = (0, import_editor_utils3.getSelectedNodesOfType)(
3548
+ state.selection,
3549
+ this.options.types
3550
+ );
3551
+ if (targets.length === 0) return false;
3552
+ let hasChanges = false;
3553
+ for (const { node, pos } of targets) {
3554
+ const newAttrs = { ...node.attrs };
3555
+ if (textAlign && this.options.textAlignValues.includes(textAlign)) {
3556
+ newAttrs.nodeTextAlign = textAlign;
3557
+ hasChanges = true;
3558
+ }
3559
+ if (verticalAlign && this.options.verticalAlignValues.includes(verticalAlign)) {
3560
+ newAttrs.nodeVerticalAlign = verticalAlign;
3561
+ hasChanges = true;
3562
+ }
3563
+ if (hasChanges) tr.setNodeMarkup(pos, void 0, newAttrs);
3564
+ }
3565
+ return hasChanges;
3566
+ },
3567
+ unsetNodeAlignment: () => ({ state, tr }) => {
3568
+ var _a, _b, _c, _d;
3569
+ const targets = (0, import_editor_utils3.getSelectedNodesOfType)(
3570
+ state.selection,
3571
+ this.options.types
3572
+ );
3573
+ if (targets.length === 0) return false;
3574
+ let hasChanges = false;
3575
+ for (const { node, pos } of targets) {
3576
+ const hasText = (_b = (_a = node.attrs) == null ? void 0 : _a.nodeTextAlign) != null ? _b : null;
3577
+ const hasV = (_d = (_c = node.attrs) == null ? void 0 : _c.nodeVerticalAlign) != null ? _d : null;
3578
+ if (hasText || hasV) {
3579
+ const newAttrs = {
3580
+ ...node.attrs,
3581
+ nodeTextAlign: null,
3582
+ nodeVerticalAlign: null
3583
+ };
3584
+ tr.setNodeMarkup(pos, void 0, newAttrs);
3585
+ hasChanges = true;
3586
+ }
3587
+ }
3588
+ return hasChanges;
3589
+ }
3590
+ };
3591
+ }
3592
+ });
3593
+
3594
+ // src/extensions/node-background/index.ts
3595
+ var import_editor_utils4 = require("@kopexa/editor-utils");
3596
+ var import_core8 = require("@tiptap/core");
3597
+ function getToggleColor(targets, inputColor) {
3598
+ var _a, _b;
3599
+ if (targets.length === 0) return null;
3600
+ for (const target of targets) {
3601
+ const currentColor = (_b = (_a = target.node.attrs) == null ? void 0 : _a.backgroundColor) != null ? _b : null;
3602
+ if (currentColor !== inputColor) {
3603
+ return inputColor;
3604
+ }
3605
+ }
3606
+ return null;
3607
+ }
3608
+ var NodeBackground = import_core8.Extension.create({
3609
+ name: "nodeBackground",
3610
+ addOptions() {
3611
+ return {
3612
+ types: [
3613
+ "paragraph",
3614
+ "heading",
3615
+ "blockquote",
3616
+ "taskList",
3617
+ "bulletList",
3618
+ "orderedList",
3619
+ "tableCell",
3620
+ "tableHeader"
3621
+ ],
3622
+ useStyle: true
3623
+ };
3624
+ },
3625
+ addGlobalAttributes() {
3626
+ return [
3627
+ {
3628
+ types: this.options.types,
3629
+ attributes: {
3630
+ backgroundColor: {
3631
+ default: null,
3632
+ parseHTML: (element) => {
3633
+ var _a;
3634
+ const styleColor = (_a = element.style) == null ? void 0 : _a.backgroundColor;
3635
+ if (styleColor) return styleColor;
3636
+ const dataColor = element.getAttribute("data-background-color");
3637
+ return dataColor || null;
3638
+ },
3639
+ renderHTML: (attributes) => {
3640
+ const color = attributes.backgroundColor;
3641
+ if (!color) return {};
3642
+ if (this.options.useStyle) {
3643
+ return {
3644
+ style: `background-color: ${color}`
3645
+ };
3646
+ } else {
3647
+ return {
3648
+ "data-background-color": color
3649
+ };
3650
+ }
3651
+ }
3652
+ }
3653
+ }
3654
+ }
3655
+ ];
3656
+ },
3657
+ addCommands() {
3658
+ const executeBackgroundCommand = (getTargetColor) => {
3659
+ return (inputColor) => ({ state, tr }) => {
3660
+ const targets = (0, import_editor_utils4.getSelectedNodesOfType)(
3661
+ state.selection,
3662
+ this.options.types
3663
+ );
3664
+ if (targets.length === 0) return false;
3665
+ const targetColor = getTargetColor(targets, inputColor);
3666
+ return (0, import_editor_utils4.updateNodesAttr)(tr, targets, "backgroundColor", targetColor);
3667
+ };
3668
+ };
3669
+ return {
3670
+ /**
3671
+ * Set background color to specific value
3672
+ */
3673
+ setNodeBackgroundColor: executeBackgroundCommand(
3674
+ (_, inputColor) => inputColor || null
3675
+ ),
3676
+ /**
3677
+ * Remove background color
3678
+ */
3679
+ unsetNodeBackgroundColor: executeBackgroundCommand(() => null),
3680
+ /**
3681
+ * Toggle background color (set if different/missing, unset if all have it)
3682
+ */
3683
+ toggleNodeBackgroundColor: executeBackgroundCommand(
3684
+ (targets, inputColor) => getToggleColor(targets, inputColor || "")
3685
+ )
3686
+ };
3687
+ }
3688
+ });
3689
+
3439
3690
  // src/extensions/selection/index.ts
3440
3691
  var import_state4 = require("@tiptap/pm/state");
3441
3692
  var import_view = require("@tiptap/pm/view");
3442
- var import_react32 = require("@tiptap/react");
3443
- var Selection = import_react32.Extension.create({
3693
+ var import_react30 = require("@tiptap/react");
3694
+ var Selection = import_react30.Extension.create({
3444
3695
  name: "selection",
3445
3696
  addProseMirrorPlugins() {
3446
3697
  const { editor } = this;
@@ -3455,7 +3706,7 @@ var Selection = import_react32.Extension.create({
3455
3706
  if (editor.isFocused === true || !editor.isEditable) {
3456
3707
  return null;
3457
3708
  }
3458
- if ((0, import_react32.isNodeSelection)(state.selection)) {
3709
+ if ((0, import_react30.isNodeSelection)(state.selection)) {
3459
3710
  return null;
3460
3711
  }
3461
3712
  return import_view.DecorationSet.create(state.doc, [
@@ -3472,7 +3723,7 @@ var Selection = import_react32.Extension.create({
3472
3723
 
3473
3724
  // src/extensions/trailing-node/index.ts
3474
3725
  var import_state5 = require("@tiptap/pm/state");
3475
- var import_react33 = require("@tiptap/react");
3726
+ var import_react31 = require("@tiptap/react");
3476
3727
  function nodeEqualsType({
3477
3728
  types,
3478
3729
  node
@@ -3483,7 +3734,7 @@ function nodeEqualsType({
3483
3734
  }
3484
3735
  return node.type === types;
3485
3736
  }
3486
- var TrailingNode = import_react33.Extension.create({
3737
+ var TrailingNode = import_react31.Extension.create({
3487
3738
  name: "trailingNode",
3488
3739
  addOptions() {
3489
3740
  return {
@@ -3529,7 +3780,7 @@ var TrailingNode = import_react33.Extension.create({
3529
3780
  });
3530
3781
 
3531
3782
  // src/extensions/ui-state/index.ts
3532
- var import_core7 = require("@tiptap/core");
3783
+ var import_core9 = require("@tiptap/core");
3533
3784
  var defaultUiState = {
3534
3785
  aiGenerationIsSelection: false,
3535
3786
  aiGenerationIsLoading: false,
@@ -3539,7 +3790,7 @@ var defaultUiState = {
3539
3790
  lockDragHandle: false,
3540
3791
  isDragging: false
3541
3792
  };
3542
- var UiState = import_core7.Extension.create({
3793
+ var UiState = import_core9.Extension.create({
3543
3794
  name: "uiState",
3544
3795
  addStorage() {
3545
3796
  return {
@@ -3764,7 +4015,7 @@ var useCreateEditor = ({
3764
4015
  const fileHandlerFromContext = useEditorFile();
3765
4016
  const fileHandler = fileHandlerProp != null ? fileHandlerProp : fileHandlerFromContext;
3766
4017
  const collaboration = useCollaboration();
3767
- const [extensions] = (0, import_react35.useState)(
4018
+ const [extensions] = (0, import_react33.useState)(
3768
4019
  () => getExtensions({
3769
4020
  editable,
3770
4021
  placeholder,
@@ -3778,7 +4029,7 @@ var useCreateEditor = ({
3778
4029
  disabled
3779
4030
  })
3780
4031
  );
3781
- const editor = (0, import_react34.useEditor)({
4032
+ const editor = (0, import_react32.useEditor)({
3782
4033
  editorProps: {
3783
4034
  attributes: {
3784
4035
  autocomplete: "off",
@@ -3797,7 +4048,7 @@ var useCreateEditor = ({
3797
4048
  content: safeParseContent(content),
3798
4049
  ...options
3799
4050
  });
3800
- (0, import_react35.useEffect)(() => {
4051
+ (0, import_react33.useEffect)(() => {
3801
4052
  if (editor && editor.isEditable !== editable) {
3802
4053
  editor.setEditable(editable);
3803
4054
  }
@@ -3864,6 +4115,8 @@ function getExtensions({
3864
4115
  }),
3865
4116
  UiState,
3866
4117
  import_extension_table.TableKit,
4118
+ NodeAlignment,
4119
+ NodeBackground,
3867
4120
  TocNode,
3868
4121
  CalloutNode,
3869
4122
  MathBlock,
@@ -4012,19 +4265,20 @@ async function handleFileUpload(editor, file, fileHandler, pos) {
4012
4265
  }
4013
4266
 
4014
4267
  // src/presets/basic/index.tsx
4268
+ var import_extension_table2 = require("@kopexa/extension-table");
4015
4269
  var import_theme9 = require("@kopexa/theme");
4016
- var import_react59 = require("@tiptap/react");
4017
- var import_react60 = require("react");
4270
+ var import_react57 = require("@tiptap/react");
4271
+ var import_react58 = require("react");
4018
4272
 
4019
4273
  // src/context/editor-context.ts
4020
4274
  var import_react_utils = require("@kopexa/react-utils");
4021
4275
  var [EditorUIProvider, useEditorUIContext] = (0, import_react_utils.createContext)();
4022
4276
 
4023
4277
  // src/hooks/use-ui-editor-state.ts
4024
- var import_react36 = require("@tiptap/react");
4278
+ var import_react34 = require("@tiptap/react");
4025
4279
  function useUiEditorState(editor) {
4026
4280
  var _a;
4027
- return (_a = (0, import_react36.useEditorState)({
4281
+ return (_a = (0, import_react34.useEditorState)({
4028
4282
  editor,
4029
4283
  selector: ({ editor: editor2 }) => {
4030
4284
  if (!editor2) return defaultUiState;
@@ -4046,14 +4300,15 @@ var import_menus = require("@tiptap/react/menus");
4046
4300
 
4047
4301
  // src/ui/link-popover/link-popover.tsx
4048
4302
  var import_button8 = require("@kopexa/button");
4303
+ var import_editor_utils6 = require("@kopexa/editor-utils");
4049
4304
  var import_icons9 = require("@kopexa/icons");
4050
4305
  var import_input3 = require("@kopexa/input");
4051
4306
  var import_popover = require("@kopexa/popover");
4052
4307
  var import_toolbar = require("@kopexa/toolbar");
4053
- var import_react37 = require("react");
4308
+ var import_react35 = require("react");
4054
4309
 
4055
4310
  // src/ui/link-popover/use-link-popover.ts
4056
- var import_editor_utils2 = require("@kopexa/editor-utils");
4311
+ var import_editor_utils5 = require("@kopexa/editor-utils");
4057
4312
  var import_icons8 = require("@kopexa/icons");
4058
4313
  var React7 = __toESM(require("react"));
4059
4314
 
@@ -4160,7 +4415,7 @@ function isLinkActive(editor) {
4160
4415
  }
4161
4416
  function shouldShowLinkButton(props) {
4162
4417
  const { editor, hideWhenUnavailable } = props;
4163
- const linkInSchema = (0, import_editor_utils2.isMarkInSchema)("link", editor);
4418
+ const linkInSchema = (0, import_editor_utils5.isMarkInSchema)("link", editor);
4164
4419
  if (!linkInSchema || !editor) {
4165
4420
  return false;
4166
4421
  }
@@ -4259,7 +4514,7 @@ function useLinkPopover(config) {
4259
4514
  hideWhenUnavailable = false,
4260
4515
  onSetLink
4261
4516
  } = config || {};
4262
- const { editor } = useTiptapEditor(providedEditor);
4517
+ const { editor } = (0, import_editor_utils5.useTiptapEditor)(providedEditor);
4263
4518
  const { isVisible, canSet, isActive } = useLinkState({
4264
4519
  editor,
4265
4520
  hideWhenUnavailable
@@ -4306,8 +4561,8 @@ var LinkMain = ({
4306
4561
  isActive,
4307
4562
  onSave
4308
4563
  }) => {
4309
- const [isEditing, setIsEditing] = (0, import_react37.useState)(!isActive || !url);
4310
- (0, import_react37.useEffect)(() => {
4564
+ const [isEditing, setIsEditing] = (0, import_react35.useState)(!isActive || !url);
4565
+ (0, import_react35.useEffect)(() => {
4311
4566
  setIsEditing(!isActive || !url);
4312
4567
  }, [isActive, url]);
4313
4568
  const handleKeyDown = (event) => {
@@ -4422,8 +4677,8 @@ function LinkPopover({
4422
4677
  children,
4423
4678
  ...buttonProps
4424
4679
  }) {
4425
- const { editor } = useTiptapEditor(providedEditor);
4426
- const [isOpen, setIsOpen] = (0, import_react37.useState)(false);
4680
+ const { editor } = (0, import_editor_utils6.useTiptapEditor)(providedEditor);
4681
+ const [isOpen, setIsOpen] = (0, import_react35.useState)(false);
4427
4682
  const {
4428
4683
  isVisible,
4429
4684
  canSet,
@@ -4439,18 +4694,18 @@ function LinkPopover({
4439
4694
  hideWhenUnavailable,
4440
4695
  onSetLink
4441
4696
  });
4442
- const handleOnOpenChange = (0, import_react37.useCallback)(
4697
+ const handleOnOpenChange = (0, import_react35.useCallback)(
4443
4698
  (nextIsOpen) => {
4444
4699
  setIsOpen(nextIsOpen);
4445
4700
  onOpenChange == null ? void 0 : onOpenChange(nextIsOpen);
4446
4701
  },
4447
4702
  [onOpenChange]
4448
4703
  );
4449
- const handleSetLink = (0, import_react37.useCallback)(() => {
4704
+ const handleSetLink = (0, import_react35.useCallback)(() => {
4450
4705
  setLink();
4451
4706
  setIsOpen(false);
4452
4707
  }, [setLink]);
4453
- const handleClick = (0, import_react37.useCallback)(
4708
+ const handleClick = (0, import_react35.useCallback)(
4454
4709
  (event) => {
4455
4710
  onClick == null ? void 0 : onClick(event);
4456
4711
  if (event.defaultPrevented) return;
@@ -4458,7 +4713,7 @@ function LinkPopover({
4458
4713
  },
4459
4714
  [onClick, isOpen]
4460
4715
  );
4461
- (0, import_react37.useEffect)(() => {
4716
+ (0, import_react35.useEffect)(() => {
4462
4717
  if (autoOpenOnLinkActive && isActive) {
4463
4718
  setIsOpen(true);
4464
4719
  }
@@ -4509,11 +4764,11 @@ function LinkPopover({
4509
4764
  LinkButton.displayName = "LinkButton";
4510
4765
 
4511
4766
  // src/ui/mark-button/index.tsx
4512
- var import_editor_utils3 = require("@kopexa/editor-utils");
4767
+ var import_editor_utils7 = require("@kopexa/editor-utils");
4513
4768
  var import_icons10 = require("@kopexa/icons");
4514
4769
  var import_toolbar2 = require("@kopexa/toolbar");
4515
- var import_react38 = require("@tiptap/react");
4516
- var import_react39 = require("react");
4770
+ var import_react36 = require("@tiptap/react");
4771
+ var import_react37 = require("react");
4517
4772
  var import_jsx_runtime17 = require("react/jsx-runtime");
4518
4773
  var markIcons = {
4519
4774
  bold: import_icons10.BoldIcon,
@@ -4535,7 +4790,7 @@ var markShortcutKeys = {
4535
4790
  };
4536
4791
  function canToggleMark(editor, type) {
4537
4792
  if (!editor || !editor.isEditable) return false;
4538
- if (!(0, import_editor_utils3.isMarkInSchema)(type, editor) || (0, import_editor_utils3.isNodeTypeSelected)(editor, ["image"]))
4793
+ if (!(0, import_editor_utils7.isMarkInSchema)(type, editor) || (0, import_editor_utils7.isNodeTypeSelected)(editor, ["image"]))
4539
4794
  return false;
4540
4795
  return editor.can().toggleMark(type);
4541
4796
  }
@@ -4560,7 +4815,7 @@ function shouldShowMarkButton(params) {
4560
4815
  return false;
4561
4816
  }
4562
4817
  if (hideWhenUnavailable) {
4563
- if ((0, import_react38.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
4818
+ if ((0, import_react36.isNodeSelection)(editor.state.selection) || !canToggleMark(editor, type)) {
4564
4819
  return false;
4565
4820
  }
4566
4821
  }
@@ -4570,7 +4825,7 @@ function getFormattedMarkName(type) {
4570
4825
  return type.charAt(0).toUpperCase() + type.slice(1);
4571
4826
  }
4572
4827
  function useMarkState(editor, type, disabled = false) {
4573
- const markInSchema = (0, import_editor_utils3.isMarkInSchema)(type, editor);
4828
+ const markInSchema = (0, import_editor_utils7.isMarkInSchema)(type, editor);
4574
4829
  const isDisabled = isMarkButtonDisabled(editor, type, disabled);
4575
4830
  const isActive = isMarkActive(editor, type);
4576
4831
  const Icon = markIcons[type];
@@ -4596,7 +4851,7 @@ var MarkButton = ({
4596
4851
  children,
4597
4852
  ...buttonProps
4598
4853
  }) => {
4599
- const { editor } = useTiptapEditor(providedEditor);
4854
+ const { editor } = (0, import_editor_utils7.useTiptapEditor)(providedEditor);
4600
4855
  const {
4601
4856
  markInSchema,
4602
4857
  isDisabled,
@@ -4605,7 +4860,7 @@ var MarkButton = ({
4605
4860
  shortcutKey,
4606
4861
  formattedName
4607
4862
  } = useMarkState(editor, type, disabled);
4608
- const handleClick = (0, import_react39.useCallback)(
4863
+ const handleClick = (0, import_react37.useCallback)(
4609
4864
  (e) => {
4610
4865
  onClick == null ? void 0 : onClick(e);
4611
4866
  if (!e.defaultPrevented && !isDisabled && editor) {
@@ -4614,7 +4869,7 @@ var MarkButton = ({
4614
4869
  },
4615
4870
  [onClick, isDisabled, editor, type]
4616
4871
  );
4617
- const show = (0, import_react39.useMemo)(() => {
4872
+ const show = (0, import_react37.useMemo)(() => {
4618
4873
  return shouldShowMarkButton({
4619
4874
  editor,
4620
4875
  type,
@@ -4689,12 +4944,12 @@ function BubbleMenu({ editor }) {
4689
4944
  }
4690
4945
 
4691
4946
  // src/ui/copy-anchor-link-button/use-scroll-to-hash.ts
4692
- var import_editor_utils4 = require("@kopexa/editor-utils");
4947
+ var import_editor_utils8 = require("@kopexa/editor-utils");
4693
4948
  var React9 = __toESM(require("react"));
4694
4949
 
4695
4950
  // src/hooks/use-floating-toolbar-visibility.ts
4696
4951
  var import_state6 = require("@tiptap/pm/state");
4697
- var import_react40 = require("@tiptap/react");
4952
+ var import_react38 = require("@tiptap/react");
4698
4953
  var React8 = __toESM(require("react"));
4699
4954
  var HIDE_FLOATING_META = "hideFloatingToolbar";
4700
4955
  var selectNodeAndHideFloating = (editor, pos) => {
@@ -4714,12 +4969,12 @@ function useScrollToHash(config = {}) {
4714
4969
  onTargetNotFound = () => {
4715
4970
  }
4716
4971
  } = config;
4717
- const { editor } = useTiptapEditor(providedEditor);
4972
+ const { editor } = (0, import_editor_utils8.useTiptapEditor)(providedEditor);
4718
4973
  const scrollToNode = React9.useCallback(
4719
4974
  (id) => {
4720
4975
  var _a, _b, _c;
4721
4976
  if (!editor) return false;
4722
- const attributeName = (_c = (_b = (_a = (0, import_editor_utils4.getEditorExtension)(editor, "uniqueID")) == null ? void 0 : _a.options) == null ? void 0 : _b.attributeName) != null ? _c : "data-id";
4977
+ const attributeName = (_c = (_b = (_a = (0, import_editor_utils8.getEditorExtension)(editor, "uniqueID")) == null ? void 0 : _a.options) == null ? void 0 : _b.attributeName) != null ? _c : "data-id";
4723
4978
  let position = null;
4724
4979
  editor.state.doc.descendants((node, pos) => {
4725
4980
  var _a2;
@@ -4796,37 +5051,37 @@ var import_button9 = require("@kopexa/button");
4796
5051
  var import_icons11 = require("@kopexa/icons");
4797
5052
  var import_input4 = require("@kopexa/input");
4798
5053
  var import_menus2 = require("@tiptap/react/menus");
4799
- var import_react41 = require("react");
5054
+ var import_react39 = require("react");
4800
5055
  var import_jsx_runtime19 = require("react/jsx-runtime");
4801
5056
  function LinkBubble({ editor }) {
4802
- const [isEditing, setIsEditing] = (0, import_react41.useState)(false);
4803
- const [url, setUrl] = (0, import_react41.useState)("");
4804
- const getCurrentUrl = (0, import_react41.useCallback)(() => {
5057
+ const [isEditing, setIsEditing] = (0, import_react39.useState)(false);
5058
+ const [url, setUrl] = (0, import_react39.useState)("");
5059
+ const getCurrentUrl = (0, import_react39.useCallback)(() => {
4805
5060
  if (!editor) return "";
4806
5061
  const attrs = editor.getAttributes("link");
4807
5062
  return attrs.href || "";
4808
5063
  }, [editor]);
4809
- (0, import_react41.useEffect)(() => {
5064
+ (0, import_react39.useEffect)(() => {
4810
5065
  const isLinkActive2 = editor == null ? void 0 : editor.isActive("link");
4811
5066
  if (isLinkActive2) {
4812
5067
  setUrl(getCurrentUrl());
4813
5068
  setIsEditing(false);
4814
5069
  }
4815
5070
  }, [editor, getCurrentUrl]);
4816
- const handleOpenLink = (0, import_react41.useCallback)(() => {
5071
+ const handleOpenLink = (0, import_react39.useCallback)(() => {
4817
5072
  const href = getCurrentUrl();
4818
5073
  if (href) {
4819
5074
  window.open(href, "_blank", "noopener,noreferrer");
4820
5075
  }
4821
5076
  }, [getCurrentUrl]);
4822
- const handleRemoveLink = (0, import_react41.useCallback)(() => {
5077
+ const handleRemoveLink = (0, import_react39.useCallback)(() => {
4823
5078
  editor == null ? void 0 : editor.chain().focus().unsetLink().run();
4824
5079
  }, [editor]);
4825
- const handleEdit = (0, import_react41.useCallback)(() => {
5080
+ const handleEdit = (0, import_react39.useCallback)(() => {
4826
5081
  setUrl(getCurrentUrl());
4827
5082
  setIsEditing(true);
4828
5083
  }, [getCurrentUrl]);
4829
- const handleSave = (0, import_react41.useCallback)(() => {
5084
+ const handleSave = (0, import_react39.useCallback)(() => {
4830
5085
  if (url) {
4831
5086
  editor == null ? void 0 : editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
4832
5087
  } else {
@@ -4834,7 +5089,7 @@ function LinkBubble({ editor }) {
4834
5089
  }
4835
5090
  setIsEditing(false);
4836
5091
  }, [editor, url]);
4837
- const handleKeyDown = (0, import_react41.useCallback)(
5092
+ const handleKeyDown = (0, import_react39.useCallback)(
4838
5093
  (e) => {
4839
5094
  if (e.key === "Enter") {
4840
5095
  e.preventDefault();
@@ -4945,24 +5200,24 @@ function LinkBubble({ editor }) {
4945
5200
 
4946
5201
  // src/ui/slash-dropdown-menu/slash-dropdown-menu.tsx
4947
5202
  var import_button10 = require("@kopexa/button");
4948
- var import_editor_utils7 = require("@kopexa/editor-utils");
5203
+ var import_editor_utils11 = require("@kopexa/editor-utils");
4949
5204
  var import_separator = require("@kopexa/separator");
4950
5205
  var import_theme7 = require("@kopexa/theme");
4951
5206
  var React11 = __toESM(require("react"));
4952
5207
 
4953
5208
  // src/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts
4954
- var import_editor_utils6 = require("@kopexa/editor-utils");
5209
+ var import_editor_utils10 = require("@kopexa/editor-utils");
4955
5210
  var import_icons13 = require("@kopexa/icons");
4956
5211
  var React10 = __toESM(require("react"));
4957
5212
 
4958
5213
  // src/ui/table-button/use-table.ts
4959
- var import_editor_utils5 = require("@kopexa/editor-utils");
5214
+ var import_editor_utils9 = require("@kopexa/editor-utils");
4960
5215
  var import_icons12 = require("@kopexa/icons");
4961
- var import_react42 = require("@tiptap/react");
4962
- var import_react43 = require("react");
5216
+ var import_react40 = require("@tiptap/react");
5217
+ var import_react41 = require("react");
4963
5218
  function canToggle(editor) {
4964
5219
  if (!editor || !editor.isEditable) return false;
4965
- if (!(0, import_editor_utils5.isNodeInSchema)("table", editor) || (0, import_editor_utils5.isNodeTypeSelected)(editor, ["image"])) {
5220
+ if (!(0, import_editor_utils9.isNodeInSchema)("table", editor) || (0, import_editor_utils9.isNodeTypeSelected)(editor, ["image"])) {
4966
5221
  return false;
4967
5222
  }
4968
5223
  try {
@@ -4988,9 +5243,9 @@ function toggleTable(editor, config) {
4988
5243
  function shouldShowButton(props) {
4989
5244
  const { editor, hideWhenUnavailable } = props;
4990
5245
  if (!editor || !editor.isEditable) return false;
4991
- if (!(0, import_editor_utils5.isNodeInSchema)("table", editor)) return false;
5246
+ if (!(0, import_editor_utils9.isNodeInSchema)("table", editor)) return false;
4992
5247
  if (hideWhenUnavailable) {
4993
- if ((0, import_react42.isNodeSelection)(editor.state.selection) || !canToggle) {
5248
+ if ((0, import_react40.isNodeSelection)(editor.state.selection) || !canToggle) {
4994
5249
  return false;
4995
5250
  }
4996
5251
  }
@@ -5002,11 +5257,11 @@ function useTableBlock(config) {
5002
5257
  hideWhenUnavailable = false,
5003
5258
  onToggled
5004
5259
  } = config || {};
5005
- const { editor } = useTiptapEditor(providedEditor);
5006
- const [isVisible, setIsVisible] = (0, import_react43.useState)(true);
5260
+ const { editor } = (0, import_editor_utils9.useTiptapEditor)(providedEditor);
5261
+ const [isVisible, setIsVisible] = (0, import_react41.useState)(true);
5007
5262
  const canToggleState = canToggle(editor);
5008
5263
  const isActive = (editor == null ? void 0 : editor.isActive("table")) || false;
5009
- (0, import_react43.useEffect)(() => {
5264
+ (0, import_react41.useEffect)(() => {
5010
5265
  if (!editor) return;
5011
5266
  const handleSelectionUpdate = () => {
5012
5267
  setIsVisible(shouldShowButton({ editor, hideWhenUnavailable }));
@@ -5017,7 +5272,7 @@ function useTableBlock(config) {
5017
5272
  editor.off("selectionUpdate", handleSelectionUpdate);
5018
5273
  };
5019
5274
  }, [editor, hideWhenUnavailable]);
5020
- const handleToggle = (0, import_react43.useCallback)(() => {
5275
+ const handleToggle = (0, import_react41.useCallback)(() => {
5021
5276
  if (!editor) return false;
5022
5277
  const success = toggleTable(editor);
5023
5278
  if (success) {
@@ -5203,8 +5458,8 @@ var getItemImplementations = () => {
5203
5458
  // AI
5204
5459
  continue_writing: {
5205
5460
  check: (editor) => {
5206
- const { hasContent } = (0, import_editor_utils6.hasContentAbove)(editor);
5207
- const extensionsReady = (0, import_editor_utils6.isExtensionAvailable)(editor, [
5461
+ const { hasContent } = (0, import_editor_utils10.hasContentAbove)(editor);
5462
+ const extensionsReady = (0, import_editor_utils10.isExtensionAvailable)(editor, [
5208
5463
  "ai",
5209
5464
  "aiAdvanced"
5210
5465
  ]);
@@ -5212,14 +5467,14 @@ var getItemImplementations = () => {
5212
5467
  },
5213
5468
  action: ({ editor }) => {
5214
5469
  const editorChain = editor.chain().focus();
5215
- const nodeSelectionPosition = (0, import_editor_utils6.findSelectionPosition)({ editor });
5470
+ const nodeSelectionPosition = (0, import_editor_utils10.findSelectionPosition)({ editor });
5216
5471
  if (nodeSelectionPosition !== null) {
5217
5472
  editorChain.setNodeSelection(nodeSelectionPosition);
5218
5473
  }
5219
5474
  editorChain.run();
5220
5475
  editor.chain().focus().aiGenerationShow().run();
5221
5476
  requestAnimationFrame(() => {
5222
- const { hasContent, content } = (0, import_editor_utils6.hasContentAbove)(editor);
5477
+ const { hasContent, content } = (0, import_editor_utils10.hasContentAbove)(editor);
5223
5478
  const snippet = content.length > 500 ? `...${content.slice(-500)}` : content;
5224
5479
  const prompt = hasContent ? `Context: ${snippet}
5225
5480
 
@@ -5233,10 +5488,10 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
5233
5488
  }
5234
5489
  },
5235
5490
  ai_ask_button: {
5236
- check: (editor) => (0, import_editor_utils6.isExtensionAvailable)(editor, ["ai", "aiAdvanced"]),
5491
+ check: (editor) => (0, import_editor_utils10.isExtensionAvailable)(editor, ["ai", "aiAdvanced"]),
5237
5492
  action: ({ editor }) => {
5238
5493
  const editorChain = editor.chain().focus();
5239
- const nodeSelectionPosition = (0, import_editor_utils6.findSelectionPosition)({ editor });
5494
+ const nodeSelectionPosition = (0, import_editor_utils10.findSelectionPosition)({ editor });
5240
5495
  if (nodeSelectionPosition !== null) {
5241
5496
  editorChain.setNodeSelection(nodeSelectionPosition);
5242
5497
  }
@@ -5246,55 +5501,55 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
5246
5501
  },
5247
5502
  // Style
5248
5503
  text: {
5249
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("paragraph", editor),
5504
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("paragraph", editor),
5250
5505
  action: ({ editor }) => {
5251
5506
  editor.chain().focus().setParagraph().run();
5252
5507
  }
5253
5508
  },
5254
5509
  heading_1: {
5255
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("heading", editor),
5510
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("heading", editor),
5256
5511
  action: ({ editor }) => {
5257
5512
  editor.chain().focus().toggleHeading({ level: 1 }).run();
5258
5513
  }
5259
5514
  },
5260
5515
  heading_2: {
5261
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("heading", editor),
5516
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("heading", editor),
5262
5517
  action: ({ editor }) => {
5263
5518
  editor.chain().focus().toggleHeading({ level: 2 }).run();
5264
5519
  }
5265
5520
  },
5266
5521
  heading_3: {
5267
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("heading", editor),
5522
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("heading", editor),
5268
5523
  action: ({ editor }) => {
5269
5524
  editor.chain().focus().toggleHeading({ level: 3 }).run();
5270
5525
  }
5271
5526
  },
5272
5527
  bullet_list: {
5273
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("bulletList", editor),
5528
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("bulletList", editor),
5274
5529
  action: ({ editor }) => {
5275
5530
  editor.chain().focus().toggleBulletList().run();
5276
5531
  }
5277
5532
  },
5278
5533
  ordered_list: {
5279
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("orderedList", editor),
5534
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("orderedList", editor),
5280
5535
  action: ({ editor }) => {
5281
5536
  editor.chain().focus().toggleOrderedList().run();
5282
5537
  }
5283
5538
  },
5284
5539
  task_list: {
5285
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("taskList", editor),
5540
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("taskList", editor),
5286
5541
  action: ({ editor }) => {
5287
5542
  editor.chain().focus().toggleTaskList().run();
5288
5543
  }
5289
5544
  },
5290
5545
  quote: {
5291
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("blockquote", editor),
5546
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("blockquote", editor),
5292
5547
  action: ({ editor }) => {
5293
5548
  editor.chain().focus().toggleBlockquote().run();
5294
5549
  }
5295
5550
  },
5296
5551
  code_block: {
5297
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("codeBlock", editor),
5552
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("codeBlock", editor),
5298
5553
  action: ({ editor }) => {
5299
5554
  editor.chain().focus().toggleNode("codeBlock", "paragraph").run();
5300
5555
  }
@@ -5311,17 +5566,17 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
5311
5566
  // action: ({ editor }: { editor: Editor }) => addEmojiTrigger(editor),
5312
5567
  // },
5313
5568
  divider: {
5314
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("horizontalRule", editor),
5569
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("horizontalRule", editor),
5315
5570
  action: ({ editor }) => {
5316
5571
  editor.chain().focus().setHorizontalRule().run();
5317
5572
  }
5318
5573
  },
5319
5574
  table: {
5320
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("table", editor),
5575
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("table", editor),
5321
5576
  action: ({ editor }) => toggleTable(editor, { rows: 3, cols: 3, withHeaderRow: true })
5322
5577
  },
5323
5578
  control: {
5324
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("controlBlock", editor),
5579
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("controlBlock", editor),
5325
5580
  action: ({ editor }) => {
5326
5581
  try {
5327
5582
  return editor.chain().focus().insertControlBlock().run();
@@ -5331,32 +5586,32 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
5331
5586
  }
5332
5587
  },
5333
5588
  table_of_contents: {
5334
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("tableOfContentsNode", editor),
5589
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("tableOfContentsNode", editor),
5335
5590
  action: ({ editor }) => {
5336
5591
  editor.chain().focus().insertTableOfContents().run();
5337
5592
  }
5338
5593
  },
5339
5594
  callout: {
5340
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("calloutNode", editor),
5595
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("calloutNode", editor),
5341
5596
  action: ({ editor }) => {
5342
5597
  editor.chain().focus().insertCallout("info").run();
5343
5598
  }
5344
5599
  },
5345
5600
  callout_warning: {
5346
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("calloutNode", editor),
5601
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("calloutNode", editor),
5347
5602
  action: ({ editor }) => {
5348
5603
  editor.chain().focus().insertCallout("warning").run();
5349
5604
  }
5350
5605
  },
5351
5606
  math: {
5352
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("mathBlock", editor),
5607
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("mathBlock", editor),
5353
5608
  action: ({ editor }) => {
5354
5609
  editor.chain().focus().insertMathBlock().run();
5355
5610
  }
5356
5611
  },
5357
5612
  // Upload
5358
5613
  image: {
5359
- check: (editor) => (0, import_editor_utils6.isNodeInSchema)("imageUpload", editor),
5614
+ check: (editor) => (0, import_editor_utils10.isNodeInSchema)("imageUpload", editor),
5360
5615
  action: ({ editor }) => {
5361
5616
  editor.chain().focus().setImageUpload().run();
5362
5617
  }
@@ -5445,7 +5700,7 @@ var Item = (props) => {
5445
5700
  '[data-selector="tiptap-slash-dropdown-menu"]'
5446
5701
  );
5447
5702
  if (!itemRef.current || !isSelected || !selector) return;
5448
- const overflow = (0, import_editor_utils7.getElementOverflowPosition)(itemRef.current, selector);
5703
+ const overflow = (0, import_editor_utils11.getElementOverflowPosition)(itemRef.current, selector);
5449
5704
  if (overflow === "top") {
5450
5705
  itemRef.current.scrollIntoView(true);
5451
5706
  } else if (overflow === "bottom") {
@@ -5563,11 +5818,12 @@ var List = ({
5563
5818
  };
5564
5819
 
5565
5820
  // src/presets/basic/editor-header.tsx
5821
+ var import_editor_utils28 = require("@kopexa/editor-utils");
5566
5822
  var import_icons25 = require("@kopexa/icons");
5567
5823
  var import_popover3 = require("@kopexa/popover");
5568
5824
  var import_toolbar10 = require("@kopexa/toolbar");
5569
5825
  var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
5570
- var import_react58 = require("react");
5826
+ var import_react56 = require("react");
5571
5827
 
5572
5828
  // src/hooks/use-cursor-visibility.ts
5573
5829
  var React13 = __toESM(require("react"));
@@ -5672,11 +5928,12 @@ function useCursorVisibility({
5672
5928
  }
5673
5929
 
5674
5930
  // src/ui/blockquote-button/blockquote-button.tsx
5931
+ var import_editor_utils13 = require("@kopexa/editor-utils");
5675
5932
  var import_toolbar4 = require("@kopexa/toolbar");
5676
5933
  var React15 = __toESM(require("react"));
5677
5934
 
5678
5935
  // src/ui/blockquote-button/use-blockquote.ts
5679
- var import_editor_utils8 = require("@kopexa/editor-utils");
5936
+ var import_editor_utils12 = require("@kopexa/editor-utils");
5680
5937
  var import_icons14 = require("@kopexa/icons");
5681
5938
  var import_state7 = require("@tiptap/pm/state");
5682
5939
  var React14 = __toESM(require("react"));
@@ -5684,7 +5941,7 @@ var BLOCKQUOTE_SHORTCUT_KEY = "mod+shift+b";
5684
5941
  function canToggleBlockquote(editor, turnInto = true) {
5685
5942
  var _a;
5686
5943
  if (!editor || !editor.isEditable) return false;
5687
- if (!(0, import_editor_utils8.isNodeInSchema)("blockquote", editor) || (0, import_editor_utils8.isNodeTypeSelected)(editor, ["image"]))
5944
+ if (!(0, import_editor_utils12.isNodeInSchema)("blockquote", editor) || (0, import_editor_utils12.isNodeTypeSelected)(editor, ["image"]))
5688
5945
  return false;
5689
5946
  if (!turnInto) {
5690
5947
  return editor.can().toggleWrap("blockquote");
@@ -5694,11 +5951,11 @@ function canToggleBlockquote(editor, turnInto = true) {
5694
5951
  const state = view.state;
5695
5952
  const selection = state.selection;
5696
5953
  if (selection.empty || selection instanceof import_state7.TextSelection) {
5697
- const pos = (_a = (0, import_editor_utils8.findNodePosition)({
5954
+ const pos = (_a = (0, import_editor_utils12.findNodePosition)({
5698
5955
  editor,
5699
5956
  node: state.selection.$anchor.node(1)
5700
5957
  })) == null ? void 0 : _a.pos;
5701
- if (!(0, import_editor_utils8.isValidPosition)(pos)) return false;
5958
+ if (!(0, import_editor_utils12.isValidPosition)(pos)) return false;
5702
5959
  }
5703
5960
  return true;
5704
5961
  } catch {
@@ -5714,11 +5971,11 @@ function toggleBlockquote(editor) {
5714
5971
  let state = view.state;
5715
5972
  let tr = state.tr;
5716
5973
  if (state.selection.empty || state.selection instanceof import_state7.TextSelection) {
5717
- const pos = (_a = (0, import_editor_utils8.findNodePosition)({
5974
+ const pos = (_a = (0, import_editor_utils12.findNodePosition)({
5718
5975
  editor,
5719
5976
  node: state.selection.$anchor.node(1)
5720
5977
  })) == null ? void 0 : _a.pos;
5721
- if (!(0, import_editor_utils8.isValidPosition)(pos)) return false;
5978
+ if (!(0, import_editor_utils12.isValidPosition)(pos)) return false;
5722
5979
  tr = tr.setSelection(import_state7.NodeSelection.create(state.doc, pos));
5723
5980
  view.dispatch(tr);
5724
5981
  state = view.state;
@@ -5743,7 +6000,7 @@ function toggleBlockquote(editor) {
5743
6000
  function shouldShowButton2(props) {
5744
6001
  const { editor, hideWhenUnavailable } = props;
5745
6002
  if (!editor || !editor.isEditable) return false;
5746
- if (!(0, import_editor_utils8.isNodeInSchema)("blockquote", editor)) return false;
6003
+ if (!(0, import_editor_utils12.isNodeInSchema)("blockquote", editor)) return false;
5747
6004
  if (hideWhenUnavailable && !editor.isActive("code")) {
5748
6005
  return canToggleBlockquote(editor);
5749
6006
  }
@@ -5755,7 +6012,7 @@ function useBlockquote(config) {
5755
6012
  hideWhenUnavailable = false,
5756
6013
  onToggled
5757
6014
  } = config || {};
5758
- const { editor } = useTiptapEditor(providedEditor);
6015
+ const { editor } = (0, import_editor_utils12.useTiptapEditor)(providedEditor);
5759
6016
  const [isVisible, setIsVisible] = React14.useState(true);
5760
6017
  const canToggle3 = canToggleBlockquote(editor);
5761
6018
  const isActive = (editor == null ? void 0 : editor.isActive("blockquote")) || false;
@@ -5801,7 +6058,7 @@ var BlockquoteButton = ({
5801
6058
  children,
5802
6059
  ...buttonProps
5803
6060
  }) => {
5804
- const { editor } = useTiptapEditor(providedEditor);
6061
+ const { editor } = (0, import_editor_utils13.useTiptapEditor)(providedEditor);
5805
6062
  const {
5806
6063
  isVisible,
5807
6064
  canToggle: canToggle3,
@@ -5852,12 +6109,13 @@ var BlockquoteButton = ({
5852
6109
  };
5853
6110
 
5854
6111
  // src/ui/codeblock-button/code-block-button.tsx
6112
+ var import_editor_utils15 = require("@kopexa/editor-utils");
5855
6113
  var import_icons16 = require("@kopexa/icons");
5856
6114
  var import_toolbar5 = require("@kopexa/toolbar");
5857
- var import_react44 = require("react");
6115
+ var import_react42 = require("react");
5858
6116
 
5859
6117
  // src/ui/codeblock-button/use-code-block.ts
5860
- var import_editor_utils9 = require("@kopexa/editor-utils");
6118
+ var import_editor_utils14 = require("@kopexa/editor-utils");
5861
6119
  var import_icons15 = require("@kopexa/icons");
5862
6120
  var import_state8 = require("@tiptap/pm/state");
5863
6121
  var React16 = __toESM(require("react"));
@@ -5865,7 +6123,7 @@ var CODE_BLOCK_SHORTCUT_KEY = "mod+alt+c";
5865
6123
  function canToggle2(editor, turnInto = true) {
5866
6124
  var _a;
5867
6125
  if (!editor || !editor.isEditable) return false;
5868
- if (!(0, import_editor_utils9.isNodeInSchema)("codeBlock", editor) || (0, import_editor_utils9.isNodeTypeSelected)(editor, ["image"]))
6126
+ if (!(0, import_editor_utils14.isNodeInSchema)("codeBlock", editor) || (0, import_editor_utils14.isNodeTypeSelected)(editor, ["image"]))
5869
6127
  return false;
5870
6128
  if (!turnInto) {
5871
6129
  return editor.can().toggleNode("codeBlock", "paragraph");
@@ -5875,11 +6133,11 @@ function canToggle2(editor, turnInto = true) {
5875
6133
  const state = view.state;
5876
6134
  const selection = state.selection;
5877
6135
  if (selection.empty || selection instanceof import_state8.TextSelection) {
5878
- const pos = (_a = (0, import_editor_utils9.findNodePosition)({
6136
+ const pos = (_a = (0, import_editor_utils14.findNodePosition)({
5879
6137
  editor,
5880
6138
  node: state.selection.$anchor.node(1)
5881
6139
  })) == null ? void 0 : _a.pos;
5882
- if (!(0, import_editor_utils9.isValidPosition)(pos)) return false;
6140
+ if (!(0, import_editor_utils14.isValidPosition)(pos)) return false;
5883
6141
  }
5884
6142
  return true;
5885
6143
  } catch {
@@ -5895,11 +6153,11 @@ function toggleCodeBlock(editor) {
5895
6153
  let state = view.state;
5896
6154
  let tr = state.tr;
5897
6155
  if (state.selection.empty || state.selection instanceof import_state8.TextSelection) {
5898
- const pos = (_a = (0, import_editor_utils9.findNodePosition)({
6156
+ const pos = (_a = (0, import_editor_utils14.findNodePosition)({
5899
6157
  editor,
5900
6158
  node: state.selection.$anchor.node(1)
5901
6159
  })) == null ? void 0 : _a.pos;
5902
- if (!(0, import_editor_utils9.isValidPosition)(pos)) return false;
6160
+ if (!(0, import_editor_utils14.isValidPosition)(pos)) return false;
5903
6161
  tr = tr.setSelection(import_state8.NodeSelection.create(state.doc, pos));
5904
6162
  view.dispatch(tr);
5905
6163
  state = view.state;
@@ -5924,7 +6182,7 @@ function toggleCodeBlock(editor) {
5924
6182
  function shouldShowButton3(props) {
5925
6183
  const { editor, hideWhenUnavailable } = props;
5926
6184
  if (!editor || !editor.isEditable) return false;
5927
- if (!(0, import_editor_utils9.isNodeInSchema)("codeBlock", editor)) return false;
6185
+ if (!(0, import_editor_utils14.isNodeInSchema)("codeBlock", editor)) return false;
5928
6186
  if (hideWhenUnavailable && !editor.isActive("code")) {
5929
6187
  return canToggle2(editor);
5930
6188
  }
@@ -5936,7 +6194,7 @@ function useCodeBlock(config) {
5936
6194
  hideWhenUnavailable = false,
5937
6195
  onToggled
5938
6196
  } = config || {};
5939
- const { editor } = useTiptapEditor(providedEditor);
6197
+ const { editor } = (0, import_editor_utils14.useTiptapEditor)(providedEditor);
5940
6198
  const [isVisible, setIsVisible] = React16.useState(true);
5941
6199
  const canToggleState = canToggle2(editor);
5942
6200
  const isActive = (editor == null ? void 0 : editor.isActive("codeBlock")) || false;
@@ -5982,13 +6240,13 @@ var CodeBlockButton = ({
5982
6240
  children,
5983
6241
  ...buttonProps
5984
6242
  }) => {
5985
- const { editor } = useTiptapEditor(providedEditor);
6243
+ const { editor } = (0, import_editor_utils15.useTiptapEditor)(providedEditor);
5986
6244
  const { isVisible, canToggle: canToggle3, isActive, handleToggle, label, shortcutKeys } = useCodeBlock({
5987
6245
  editor,
5988
6246
  hideWhenUnavailable,
5989
6247
  onToggled
5990
6248
  });
5991
- const handleClick = (0, import_react44.useCallback)(
6249
+ const handleClick = (0, import_react42.useCallback)(
5992
6250
  (event) => {
5993
6251
  onClick == null ? void 0 : onClick(event);
5994
6252
  if (event.defaultPrevented) return;
@@ -6023,18 +6281,20 @@ var CodeBlockButton = ({
6023
6281
 
6024
6282
  // src/ui/color-highlight-popover/color-highlight-popover.tsx
6025
6283
  var import_button11 = require("@kopexa/button");
6284
+ var import_editor_utils18 = require("@kopexa/editor-utils");
6026
6285
  var import_icons18 = require("@kopexa/icons");
6027
6286
  var import_popover2 = require("@kopexa/popover");
6028
6287
  var import_toolbar7 = require("@kopexa/toolbar");
6029
- var import_react46 = require("react");
6288
+ var import_react44 = require("react");
6030
6289
 
6031
6290
  // src/ui/color-highlight-button/color-highlight-button.tsx
6291
+ var import_editor_utils17 = require("@kopexa/editor-utils");
6032
6292
  var import_theme8 = require("@kopexa/theme");
6033
6293
  var import_toolbar6 = require("@kopexa/toolbar");
6034
- var import_react45 = require("react");
6294
+ var import_react43 = require("react");
6035
6295
 
6036
6296
  // src/ui/color-highlight-button/use-color-highlight.ts
6037
- var import_editor_utils10 = require("@kopexa/editor-utils");
6297
+ var import_editor_utils16 = require("@kopexa/editor-utils");
6038
6298
  var import_icons17 = require("@kopexa/icons");
6039
6299
  var import_use_is_mobile = require("@kopexa/use-is-mobile");
6040
6300
  var React17 = __toESM(require("react"));
@@ -6100,7 +6360,7 @@ function pickHighlightColorsByValue(values) {
6100
6360
  }
6101
6361
  function canColorHighlight(editor) {
6102
6362
  if (!editor || !editor.isEditable) return false;
6103
- if (!(0, import_editor_utils10.isMarkInSchema)("highlight", editor) || (0, import_editor_utils10.isNodeTypeSelected)(editor, ["image"]))
6363
+ if (!(0, import_editor_utils16.isMarkInSchema)("highlight", editor) || (0, import_editor_utils16.isNodeTypeSelected)(editor, ["image"]))
6104
6364
  return false;
6105
6365
  return editor.can().setMark("highlight");
6106
6366
  }
@@ -6116,7 +6376,7 @@ function removeHighlight(editor) {
6116
6376
  function shouldShowButton4(props) {
6117
6377
  const { editor, hideWhenUnavailable } = props;
6118
6378
  if (!editor || !editor.isEditable) return false;
6119
- if (!(0, import_editor_utils10.isMarkInSchema)("highlight", editor)) return false;
6379
+ if (!(0, import_editor_utils16.isMarkInSchema)("highlight", editor)) return false;
6120
6380
  if (hideWhenUnavailable && !editor.isActive("code")) {
6121
6381
  return canColorHighlight(editor);
6122
6382
  }
@@ -6130,7 +6390,7 @@ function useColorHighlight(config) {
6130
6390
  hideWhenUnavailable = false,
6131
6391
  onApplied
6132
6392
  } = config;
6133
- const { editor } = useTiptapEditor(providedEditor);
6393
+ const { editor } = (0, import_editor_utils16.useTiptapEditor)(providedEditor);
6134
6394
  const isMobile = (0, import_use_is_mobile.useIsMobile)();
6135
6395
  const [isVisible, setIsVisible] = React17.useState(true);
6136
6396
  const canColorHighlightState = canColorHighlight(editor);
@@ -6211,7 +6471,7 @@ var ColorHighlightButton = ({
6211
6471
  className,
6212
6472
  ...buttonProps
6213
6473
  }) => {
6214
- const { editor } = useTiptapEditor(providedEditor);
6474
+ const { editor } = (0, import_editor_utils17.useTiptapEditor)(providedEditor);
6215
6475
  const {
6216
6476
  isVisible,
6217
6477
  canColorHighlight: canColorHighlight2,
@@ -6226,7 +6486,7 @@ var ColorHighlightButton = ({
6226
6486
  hideWhenUnavailable,
6227
6487
  onApplied
6228
6488
  });
6229
- const handleClick = (0, import_react45.useCallback)(
6489
+ const handleClick = (0, import_react43.useCallback)(
6230
6490
  (event) => {
6231
6491
  onClick == null ? void 0 : onClick(event);
6232
6492
  if (event.defaultPrevented) return;
@@ -6234,7 +6494,7 @@ var ColorHighlightButton = ({
6234
6494
  },
6235
6495
  [handleColorHighlight, onClick]
6236
6496
  );
6237
- const buttonStyle = (0, import_react45.useMemo)(
6497
+ const buttonStyle = (0, import_react43.useMemo)(
6238
6498
  () => ({
6239
6499
  ...style,
6240
6500
  "--highlight-color": highlightColor
@@ -6317,8 +6577,8 @@ function ColorHighlightPopoverContent({
6317
6577
  ])
6318
6578
  }) {
6319
6579
  const { handleRemoveHighlight } = useColorHighlight({ editor });
6320
- const containerRef = (0, import_react46.useRef)(null);
6321
- const menuItems = (0, import_react46.useMemo)(
6580
+ const containerRef = (0, import_react44.useRef)(null);
6581
+ const menuItems = (0, import_react44.useMemo)(
6322
6582
  () => [...colors, { label: "Remove highlight", value: "none" }],
6323
6583
  [colors]
6324
6584
  );
@@ -6385,8 +6645,8 @@ function ColorHighlightPopover({
6385
6645
  onApplied,
6386
6646
  ...props
6387
6647
  }) {
6388
- const { editor } = useTiptapEditor(providedEditor);
6389
- const [isOpen, setIsOpen] = (0, import_react46.useState)(false);
6648
+ const { editor } = (0, import_editor_utils18.useTiptapEditor)(providedEditor);
6649
+ const [isOpen, setIsOpen] = (0, import_react44.useState)(false);
6390
6650
  const { isVisible, canColorHighlight: canColorHighlight2, isActive, label } = useColorHighlight({
6391
6651
  editor,
6392
6652
  hideWhenUnavailable,
@@ -6418,19 +6678,19 @@ function ColorHighlightPopover({
6418
6678
  // src/ui/heading-dropdown-menu/index.tsx
6419
6679
  var import_button13 = require("@kopexa/button");
6420
6680
  var import_dropdown_menu = require("@kopexa/dropdown-menu");
6421
- var import_editor_utils12 = require("@kopexa/editor-utils");
6681
+ var import_editor_utils20 = require("@kopexa/editor-utils");
6422
6682
  var import_icons20 = require("@kopexa/icons");
6423
- var import_react48 = require("@tiptap/react");
6683
+ var import_react46 = require("@tiptap/react");
6424
6684
  var React19 = __toESM(require("react"));
6425
6685
 
6426
6686
  // src/ui/heading-button/index.tsx
6427
6687
  var import_button12 = require("@kopexa/button");
6428
- var import_editor_utils11 = require("@kopexa/editor-utils");
6688
+ var import_editor_utils19 = require("@kopexa/editor-utils");
6429
6689
  var import_icons19 = require("@kopexa/icons");
6430
6690
  var React18 = __toESM(require("react"));
6431
6691
 
6432
6692
  // src/ui/heading-button/utils.ts
6433
- var import_react47 = require("@tiptap/react");
6693
+ var import_react45 = require("@tiptap/react");
6434
6694
  var headingShortcutKeys = {
6435
6695
  1: "Ctrl-Alt-1",
6436
6696
  2: "Ctrl-Alt-2",
@@ -6471,7 +6731,7 @@ function shouldShowHeadingButton(params) {
6471
6731
  return false;
6472
6732
  }
6473
6733
  if (hideWhenUnavailable) {
6474
- if ((0, import_react47.isNodeSelection)(editor.state.selection)) {
6734
+ if ((0, import_react45.isNodeSelection)(editor.state.selection)) {
6475
6735
  return false;
6476
6736
  }
6477
6737
  }
@@ -6492,7 +6752,7 @@ var headingIcons = {
6492
6752
  6: import_icons19.HeadingSixIcon
6493
6753
  };
6494
6754
  function useHeadingState(editor, level, disabled = false) {
6495
- const headingInSchema = (0, import_editor_utils11.isNodeInSchema)("heading", editor);
6755
+ const headingInSchema = (0, import_editor_utils19.isNodeInSchema)("heading", editor);
6496
6756
  const isDisabled = isHeadingButtonDisabled(editor, level, disabled);
6497
6757
  const isActive = isHeadingActive(editor, level);
6498
6758
  const Icon = headingIcons[level];
@@ -6519,7 +6779,7 @@ var HeadingButton = ({
6519
6779
  ref,
6520
6780
  ...buttonProps
6521
6781
  }) => {
6522
- const { editor } = useTiptapEditor(providedEditor);
6782
+ const { editor } = (0, import_editor_utils19.useTiptapEditor)(providedEditor);
6523
6783
  const {
6524
6784
  headingInSchema,
6525
6785
  isDisabled,
@@ -6583,8 +6843,8 @@ function HeadingDropdownMenu({
6583
6843
  }) {
6584
6844
  var _a;
6585
6845
  const [isOpen, setIsOpen] = React19.useState(false);
6586
- const { editor } = useTiptapEditor(providedEditor);
6587
- const headingInSchema = (0, import_editor_utils12.isNodeInSchema)("heading", editor);
6846
+ const { editor } = (0, import_editor_utils20.useTiptapEditor)(providedEditor);
6847
+ const headingInSchema = (0, import_editor_utils20.isNodeInSchema)("heading", editor);
6588
6848
  const handleOnOpenChange = React19.useCallback(
6589
6849
  (open) => {
6590
6850
  setIsOpen(open);
@@ -6614,7 +6874,7 @@ function HeadingDropdownMenu({
6614
6874
  return false;
6615
6875
  }
6616
6876
  if (hideWhenUnavailable) {
6617
- if ((0, import_react48.isNodeSelection)(editor.state.selection) || !canToggleAnyHeading()) {
6877
+ if ((0, import_react46.isNodeSelection)(editor.state.selection) || !canToggleAnyHeading()) {
6618
6878
  return false;
6619
6879
  }
6620
6880
  }
@@ -6659,17 +6919,17 @@ function HeadingDropdownMenu({
6659
6919
  // src/ui/list-dropdown-menu/index.tsx
6660
6920
  var import_button15 = require("@kopexa/button");
6661
6921
  var import_dropdown_menu2 = require("@kopexa/dropdown-menu");
6662
- var import_editor_utils14 = require("@kopexa/editor-utils");
6922
+ var import_editor_utils22 = require("@kopexa/editor-utils");
6663
6923
  var import_icons22 = require("@kopexa/icons");
6664
- var import_react51 = require("@tiptap/react");
6665
- var import_react52 = require("react");
6924
+ var import_react49 = require("@tiptap/react");
6925
+ var import_react50 = require("react");
6666
6926
 
6667
6927
  // src/ui/list-button/index.tsx
6668
6928
  var import_button14 = require("@kopexa/button");
6669
- var import_editor_utils13 = require("@kopexa/editor-utils");
6929
+ var import_editor_utils21 = require("@kopexa/editor-utils");
6670
6930
  var import_icons21 = require("@kopexa/icons");
6671
- var import_react49 = require("@tiptap/react");
6672
- var import_react50 = require("react");
6931
+ var import_react47 = require("@tiptap/react");
6932
+ var import_react48 = require("react");
6673
6933
  var import_jsx_runtime27 = require("react/jsx-runtime");
6674
6934
  var listOptions = [
6675
6935
  {
@@ -6744,14 +7004,14 @@ function shouldShowListButton(params) {
6744
7004
  return false;
6745
7005
  }
6746
7006
  if (hideWhenUnavailable) {
6747
- if ((0, import_react49.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
7007
+ if ((0, import_react47.isNodeSelection)(editor.state.selection) || !canToggleList(editor, type)) {
6748
7008
  return false;
6749
7009
  }
6750
7010
  }
6751
7011
  return true;
6752
7012
  }
6753
7013
  function useListState(editor, type) {
6754
- const listInSchema = (0, import_editor_utils13.isNodeInSchema)(type, editor);
7014
+ const listInSchema = (0, import_editor_utils21.isNodeInSchema)(type, editor);
6755
7015
  const listOption = getListOption(type);
6756
7016
  const isActive = isListActive(editor, type);
6757
7017
  const shortcutKey = listShortcutKeys[type];
@@ -6773,13 +7033,13 @@ var ListButton = ({
6773
7033
  ref,
6774
7034
  ...buttonProps
6775
7035
  }) => {
6776
- const { editor } = useTiptapEditor(providedEditor);
7036
+ const { editor } = (0, import_editor_utils21.useTiptapEditor)(providedEditor);
6777
7037
  const { listInSchema, listOption, isActive, shortcutKey } = useListState(
6778
7038
  editor,
6779
7039
  type
6780
7040
  );
6781
7041
  const Icon = (listOption == null ? void 0 : listOption.icon) || import_icons21.ListIcon;
6782
- const handleClick = (0, import_react50.useCallback)(
7042
+ const handleClick = (0, import_react48.useCallback)(
6783
7043
  (e) => {
6784
7044
  onClick == null ? void 0 : onClick(e);
6785
7045
  if (!e.defaultPrevented && editor) {
@@ -6788,7 +7048,7 @@ var ListButton = ({
6788
7048
  },
6789
7049
  [onClick, editor, type]
6790
7050
  );
6791
- const show = (0, import_react50.useMemo)(() => {
7051
+ const show = (0, import_react48.useMemo)(() => {
6792
7052
  return shouldShowListButton({
6793
7053
  editor,
6794
7054
  type,
@@ -6842,24 +7102,24 @@ function shouldShowListDropdown(params) {
6842
7102
  return false;
6843
7103
  }
6844
7104
  if (hideWhenUnavailable) {
6845
- if ((0, import_react51.isNodeSelection)(editor.state.selection) || !canToggleAny) {
7105
+ if ((0, import_react49.isNodeSelection)(editor.state.selection) || !canToggleAny) {
6846
7106
  return false;
6847
7107
  }
6848
7108
  }
6849
7109
  return true;
6850
7110
  }
6851
7111
  function useListDropdownState(editor, availableTypes) {
6852
- const [isOpen, setIsOpen] = (0, import_react52.useState)(false);
7112
+ const [isOpen, setIsOpen] = (0, import_react50.useState)(false);
6853
7113
  const listInSchema = availableTypes.some(
6854
- (type) => (0, import_editor_utils14.isNodeInSchema)(type, editor)
7114
+ (type) => (0, import_editor_utils22.isNodeInSchema)(type, editor)
6855
7115
  );
6856
- const filteredLists = (0, import_react52.useMemo)(
7116
+ const filteredLists = (0, import_react50.useMemo)(
6857
7117
  () => getFilteredListOptions(availableTypes),
6858
7118
  [availableTypes]
6859
7119
  );
6860
7120
  const canToggleAny = canToggleAnyList(editor, availableTypes);
6861
7121
  const isAnyActive = isAnyListActive(editor, availableTypes);
6862
- const handleOpenChange = (0, import_react52.useCallback)(
7122
+ const handleOpenChange = (0, import_react50.useCallback)(
6863
7123
  (open, callback) => {
6864
7124
  setIsOpen(open);
6865
7125
  callback == null ? void 0 : callback(open);
@@ -6877,7 +7137,7 @@ function useListDropdownState(editor, availableTypes) {
6877
7137
  };
6878
7138
  }
6879
7139
  function useActiveListIcon(editor, filteredLists) {
6880
- return (0, import_react52.useCallback)(() => {
7140
+ return (0, import_react50.useCallback)(() => {
6881
7141
  const activeOption = filteredLists.find(
6882
7142
  (option) => isListActive(editor, option.type)
6883
7143
  );
@@ -6891,7 +7151,7 @@ function ListDropdownMenu({
6891
7151
  onOpenChange,
6892
7152
  ...props
6893
7153
  }) {
6894
- const { editor } = useTiptapEditor(providedEditor);
7154
+ const { editor } = (0, import_editor_utils22.useTiptapEditor)(providedEditor);
6895
7155
  const {
6896
7156
  isOpen,
6897
7157
  listInSchema,
@@ -6901,7 +7161,7 @@ function ListDropdownMenu({
6901
7161
  handleOpenChange
6902
7162
  } = useListDropdownState(editor, types);
6903
7163
  const getActiveIcon = useActiveListIcon(editor, filteredLists);
6904
- const show = (0, import_react52.useMemo)(() => {
7164
+ const show = (0, import_react50.useMemo)(() => {
6905
7165
  return shouldShowListDropdown({
6906
7166
  editor,
6907
7167
  listTypes: types,
@@ -6910,7 +7170,7 @@ function ListDropdownMenu({
6910
7170
  canToggleAny
6911
7171
  });
6912
7172
  }, [editor, types, hideWhenUnavailable, listInSchema, canToggleAny]);
6913
- const handleOnOpenChange = (0, import_react52.useCallback)(
7173
+ const handleOnOpenChange = (0, import_react50.useCallback)(
6914
7174
  (open) => handleOpenChange(open, onOpenChange),
6915
7175
  [handleOpenChange, onOpenChange]
6916
7176
  );
@@ -6949,8 +7209,9 @@ function ListDropdownMenu({
6949
7209
  }
6950
7210
 
6951
7211
  // src/ui/table-button/index.tsx
7212
+ var import_editor_utils23 = require("@kopexa/editor-utils");
6952
7213
  var import_toolbar8 = require("@kopexa/toolbar");
6953
- var import_react53 = require("react");
7214
+ var import_react51 = require("react");
6954
7215
  var import_jsx_runtime29 = require("react/jsx-runtime");
6955
7216
  var TableButton = ({
6956
7217
  editor: providedEditor,
@@ -6961,7 +7222,7 @@ var TableButton = ({
6961
7222
  children,
6962
7223
  ...buttonProps
6963
7224
  }) => {
6964
- const { editor } = useTiptapEditor(providedEditor);
7225
+ const { editor } = (0, import_editor_utils23.useTiptapEditor)(providedEditor);
6965
7226
  const {
6966
7227
  isVisible,
6967
7228
  canToggle: canToggle3,
@@ -6975,7 +7236,7 @@ var TableButton = ({
6975
7236
  hideWhenUnavailable,
6976
7237
  onToggled
6977
7238
  });
6978
- const handleClick = (0, import_react53.useCallback)(
7239
+ const handleClick = (0, import_react51.useCallback)(
6979
7240
  (event) => {
6980
7241
  onClick == null ? void 0 : onClick(event);
6981
7242
  if (event.defaultPrevented) return;
@@ -7012,12 +7273,13 @@ var TableButton = ({
7012
7273
 
7013
7274
  // src/ui/text-align-button/text-align-button.tsx
7014
7275
  var import_button16 = require("@kopexa/button");
7015
- var import_react55 = require("react");
7276
+ var import_editor_utils25 = require("@kopexa/editor-utils");
7277
+ var import_react53 = require("react");
7016
7278
 
7017
7279
  // src/ui/text-align-button/use-text-align.ts
7018
- var import_editor_utils15 = require("@kopexa/editor-utils");
7280
+ var import_editor_utils24 = require("@kopexa/editor-utils");
7019
7281
  var import_icons23 = require("@kopexa/icons");
7020
- var import_react54 = require("react");
7282
+ var import_react52 = require("react");
7021
7283
  var TEXT_ALIGN_SHORTCUT_KEYS = {
7022
7284
  left: "mod+shift+l",
7023
7285
  center: "mod+shift+e",
@@ -7038,7 +7300,7 @@ var textAlignLabels = {
7038
7300
  };
7039
7301
  function canSetTextAlign(editor, align) {
7040
7302
  if (!editor || !editor.isEditable) return false;
7041
- if (!(0, import_editor_utils15.isExtensionAvailable)(editor, "textAlign") || (0, import_editor_utils15.isNodeTypeSelected)(editor, ["image"]))
7303
+ if (!(0, import_editor_utils24.isExtensionAvailable)(editor, "textAlign") || (0, import_editor_utils24.isNodeTypeSelected)(editor, ["image"]))
7042
7304
  return false;
7043
7305
  return editor.can().setTextAlign(align);
7044
7306
  }
@@ -7061,7 +7323,7 @@ function setTextAlign(editor, align) {
7061
7323
  function shouldShowButton5(props) {
7062
7324
  const { editor, hideWhenUnavailable, align } = props;
7063
7325
  if (!editor || !editor.isEditable) return false;
7064
- if (!(0, import_editor_utils15.isExtensionAvailable)(editor, "textAlign")) return false;
7326
+ if (!(0, import_editor_utils24.isExtensionAvailable)(editor, "textAlign")) return false;
7065
7327
  if (hideWhenUnavailable && !editor.isActive("code")) {
7066
7328
  return canSetTextAlign(editor, align);
7067
7329
  }
@@ -7074,11 +7336,11 @@ function useTextAlign(config) {
7074
7336
  hideWhenUnavailable = false,
7075
7337
  onAligned
7076
7338
  } = config;
7077
- const { editor } = useTiptapEditor(providedEditor);
7078
- const [isVisible, setIsVisible] = (0, import_react54.useState)(true);
7339
+ const { editor } = (0, import_editor_utils24.useTiptapEditor)(providedEditor);
7340
+ const [isVisible, setIsVisible] = (0, import_react52.useState)(true);
7079
7341
  const canAlign = canSetTextAlign(editor, align);
7080
7342
  const isActive = isTextAlignActive(editor, align);
7081
- (0, import_react54.useEffect)(() => {
7343
+ (0, import_react52.useEffect)(() => {
7082
7344
  if (!editor) return;
7083
7345
  const handleSelectionUpdate = () => {
7084
7346
  setIsVisible(shouldShowButton5({ editor, align, hideWhenUnavailable }));
@@ -7089,7 +7351,7 @@ function useTextAlign(config) {
7089
7351
  editor.off("selectionUpdate", handleSelectionUpdate);
7090
7352
  };
7091
7353
  }, [editor, hideWhenUnavailable, align]);
7092
- const handleTextAlign = (0, import_react54.useCallback)(() => {
7354
+ const handleTextAlign = (0, import_react52.useCallback)(() => {
7093
7355
  if (!editor) return false;
7094
7356
  const success = setTextAlign(editor, align);
7095
7357
  if (success) {
@@ -7121,7 +7383,7 @@ var TextAlignButton = ({
7121
7383
  children,
7122
7384
  ...buttonProps
7123
7385
  }) => {
7124
- const { editor } = useTiptapEditor(providedEditor);
7386
+ const { editor } = (0, import_editor_utils25.useTiptapEditor)(providedEditor);
7125
7387
  const {
7126
7388
  isVisible,
7127
7389
  handleTextAlign,
@@ -7136,7 +7398,7 @@ var TextAlignButton = ({
7136
7398
  hideWhenUnavailable,
7137
7399
  onAligned
7138
7400
  });
7139
- const handleClick = (0, import_react55.useCallback)(
7401
+ const handleClick = (0, import_react53.useCallback)(
7140
7402
  (e) => {
7141
7403
  onClick == null ? void 0 : onClick(e);
7142
7404
  if (e.defaultPrevented) return;
@@ -7169,13 +7431,14 @@ var TextAlignButton = ({
7169
7431
  };
7170
7432
 
7171
7433
  // src/ui/undo-redo-button/undo-redo-button.tsx
7434
+ var import_editor_utils27 = require("@kopexa/editor-utils");
7172
7435
  var import_toolbar9 = require("@kopexa/toolbar");
7173
- var import_react57 = require("react");
7436
+ var import_react55 = require("react");
7174
7437
 
7175
7438
  // src/ui/undo-redo-button/use-undo-redo.ts
7176
- var import_editor_utils16 = require("@kopexa/editor-utils");
7439
+ var import_editor_utils26 = require("@kopexa/editor-utils");
7177
7440
  var import_icons24 = require("@kopexa/icons");
7178
- var import_react56 = require("react");
7441
+ var import_react54 = require("react");
7179
7442
  var UNDO_REDO_SHORTCUT_KEYS = {
7180
7443
  undo: "mod+z",
7181
7444
  redo: "mod+shift+z"
@@ -7190,7 +7453,7 @@ var historyIcons = {
7190
7453
  };
7191
7454
  function canExecuteUndoRedoAction(editor, action) {
7192
7455
  if (!editor || !editor.isEditable) return false;
7193
- if ((0, import_editor_utils16.isNodeTypeSelected)(editor, ["image"])) return false;
7456
+ if ((0, import_editor_utils26.isNodeTypeSelected)(editor, ["image"])) return false;
7194
7457
  return action === "undo" ? editor.can().undo() : editor.can().redo();
7195
7458
  }
7196
7459
  function executeUndoRedoAction(editor, action) {
@@ -7214,10 +7477,10 @@ function useUndoRedo(config) {
7214
7477
  hideWhenUnavailable = false,
7215
7478
  onExecuted
7216
7479
  } = config;
7217
- const { editor } = useTiptapEditor(providedEditor);
7218
- const [isVisible, setIsVisible] = (0, import_react56.useState)(true);
7480
+ const { editor } = (0, import_editor_utils26.useTiptapEditor)(providedEditor);
7481
+ const [isVisible, setIsVisible] = (0, import_react54.useState)(true);
7219
7482
  const canExecute = canExecuteUndoRedoAction(editor, action);
7220
- (0, import_react56.useEffect)(() => {
7483
+ (0, import_react54.useEffect)(() => {
7221
7484
  if (!editor) return;
7222
7485
  const handleUpdate = () => {
7223
7486
  setIsVisible(shouldShowButton6({ editor, hideWhenUnavailable, action }));
@@ -7228,7 +7491,7 @@ function useUndoRedo(config) {
7228
7491
  editor.off("transaction", handleUpdate);
7229
7492
  };
7230
7493
  }, [editor, hideWhenUnavailable, action]);
7231
- const handleAction = (0, import_react56.useCallback)(() => {
7494
+ const handleAction = (0, import_react54.useCallback)(() => {
7232
7495
  if (!editor) return false;
7233
7496
  const success = executeUndoRedoAction(editor, action);
7234
7497
  if (success) {
@@ -7259,14 +7522,14 @@ var UndoRedoButton = ({
7259
7522
  children,
7260
7523
  ...buttonProps
7261
7524
  }) => {
7262
- const { editor } = useTiptapEditor(providedEditor);
7525
+ const { editor } = (0, import_editor_utils27.useTiptapEditor)(providedEditor);
7263
7526
  const { isVisible, handleAction, label, canExecute, Icon, shortcutKeys } = useUndoRedo({
7264
7527
  editor,
7265
7528
  action,
7266
7529
  hideWhenUnavailable,
7267
7530
  onExecuted
7268
7531
  });
7269
- const handleClick = (0, import_react57.useCallback)(
7532
+ const handleClick = (0, import_react55.useCallback)(
7270
7533
  (event) => {
7271
7534
  onClick == null ? void 0 : onClick(event);
7272
7535
  if (event.defaultPrevented) return;
@@ -7304,11 +7567,11 @@ var EditorHeader = ({
7304
7567
  variant
7305
7568
  }) => {
7306
7569
  var _a, _b;
7307
- const { editor } = useTiptapEditor(providedEditor);
7570
+ const { editor } = (0, import_editor_utils28.useTiptapEditor)(providedEditor);
7308
7571
  const isMobile = (0, import_use_is_mobile2.useIsMobile)();
7309
7572
  const windowSize = useWindowSize();
7310
7573
  const { styles } = useEditorUIContext();
7311
- const toolbarRef = (0, import_react58.useRef)(null);
7574
+ const toolbarRef = (0, import_react56.useRef)(null);
7312
7575
  const bodyRect = useCursorVisibility({
7313
7576
  editor,
7314
7577
  overlayHeight: (_b = (_a = toolbarRef.current) == null ? void 0 : _a.getBoundingClientRect().height) != null ? _b : 0
@@ -7381,9 +7644,9 @@ function MoreOptions({
7381
7644
  hideWhenUnavailable = false,
7382
7645
  ...props
7383
7646
  }) {
7384
- const { editor } = useTiptapEditor(providedEditor);
7385
- const [show, setShow] = (0, import_react58.useState)(false);
7386
- (0, import_react58.useEffect)(() => {
7647
+ const { editor } = (0, import_editor_utils28.useTiptapEditor)(providedEditor);
7648
+ const [show, setShow] = (0, import_react56.useState)(false);
7649
+ (0, import_react56.useEffect)(() => {
7387
7650
  if (!editor) return;
7388
7651
  const handleSelectionUpdate = () => {
7389
7652
  setShow(
@@ -7492,7 +7755,7 @@ var BasicEditor = ({
7492
7755
  ...options
7493
7756
  });
7494
7757
  const styles = (0, import_theme9.editorBasic)({ variant, bordered });
7495
- const resolveVariable = (0, import_react60.useCallback)(
7758
+ const resolveVariable = (0, import_react58.useCallback)(
7496
7759
  (name) => variableValues == null ? void 0 : variableValues[name],
7497
7760
  [variableValues]
7498
7761
  );
@@ -7502,7 +7765,7 @@ var BasicEditor = ({
7502
7765
  const isBottomToolbar = variant === "field";
7503
7766
  const hasVariables = variables && variables.length > 0;
7504
7767
  const hasPagination = !!pagesOptions;
7505
- const editorContent = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react59.EditorContext.Provider, { value: { editor }, children: [
7768
+ const editorContent = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EditorUIProvider, { value: { styles }, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: styles.root(), "data-slot": "editor", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_react57.EditorContext.Provider, { value: { editor }, children: [
7506
7769
  showToolbar && !isBottomToolbar && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(EditorHeader, { editor, variant }),
7507
7770
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7508
7771
  EditorContentArea,
@@ -7525,10 +7788,10 @@ var EditorContentArea = ({
7525
7788
  hasPagination
7526
7789
  }) => {
7527
7790
  const styles = (0, import_theme9.editorBasic)({ variant });
7528
- const { editor } = (0, import_react60.useContext)(import_react59.EditorContext);
7791
+ const { editor } = (0, import_react58.useContext)(import_react57.EditorContext);
7529
7792
  const { isDragging } = useUiEditorState(editor);
7530
7793
  useScrollToHash();
7531
- const handleKeyDown = (0, import_react60.useCallback)(
7794
+ const handleKeyDown = (0, import_react58.useCallback)(
7532
7795
  (e) => {
7533
7796
  if (!(editor == null ? void 0 : editor.isFocused)) return;
7534
7797
  const isMod = e.metaKey || e.ctrlKey;
@@ -7572,7 +7835,7 @@ var EditorContentArea = ({
7572
7835
  // biome-ignore lint/a11y/noStaticElementInteractions: Wrapper intercepts keyboard shortcuts to prevent propagation
7573
7836
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: styles.wrapper(), onKeyDown: handleKeyDown, children: [
7574
7837
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
7575
- import_react59.EditorContent,
7838
+ import_react57.EditorContent,
7576
7839
  {
7577
7840
  editor,
7578
7841
  role: "presentation",
@@ -7587,7 +7850,23 @@ var EditorContentArea = ({
7587
7850
  }
7588
7851
  ),
7589
7852
  isEditable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(BubbleMenu, { editor }),
7590
- isEditable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(LinkBubble, { editor })
7853
+ isEditable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(LinkBubble, { editor }),
7854
+ isEditable && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
7855
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_extension_table2.TableHandle, { editor }),
7856
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7857
+ import_extension_table2.TableSelectionOverlay,
7858
+ {
7859
+ showResizeHandles: true,
7860
+ cellMenu: (props) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
7861
+ import_extension_table2.TableCellHandleMenu,
7862
+ {
7863
+ editor: props.editor,
7864
+ onOpenChange: props.onOpenChange
7865
+ }
7866
+ )
7867
+ }
7868
+ )
7869
+ ] })
7591
7870
  ] })
7592
7871
  );
7593
7872
  };