@kopexa/tiptap 17.1.0 → 17.2.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-SFG45HEU.mjs → chunk-2U5CQUZH.mjs} +1 -1
- package/dist/{chunk-QCRK7XVV.mjs → chunk-32SUXCAQ.mjs} +1 -1
- package/dist/chunk-5GFFTVMZ.mjs +62 -0
- package/dist/{chunk-B6SP3ADV.mjs → chunk-7SRL3P4B.mjs} +8 -8
- package/dist/{chunk-WKJGDCGA.mjs → chunk-7VGROP26.mjs} +1 -1
- package/dist/{chunk-6YGMTHOY.mjs → chunk-7VW67NVL.mjs} +1 -1
- package/dist/{chunk-SCL22AGK.mjs → chunk-BXHPO3T7.mjs} +14 -4
- package/dist/{chunk-EBFGDPWY.mjs → chunk-E5NW3MJZ.mjs} +4 -4
- package/dist/chunk-LMCQMSW2.mjs +345 -0
- package/dist/{chunk-EH2JHHGJ.mjs → chunk-NEHW62L7.mjs} +1 -3
- package/dist/{chunk-KTIMXK5V.mjs → chunk-NSYSECKW.mjs} +3 -3
- package/dist/{chunk-Z6GJ2GKW.mjs → chunk-QAE2D4KV.mjs} +13 -13
- package/dist/{chunk-IY4SCXZN.mjs → chunk-UU6JK5HX.mjs} +105 -11
- package/dist/{chunk-DSK3HK5D.mjs → chunk-UVHVCION.mjs} +14 -4
- package/dist/{chunk-MYO2CUDR.mjs → chunk-VF3G2URZ.mjs} +10 -2
- package/dist/chunk-VRQ6OSAZ.mjs +76 -0
- package/dist/chunk-WAAH3NLG.mjs +77 -0
- package/dist/context/editor-file-context.d.mts +70 -0
- package/dist/context/editor-file-context.d.ts +70 -0
- package/dist/context/editor-file-context.js +96 -0
- package/dist/context/editor-file-context.mjs +12 -0
- package/dist/extensions/callout/callout-view.js +8 -1
- package/dist/extensions/callout/callout-view.mjs +1 -1
- package/dist/extensions/callout/index.js +8 -1
- package/dist/extensions/callout/index.mjs +2 -2
- package/dist/extensions/image/image-view.d.mts +15 -0
- package/dist/extensions/image/image-view.d.ts +15 -0
- package/dist/extensions/image/image-view.js +423 -0
- package/dist/extensions/image/image-view.mjs +12 -0
- package/dist/extensions/image/index.d.mts +66 -0
- package/dist/extensions/image/index.d.ts +66 -0
- package/dist/extensions/image/index.js +495 -0
- package/dist/extensions/image/index.mjs +16 -0
- package/dist/extensions/image/messages.d.mts +56 -0
- package/dist/extensions/image/messages.d.ts +56 -0
- package/dist/extensions/image/messages.js +85 -0
- package/dist/extensions/image/messages.mjs +7 -0
- package/dist/extensions/math/index.js +20 -6
- package/dist/extensions/math/index.mjs +4 -4
- package/dist/extensions/math/inline-math-view.js +10 -3
- package/dist/extensions/math/inline-math-view.mjs +1 -1
- package/dist/extensions/math/inline-math.js +10 -3
- package/dist/extensions/math/inline-math.mjs +2 -2
- package/dist/extensions/math/math-block-view.js +10 -3
- package/dist/extensions/math/math-block-view.mjs +1 -1
- package/dist/hooks/use-create-editor.d.mts +12 -2
- package/dist/hooks/use-create-editor.d.ts +12 -2
- package/dist/hooks/use-create-editor.js +809 -237
- package/dist/hooks/use-create-editor.mjs +14 -10
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +1261 -630
- package/dist/index.mjs +51 -37
- package/dist/presets/basic/editor-header.mjs +16 -16
- package/dist/presets/basic/index.d.mts +2 -0
- package/dist/presets/basic/index.d.ts +2 -0
- package/dist/presets/basic/index.js +1198 -628
- package/dist/presets/basic/index.mjs +36 -32
- package/dist/ui/bubble-menu/index.mjs +5 -5
- package/dist/ui/color-highlight-popover/color-highlight-popover.mjs +2 -2
- package/dist/ui/color-highlight-popover/index.mjs +2 -2
- package/dist/ui/copy-anchor-link-button/use-scroll-to-hash.mjs +2 -2
- package/dist/ui/link-popover/index.mjs +3 -3
- package/dist/ui/link-popover/link-popover.mjs +3 -3
- package/dist/ui/link-popover/use-link-popover.mjs +2 -2
- package/dist/ui/slash-dropdown-menu/index.js +1 -3
- package/dist/ui/slash-dropdown-menu/index.mjs +6 -6
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +1 -3
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +4 -4
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +1 -3
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.mjs +1 -1
- package/dist/ui/suggestion-menu/index.mjs +2 -2
- package/dist/ui/suggestion-menu/suggestion-menu.mjs +2 -2
- package/package.json +25 -24
- package/dist/{chunk-XL5FS7LN.mjs → chunk-C5RQWJKE.mjs} +3 -3
- package/dist/{chunk-JNL4KY45.mjs → chunk-DZLGLP7R.mjs} +3 -3
- package/dist/{chunk-LHXRE26G.mjs → chunk-VTKJPVNM.mjs} +3 -3
- package/dist/{chunk-XLSZK3WJ.mjs → chunk-ZYFCSR3E.mjs} +3 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/extensions/image/messages.ts
|
|
4
|
+
import { defineMessages } from "react-intl";
|
|
5
|
+
var messages = defineMessages({
|
|
6
|
+
loading: {
|
|
7
|
+
id: "editor.image.loading",
|
|
8
|
+
defaultMessage: "Loading image..."
|
|
9
|
+
},
|
|
10
|
+
error: {
|
|
11
|
+
id: "editor.image.error",
|
|
12
|
+
defaultMessage: "Failed to load image"
|
|
13
|
+
},
|
|
14
|
+
upload_error: {
|
|
15
|
+
id: "editor.image.upload_error",
|
|
16
|
+
defaultMessage: "Failed to upload image"
|
|
17
|
+
},
|
|
18
|
+
uploading: {
|
|
19
|
+
id: "editor.image.uploading",
|
|
20
|
+
defaultMessage: "Uploading..."
|
|
21
|
+
},
|
|
22
|
+
upload_placeholder: {
|
|
23
|
+
id: "editor.image.upload_placeholder",
|
|
24
|
+
defaultMessage: "Click to upload or drag & drop"
|
|
25
|
+
},
|
|
26
|
+
upload_hint: {
|
|
27
|
+
id: "editor.image.upload_hint",
|
|
28
|
+
defaultMessage: "PNG, JPG, GIF, WebP, SVG"
|
|
29
|
+
},
|
|
30
|
+
alt_text: {
|
|
31
|
+
id: "editor.image.alt_text",
|
|
32
|
+
defaultMessage: "Alt text"
|
|
33
|
+
},
|
|
34
|
+
alt_placeholder: {
|
|
35
|
+
id: "editor.image.alt_placeholder",
|
|
36
|
+
defaultMessage: "Describe the image..."
|
|
37
|
+
},
|
|
38
|
+
files_not_supported: {
|
|
39
|
+
id: "editor.image.files_not_supported",
|
|
40
|
+
defaultMessage: "File upload is not configured"
|
|
41
|
+
},
|
|
42
|
+
file_too_large: {
|
|
43
|
+
id: "editor.image.file_too_large",
|
|
44
|
+
defaultMessage: "File is too large (max {maxSize})"
|
|
45
|
+
},
|
|
46
|
+
invalid_type: {
|
|
47
|
+
id: "editor.image.invalid_type",
|
|
48
|
+
defaultMessage: "Invalid file type"
|
|
49
|
+
},
|
|
50
|
+
retry: {
|
|
51
|
+
id: "editor.image.retry",
|
|
52
|
+
defaultMessage: "Retry"
|
|
53
|
+
},
|
|
54
|
+
remove: {
|
|
55
|
+
id: "editor.image.remove",
|
|
56
|
+
defaultMessage: "Remove"
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
messages
|
|
62
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
SlashDropdownMenu
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
useScrollToHash
|
|
7
|
-
} from "./chunk-JNL4KY45.mjs";
|
|
4
|
+
} from "./chunk-E5NW3MJZ.mjs";
|
|
8
5
|
import {
|
|
9
6
|
LinkBubble
|
|
10
7
|
} from "./chunk-XNDXYI2N.mjs";
|
|
11
8
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
9
|
+
useScrollToHash
|
|
10
|
+
} from "./chunk-DZLGLP7R.mjs";
|
|
14
11
|
import {
|
|
15
12
|
EditorHeader
|
|
16
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QAE2D4KV.mjs";
|
|
14
|
+
import {
|
|
15
|
+
BubbleMenu
|
|
16
|
+
} from "./chunk-NSYSECKW.mjs";
|
|
17
17
|
import {
|
|
18
18
|
useUiEditorState
|
|
19
19
|
} from "./chunk-BXJYNSWQ.mjs";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-REJEJXOZ.mjs";
|
|
23
23
|
import {
|
|
24
24
|
useCreateEditor
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-UU6JK5HX.mjs";
|
|
26
26
|
|
|
27
27
|
// src/presets/basic/index.tsx
|
|
28
28
|
import {
|
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
import { Button } from "@kopexa/button";
|
|
8
8
|
import { Dialog } from "@kopexa/dialog";
|
|
9
9
|
import { Label } from "@kopexa/label";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
NodeViewWrapper,
|
|
12
|
+
useEditorState
|
|
13
|
+
} from "@tiptap/react";
|
|
11
14
|
import katex from "katex";
|
|
12
15
|
import "katex/dist/katex.min.css";
|
|
13
16
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -17,6 +20,13 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
17
20
|
const intl = useIntl();
|
|
18
21
|
const attrs = node.attrs;
|
|
19
22
|
const { latex = "" } = attrs;
|
|
23
|
+
const isEditable = useEditorState({
|
|
24
|
+
editor,
|
|
25
|
+
selector: ({ editor: e }) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
20
30
|
const [isOpen, setIsOpen] = useState(false);
|
|
21
31
|
const [localLatex, setLocalLatex] = useState(latex);
|
|
22
32
|
const [error, setError] = useState(null);
|
|
@@ -69,11 +79,11 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
69
79
|
(e) => {
|
|
70
80
|
e.stopPropagation();
|
|
71
81
|
e.preventDefault();
|
|
72
|
-
if (
|
|
82
|
+
if (isEditable) {
|
|
73
83
|
setIsOpen(true);
|
|
74
84
|
}
|
|
75
85
|
},
|
|
76
|
-
[
|
|
86
|
+
[isEditable]
|
|
77
87
|
);
|
|
78
88
|
const isEmpty = !latex;
|
|
79
89
|
return /* @__PURE__ */ jsxs(
|
|
@@ -87,7 +97,7 @@ function InlineMathView({ editor, node, getPos }) {
|
|
|
87
97
|
/* @__PURE__ */ jsx(
|
|
88
98
|
"span",
|
|
89
99
|
{
|
|
90
|
-
className: `inline-math cursor-pointer rounded px-0.5 transition-colors ${
|
|
100
|
+
className: `inline-math cursor-pointer rounded px-0.5 transition-colors ${isEditable ? "hover:bg-primary/10 hover:ring-1 hover:ring-primary/20" : ""} ${isEmpty ? "text-muted-foreground italic" : ""}`,
|
|
91
101
|
onClick: handleClick,
|
|
92
102
|
children: isEmpty ? /* @__PURE__ */ jsx("span", { className: "text-xs", children: "$?$" }) : renderedHtml ? /* @__PURE__ */ jsx(
|
|
93
103
|
"span",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useSlashDropdownMenu
|
|
4
|
-
} from "./chunk-EH2JHHGJ.mjs";
|
|
5
2
|
import {
|
|
6
3
|
SuggestionMenu
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZYFCSR3E.mjs";
|
|
8
5
|
import {
|
|
9
6
|
filterSuggestionItems
|
|
10
7
|
} from "./chunk-CNVACBGT.mjs";
|
|
8
|
+
import {
|
|
9
|
+
useSlashDropdownMenu
|
|
10
|
+
} from "./chunk-NEHW62L7.mjs";
|
|
11
11
|
|
|
12
12
|
// src/ui/slash-dropdown-menu/slash-dropdown-menu.tsx
|
|
13
13
|
import { Button } from "@kopexa/button";
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
messages
|
|
4
|
+
} from "./chunk-5GFFTVMZ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
useEditorFile
|
|
7
|
+
} from "./chunk-VRQ6OSAZ.mjs";
|
|
8
|
+
|
|
9
|
+
// src/extensions/image/image-view.tsx
|
|
10
|
+
import { IconButton } from "@kopexa/button";
|
|
11
|
+
import {
|
|
12
|
+
AlertCircleIcon,
|
|
13
|
+
ArrowCounterClockwiseIcon,
|
|
14
|
+
ImageIcon,
|
|
15
|
+
TrashIcon,
|
|
16
|
+
UploadIcon
|
|
17
|
+
} from "@kopexa/icons";
|
|
18
|
+
import { imagePlaceholder } from "@kopexa/theme";
|
|
19
|
+
import {
|
|
20
|
+
NodeViewWrapper,
|
|
21
|
+
useEditorState
|
|
22
|
+
} from "@tiptap/react";
|
|
23
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
24
|
+
import { useIntl } from "react-intl";
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
function ImageNodeView({ editor, node, getPos }) {
|
|
27
|
+
var _a;
|
|
28
|
+
const intl = useIntl();
|
|
29
|
+
const fileHandler = useEditorFile();
|
|
30
|
+
const attrs = node.attrs;
|
|
31
|
+
const isEditable = useEditorState({
|
|
32
|
+
editor,
|
|
33
|
+
selector: ({ editor: e }) => {
|
|
34
|
+
var _a2;
|
|
35
|
+
return (_a2 = e == null ? void 0 : e.isEditable) != null ? _a2 : false;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const { src, alt, title, uploadState, uploadProgress } = attrs;
|
|
39
|
+
const [resolvedUrl, setResolvedUrl] = useState(null);
|
|
40
|
+
const [resolveState, setResolveState] = useState("idle");
|
|
41
|
+
const needsResolve = (_a = fileHandler == null ? void 0 : fileHandler.isReference(src)) != null ? _a : false;
|
|
42
|
+
const resolveImage = useCallback(async () => {
|
|
43
|
+
if (!src) return;
|
|
44
|
+
if (!needsResolve) {
|
|
45
|
+
setResolvedUrl(src);
|
|
46
|
+
setResolveState("resolved");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (!fileHandler) {
|
|
50
|
+
setResolveState("error");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setResolveState("loading");
|
|
54
|
+
try {
|
|
55
|
+
const url = await fileHandler.resolve(src);
|
|
56
|
+
setResolvedUrl(url);
|
|
57
|
+
setResolveState("resolved");
|
|
58
|
+
} catch {
|
|
59
|
+
setResolveState("error");
|
|
60
|
+
}
|
|
61
|
+
}, [src, needsResolve, fileHandler]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
resolveImage();
|
|
64
|
+
}, [resolveImage]);
|
|
65
|
+
const handleRetry = useCallback(() => {
|
|
66
|
+
resolveImage();
|
|
67
|
+
}, [resolveImage]);
|
|
68
|
+
const handleRemove = useCallback(() => {
|
|
69
|
+
const pos = getPos();
|
|
70
|
+
if (pos === void 0) return;
|
|
71
|
+
editor.commands.deleteRange({
|
|
72
|
+
from: pos,
|
|
73
|
+
to: pos + node.nodeSize
|
|
74
|
+
});
|
|
75
|
+
}, [editor, getPos, node.nodeSize]);
|
|
76
|
+
const fileInputRef = useRef(null);
|
|
77
|
+
const handleFileSelect = useCallback(
|
|
78
|
+
async (file) => {
|
|
79
|
+
if (!fileHandler) return;
|
|
80
|
+
const pos = getPos();
|
|
81
|
+
if (pos === void 0) return;
|
|
82
|
+
editor.view.dispatch(
|
|
83
|
+
editor.state.tr.setNodeMarkup(pos, void 0, {
|
|
84
|
+
...attrs,
|
|
85
|
+
uploadState: "uploading",
|
|
86
|
+
uploadProgress: 0
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
try {
|
|
90
|
+
const ref = await fileHandler.upload(file, (percent) => {
|
|
91
|
+
const currentPos = getPos();
|
|
92
|
+
if (currentPos === void 0) return;
|
|
93
|
+
editor.view.dispatch(
|
|
94
|
+
editor.state.tr.setNodeMarkup(currentPos, void 0, {
|
|
95
|
+
...attrs,
|
|
96
|
+
uploadState: "uploading",
|
|
97
|
+
uploadProgress: percent
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
const finalPos = getPos();
|
|
102
|
+
if (finalPos === void 0) return;
|
|
103
|
+
editor.view.dispatch(
|
|
104
|
+
editor.state.tr.setNodeMarkup(finalPos, void 0, {
|
|
105
|
+
src: ref,
|
|
106
|
+
uploadState: null,
|
|
107
|
+
uploadProgress: null
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
} catch {
|
|
111
|
+
const errorPos = getPos();
|
|
112
|
+
if (errorPos === void 0) return;
|
|
113
|
+
editor.view.dispatch(
|
|
114
|
+
editor.state.tr.setNodeMarkup(errorPos, void 0, {
|
|
115
|
+
...attrs,
|
|
116
|
+
uploadState: "error",
|
|
117
|
+
uploadProgress: null
|
|
118
|
+
})
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
[fileHandler, editor, getPos, attrs]
|
|
123
|
+
);
|
|
124
|
+
const handleInputChange = useCallback(
|
|
125
|
+
(e) => {
|
|
126
|
+
var _a2;
|
|
127
|
+
const file = (_a2 = e.target.files) == null ? void 0 : _a2[0];
|
|
128
|
+
if (file) {
|
|
129
|
+
handleFileSelect(file);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
[handleFileSelect]
|
|
133
|
+
);
|
|
134
|
+
const handleDrop = useCallback(
|
|
135
|
+
(e) => {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
e.stopPropagation();
|
|
138
|
+
const file = e.dataTransfer.files[0];
|
|
139
|
+
if (file == null ? void 0 : file.type.startsWith("image/")) {
|
|
140
|
+
handleFileSelect(file);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[handleFileSelect]
|
|
144
|
+
);
|
|
145
|
+
const handleDragOver = useCallback((e) => {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
e.stopPropagation();
|
|
148
|
+
}, []);
|
|
149
|
+
const styles = useMemo(() => imagePlaceholder({ size: "md" }), []);
|
|
150
|
+
const errorStyles = useMemo(
|
|
151
|
+
() => imagePlaceholder({ size: "md", variant: "error" }),
|
|
152
|
+
[]
|
|
153
|
+
);
|
|
154
|
+
const uploadingStyles = useMemo(
|
|
155
|
+
() => imagePlaceholder({ size: "md", variant: "uploading" }),
|
|
156
|
+
[]
|
|
157
|
+
);
|
|
158
|
+
const disabledStyles = useMemo(
|
|
159
|
+
() => imagePlaceholder({ size: "md", variant: "disabled" }),
|
|
160
|
+
[]
|
|
161
|
+
);
|
|
162
|
+
const isEmpty = !src;
|
|
163
|
+
if (isEmpty && !uploadState) {
|
|
164
|
+
if (!fileHandler) {
|
|
165
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ jsx("div", { className: disabledStyles.root(), children: /* @__PURE__ */ jsxs("div", { className: disabledStyles.content(), children: [
|
|
166
|
+
/* @__PURE__ */ jsx(ImageIcon, { className: disabledStyles.icon() }),
|
|
167
|
+
/* @__PURE__ */ jsx("span", { className: disabledStyles.text(), children: intl.formatMessage(messages.files_not_supported) }),
|
|
168
|
+
isEditable && /* @__PURE__ */ jsx(
|
|
169
|
+
IconButton,
|
|
170
|
+
{
|
|
171
|
+
size: "sm",
|
|
172
|
+
variant: "ghost",
|
|
173
|
+
onClick: handleRemove,
|
|
174
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
175
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-4" })
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] }) }) });
|
|
179
|
+
}
|
|
180
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ jsxs(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
className: styles.root(),
|
|
184
|
+
onClick: () => {
|
|
185
|
+
var _a2;
|
|
186
|
+
return (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
187
|
+
},
|
|
188
|
+
onDrop: handleDrop,
|
|
189
|
+
onDragOver: handleDragOver,
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ jsxs("div", { className: styles.content(), children: [
|
|
192
|
+
/* @__PURE__ */ jsx(UploadIcon, { className: styles.icon() }),
|
|
193
|
+
/* @__PURE__ */ jsx("span", { className: styles.text(), children: intl.formatMessage(messages.upload_placeholder) }),
|
|
194
|
+
/* @__PURE__ */ jsx("span", { className: styles.hint(), children: intl.formatMessage(messages.upload_hint) })
|
|
195
|
+
] }),
|
|
196
|
+
/* @__PURE__ */ jsx(
|
|
197
|
+
"input",
|
|
198
|
+
{
|
|
199
|
+
ref: fileInputRef,
|
|
200
|
+
type: "file",
|
|
201
|
+
accept: "image/*",
|
|
202
|
+
className: "hidden",
|
|
203
|
+
onChange: handleInputChange
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
isEditable && /* @__PURE__ */ jsx(
|
|
207
|
+
IconButton,
|
|
208
|
+
{
|
|
209
|
+
size: "sm",
|
|
210
|
+
variant: "ghost",
|
|
211
|
+
className: styles.removeButton(),
|
|
212
|
+
onClick: (e) => {
|
|
213
|
+
e.stopPropagation();
|
|
214
|
+
handleRemove();
|
|
215
|
+
},
|
|
216
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
217
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-3.5" })
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
) });
|
|
223
|
+
}
|
|
224
|
+
if (uploadState === "uploading") {
|
|
225
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ jsx("div", { className: uploadingStyles.root(), children: /* @__PURE__ */ jsxs("div", { className: uploadingStyles.content(), children: [
|
|
226
|
+
/* @__PURE__ */ jsxs("div", { className: "relative size-12", children: [
|
|
227
|
+
/* @__PURE__ */ jsxs(
|
|
228
|
+
"svg",
|
|
229
|
+
{
|
|
230
|
+
className: "size-12 -rotate-90",
|
|
231
|
+
viewBox: "0 0 36 36",
|
|
232
|
+
"aria-hidden": "true",
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ jsx(
|
|
235
|
+
"circle",
|
|
236
|
+
{
|
|
237
|
+
cx: "18",
|
|
238
|
+
cy: "18",
|
|
239
|
+
r: "16",
|
|
240
|
+
fill: "none",
|
|
241
|
+
className: "stroke-muted",
|
|
242
|
+
strokeWidth: "2"
|
|
243
|
+
}
|
|
244
|
+
),
|
|
245
|
+
/* @__PURE__ */ jsx(
|
|
246
|
+
"circle",
|
|
247
|
+
{
|
|
248
|
+
cx: "18",
|
|
249
|
+
cy: "18",
|
|
250
|
+
r: "16",
|
|
251
|
+
fill: "none",
|
|
252
|
+
className: "stroke-primary",
|
|
253
|
+
strokeWidth: "2",
|
|
254
|
+
strokeDasharray: 100,
|
|
255
|
+
strokeDashoffset: 100 - (uploadProgress != null ? uploadProgress : 0),
|
|
256
|
+
strokeLinecap: "round"
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
/* @__PURE__ */ jsxs("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium", children: [
|
|
263
|
+
uploadProgress != null ? uploadProgress : 0,
|
|
264
|
+
"%"
|
|
265
|
+
] })
|
|
266
|
+
] }),
|
|
267
|
+
/* @__PURE__ */ jsx("span", { className: uploadingStyles.text(), children: intl.formatMessage(messages.uploading) })
|
|
268
|
+
] }) }) });
|
|
269
|
+
}
|
|
270
|
+
if (uploadState === "error") {
|
|
271
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ jsx("div", { className: errorStyles.root(), children: /* @__PURE__ */ jsxs("div", { className: errorStyles.content(), children: [
|
|
272
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { className: errorStyles.icon() }),
|
|
273
|
+
/* @__PURE__ */ jsx("span", { className: errorStyles.text(), children: intl.formatMessage(messages.upload_error) }),
|
|
274
|
+
isEditable && /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsx(
|
|
275
|
+
IconButton,
|
|
276
|
+
{
|
|
277
|
+
size: "sm",
|
|
278
|
+
variant: "ghost",
|
|
279
|
+
onClick: handleRemove,
|
|
280
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
281
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-4" })
|
|
282
|
+
}
|
|
283
|
+
) })
|
|
284
|
+
] }) }) });
|
|
285
|
+
}
|
|
286
|
+
if (resolveState === "loading") {
|
|
287
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ jsx("div", { className: `${uploadingStyles.root()} animate-pulse`, children: /* @__PURE__ */ jsx("span", { className: uploadingStyles.text(), children: intl.formatMessage(messages.loading) }) }) });
|
|
288
|
+
}
|
|
289
|
+
if (resolveState === "error") {
|
|
290
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image", children: /* @__PURE__ */ jsx("div", { className: errorStyles.root(), children: /* @__PURE__ */ jsxs("div", { className: errorStyles.content(), children: [
|
|
291
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { className: errorStyles.icon() }),
|
|
292
|
+
/* @__PURE__ */ jsx("span", { className: errorStyles.text(), children: intl.formatMessage(messages.error) }),
|
|
293
|
+
isEditable && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
IconButton,
|
|
296
|
+
{
|
|
297
|
+
size: "sm",
|
|
298
|
+
variant: "outline",
|
|
299
|
+
onClick: handleRetry,
|
|
300
|
+
"aria-label": intl.formatMessage(messages.retry),
|
|
301
|
+
children: /* @__PURE__ */ jsx(ArrowCounterClockwiseIcon, { className: "size-4" })
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
/* @__PURE__ */ jsx(
|
|
305
|
+
IconButton,
|
|
306
|
+
{
|
|
307
|
+
size: "sm",
|
|
308
|
+
variant: "ghost",
|
|
309
|
+
onClick: handleRemove,
|
|
310
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
311
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-4" })
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
] })
|
|
315
|
+
] }) }) });
|
|
316
|
+
}
|
|
317
|
+
return /* @__PURE__ */ jsxs(NodeViewWrapper, { className: "my-4 relative group", "data-type": "image", children: [
|
|
318
|
+
/* @__PURE__ */ jsx(
|
|
319
|
+
"img",
|
|
320
|
+
{
|
|
321
|
+
src: resolvedUrl != null ? resolvedUrl : src,
|
|
322
|
+
alt: alt != null ? alt : "",
|
|
323
|
+
title: title != null ? title : void 0,
|
|
324
|
+
className: "max-w-full h-auto rounded-lg",
|
|
325
|
+
draggable: false
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
isEditable && /* @__PURE__ */ jsx("div", { className: "absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1", children: /* @__PURE__ */ jsx(
|
|
329
|
+
IconButton,
|
|
330
|
+
{
|
|
331
|
+
size: "sm",
|
|
332
|
+
variant: "outline",
|
|
333
|
+
onClick: handleRemove,
|
|
334
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
335
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-3.5" })
|
|
336
|
+
}
|
|
337
|
+
) })
|
|
338
|
+
] });
|
|
339
|
+
}
|
|
340
|
+
var image_view_default = ImageNodeView;
|
|
341
|
+
|
|
342
|
+
export {
|
|
343
|
+
ImageNodeView,
|
|
344
|
+
image_view_default
|
|
345
|
+
};
|
|
@@ -351,9 +351,7 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
|
|
|
351
351
|
image: {
|
|
352
352
|
check: (editor) => isNodeInSchema("image", editor),
|
|
353
353
|
action: ({ editor }) => {
|
|
354
|
-
editor.chain().focus().
|
|
355
|
-
type: "imageUpload"
|
|
356
|
-
}).run();
|
|
354
|
+
editor.chain().focus().setImage({ src: "" }).run();
|
|
357
355
|
}
|
|
358
356
|
}
|
|
359
357
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
LinkPopover
|
|
4
|
-
} from "./chunk-WKJGDCGA.mjs";
|
|
5
2
|
import {
|
|
6
3
|
MarkButton
|
|
7
4
|
} from "./chunk-LNVWG34E.mjs";
|
|
5
|
+
import {
|
|
6
|
+
LinkPopover
|
|
7
|
+
} from "./chunk-7VGROP26.mjs";
|
|
8
8
|
|
|
9
9
|
// src/ui/bubble-menu/index.tsx
|
|
10
10
|
import { Toolbar, ToolbarGroup, ToolbarSeparator } from "@kopexa/toolbar";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
UndoRedoButton
|
|
4
|
+
} from "./chunk-2SI7MRAE.mjs";
|
|
2
5
|
import {
|
|
3
6
|
TableButton
|
|
4
7
|
} from "./chunk-VX3HSJ76.mjs";
|
|
@@ -8,31 +11,31 @@ import {
|
|
|
8
11
|
import {
|
|
9
12
|
canSetTextAlign
|
|
10
13
|
} from "./chunk-IQERE7KP.mjs";
|
|
11
|
-
import {
|
|
12
|
-
UndoRedoButton
|
|
13
|
-
} from "./chunk-2SI7MRAE.mjs";
|
|
14
14
|
import {
|
|
15
15
|
ListDropdownMenu
|
|
16
16
|
} from "./chunk-Q7DFJ5NI.mjs";
|
|
17
|
-
import {
|
|
18
|
-
ColorHighlightPopover
|
|
19
|
-
} from "./chunk-XL5FS7LN.mjs";
|
|
20
17
|
import {
|
|
21
18
|
HeadingDropdownMenu
|
|
22
19
|
} from "./chunk-V6TAZMQN.mjs";
|
|
23
20
|
import {
|
|
24
|
-
|
|
25
|
-
} from "./chunk-
|
|
21
|
+
ColorHighlightPopover
|
|
22
|
+
} from "./chunk-C5RQWJKE.mjs";
|
|
23
|
+
import {
|
|
24
|
+
BlockquoteButton
|
|
25
|
+
} from "./chunk-W2FLOOJ6.mjs";
|
|
26
26
|
import {
|
|
27
27
|
MarkButton,
|
|
28
28
|
canToggleMark
|
|
29
29
|
} from "./chunk-LNVWG34E.mjs";
|
|
30
|
+
import {
|
|
31
|
+
LinkPopover
|
|
32
|
+
} from "./chunk-7VGROP26.mjs";
|
|
30
33
|
import {
|
|
31
34
|
CodeBlockButton
|
|
32
35
|
} from "./chunk-OEVR5N7X.mjs";
|
|
33
36
|
import {
|
|
34
|
-
|
|
35
|
-
} from "./chunk-
|
|
37
|
+
useTiptapEditor
|
|
38
|
+
} from "./chunk-P55PLOHR.mjs";
|
|
36
39
|
import {
|
|
37
40
|
useEditorUIContext
|
|
38
41
|
} from "./chunk-REJEJXOZ.mjs";
|
|
@@ -42,9 +45,6 @@ import {
|
|
|
42
45
|
import {
|
|
43
46
|
useWindowSize
|
|
44
47
|
} from "./chunk-DT7ML2P4.mjs";
|
|
45
|
-
import {
|
|
46
|
-
useTiptapEditor
|
|
47
|
-
} from "./chunk-P55PLOHR.mjs";
|
|
48
48
|
|
|
49
49
|
// src/presets/basic/editor-header.tsx
|
|
50
50
|
import { MoreVerticalIcon } from "@kopexa/icons";
|