@kopexa/tiptap 17.1.0 → 17.2.1
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-EBFGDPWY.mjs → chunk-3ZPLSXTZ.mjs} +2 -2
- package/dist/{chunk-EH2JHHGJ.mjs → chunk-6552DQWB.mjs} +2 -4
- 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-DSBJFMHK.mjs +38 -0
- package/dist/chunk-EAAQE5ZV.mjs +283 -0
- package/dist/{chunk-Z6GJ2GKW.mjs → chunk-FDPXD6VC.mjs} +10 -10
- package/dist/chunk-HTJ2RXOG.mjs +32 -0
- package/dist/chunk-KYLBKQ2E.mjs +203 -0
- package/dist/chunk-N3JE67CS.mjs +81 -0
- package/dist/{chunk-KTIMXK5V.mjs → chunk-NSYSECKW.mjs} +3 -3
- package/dist/{chunk-IY4SCXZN.mjs → chunk-SCYH6NOA.mjs} +109 -8
- package/dist/{chunk-DSK3HK5D.mjs → chunk-UVHVCION.mjs} +14 -4
- package/dist/{chunk-MYO2CUDR.mjs → chunk-VF3G2URZ.mjs} +10 -2
- package/dist/{chunk-B6SP3ADV.mjs → chunk-VFCZOVWU.mjs} +5 -5
- package/dist/chunk-VRQ6OSAZ.mjs +76 -0
- package/dist/chunk-Z365KVQY.mjs +34 -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 +255 -0
- package/dist/extensions/image/image-view.mjs +12 -0
- package/dist/extensions/image/index.d.mts +29 -0
- package/dist/extensions/image/index.d.ts +29 -0
- package/dist/extensions/image/index.js +282 -0
- package/dist/extensions/image/index.mjs +16 -0
- package/dist/extensions/image/messages.d.mts +28 -0
- package/dist/extensions/image/messages.d.ts +28 -0
- package/dist/extensions/image/messages.js +57 -0
- package/dist/extensions/image/messages.mjs +7 -0
- package/dist/extensions/image-upload/image-upload-view.d.mts +12 -0
- package/dist/extensions/image-upload/image-upload-view.d.ts +12 -0
- package/dist/extensions/image-upload/image-upload-view.js +338 -0
- package/dist/extensions/image-upload/image-upload-view.mjs +12 -0
- package/dist/extensions/image-upload/index.d.mts +46 -0
- package/dist/extensions/image-upload/index.d.ts +46 -0
- package/dist/extensions/image-upload/index.js +414 -0
- package/dist/extensions/image-upload/index.mjs +16 -0
- package/dist/extensions/image-upload/messages.d.mts +32 -0
- package/dist/extensions/image-upload/messages.d.ts +32 -0
- package/dist/extensions/image-upload/messages.js +61 -0
- package/dist/extensions/image-upload/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 +972 -237
- package/dist/hooks/use-create-editor.mjs +15 -8
- package/dist/index.d.mts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +1427 -631
- package/dist/index.mjs +43 -23
- package/dist/presets/basic/editor-header.mjs +8 -8
- package/dist/presets/basic/index.d.mts +2 -0
- package/dist/presets/basic/index.d.ts +2 -0
- package/dist/presets/basic/index.js +1367 -634
- package/dist/presets/basic/index.mjs +29 -22
- 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 +2 -4
- package/dist/ui/slash-dropdown-menu/index.mjs +4 -4
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.js +2 -4
- package/dist/ui/slash-dropdown-menu/slash-dropdown-menu.mjs +4 -4
- package/dist/ui/slash-dropdown-menu/use-slash-dropdown-menu.js +2 -4
- 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 +26 -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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useSlashDropdownMenu
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6552DQWB.mjs";
|
|
5
5
|
import {
|
|
6
6
|
SuggestionMenu
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZYFCSR3E.mjs";
|
|
8
8
|
import {
|
|
9
9
|
filterSuggestionItems
|
|
10
10
|
} from "./chunk-CNVACBGT.mjs";
|
|
@@ -349,11 +349,9 @@ Continue writing from where the text above ends. Write ONLY ONE SENTENCE. DONT R
|
|
|
349
349
|
},
|
|
350
350
|
// Upload
|
|
351
351
|
image: {
|
|
352
|
-
check: (editor) => isNodeInSchema("
|
|
352
|
+
check: (editor) => isNodeInSchema("imageUpload", editor),
|
|
353
353
|
action: ({ editor }) => {
|
|
354
|
-
editor.chain().focus().
|
|
355
|
-
type: "imageUpload"
|
|
356
|
-
}).run();
|
|
354
|
+
editor.chain().focus().setImageUpload().run();
|
|
357
355
|
}
|
|
358
356
|
}
|
|
359
357
|
};
|
|
@@ -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",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/extensions/image-upload/messages.ts
|
|
4
|
+
import { defineMessages } from "react-intl";
|
|
5
|
+
var messages = defineMessages({
|
|
6
|
+
upload_error: {
|
|
7
|
+
id: "editor.image.upload_error",
|
|
8
|
+
defaultMessage: "Failed to upload image"
|
|
9
|
+
},
|
|
10
|
+
uploading: {
|
|
11
|
+
id: "editor.image.uploading",
|
|
12
|
+
defaultMessage: "Uploading..."
|
|
13
|
+
},
|
|
14
|
+
upload_placeholder: {
|
|
15
|
+
id: "editor.image.upload_placeholder",
|
|
16
|
+
defaultMessage: "Click to upload or drag & drop"
|
|
17
|
+
},
|
|
18
|
+
upload_hint: {
|
|
19
|
+
id: "editor.image.upload_hint",
|
|
20
|
+
defaultMessage: "PNG, JPG, GIF, WebP, SVG"
|
|
21
|
+
},
|
|
22
|
+
click_to_retry: {
|
|
23
|
+
id: "editor.image.click_to_retry",
|
|
24
|
+
defaultMessage: "Click to try again"
|
|
25
|
+
},
|
|
26
|
+
files_not_supported: {
|
|
27
|
+
id: "editor.image.files_not_supported",
|
|
28
|
+
defaultMessage: "File upload is not configured"
|
|
29
|
+
},
|
|
30
|
+
remove: {
|
|
31
|
+
id: "editor.image.remove",
|
|
32
|
+
defaultMessage: "Remove"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
messages
|
|
38
|
+
};
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
messages
|
|
4
|
+
} from "./chunk-DSBJFMHK.mjs";
|
|
5
|
+
import {
|
|
6
|
+
useEditorFile
|
|
7
|
+
} from "./chunk-VRQ6OSAZ.mjs";
|
|
8
|
+
|
|
9
|
+
// src/extensions/image-upload/image-upload-view.tsx
|
|
10
|
+
import { IconButton } from "@kopexa/button";
|
|
11
|
+
import {
|
|
12
|
+
AlertCircleIcon,
|
|
13
|
+
ImageIcon,
|
|
14
|
+
TrashIcon,
|
|
15
|
+
UploadIcon
|
|
16
|
+
} from "@kopexa/icons";
|
|
17
|
+
import { imagePlaceholder } from "@kopexa/theme";
|
|
18
|
+
import {
|
|
19
|
+
NodeViewWrapper,
|
|
20
|
+
useEditorState
|
|
21
|
+
} from "@tiptap/react";
|
|
22
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
23
|
+
import { useIntl } from "react-intl";
|
|
24
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
function ImageUploadNodeView({ editor, node, getPos }) {
|
|
26
|
+
const intl = useIntl();
|
|
27
|
+
const fileHandler = useEditorFile();
|
|
28
|
+
const isEditable = useEditorState({
|
|
29
|
+
editor,
|
|
30
|
+
selector: ({ editor: e }) => {
|
|
31
|
+
var _a;
|
|
32
|
+
return (_a = e == null ? void 0 : e.isEditable) != null ? _a : false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const [uploadState, setUploadState] = useState("idle");
|
|
36
|
+
const [uploadProgress, setUploadProgress] = useState(0);
|
|
37
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
38
|
+
const fileInputRef = useRef(null);
|
|
39
|
+
const handleRemove = useCallback(() => {
|
|
40
|
+
const pos = getPos();
|
|
41
|
+
if (pos === void 0) return;
|
|
42
|
+
editor.commands.deleteRange({
|
|
43
|
+
from: pos,
|
|
44
|
+
to: pos + node.nodeSize
|
|
45
|
+
});
|
|
46
|
+
}, [editor, getPos, node.nodeSize]);
|
|
47
|
+
const handleFileSelect = useCallback(
|
|
48
|
+
async (file) => {
|
|
49
|
+
if (!fileHandler) return;
|
|
50
|
+
const pos = getPos();
|
|
51
|
+
if (pos === void 0) return;
|
|
52
|
+
setUploadState("uploading");
|
|
53
|
+
setUploadProgress(0);
|
|
54
|
+
try {
|
|
55
|
+
const ref = await fileHandler.upload(file, (percent) => {
|
|
56
|
+
setUploadProgress(percent);
|
|
57
|
+
});
|
|
58
|
+
const currentPos = getPos();
|
|
59
|
+
if (currentPos === void 0) return;
|
|
60
|
+
editor.chain().focus().deleteRange({ from: currentPos, to: currentPos + node.nodeSize }).insertContentAt(currentPos, {
|
|
61
|
+
type: "image",
|
|
62
|
+
attrs: {
|
|
63
|
+
src: ref,
|
|
64
|
+
alt: file.name.replace(/\.[^/.]+$/, ""),
|
|
65
|
+
title: file.name.replace(/\.[^/.]+$/, "")
|
|
66
|
+
}
|
|
67
|
+
}).run();
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("[ImageUpload] Upload failed:", error);
|
|
70
|
+
setUploadState("error");
|
|
71
|
+
setUploadProgress(0);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
[fileHandler, editor, getPos, node.nodeSize]
|
|
75
|
+
);
|
|
76
|
+
const handleInputChange = useCallback(
|
|
77
|
+
(e) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
80
|
+
if (file) {
|
|
81
|
+
handleFileSelect(file);
|
|
82
|
+
}
|
|
83
|
+
e.target.value = "";
|
|
84
|
+
},
|
|
85
|
+
[handleFileSelect]
|
|
86
|
+
);
|
|
87
|
+
const handleDrop = useCallback(
|
|
88
|
+
(e) => {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
e.stopPropagation();
|
|
91
|
+
setIsDragOver(false);
|
|
92
|
+
const file = e.dataTransfer.files[0];
|
|
93
|
+
if (file == null ? void 0 : file.type.startsWith("image/")) {
|
|
94
|
+
handleFileSelect(file);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
[handleFileSelect]
|
|
98
|
+
);
|
|
99
|
+
const handleDragOver = useCallback((e) => {
|
|
100
|
+
e.preventDefault();
|
|
101
|
+
e.stopPropagation();
|
|
102
|
+
}, []);
|
|
103
|
+
const handleDragEnter = useCallback((e) => {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
setIsDragOver(true);
|
|
107
|
+
}, []);
|
|
108
|
+
const handleDragLeave = useCallback((e) => {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
e.stopPropagation();
|
|
111
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
112
|
+
setIsDragOver(false);
|
|
113
|
+
}
|
|
114
|
+
}, []);
|
|
115
|
+
const handleClick = useCallback(() => {
|
|
116
|
+
var _a;
|
|
117
|
+
if (uploadState === "idle" || uploadState === "error") {
|
|
118
|
+
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
119
|
+
}
|
|
120
|
+
}, [uploadState]);
|
|
121
|
+
const styles = useMemo(
|
|
122
|
+
() => imagePlaceholder({
|
|
123
|
+
size: "md",
|
|
124
|
+
variant: isDragOver ? "default" : void 0
|
|
125
|
+
}),
|
|
126
|
+
[isDragOver]
|
|
127
|
+
);
|
|
128
|
+
const errorStyles = useMemo(
|
|
129
|
+
() => imagePlaceholder({ size: "md", variant: "error" }),
|
|
130
|
+
[]
|
|
131
|
+
);
|
|
132
|
+
const uploadingStyles = useMemo(
|
|
133
|
+
() => imagePlaceholder({ size: "md", variant: "uploading" }),
|
|
134
|
+
[]
|
|
135
|
+
);
|
|
136
|
+
const disabledStyles = useMemo(
|
|
137
|
+
() => imagePlaceholder({ size: "md", variant: "disabled" }),
|
|
138
|
+
[]
|
|
139
|
+
);
|
|
140
|
+
if (!fileHandler) {
|
|
141
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ jsx("div", { className: disabledStyles.root(), children: /* @__PURE__ */ jsxs("div", { className: disabledStyles.content(), children: [
|
|
142
|
+
/* @__PURE__ */ jsx(ImageIcon, { className: disabledStyles.icon() }),
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: disabledStyles.text(), children: intl.formatMessage(messages.files_not_supported) }),
|
|
144
|
+
isEditable && /* @__PURE__ */ jsx(
|
|
145
|
+
IconButton,
|
|
146
|
+
{
|
|
147
|
+
size: "sm",
|
|
148
|
+
variant: "ghost",
|
|
149
|
+
onClick: handleRemove,
|
|
150
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
151
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-4" })
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
] }) }) });
|
|
155
|
+
}
|
|
156
|
+
if (uploadState === "uploading") {
|
|
157
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ jsx("div", { className: uploadingStyles.root(), children: /* @__PURE__ */ jsxs("div", { className: uploadingStyles.content(), children: [
|
|
158
|
+
/* @__PURE__ */ jsxs("div", { className: "relative size-12", children: [
|
|
159
|
+
/* @__PURE__ */ jsxs(
|
|
160
|
+
"svg",
|
|
161
|
+
{
|
|
162
|
+
className: "size-12 -rotate-90",
|
|
163
|
+
viewBox: "0 0 36 36",
|
|
164
|
+
"aria-hidden": "true",
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
"circle",
|
|
168
|
+
{
|
|
169
|
+
cx: "18",
|
|
170
|
+
cy: "18",
|
|
171
|
+
r: "16",
|
|
172
|
+
fill: "none",
|
|
173
|
+
className: "stroke-muted",
|
|
174
|
+
strokeWidth: "2"
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"circle",
|
|
179
|
+
{
|
|
180
|
+
cx: "18",
|
|
181
|
+
cy: "18",
|
|
182
|
+
r: "16",
|
|
183
|
+
fill: "none",
|
|
184
|
+
className: "stroke-primary",
|
|
185
|
+
strokeWidth: "2",
|
|
186
|
+
strokeDasharray: 100,
|
|
187
|
+
strokeDashoffset: 100 - uploadProgress,
|
|
188
|
+
strokeLinecap: "round"
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsxs("span", { className: "absolute inset-0 flex items-center justify-center text-xs font-medium", children: [
|
|
195
|
+
uploadProgress,
|
|
196
|
+
"%"
|
|
197
|
+
] })
|
|
198
|
+
] }),
|
|
199
|
+
/* @__PURE__ */ jsx("span", { className: uploadingStyles.text(), children: intl.formatMessage(messages.uploading) })
|
|
200
|
+
] }) }) });
|
|
201
|
+
}
|
|
202
|
+
if (uploadState === "error") {
|
|
203
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ jsxs("div", { className: errorStyles.root(), onClick: handleClick, children: [
|
|
204
|
+
/* @__PURE__ */ jsxs("div", { className: errorStyles.content(), children: [
|
|
205
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { className: errorStyles.icon() }),
|
|
206
|
+
/* @__PURE__ */ jsx("span", { className: errorStyles.text(), children: intl.formatMessage(messages.upload_error) }),
|
|
207
|
+
/* @__PURE__ */ jsx("span", { className: errorStyles.hint(), children: intl.formatMessage(messages.click_to_retry) })
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
"input",
|
|
211
|
+
{
|
|
212
|
+
ref: fileInputRef,
|
|
213
|
+
type: "file",
|
|
214
|
+
accept: "image/*",
|
|
215
|
+
className: "hidden",
|
|
216
|
+
onChange: handleInputChange
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
isEditable && /* @__PURE__ */ jsx(
|
|
220
|
+
IconButton,
|
|
221
|
+
{
|
|
222
|
+
size: "sm",
|
|
223
|
+
variant: "ghost",
|
|
224
|
+
className: errorStyles.removeButton(),
|
|
225
|
+
onClick: (e) => {
|
|
226
|
+
e.stopPropagation();
|
|
227
|
+
handleRemove();
|
|
228
|
+
},
|
|
229
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
230
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-3.5" })
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
] }) });
|
|
234
|
+
}
|
|
235
|
+
return /* @__PURE__ */ jsx(NodeViewWrapper, { className: "my-4", "data-type": "image-upload", children: /* @__PURE__ */ jsxs(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
className: `${styles.root()} ${isDragOver ? "border-primary bg-primary/10" : ""}`,
|
|
239
|
+
onClick: handleClick,
|
|
240
|
+
onDrop: handleDrop,
|
|
241
|
+
onDragOver: handleDragOver,
|
|
242
|
+
onDragEnter: handleDragEnter,
|
|
243
|
+
onDragLeave: handleDragLeave,
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsxs("div", { className: styles.content(), children: [
|
|
246
|
+
/* @__PURE__ */ jsx(UploadIcon, { className: styles.icon() }),
|
|
247
|
+
/* @__PURE__ */ jsx("span", { className: styles.text(), children: intl.formatMessage(messages.upload_placeholder) }),
|
|
248
|
+
/* @__PURE__ */ jsx("span", { className: styles.hint(), children: intl.formatMessage(messages.upload_hint) })
|
|
249
|
+
] }),
|
|
250
|
+
/* @__PURE__ */ jsx(
|
|
251
|
+
"input",
|
|
252
|
+
{
|
|
253
|
+
ref: fileInputRef,
|
|
254
|
+
type: "file",
|
|
255
|
+
accept: "image/*",
|
|
256
|
+
className: "hidden",
|
|
257
|
+
onChange: handleInputChange
|
|
258
|
+
}
|
|
259
|
+
),
|
|
260
|
+
isEditable && /* @__PURE__ */ jsx(
|
|
261
|
+
IconButton,
|
|
262
|
+
{
|
|
263
|
+
size: "sm",
|
|
264
|
+
variant: "ghost",
|
|
265
|
+
className: styles.removeButton(),
|
|
266
|
+
onClick: (e) => {
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
handleRemove();
|
|
269
|
+
},
|
|
270
|
+
"aria-label": intl.formatMessage(messages.remove),
|
|
271
|
+
children: /* @__PURE__ */ jsx(TrashIcon, { className: "size-3.5" })
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
) });
|
|
277
|
+
}
|
|
278
|
+
var image_upload_view_default = ImageUploadNodeView;
|
|
279
|
+
|
|
280
|
+
export {
|
|
281
|
+
ImageUploadNodeView,
|
|
282
|
+
image_upload_view_default
|
|
283
|
+
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
TableButton
|
|
4
|
-
} from "./chunk-VX3HSJ76.mjs";
|
|
5
2
|
import {
|
|
6
3
|
TextAlignButton
|
|
7
4
|
} from "./chunk-GYIYX2JH.mjs";
|
|
@@ -11,28 +8,34 @@ import {
|
|
|
11
8
|
import {
|
|
12
9
|
UndoRedoButton
|
|
13
10
|
} from "./chunk-2SI7MRAE.mjs";
|
|
11
|
+
import {
|
|
12
|
+
TableButton
|
|
13
|
+
} from "./chunk-VX3HSJ76.mjs";
|
|
14
14
|
import {
|
|
15
15
|
ListDropdownMenu
|
|
16
16
|
} from "./chunk-Q7DFJ5NI.mjs";
|
|
17
17
|
import {
|
|
18
18
|
ColorHighlightPopover
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-C5RQWJKE.mjs";
|
|
20
20
|
import {
|
|
21
21
|
HeadingDropdownMenu
|
|
22
22
|
} from "./chunk-V6TAZMQN.mjs";
|
|
23
|
-
import {
|
|
24
|
-
LinkPopover
|
|
25
|
-
} from "./chunk-WKJGDCGA.mjs";
|
|
26
23
|
import {
|
|
27
24
|
MarkButton,
|
|
28
25
|
canToggleMark
|
|
29
26
|
} from "./chunk-LNVWG34E.mjs";
|
|
27
|
+
import {
|
|
28
|
+
LinkPopover
|
|
29
|
+
} from "./chunk-7VGROP26.mjs";
|
|
30
30
|
import {
|
|
31
31
|
CodeBlockButton
|
|
32
32
|
} from "./chunk-OEVR5N7X.mjs";
|
|
33
33
|
import {
|
|
34
34
|
BlockquoteButton
|
|
35
35
|
} from "./chunk-W2FLOOJ6.mjs";
|
|
36
|
+
import {
|
|
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";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
ImageNodeView
|
|
4
|
+
} from "./chunk-KYLBKQ2E.mjs";
|
|
5
|
+
|
|
6
|
+
// src/extensions/image/index.ts
|
|
7
|
+
import { Image as TiptapImage } from "@tiptap/extension-image";
|
|
8
|
+
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
9
|
+
var ImageNode = TiptapImage.extend({
|
|
10
|
+
addAttributes() {
|
|
11
|
+
var _a;
|
|
12
|
+
return {
|
|
13
|
+
...(_a = this.parent) == null ? void 0 : _a.call(this),
|
|
14
|
+
// Upload state for drag & drop / paste uploads
|
|
15
|
+
uploadState: {
|
|
16
|
+
default: null,
|
|
17
|
+
rendered: false
|
|
18
|
+
},
|
|
19
|
+
uploadProgress: {
|
|
20
|
+
default: null,
|
|
21
|
+
rendered: false
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
addNodeView() {
|
|
26
|
+
return ReactNodeViewRenderer(ImageNodeView);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
ImageNode
|
|
32
|
+
};
|