@firecms/editor 3.0.0-beta.11 → 3.0.0-beta.13
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/editor.d.ts +2 -2
- package/dist/extensions/slashCommand.d.ts +1 -2
- package/dist/index.es.js +9 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +40 -39
package/dist/editor.d.ts
CHANGED
|
@@ -15,11 +15,11 @@ export type FireCMSEditorProps = {
|
|
|
15
15
|
to: number;
|
|
16
16
|
};
|
|
17
17
|
aiController?: EditorAIController;
|
|
18
|
-
onDisabledAutocompleteClick?: () => void;
|
|
19
18
|
customComponents?: CustomEditorComponent[];
|
|
19
|
+
disabled?: boolean;
|
|
20
20
|
};
|
|
21
21
|
export type CustomEditorComponent = {
|
|
22
22
|
name: string;
|
|
23
23
|
component: React.FC;
|
|
24
24
|
};
|
|
25
|
-
export declare const FireCMSEditor: ({ content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight, handleImageUpload, aiController,
|
|
25
|
+
export declare const FireCMSEditor: ({ content, onJsonContentChange, onHtmlContentChange, onMarkdownContentChange, version, textSize, highlight, handleImageUpload, aiController, disabled }: FireCMSEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -85,8 +85,7 @@ export interface SuggestionItem {
|
|
|
85
85
|
aiController?: EditorAIController;
|
|
86
86
|
}) => void;
|
|
87
87
|
}
|
|
88
|
-
export declare const suggestion: (ref: React.MutableRefObject<any>, { upload,
|
|
88
|
+
export declare const suggestion: (ref: React.MutableRefObject<any>, { upload, aiController }: {
|
|
89
89
|
upload: UploadFn;
|
|
90
|
-
onDisabledAutocompleteClick?: () => void;
|
|
91
90
|
aiController?: EditorAIController;
|
|
92
91
|
}) => Omit<SuggestionOptions<SuggestionItem, any>, "editor">;
|
package/dist/index.es.js
CHANGED
|
@@ -1386,25 +1386,15 @@ const SlashCommand = Node.create({
|
|
|
1386
1386
|
});
|
|
1387
1387
|
const suggestion = (ref, {
|
|
1388
1388
|
upload,
|
|
1389
|
-
onDisabledAutocompleteClick,
|
|
1390
1389
|
aiController
|
|
1391
1390
|
}) => ({
|
|
1392
1391
|
items: ({
|
|
1393
1392
|
query
|
|
1394
1393
|
}) => {
|
|
1395
1394
|
const availableSuggestionItems = [...suggestionItems];
|
|
1396
|
-
if (
|
|
1395
|
+
if (aiController) {
|
|
1397
1396
|
availableSuggestionItems.push(autocompleteSuggestionItem);
|
|
1398
1397
|
}
|
|
1399
|
-
if (onDisabledAutocompleteClick) {
|
|
1400
|
-
availableSuggestionItems.push({
|
|
1401
|
-
title: "Autocomplete",
|
|
1402
|
-
description: "Add text based on the context.",
|
|
1403
|
-
searchTerms: ["ai"],
|
|
1404
|
-
icon: /* @__PURE__ */ jsx(AutoFixHighIcon, { size: 18 }),
|
|
1405
|
-
command: onDisabledAutocompleteClick
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
1398
|
return availableSuggestionItems.filter((item) => {
|
|
1409
1399
|
const inTitle = item.title.toLowerCase().startsWith(query.toLowerCase());
|
|
1410
1400
|
if (inTitle) return inTitle;
|
|
@@ -1639,6 +1629,7 @@ const CommandList = forwardRef((props, ref) => {
|
|
|
1639
1629
|
}
|
|
1640
1630
|
return t12;
|
|
1641
1631
|
});
|
|
1632
|
+
CommandList.displayName = "CommandList";
|
|
1642
1633
|
const autocompleteSuggestionItem = {
|
|
1643
1634
|
title: "Autocomplete",
|
|
1644
1635
|
description: "Add text based on the context.",
|
|
@@ -1835,7 +1826,7 @@ const FireCMSEditor = ({
|
|
|
1835
1826
|
highlight,
|
|
1836
1827
|
handleImageUpload,
|
|
1837
1828
|
aiController,
|
|
1838
|
-
|
|
1829
|
+
disabled
|
|
1839
1830
|
}) => {
|
|
1840
1831
|
const ref = React.useRef(null);
|
|
1841
1832
|
const editorRef = React.useRef(null);
|
|
@@ -1851,6 +1842,9 @@ const FireCMSEditor = ({
|
|
|
1851
1842
|
editorRef.current?.commands.setContent(content ?? "");
|
|
1852
1843
|
}
|
|
1853
1844
|
}, [version]);
|
|
1845
|
+
useEffect(() => {
|
|
1846
|
+
editorRef?.current?.setEditable(!disabled);
|
|
1847
|
+
}, [disabled]);
|
|
1854
1848
|
useEffect(() => {
|
|
1855
1849
|
if (version === void 0) return;
|
|
1856
1850
|
if (editorRef.current && version > 0) {
|
|
@@ -1919,12 +1913,12 @@ const FireCMSEditor = ({
|
|
|
1919
1913
|
},
|
|
1920
1914
|
suggestion: suggestion(ref, {
|
|
1921
1915
|
upload: handleImageUpload,
|
|
1922
|
-
aiController
|
|
1923
|
-
onDisabledAutocompleteClick
|
|
1916
|
+
aiController
|
|
1924
1917
|
})
|
|
1925
1918
|
})
|
|
1926
1919
|
], []);
|
|
1927
1920
|
return /* @__PURE__ */ jsx("div", { ref, className: "relative min-h-[300px] w-full", children: /* @__PURE__ */ jsx(EditorProvider, { content: content ?? "", extensions, editorProps: {
|
|
1921
|
+
editable: () => !disabled,
|
|
1928
1922
|
attributes: {
|
|
1929
1923
|
class: cls(proseClass, "prose-headings:font-title font-default focus:outline-none max-w-full p-12")
|
|
1930
1924
|
}
|
|
@@ -1932,6 +1926,7 @@ const FireCMSEditor = ({
|
|
|
1932
1926
|
editor: editor_0
|
|
1933
1927
|
}) => {
|
|
1934
1928
|
editorRef.current = editor_0;
|
|
1929
|
+
editor_0.setEditable(!disabled);
|
|
1935
1930
|
}, onUpdate: ({
|
|
1936
1931
|
editor: editor_1
|
|
1937
1932
|
}) => {
|