neuphlo-editor 2.0.1 → 2.1.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-P3YFYEUB.js +1351 -0
- package/dist/chunk-P3YFYEUB.js.map +1 -0
- package/dist/headless/index.js +1 -1
- package/dist/react/index.cjs +36 -17
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +37 -18
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -28,6 +28,7 @@ type NeuphloEditorProps = {
|
|
|
28
28
|
onUpdate?: EditorContentProps["onUpdate"];
|
|
29
29
|
onCreate?: EditorContentProps["onCreate"];
|
|
30
30
|
uploadImage?: (file: File) => Promise<string>;
|
|
31
|
+
browseAssets?: (onSelect: (url: string) => void) => void;
|
|
31
32
|
collaboration?: {
|
|
32
33
|
doc: any;
|
|
33
34
|
field: string;
|
|
@@ -38,7 +39,7 @@ type NeuphloEditorProps = {
|
|
|
38
39
|
slashCommand?: boolean;
|
|
39
40
|
placeholder?: string;
|
|
40
41
|
};
|
|
41
|
-
declare function Editor({ content, className, editable, immediatelyRender, showTextMenu, showSlashMenu, showImageMenu, showDragHandle, extensions, bubbleMenuExtras, onUpdate, onCreate, uploadImage, collaboration, mentionOptions, referenceOptions, slashCommand, placeholder, }: NeuphloEditorProps): react_jsx_runtime.JSX.Element;
|
|
42
|
+
declare function Editor({ content, className, editable, immediatelyRender, showTextMenu, showSlashMenu, showImageMenu, showDragHandle, extensions, bubbleMenuExtras, onUpdate, onCreate, uploadImage, browseAssets, collaboration, mentionOptions, referenceOptions, slashCommand, placeholder, }: NeuphloEditorProps): react_jsx_runtime.JSX.Element;
|
|
42
43
|
|
|
43
44
|
type ExtraRenderer = (editor: Editor$1) => ReactNode;
|
|
44
45
|
type TextMenuProps = {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ type NeuphloEditorProps = {
|
|
|
28
28
|
onUpdate?: EditorContentProps["onUpdate"];
|
|
29
29
|
onCreate?: EditorContentProps["onCreate"];
|
|
30
30
|
uploadImage?: (file: File) => Promise<string>;
|
|
31
|
+
browseAssets?: (onSelect: (url: string) => void) => void;
|
|
31
32
|
collaboration?: {
|
|
32
33
|
doc: any;
|
|
33
34
|
field: string;
|
|
@@ -38,7 +39,7 @@ type NeuphloEditorProps = {
|
|
|
38
39
|
slashCommand?: boolean;
|
|
39
40
|
placeholder?: string;
|
|
40
41
|
};
|
|
41
|
-
declare function Editor({ content, className, editable, immediatelyRender, showTextMenu, showSlashMenu, showImageMenu, showDragHandle, extensions, bubbleMenuExtras, onUpdate, onCreate, uploadImage, collaboration, mentionOptions, referenceOptions, slashCommand, placeholder, }: NeuphloEditorProps): react_jsx_runtime.JSX.Element;
|
|
42
|
+
declare function Editor({ content, className, editable, immediatelyRender, showTextMenu, showSlashMenu, showImageMenu, showDragHandle, extensions, bubbleMenuExtras, onUpdate, onCreate, uploadImage, browseAssets, collaboration, mentionOptions, referenceOptions, slashCommand, placeholder, }: NeuphloEditorProps): react_jsx_runtime.JSX.Element;
|
|
42
43
|
|
|
43
44
|
type ExtraRenderer = (editor: Editor$1) => ReactNode;
|
|
44
45
|
type TextMenuProps = {
|
package/dist/react/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
queryAtom,
|
|
20
20
|
setDragHandleCallbacks,
|
|
21
21
|
store_exports
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-P3YFYEUB.js";
|
|
23
23
|
|
|
24
24
|
// src/headless/extensions/extension-kit.ts
|
|
25
25
|
import Collaboration from "@tiptap/extension-collaboration";
|
|
@@ -110,6 +110,7 @@ var ExtensionKit = (options) => {
|
|
|
110
110
|
Underline,
|
|
111
111
|
ImageBlock.configure({
|
|
112
112
|
uploadImage: options?.uploadImage,
|
|
113
|
+
browseAssets: options?.browseAssets,
|
|
113
114
|
nodeView: options?.imageBlockView
|
|
114
115
|
}),
|
|
115
116
|
VideoBlock.configure({
|
|
@@ -1483,13 +1484,14 @@ var ImageUploader = ({ onUpload, editor }) => {
|
|
|
1483
1484
|
const [loading, setLoading] = useState6(false);
|
|
1484
1485
|
const [draggedInside, setDraggedInside] = useState6(false);
|
|
1485
1486
|
const fileInputRef = useRef5(null);
|
|
1487
|
+
const imageExtension = editor.extensionManager.extensions.find(
|
|
1488
|
+
(ext) => ext.name === "imageBlock"
|
|
1489
|
+
);
|
|
1490
|
+
const browseAssets = imageExtension?.options?.browseAssets;
|
|
1486
1491
|
const uploadFile = useCallback5(
|
|
1487
1492
|
async (file) => {
|
|
1488
1493
|
setLoading(true);
|
|
1489
1494
|
try {
|
|
1490
|
-
const imageExtension = editor.extensionManager.extensions.find(
|
|
1491
|
-
(ext) => ext.name === "imageBlock"
|
|
1492
|
-
);
|
|
1493
1495
|
const uploadImage = imageExtension?.options?.uploadImage;
|
|
1494
1496
|
if (uploadImage) {
|
|
1495
1497
|
const url = await uploadImage(file);
|
|
@@ -1503,7 +1505,7 @@ var ImageUploader = ({ onUpload, editor }) => {
|
|
|
1503
1505
|
setLoading(false);
|
|
1504
1506
|
}
|
|
1505
1507
|
},
|
|
1506
|
-
[
|
|
1508
|
+
[imageExtension, onUpload]
|
|
1507
1509
|
);
|
|
1508
1510
|
const handleUploadClick = useCallback5(() => {
|
|
1509
1511
|
fileInputRef.current?.click();
|
|
@@ -1554,19 +1556,34 @@ var ImageUploader = ({ onUpload, editor }) => {
|
|
|
1554
1556
|
/* @__PURE__ */ jsx9(IconPhoto2, { size: 48, className: "nph-image-uploader__icon" }),
|
|
1555
1557
|
/* @__PURE__ */ jsxs9("div", { className: "nph-image-uploader__content", children: [
|
|
1556
1558
|
/* @__PURE__ */ jsx9("div", { className: "nph-image-uploader__text", children: draggedInside ? "Drop image here" : "Drag and drop or" }),
|
|
1557
|
-
/* @__PURE__ */
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1559
|
+
/* @__PURE__ */ jsxs9("div", { className: "nph-image-uploader__actions", children: [
|
|
1560
|
+
/* @__PURE__ */ jsxs9(
|
|
1561
|
+
"button",
|
|
1562
|
+
{
|
|
1563
|
+
type: "button",
|
|
1564
|
+
disabled: draggedInside,
|
|
1565
|
+
onClick: handleUploadClick,
|
|
1566
|
+
className: "nph-btn nph-btn-ghost nph-btn-sm nph-image-uploader__button",
|
|
1567
|
+
children: [
|
|
1568
|
+
/* @__PURE__ */ jsx9(IconUpload2, { size: 16 }),
|
|
1569
|
+
"Upload an image"
|
|
1570
|
+
]
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
1573
|
+
browseAssets && /* @__PURE__ */ jsxs9(
|
|
1574
|
+
"button",
|
|
1575
|
+
{
|
|
1576
|
+
type: "button",
|
|
1577
|
+
disabled: draggedInside,
|
|
1578
|
+
onClick: () => browseAssets(onUpload),
|
|
1579
|
+
className: "nph-btn nph-btn-ghost nph-btn-sm nph-image-uploader__button",
|
|
1580
|
+
children: [
|
|
1581
|
+
/* @__PURE__ */ jsx9(IconPhoto2, { size: 16 }),
|
|
1582
|
+
"Browse assets"
|
|
1583
|
+
]
|
|
1584
|
+
}
|
|
1585
|
+
)
|
|
1586
|
+
] })
|
|
1570
1587
|
] }),
|
|
1571
1588
|
/* @__PURE__ */ jsx9(
|
|
1572
1589
|
"input",
|
|
@@ -2690,6 +2707,7 @@ function Editor5({
|
|
|
2690
2707
|
onUpdate,
|
|
2691
2708
|
onCreate,
|
|
2692
2709
|
uploadImage,
|
|
2710
|
+
browseAssets,
|
|
2693
2711
|
collaboration,
|
|
2694
2712
|
mentionOptions,
|
|
2695
2713
|
referenceOptions,
|
|
@@ -2762,6 +2780,7 @@ function Editor5({
|
|
|
2762
2780
|
extensions: [
|
|
2763
2781
|
...extension_kit_default({
|
|
2764
2782
|
uploadImage,
|
|
2783
|
+
browseAssets,
|
|
2765
2784
|
collaboration,
|
|
2766
2785
|
imageBlockView: ImageBlockView,
|
|
2767
2786
|
videoBlockView: VideoBlockView,
|