@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.
- package/dist/{chunk-AASYBJDX.mjs → chunk-2SI7MRAE.mjs} +1 -1
- package/dist/{chunk-6W7J7PHZ.mjs → chunk-B2DHYFSH.mjs} +6 -7
- package/dist/{chunk-RQPJU4UB.mjs → chunk-B7WJOQ3X.mjs} +1 -1
- package/dist/{chunk-ACWAVTTK.mjs → chunk-BEV5U2DK.mjs} +6 -6
- package/dist/{chunk-TGQP45HH.mjs → chunk-EHY2NAW7.mjs} +1 -3
- package/dist/{chunk-O5P45H3I.mjs → chunk-GYIYX2JH.mjs} +1 -1
- package/dist/{chunk-QCULSZRZ.mjs → chunk-IOB3REX6.mjs} +1 -3
- package/dist/{chunk-ILPDDC4W.mjs → chunk-IQERE7KP.mjs} +1 -4
- package/dist/{chunk-6SS62RYU.mjs → chunk-JNL4KY45.mjs} +1 -3
- package/dist/{chunk-R2RRQUU5.mjs → chunk-LHXRE26G.mjs} +2 -2
- package/dist/{chunk-F2HHFSM4.mjs → chunk-LNVWG34E.mjs} +1 -4
- package/dist/chunk-NUCXXNTA.mjs +131 -0
- package/dist/{chunk-GLQRF7PR.mjs → chunk-OEVR5N7X.mjs} +2 -10
- package/dist/{chunk-YYHNT322.mjs → chunk-OZWCQMRA.mjs} +27 -19
- package/dist/{chunk-OX2A52WL.mjs → chunk-Q7DFJ5NI.mjs} +2 -4
- package/dist/{chunk-ODBSAQ5V.mjs → chunk-QF3YHPWM.mjs} +2 -4
- package/dist/{chunk-R5AMMJTQ.mjs → chunk-REJEJXOZ.mjs} +3 -3
- package/dist/chunk-TZQQ6C2Q.mjs +101 -0
- package/dist/{chunk-KI3YOPAA.mjs → chunk-UJ4BNZ63.mjs} +1 -4
- package/dist/{chunk-4LAWYE7B.mjs → chunk-V6TAZMQN.mjs} +2 -4
- package/dist/{chunk-QP2LCU5N.mjs → chunk-VX3HSJ76.mjs} +2 -2
- package/dist/{chunk-WCBSINO5.mjs → chunk-W2FLOOJ6.mjs} +1 -1
- package/dist/{chunk-JHMEXFB3.mjs → chunk-WHJ4B43N.mjs} +1 -1
- package/dist/{chunk-YD56B5SG.mjs → chunk-WPRDVMPN.mjs} +19 -18
- package/dist/{chunk-44V2Y6IU.mjs → chunk-XL5FS7LN.mjs} +3 -3
- package/dist/{chunk-ZSYXHD7D.mjs → chunk-YJAHZXLG.mjs} +1 -4
- package/dist/{chunk-T7LL5ZSR.mjs → chunk-ZVTJ6XD7.mjs} +1 -3
- package/dist/{chunk-I7WKP3OM.mjs → chunk-ZZ4OU46C.mjs} +6 -6
- package/dist/context/editor-context.d.mts +4 -4
- package/dist/context/editor-context.d.ts +4 -4
- package/dist/context/editor-context.js +5 -5
- package/dist/context/editor-context.mjs +5 -6
- package/dist/extensions/link/index.mjs +0 -1
- package/dist/extensions/selection/index.mjs +0 -1
- package/dist/extensions/trailing-node/index.mjs +0 -1
- package/dist/extensions/ui-state/index.mjs +0 -1
- package/dist/hooks/use-create-editor.d.mts +16 -5
- package/dist/hooks/use-create-editor.d.ts +16 -5
- package/dist/hooks/use-create-editor.js +84 -1062
- package/dist/hooks/use-create-editor.mjs +5 -18
- package/dist/hooks/use-cursor-visibility.mjs +0 -1
- package/dist/hooks/use-floating-element.mjs +0 -1
- package/dist/hooks/use-floating-toolbar-visibility.mjs +0 -1
- package/dist/hooks/use-menu-navigation.mjs +0 -1
- package/dist/hooks/use-tiptap-editor.mjs +0 -1
- package/dist/hooks/use-ui-editor-state.mjs +0 -1
- package/dist/hooks/use-window-size.mjs +0 -1
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +483 -1584
- package/dist/index.mjs +39 -60
- package/dist/presets/basic/editor-header.js +112 -167
- package/dist/presets/basic/editor-header.mjs +25 -25
- package/dist/presets/basic/index.d.mts +6 -3
- package/dist/presets/basic/index.d.ts +6 -3
- package/dist/presets/basic/index.js +386 -1468
- package/dist/presets/basic/index.mjs +32 -46
- package/dist/ui/blockquote-button/blockquote-button.js +12 -67
- package/dist/ui/blockquote-button/blockquote-button.mjs +2 -4
- package/dist/ui/blockquote-button/index.js +12 -67
- package/dist/ui/blockquote-button/index.mjs +2 -4
- package/dist/ui/blockquote-button/use-blockquote.js +12 -65
- package/dist/ui/blockquote-button/use-blockquote.mjs +1 -3
- package/dist/ui/codeblock-button/code-block-button.js +13 -76
- package/dist/ui/codeblock-button/code-block-button.mjs +2 -4
- package/dist/ui/codeblock-button/index.js +13 -76
- package/dist/ui/codeblock-button/index.mjs +2 -4
- package/dist/ui/codeblock-button/use-code-block.js +12 -65
- package/dist/ui/codeblock-button/use-code-block.mjs +1 -3
- package/dist/ui/color-highlight-button/color-highlight-button.js +3 -23
- package/dist/ui/color-highlight-button/color-highlight-button.mjs +2 -4
- package/dist/ui/color-highlight-button/index.js +3 -23
- package/dist/ui/color-highlight-button/index.mjs +2 -4
- package/dist/ui/color-highlight-button/use-color-highlight.js +3 -21
- package/dist/ui/color-highlight-button/use-color-highlight.mjs +1 -3
- package/dist/ui/color-highlight-popover/color-highlight-popover.js +4 -24
- package/dist/ui/color-highlight-popover/color-highlight-popover.mjs +3 -5
- package/dist/ui/color-highlight-popover/index.js +4 -24
- package/dist/ui/color-highlight-popover/index.mjs +3 -5
- package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.js +2 -18
- package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.mjs +1 -3
- package/dist/ui/heading-button/index.js +2 -9
- package/dist/ui/heading-button/index.mjs +1 -3
- package/dist/ui/heading-button/utils.mjs +0 -1
- package/dist/ui/heading-dropdown-menu/index.js +4 -10
- package/dist/ui/heading-dropdown-menu/index.mjs +2 -4
- package/dist/ui/link-popover/index.js +2 -6
- package/dist/ui/link-popover/index.mjs +3 -4
- package/dist/ui/link-popover/link-popover.js +2 -6
- package/dist/ui/link-popover/link-popover.mjs +3 -4
- package/dist/ui/link-popover/use-link-popover.js +2 -6
- package/dist/ui/link-popover/use-link-popover.mjs +2 -3
- package/dist/ui/list-button/index.js +2 -9
- package/dist/ui/list-button/index.mjs +1 -3
- package/dist/ui/list-dropdown-menu/index.js +4 -10
- package/dist/ui/list-dropdown-menu/index.mjs +2 -4
- package/dist/ui/mark-button/index.js +3 -21
- package/dist/ui/mark-button/index.mjs +1 -3
- package/dist/ui/reset-all-formatting-button/index.mjs +0 -1
- package/dist/ui/reset-all-formatting-button/reset-all-formatting-button.mjs +0 -1
- package/dist/ui/reset-all-formatting-button/use-reset-all-formatting.mjs +0 -1
- package/dist/ui/slash-dropdown-menu/index.js +27 -129
- package/dist/ui/slash-dropdown-menu/index.mjs +3 -5
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +27 -129
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +3 -5
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +23 -116
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.mjs +2 -4
- package/dist/ui/suggestion-menu/index.mjs +0 -1
- package/dist/ui/suggestion-menu/suggestion-menu-utils.mjs +0 -1
- package/dist/ui/suggestion-menu/suggestion-menu.mjs +0 -1
- package/dist/ui/table-button/index.js +4 -24
- package/dist/ui/table-button/index.mjs +2 -4
- package/dist/ui/table-button/use-table.js +3 -21
- package/dist/ui/table-button/use-table.mjs +1 -3
- package/dist/ui/text-align-button/index.js +3 -32
- package/dist/ui/text-align-button/index.mjs +2 -4
- package/dist/ui/text-align-button/text-align-button.js +3 -32
- package/dist/ui/text-align-button/text-align-button.mjs +2 -4
- package/dist/ui/text-align-button/use-text-align.js +3 -30
- package/dist/ui/text-align-button/use-text-align.mjs +1 -3
- package/dist/ui/undo-redo-button/index.js +2 -18
- package/dist/ui/undo-redo-button/index.mjs +2 -4
- package/dist/ui/undo-redo-button/undo-redo-button.js +2 -18
- package/dist/ui/undo-redo-button/undo-redo-button.mjs +2 -4
- package/dist/ui/undo-redo-button/use-undo-redo.js +2 -16
- package/dist/ui/undo-redo-button/use-undo-redo.mjs +1 -3
- package/dist/utils/index.d.mts +1 -101
- package/dist/utils/index.d.ts +1 -101
- package/dist/utils/index.js +0 -166
- package/dist/utils/index.mjs +1 -28
- package/dist/utils/safe-parse.mjs +0 -1
- package/package.json +36 -30
- package/dist/chunk-4HTILXJM.mjs +0 -104
- package/dist/chunk-4IIGLBTD.mjs +0 -81
- package/dist/chunk-574UV65T.mjs +0 -111
- package/dist/chunk-7HC7D256.mjs +0 -91
- package/dist/chunk-AC22DSDA.mjs +0 -540
- package/dist/chunk-AGOMESFC.mjs +0 -1
- package/dist/chunk-BXPGSCTT.mjs +0 -39
- package/dist/chunk-C6M3CDOK.mjs +0 -254
- package/dist/chunk-EN3J5AMF.mjs +0 -12
- package/dist/chunk-HYDS6H67.mjs +0 -58
- package/dist/chunk-KRLE4MMD.mjs +0 -116
- package/dist/chunk-LKOQAQPZ.mjs +0 -13
- package/dist/chunk-LXZ53XU7.mjs +0 -1
- package/dist/chunk-T6P7CS4F.mjs +0 -42
- package/dist/chunk-TVFWG7IC.mjs +0 -43
- package/dist/chunk-VULWMVYS.mjs +0 -11
- package/dist/chunk-WKV76XOR.mjs +0 -8
- package/dist/extensions/table/index.d.mts +0 -8
- package/dist/extensions/table/index.d.ts +0 -8
- package/dist/extensions/table/index.js +0 -1044
- package/dist/extensions/table/index.mjs +0 -33
- package/dist/extensions/table/kit.d.mts +0 -30
- package/dist/extensions/table/kit.d.ts +0 -30
- package/dist/extensions/table/kit.js +0 -1034
- package/dist/extensions/table/kit.mjs +0 -20
- package/dist/extensions/table/table/icons.d.mts +0 -13
- package/dist/extensions/table/table/icons.d.ts +0 -13
- package/dist/extensions/table/table/icons.js +0 -81
- package/dist/extensions/table/table/icons.mjs +0 -8
- package/dist/extensions/table/table/index.d.mts +0 -3
- package/dist/extensions/table/table/index.d.ts +0 -3
- package/dist/extensions/table/table/index.js +0 -818
- package/dist/extensions/table/table/index.mjs +0 -16
- package/dist/extensions/table/table/table-controls.d.mts +0 -10
- package/dist/extensions/table/table/table-controls.d.ts +0 -10
- package/dist/extensions/table/table/table-controls.js +0 -129
- package/dist/extensions/table/table/table-controls.mjs +0 -8
- package/dist/extensions/table/table/table-view.d.mts +0 -43
- package/dist/extensions/table/table/table-view.d.ts +0 -43
- package/dist/extensions/table/table/table-view.js +0 -610
- package/dist/extensions/table/table/table-view.mjs +0 -12
- package/dist/extensions/table/table/table.d.mts +0 -17
- package/dist/extensions/table/table/table.d.ts +0 -17
- package/dist/extensions/table/table/table.js +0 -816
- package/dist/extensions/table/table/table.mjs +0 -15
- package/dist/extensions/table/table/utilities/col-style.d.mts +0 -3
- package/dist/extensions/table/table/utilities/col-style.d.ts +0 -3
- package/dist/extensions/table/table/utilities/col-style.js +0 -36
- package/dist/extensions/table/table/utilities/col-style.mjs +0 -8
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.d.mts +0 -5
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.d.ts +0 -5
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.js +0 -66
- package/dist/extensions/table/table/utilities/delete-table-when-all-cells-selected.mjs +0 -40
- package/dist/extensions/table/table/utilities/get-table-node-types.d.mts +0 -7
- package/dist/extensions/table/table/utilities/get-table-node-types.d.ts +0 -7
- package/dist/extensions/table/table/utilities/get-table-node-types.js +0 -44
- package/dist/extensions/table/table/utilities/get-table-node-types.mjs +0 -21
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.d.mts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.d.ts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.js +0 -80
- package/dist/extensions/table/table/utilities/insert-line-above-table-action.mjs +0 -9
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.d.mts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.d.ts +0 -5
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.js +0 -79
- package/dist/extensions/table/table/utilities/insert-line-below-table-action.mjs +0 -9
- package/dist/extensions/table/table/utilities/is-cell-selection.d.mts +0 -5
- package/dist/extensions/table/table/utilities/is-cell-selection.d.ts +0 -5
- package/dist/extensions/table/table/utilities/is-cell-selection.js +0 -34
- package/dist/extensions/table/table/utilities/is-cell-selection.mjs +0 -8
- package/dist/extensions/table/table-cell.d.mts +0 -8
- package/dist/extensions/table/table-cell.d.ts +0 -8
- package/dist/extensions/table/table-cell.js +0 -139
- package/dist/extensions/table/table-cell.mjs +0 -8
- package/dist/extensions/table/table-header.d.mts +0 -6
- package/dist/extensions/table/table-header.d.ts +0 -6
- package/dist/extensions/table/table-header.js +0 -104
- package/dist/extensions/table/table-header.mjs +0 -8
- package/dist/extensions/table/table-row.d.mts +0 -6
- package/dist/extensions/table/table-row.d.ts +0 -6
- package/dist/extensions/table/table-row.js +0 -35
- package/dist/extensions/table/table-row.mjs +0 -8
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
toggleTable
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YJAHZXLG.mjs";
|
|
5
|
+
|
|
6
|
+
// src/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts
|
|
5
7
|
import {
|
|
6
8
|
findSelectionPosition,
|
|
7
9
|
hasContentAbove,
|
|
8
10
|
isExtensionAvailable,
|
|
9
11
|
isNodeInSchema
|
|
10
|
-
} from "
|
|
11
|
-
|
|
12
|
-
// src/ui/slash-dropdown-menu/use-slash-dropdown-menu.ts
|
|
12
|
+
} from "@kopexa/editor-utils";
|
|
13
13
|
import {
|
|
14
14
|
AiSparklesIcon,
|
|
15
15
|
BlockquoteIcon,
|
|
@@ -283,11 +283,10 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
|
|
|
283
283
|
action: ({ editor }) => toggleTable(editor, { rows: 3, cols: 3, withHeaderRow: true })
|
|
284
284
|
},
|
|
285
285
|
control: {
|
|
286
|
-
check: (editor) => isNodeInSchema("
|
|
286
|
+
check: (editor) => isNodeInSchema("controlBlock", editor),
|
|
287
287
|
action: ({ editor }) => {
|
|
288
|
-
console.log("hoho");
|
|
289
288
|
try {
|
|
290
|
-
return editor.chain().focus().
|
|
289
|
+
return editor.chain().focus().insertControlBlock().run();
|
|
291
290
|
} catch (e) {
|
|
292
291
|
console.error(e);
|
|
293
292
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
findNodePosition,
|
|
4
|
-
isNodeInSchema,
|
|
5
|
-
isNodeTypeSelected,
|
|
6
|
-
isValidPosition
|
|
7
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
8
2
|
import {
|
|
9
3
|
useTiptapEditor
|
|
10
4
|
} from "./chunk-P55PLOHR.mjs";
|
|
11
5
|
|
|
12
6
|
// src/ui/codeblock-button/use-code-block.ts
|
|
7
|
+
import {
|
|
8
|
+
findNodePosition,
|
|
9
|
+
isNodeInSchema,
|
|
10
|
+
isNodeTypeSelected,
|
|
11
|
+
isValidPosition
|
|
12
|
+
} from "@kopexa/editor-utils";
|
|
13
13
|
import { CodeblockIcon } from "@kopexa/icons";
|
|
14
14
|
import { NodeSelection, TextSelection } from "@tiptap/pm/state";
|
|
15
15
|
import * as React from "react";
|
|
@@ -7,15 +7,13 @@ import {
|
|
|
7
7
|
shouldShowHeadingButton,
|
|
8
8
|
toggleHeading
|
|
9
9
|
} from "./chunk-33QD5PYJ.mjs";
|
|
10
|
-
import {
|
|
11
|
-
isNodeInSchema
|
|
12
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
13
10
|
import {
|
|
14
11
|
useTiptapEditor
|
|
15
12
|
} from "./chunk-P55PLOHR.mjs";
|
|
16
13
|
|
|
17
14
|
// src/ui/heading-button/index.tsx
|
|
18
15
|
import { Button } from "@kopexa/button";
|
|
16
|
+
import { isNodeInSchema } from "@kopexa/editor-utils";
|
|
19
17
|
import {
|
|
20
18
|
HeadingFiveIcon,
|
|
21
19
|
HeadingFourIcon,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
isNodeInSchema
|
|
4
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
5
2
|
import {
|
|
6
3
|
useTiptapEditor
|
|
7
4
|
} from "./chunk-P55PLOHR.mjs";
|
|
8
5
|
|
|
9
6
|
// src/ui/list-button/index.tsx
|
|
10
7
|
import { Button } from "@kopexa/button";
|
|
8
|
+
import { isNodeInSchema } from "@kopexa/editor-utils";
|
|
11
9
|
import { ListIcon, ListOrderedIcon, ListTodoIcon } from "@kopexa/icons";
|
|
12
10
|
import { isNodeSelection } from "@tiptap/react";
|
|
13
11
|
import { useCallback, useMemo } from "react";
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
isExtensionAvailable,
|
|
4
|
-
isNodeTypeSelected
|
|
5
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
6
2
|
import {
|
|
7
3
|
useTiptapEditor
|
|
8
4
|
} from "./chunk-P55PLOHR.mjs";
|
|
9
5
|
|
|
10
6
|
// src/ui/text-align-button/use-text-align.ts
|
|
7
|
+
import { isExtensionAvailable, isNodeTypeSelected } from "@kopexa/editor-utils";
|
|
11
8
|
import {
|
|
12
9
|
AlignCenterIcon,
|
|
13
10
|
AlignJustifyIcon,
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
getEditorExtension
|
|
4
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
5
2
|
import {
|
|
6
3
|
selectNodeAndHideFloating
|
|
7
4
|
} from "./chunk-TDFS3DCZ.mjs";
|
|
@@ -10,6 +7,7 @@ import {
|
|
|
10
7
|
} from "./chunk-P55PLOHR.mjs";
|
|
11
8
|
|
|
12
9
|
// src/ui/copy-anchor-link-button/use-scroll-to-hash.ts
|
|
10
|
+
import { getEditorExtension } from "@kopexa/editor-utils";
|
|
13
11
|
import * as React from "react";
|
|
14
12
|
function useScrollToHash(config = {}) {
|
|
15
13
|
const {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
isMarkInSchema,
|
|
4
3
|
sanitizeUrl
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TZQQ6C2Q.mjs";
|
|
6
5
|
import {
|
|
7
6
|
useTiptapEditor
|
|
8
7
|
} from "./chunk-P55PLOHR.mjs";
|
|
9
8
|
|
|
10
9
|
// src/ui/link-popover/use-link-popover.ts
|
|
10
|
+
import { isMarkInSchema } from "@kopexa/editor-utils";
|
|
11
11
|
import { LinkIcon } from "@kopexa/icons";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
function canSetLink(editor) {
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
isMarkInSchema,
|
|
4
|
-
isNodeTypeSelected
|
|
5
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
6
2
|
import {
|
|
7
3
|
useTiptapEditor
|
|
8
4
|
} from "./chunk-P55PLOHR.mjs";
|
|
9
5
|
|
|
10
6
|
// src/ui/mark-button/index.tsx
|
|
7
|
+
import { isMarkInSchema, isNodeTypeSelected } from "@kopexa/editor-utils";
|
|
11
8
|
import {
|
|
12
9
|
BoldIcon,
|
|
13
10
|
CodeIcon,
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
safeParseContent
|
|
4
|
+
} from "./chunk-7LHOYNVF.mjs";
|
|
5
|
+
import {
|
|
6
|
+
Link
|
|
7
|
+
} from "./chunk-CUT6PA4X.mjs";
|
|
8
|
+
import {
|
|
9
|
+
Selection
|
|
10
|
+
} from "./chunk-U5XAL46P.mjs";
|
|
11
|
+
import {
|
|
12
|
+
TrailingNode
|
|
13
|
+
} from "./chunk-H6LC4LDQ.mjs";
|
|
14
|
+
import {
|
|
15
|
+
UiState
|
|
16
|
+
} from "./chunk-KR42JAVB.mjs";
|
|
17
|
+
|
|
18
|
+
// src/hooks/use-create-editor.ts
|
|
19
|
+
import { CodeKit } from "@kopexa/extension-code";
|
|
20
|
+
import { ControlKit } from "@kopexa/extension-controlref";
|
|
21
|
+
import { TableKit } from "@kopexa/extension-table";
|
|
22
|
+
import { Highlight } from "@tiptap/extension-highlight";
|
|
23
|
+
import InvisibleCharacters from "@tiptap/extension-invisible-characters";
|
|
24
|
+
import { TaskItem, TaskList } from "@tiptap/extension-list";
|
|
25
|
+
import { Subscript } from "@tiptap/extension-subscript";
|
|
26
|
+
import { Superscript } from "@tiptap/extension-superscript";
|
|
27
|
+
import {
|
|
28
|
+
getHierarchicalIndexes,
|
|
29
|
+
TableOfContents
|
|
30
|
+
} from "@tiptap/extension-table-of-contents";
|
|
31
|
+
import { TextAlign } from "@tiptap/extension-text-align";
|
|
32
|
+
import { TextStyleKit } from "@tiptap/extension-text-style";
|
|
33
|
+
import { Typography } from "@tiptap/extension-typography";
|
|
34
|
+
import { UniqueID } from "@tiptap/extension-unique-id";
|
|
35
|
+
import { CharacterCount, Placeholder } from "@tiptap/extensions";
|
|
36
|
+
import {
|
|
37
|
+
useEditor
|
|
38
|
+
} from "@tiptap/react";
|
|
39
|
+
import { StarterKit } from "@tiptap/starter-kit";
|
|
40
|
+
var useCreateEditor = ({
|
|
41
|
+
content,
|
|
42
|
+
editable = true,
|
|
43
|
+
placeholder = "Write, type '/' for commands\u2026",
|
|
44
|
+
onChange,
|
|
45
|
+
controlResolver,
|
|
46
|
+
...options
|
|
47
|
+
}) => {
|
|
48
|
+
const editor = useEditor({
|
|
49
|
+
editorProps: {
|
|
50
|
+
attributes: {
|
|
51
|
+
autocomplete: "off",
|
|
52
|
+
autocorrect: "off",
|
|
53
|
+
autocapitalize: "off",
|
|
54
|
+
"aria-label": "Main content area, start typing to enter text."
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
immediatelyRender: false,
|
|
58
|
+
shouldRerenderOnTransaction: false,
|
|
59
|
+
extensions: getExtensions({ editable, placeholder, controlResolver }),
|
|
60
|
+
editable,
|
|
61
|
+
onUpdate: ({ editor: editor2 }) => {
|
|
62
|
+
onChange == null ? void 0 : onChange(editor2.getJSON());
|
|
63
|
+
},
|
|
64
|
+
content: safeParseContent(content),
|
|
65
|
+
...options
|
|
66
|
+
});
|
|
67
|
+
return editor;
|
|
68
|
+
};
|
|
69
|
+
function getExtensions({
|
|
70
|
+
editable,
|
|
71
|
+
placeholder,
|
|
72
|
+
controlResolver
|
|
73
|
+
}) {
|
|
74
|
+
return [
|
|
75
|
+
StarterKit.configure({
|
|
76
|
+
trailingNode: false,
|
|
77
|
+
// we use our custom trailing node extension
|
|
78
|
+
link: false,
|
|
79
|
+
// we use our custom link extension
|
|
80
|
+
code: false,
|
|
81
|
+
// we use our own
|
|
82
|
+
codeBlock: false
|
|
83
|
+
// we use our own
|
|
84
|
+
// undoRedo should be dynamic based on collaboration, later.^
|
|
85
|
+
}),
|
|
86
|
+
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
87
|
+
TaskList,
|
|
88
|
+
TaskItem.configure({ nested: true }),
|
|
89
|
+
InvisibleCharacters.configure({
|
|
90
|
+
visible: false
|
|
91
|
+
}),
|
|
92
|
+
TableOfContents.configure({
|
|
93
|
+
getIndex: getHierarchicalIndexes
|
|
94
|
+
}),
|
|
95
|
+
Selection,
|
|
96
|
+
Link.configure({ openOnClick: !editable }),
|
|
97
|
+
// disable link click when editing
|
|
98
|
+
TextStyleKit,
|
|
99
|
+
Highlight.configure({ multicolor: true }),
|
|
100
|
+
CharacterCount,
|
|
101
|
+
Typography,
|
|
102
|
+
Superscript,
|
|
103
|
+
Subscript,
|
|
104
|
+
CodeKit,
|
|
105
|
+
TrailingNode,
|
|
106
|
+
UniqueID.configure({
|
|
107
|
+
types: [
|
|
108
|
+
"paragraph",
|
|
109
|
+
"bulletList",
|
|
110
|
+
"orderedList",
|
|
111
|
+
"taskList",
|
|
112
|
+
"heading",
|
|
113
|
+
"blockquote",
|
|
114
|
+
"codeBlock"
|
|
115
|
+
]
|
|
116
|
+
// filterTransaction: (transaction) => !isChangeOrigin(transaction),
|
|
117
|
+
}),
|
|
118
|
+
UiState,
|
|
119
|
+
TableKit,
|
|
120
|
+
Placeholder.configure({
|
|
121
|
+
placeholder,
|
|
122
|
+
emptyNodeClass: "is-empty with-slash"
|
|
123
|
+
}),
|
|
124
|
+
ControlKit.configure({ resolver: controlResolver })
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
useCreateEditor,
|
|
130
|
+
getExtensions
|
|
131
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useCodeBlock
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BEV5U2DK.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useTiptapEditor
|
|
7
7
|
} from "./chunk-P55PLOHR.mjs";
|
|
@@ -22,15 +22,7 @@ var CodeBlockButton = ({
|
|
|
22
22
|
...buttonProps
|
|
23
23
|
}) => {
|
|
24
24
|
const { editor } = useTiptapEditor(providedEditor);
|
|
25
|
-
const {
|
|
26
|
-
isVisible,
|
|
27
|
-
canToggle,
|
|
28
|
-
isActive,
|
|
29
|
-
handleToggle,
|
|
30
|
-
label,
|
|
31
|
-
shortcutKeys,
|
|
32
|
-
Icon
|
|
33
|
-
} = useCodeBlock({
|
|
25
|
+
const { isVisible, canToggle, isActive, handleToggle, label, shortcutKeys } = useCodeBlock({
|
|
34
26
|
editor,
|
|
35
27
|
hideWhenUnavailable,
|
|
36
28
|
onToggled
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
TableButton
|
|
4
|
+
} from "./chunk-VX3HSJ76.mjs";
|
|
2
5
|
import {
|
|
3
6
|
TextAlignButton
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GYIYX2JH.mjs";
|
|
5
8
|
import {
|
|
6
9
|
canSetTextAlign
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IQERE7KP.mjs";
|
|
8
11
|
import {
|
|
9
12
|
UndoRedoButton
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2SI7MRAE.mjs";
|
|
11
14
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
HeadingDropdownMenu
|
|
16
|
+
} from "./chunk-V6TAZMQN.mjs";
|
|
17
|
+
import {
|
|
18
|
+
LinkPopover
|
|
19
|
+
} from "./chunk-WHJ4B43N.mjs";
|
|
14
20
|
import {
|
|
15
21
|
ListDropdownMenu
|
|
16
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-Q7DFJ5NI.mjs";
|
|
17
23
|
import {
|
|
18
24
|
MarkButton,
|
|
19
25
|
canToggleMark
|
|
20
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-LNVWG34E.mjs";
|
|
21
27
|
import {
|
|
22
28
|
ColorHighlightPopover
|
|
23
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-XL5FS7LN.mjs";
|
|
24
30
|
import {
|
|
25
|
-
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import {
|
|
28
|
-
LinkPopover
|
|
29
|
-
} from "./chunk-JHMEXFB3.mjs";
|
|
31
|
+
BlockquoteButton
|
|
32
|
+
} from "./chunk-W2FLOOJ6.mjs";
|
|
30
33
|
import {
|
|
31
34
|
CodeBlockButton
|
|
32
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-OEVR5N7X.mjs";
|
|
33
36
|
import {
|
|
34
|
-
|
|
35
|
-
} from "./chunk-
|
|
37
|
+
useEditorUIContext
|
|
38
|
+
} from "./chunk-REJEJXOZ.mjs";
|
|
36
39
|
import {
|
|
37
40
|
useCursorVisibility
|
|
38
41
|
} from "./chunk-R2GM4A3T.mjs";
|
|
@@ -60,6 +63,7 @@ var EditorHeader = ({ editor: providedEditor }) => {
|
|
|
60
63
|
const { editor } = useTiptapEditor(providedEditor);
|
|
61
64
|
const isMobile = useIsMobile();
|
|
62
65
|
const windowSize = useWindowSize();
|
|
66
|
+
const { styles } = useEditorUIContext();
|
|
63
67
|
const toolbarRef = useRef(null);
|
|
64
68
|
const bodyRect = useCursorVisibility({
|
|
65
69
|
editor,
|
|
@@ -68,15 +72,18 @@ var EditorHeader = ({ editor: providedEditor }) => {
|
|
|
68
72
|
if (!(editor == null ? void 0 : editor.isEditable)) {
|
|
69
73
|
return null;
|
|
70
74
|
}
|
|
71
|
-
return /* @__PURE__ */ jsx(
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { className: styles.toolbar(), "data-slot": "editor-toolbar", children: /* @__PURE__ */ jsx(
|
|
72
76
|
Toolbar,
|
|
73
77
|
{
|
|
78
|
+
sticky: true,
|
|
79
|
+
radius: "none",
|
|
80
|
+
border: "none",
|
|
74
81
|
style: isMobile ? {
|
|
75
82
|
bottom: `calc(100% - ${windowSize.height - bodyRect.y}px)`
|
|
76
83
|
} : {},
|
|
77
84
|
children: /* @__PURE__ */ jsx(MainToolbarContent, {})
|
|
78
85
|
}
|
|
79
|
-
);
|
|
86
|
+
) });
|
|
80
87
|
};
|
|
81
88
|
var MainToolbarContent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
82
89
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
@@ -143,6 +150,7 @@ function MoreOptions({
|
|
|
143
150
|
variant: "ghost",
|
|
144
151
|
color: "default",
|
|
145
152
|
tabIndex: -1,
|
|
153
|
+
size: "md",
|
|
146
154
|
"aria-label": "More options",
|
|
147
155
|
title: "More options",
|
|
148
156
|
isIconOnly: true,
|
|
@@ -159,7 +167,7 @@ function MoreOptions({
|
|
|
159
167
|
align: "end",
|
|
160
168
|
alignOffset: 4,
|
|
161
169
|
sideOffset: 4,
|
|
162
|
-
children: /* @__PURE__ */ jsxs(Toolbar, {
|
|
170
|
+
children: /* @__PURE__ */ jsxs(Toolbar, { children: [
|
|
163
171
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
164
172
|
/* @__PURE__ */ jsx(MarkButton, { type: "superscript" }),
|
|
165
173
|
/* @__PURE__ */ jsx(MarkButton, { type: "subscript" })
|
|
@@ -4,10 +4,7 @@ import {
|
|
|
4
4
|
canToggleList,
|
|
5
5
|
isListActive,
|
|
6
6
|
listOptions
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
isNodeInSchema
|
|
10
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
7
|
+
} from "./chunk-IOB3REX6.mjs";
|
|
11
8
|
import {
|
|
12
9
|
useTiptapEditor
|
|
13
10
|
} from "./chunk-P55PLOHR.mjs";
|
|
@@ -15,6 +12,7 @@ import {
|
|
|
15
12
|
// src/ui/list-dropdown-menu/index.tsx
|
|
16
13
|
import { Button } from "@kopexa/button";
|
|
17
14
|
import { DropdownMenu } from "@kopexa/dropdown-menu";
|
|
15
|
+
import { isNodeInSchema } from "@kopexa/editor-utils";
|
|
18
16
|
import { ChevronDownIcon, ListIcon } from "@kopexa/icons";
|
|
19
17
|
import { isNodeSelection } from "@tiptap/react";
|
|
20
18
|
import { useCallback, useMemo, useState } from "react";
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useSlashDropdownMenu
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-B2DHYFSH.mjs";
|
|
5
5
|
import {
|
|
6
6
|
SuggestionMenu
|
|
7
7
|
} from "./chunk-XLSZK3WJ.mjs";
|
|
8
8
|
import {
|
|
9
9
|
filterSuggestionItems
|
|
10
10
|
} from "./chunk-CNVACBGT.mjs";
|
|
11
|
-
import {
|
|
12
|
-
getElementOverflowPosition
|
|
13
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
14
11
|
|
|
15
12
|
// src/ui/slash-dropdown-menu/slash-dropdown-menu.tsx
|
|
16
13
|
import { Button } from "@kopexa/button";
|
|
14
|
+
import { getElementOverflowPosition } from "@kopexa/editor-utils";
|
|
17
15
|
import { Separator } from "@kopexa/separator";
|
|
18
16
|
import { slashDropdownMenu } from "@kopexa/theme";
|
|
19
17
|
import * as React from "react";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// src/context/editor-context.ts
|
|
4
4
|
import { createContext } from "@kopexa/react-utils";
|
|
5
|
-
var [
|
|
5
|
+
var [EditorUIProvider, useEditorUIContext] = createContext();
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
EditorUIProvider,
|
|
9
|
+
useEditorUIContext
|
|
10
10
|
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/utils/index.ts
|
|
4
|
+
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
5
|
+
var handleImageUpload = async (file, onProgress, abortSignal) => {
|
|
6
|
+
if (!file) {
|
|
7
|
+
throw new Error("No file provided");
|
|
8
|
+
}
|
|
9
|
+
if (file.size > MAX_FILE_SIZE) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`File size exceeds maximum allowed (${MAX_FILE_SIZE / (1024 * 1024)}MB)`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
for (let progress = 0; progress <= 100; progress += 10) {
|
|
15
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
16
|
+
throw new Error("Upload cancelled");
|
|
17
|
+
}
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
19
|
+
onProgress == null ? void 0 : onProgress({ progress });
|
|
20
|
+
}
|
|
21
|
+
return "/images/placeholder-image.png";
|
|
22
|
+
};
|
|
23
|
+
var convertFileToBase64 = (file, abortSignal) => {
|
|
24
|
+
if (!file) {
|
|
25
|
+
return Promise.reject(new Error("No file provided"));
|
|
26
|
+
}
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const reader = new FileReader();
|
|
29
|
+
const abortHandler = () => {
|
|
30
|
+
reader.abort();
|
|
31
|
+
reject(new Error("Upload cancelled"));
|
|
32
|
+
};
|
|
33
|
+
if (abortSignal) {
|
|
34
|
+
abortSignal.addEventListener("abort", abortHandler);
|
|
35
|
+
}
|
|
36
|
+
reader.onloadend = () => {
|
|
37
|
+
if (abortSignal) {
|
|
38
|
+
abortSignal.removeEventListener("abort", abortHandler);
|
|
39
|
+
}
|
|
40
|
+
if (typeof reader.result === "string") {
|
|
41
|
+
resolve(reader.result);
|
|
42
|
+
} else {
|
|
43
|
+
reject(new Error("Failed to convert File to base64"));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
reader.onerror = (error) => reject(new Error(`File reading error: ${error}`));
|
|
47
|
+
reader.readAsDataURL(file);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var ATTR_WHITESPACE = (
|
|
51
|
+
// eslint-disable-next-line no-control-regex
|
|
52
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: we can do this yay
|
|
53
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
54
|
+
);
|
|
55
|
+
function isAllowedUri(uri, protocols) {
|
|
56
|
+
const allowedProtocols = [
|
|
57
|
+
"http",
|
|
58
|
+
"https",
|
|
59
|
+
"ftp",
|
|
60
|
+
"ftps",
|
|
61
|
+
"mailto",
|
|
62
|
+
"tel",
|
|
63
|
+
"callto",
|
|
64
|
+
"sms",
|
|
65
|
+
"cid",
|
|
66
|
+
"xmpp"
|
|
67
|
+
];
|
|
68
|
+
if (protocols) {
|
|
69
|
+
for (const protocol of protocols) {
|
|
70
|
+
const nextProtocol = typeof protocol === "string" ? protocol : protocol.scheme;
|
|
71
|
+
if (nextProtocol) {
|
|
72
|
+
allowedProtocols.push(nextProtocol);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return !uri || uri.replace(ATTR_WHITESPACE, "").match(
|
|
77
|
+
new RegExp(
|
|
78
|
+
// eslint-disable-next-line no-useless-escape
|
|
79
|
+
`^(?:(?:${allowedProtocols.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
|
|
80
|
+
"i"
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function sanitizeUrl(inputUrl, baseUrl, protocols) {
|
|
85
|
+
try {
|
|
86
|
+
const url = new URL(inputUrl, baseUrl);
|
|
87
|
+
if (isAllowedUri(url.href, protocols)) {
|
|
88
|
+
return url.href;
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
return "#";
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
MAX_FILE_SIZE,
|
|
97
|
+
handleImageUpload,
|
|
98
|
+
convertFileToBase64,
|
|
99
|
+
isAllowedUri,
|
|
100
|
+
sanitizeUrl
|
|
101
|
+
};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
isMarkInSchema,
|
|
4
|
-
isNodeTypeSelected
|
|
5
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
6
2
|
import {
|
|
7
3
|
useTiptapEditor
|
|
8
4
|
} from "./chunk-P55PLOHR.mjs";
|
|
9
5
|
|
|
10
6
|
// src/ui/color-highlight-button/use-color-highlight.ts
|
|
7
|
+
import { isMarkInSchema, isNodeTypeSelected } from "@kopexa/editor-utils";
|
|
11
8
|
import { HighlighterIcon } from "@kopexa/icons";
|
|
12
9
|
import { useIsMobile } from "@kopexa/use-is-mobile";
|
|
13
10
|
import * as React from "react";
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HeadingButton,
|
|
4
4
|
headingIcons
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EHY2NAW7.mjs";
|
|
6
6
|
import {
|
|
7
7
|
getFormattedHeadingName
|
|
8
8
|
} from "./chunk-33QD5PYJ.mjs";
|
|
9
|
-
import {
|
|
10
|
-
isNodeInSchema
|
|
11
|
-
} from "./chunk-C6M3CDOK.mjs";
|
|
12
9
|
import {
|
|
13
10
|
useTiptapEditor
|
|
14
11
|
} from "./chunk-P55PLOHR.mjs";
|
|
@@ -16,6 +13,7 @@ import {
|
|
|
16
13
|
// src/ui/heading-dropdown-menu/index.tsx
|
|
17
14
|
import { Button } from "@kopexa/button";
|
|
18
15
|
import { DropdownMenu } from "@kopexa/dropdown-menu";
|
|
16
|
+
import { isNodeInSchema } from "@kopexa/editor-utils";
|
|
19
17
|
import { ChevronDownIcon, HeadingIcon } from "@kopexa/icons";
|
|
20
18
|
import { isNodeSelection } from "@tiptap/react";
|
|
21
19
|
import * as React from "react";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useTableBlock
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YJAHZXLG.mjs";
|
|
5
5
|
import {
|
|
6
6
|
useTiptapEditor
|
|
7
7
|
} from "./chunk-P55PLOHR.mjs";
|
|
@@ -56,7 +56,7 @@ var TableButton = ({
|
|
|
56
56
|
tabIndex: -1,
|
|
57
57
|
"aria-label": label,
|
|
58
58
|
"aria-pressed": isActive,
|
|
59
|
-
|
|
59
|
+
title: label,
|
|
60
60
|
onClick: handleClick,
|
|
61
61
|
isIconOnly: !text && !children,
|
|
62
62
|
...buttonProps,
|