neuphlo-editor 2.0.0 → 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 +51 -21
- 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 +52 -22
- 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({
|
|
@@ -1349,6 +1350,7 @@ var ImageBlockMenu = ({ editor, getPos, appendTo }) => {
|
|
|
1349
1350
|
if (!ctx.editor) return { isVisible: false, align: "center", width: 100 };
|
|
1350
1351
|
const { state } = ctx.editor;
|
|
1351
1352
|
const { selection } = state;
|
|
1353
|
+
if (!ctx.editor.isEditable) return { isVisible: false, align: "center", width: 100 };
|
|
1352
1354
|
const isNodeSel = selection instanceof NodeSelection3;
|
|
1353
1355
|
const isThisNode = isNodeSel && selection.from === getPos();
|
|
1354
1356
|
const visible = isThisNode;
|
|
@@ -1482,13 +1484,14 @@ var ImageUploader = ({ onUpload, editor }) => {
|
|
|
1482
1484
|
const [loading, setLoading] = useState6(false);
|
|
1483
1485
|
const [draggedInside, setDraggedInside] = useState6(false);
|
|
1484
1486
|
const fileInputRef = useRef5(null);
|
|
1487
|
+
const imageExtension = editor.extensionManager.extensions.find(
|
|
1488
|
+
(ext) => ext.name === "imageBlock"
|
|
1489
|
+
);
|
|
1490
|
+
const browseAssets = imageExtension?.options?.browseAssets;
|
|
1485
1491
|
const uploadFile = useCallback5(
|
|
1486
1492
|
async (file) => {
|
|
1487
1493
|
setLoading(true);
|
|
1488
1494
|
try {
|
|
1489
|
-
const imageExtension = editor.extensionManager.extensions.find(
|
|
1490
|
-
(ext) => ext.name === "imageBlock"
|
|
1491
|
-
);
|
|
1492
1495
|
const uploadImage = imageExtension?.options?.uploadImage;
|
|
1493
1496
|
if (uploadImage) {
|
|
1494
1497
|
const url = await uploadImage(file);
|
|
@@ -1502,7 +1505,7 @@ var ImageUploader = ({ onUpload, editor }) => {
|
|
|
1502
1505
|
setLoading(false);
|
|
1503
1506
|
}
|
|
1504
1507
|
},
|
|
1505
|
-
[
|
|
1508
|
+
[imageExtension, onUpload]
|
|
1506
1509
|
);
|
|
1507
1510
|
const handleUploadClick = useCallback5(() => {
|
|
1508
1511
|
fileInputRef.current?.click();
|
|
@@ -1553,19 +1556,34 @@ var ImageUploader = ({ onUpload, editor }) => {
|
|
|
1553
1556
|
/* @__PURE__ */ jsx9(IconPhoto2, { size: 48, className: "nph-image-uploader__icon" }),
|
|
1554
1557
|
/* @__PURE__ */ jsxs9("div", { className: "nph-image-uploader__content", children: [
|
|
1555
1558
|
/* @__PURE__ */ jsx9("div", { className: "nph-image-uploader__text", children: draggedInside ? "Drop image here" : "Drag and drop or" }),
|
|
1556
|
-
/* @__PURE__ */
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
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
|
+
] })
|
|
1569
1587
|
] }),
|
|
1570
1588
|
/* @__PURE__ */ jsx9(
|
|
1571
1589
|
"input",
|
|
@@ -1686,13 +1704,14 @@ var ImageBlockView = (props) => {
|
|
|
1686
1704
|
position: "relative"
|
|
1687
1705
|
});
|
|
1688
1706
|
if (!src || src === "") {
|
|
1707
|
+
if (!editor.isEditable) return /* @__PURE__ */ jsx11(NodeViewWrapper, {});
|
|
1689
1708
|
return /* @__PURE__ */ jsx11(NodeViewWrapper, { style: { width: "100%", marginTop: "0.5rem", marginBottom: "0.5rem" }, children: /* @__PURE__ */ jsx11("div", { ref: imageWrapperRef, children: /* @__PURE__ */ jsx11(ImageUploader, { onUpload: handleUpload, editor }) }) });
|
|
1690
1709
|
}
|
|
1691
1710
|
if (loading) {
|
|
1692
1711
|
return /* @__PURE__ */ jsx11(NodeViewWrapper, { style: getWrapperStyle(), children: /* @__PURE__ */ jsx11("div", { ref: imageWrapperRef, children: /* @__PURE__ */ jsx11(ImageBlockLoading, {}) }) });
|
|
1693
1712
|
}
|
|
1694
1713
|
return /* @__PURE__ */ jsx11(NodeViewWrapper, { style: getWrapperStyle(), children: /* @__PURE__ */ jsxs11("div", { contentEditable: false, ref: imageWrapperRef, style: getContentStyle(), children: [
|
|
1695
|
-
/* @__PURE__ */ jsx11(ImageResizeHandle, { onResize: handleResize, currentWidth: width, children: /* @__PURE__ */ jsx11(
|
|
1714
|
+
editor.isEditable ? /* @__PURE__ */ jsx11(ImageResizeHandle, { onResize: handleResize, currentWidth: width, children: /* @__PURE__ */ jsx11(
|
|
1696
1715
|
"img",
|
|
1697
1716
|
{
|
|
1698
1717
|
src,
|
|
@@ -1700,8 +1719,15 @@ var ImageBlockView = (props) => {
|
|
|
1700
1719
|
onClick,
|
|
1701
1720
|
className: "nph-image-block"
|
|
1702
1721
|
}
|
|
1703
|
-
) })
|
|
1704
|
-
|
|
1722
|
+
) }) : /* @__PURE__ */ jsx11(
|
|
1723
|
+
"img",
|
|
1724
|
+
{
|
|
1725
|
+
src,
|
|
1726
|
+
alt: alt || "",
|
|
1727
|
+
className: "nph-image-block"
|
|
1728
|
+
}
|
|
1729
|
+
),
|
|
1730
|
+
editor.isEditable && /* @__PURE__ */ jsx11(ImageBlockMenu, { editor, getPos, appendTo: imageWrapperRef })
|
|
1705
1731
|
] }) });
|
|
1706
1732
|
};
|
|
1707
1733
|
|
|
@@ -1729,6 +1755,7 @@ var VideoBlockMenu = ({ editor, getPos }) => {
|
|
|
1729
1755
|
if (!ctx.editor) return { isVisible: false, align: "center", width: 100 };
|
|
1730
1756
|
const { state } = ctx.editor;
|
|
1731
1757
|
const { selection } = state;
|
|
1758
|
+
if (!ctx.editor.isEditable) return { isVisible: false, align: "center", width: 100 };
|
|
1732
1759
|
const isNodeSel = selection instanceof NodeSelection4;
|
|
1733
1760
|
const isThisNode = isNodeSel && selection.from === getPos();
|
|
1734
1761
|
let currentAlign = "center";
|
|
@@ -1898,6 +1925,7 @@ var VideoBlockView = (props) => {
|
|
|
1898
1925
|
}
|
|
1899
1926
|
};
|
|
1900
1927
|
if (!src || src === "") {
|
|
1928
|
+
if (!editor.isEditable) return /* @__PURE__ */ jsx13(NodeViewWrapper2, {});
|
|
1901
1929
|
return /* @__PURE__ */ jsx13(NodeViewWrapper2, { style: getWrapperStyle(), children: /* @__PURE__ */ jsx13("div", { ref: wrapperRef, children: /* @__PURE__ */ jsxs13("div", { className: "nph-video-input", children: [
|
|
1902
1930
|
/* @__PURE__ */ jsx13("div", { className: "nph-video-input__icon", children: /* @__PURE__ */ jsx13(IconVideo2, { size: 24 }) }),
|
|
1903
1931
|
/* @__PURE__ */ jsxs13("div", { className: "nph-video-input__content", children: [
|
|
@@ -1950,7 +1978,7 @@ var VideoBlockView = (props) => {
|
|
|
1950
1978
|
}
|
|
1951
1979
|
)
|
|
1952
1980
|
] }),
|
|
1953
|
-
/* @__PURE__ */ jsx13(VideoBlockMenu, { editor, getPos })
|
|
1981
|
+
editor.isEditable && /* @__PURE__ */ jsx13(VideoBlockMenu, { editor, getPos })
|
|
1954
1982
|
]
|
|
1955
1983
|
}
|
|
1956
1984
|
) });
|
|
@@ -2679,6 +2707,7 @@ function Editor5({
|
|
|
2679
2707
|
onUpdate,
|
|
2680
2708
|
onCreate,
|
|
2681
2709
|
uploadImage,
|
|
2710
|
+
browseAssets,
|
|
2682
2711
|
collaboration,
|
|
2683
2712
|
mentionOptions,
|
|
2684
2713
|
referenceOptions,
|
|
@@ -2751,6 +2780,7 @@ function Editor5({
|
|
|
2751
2780
|
extensions: [
|
|
2752
2781
|
...extension_kit_default({
|
|
2753
2782
|
uploadImage,
|
|
2783
|
+
browseAssets,
|
|
2754
2784
|
collaboration,
|
|
2755
2785
|
imageBlockView: ImageBlockView,
|
|
2756
2786
|
videoBlockView: VideoBlockView,
|