@weavour/react 0.1.8 → 0.1.11
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/index.js +7 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var WeavourEditor = forwardRef(function WeavourEditor2(props, ref) {
|
|
|
12
12
|
latest.current = props;
|
|
13
13
|
const initial = useRef(null);
|
|
14
14
|
const previousLive = useRef("");
|
|
15
|
+
const previousBlocks = useRef(props.customBlocks ?? props.editorConfig?.customBlocks);
|
|
15
16
|
const active = () => {
|
|
16
17
|
if (!editor.current) throw new EditorError("not_ready", "Editor is not mounted.");
|
|
17
18
|
return editor.current;
|
|
@@ -56,17 +57,21 @@ var WeavourEditor = forwardRef(function WeavourEditor2(props, ref) {
|
|
|
56
57
|
useEffect(() => {
|
|
57
58
|
const config = { mode: props.mode ?? props.editorConfig?.mode, mergeTags: props.mergeTags, displayConditions: props.displayConditions };
|
|
58
59
|
for (const key of liveKeys) if (Object.hasOwn(props, key)) Object.assign(config, { [key]: props[key] });
|
|
60
|
+
const blocks = props.customBlocks ?? props.editorConfig?.customBlocks;
|
|
61
|
+
const callbacksChanged = blocks !== previousBlocks.current;
|
|
62
|
+
if (blocks !== void 0) config.customBlocks = blocks;
|
|
59
63
|
const serialized = JSON.stringify(config);
|
|
60
|
-
if (serialized !== previousLive.current) {
|
|
64
|
+
if (serialized !== previousLive.current || callbacksChanged) {
|
|
61
65
|
try {
|
|
62
66
|
editor.current?.updateConfig(config);
|
|
63
67
|
previousLive.current = serialized;
|
|
68
|
+
previousBlocks.current = blocks;
|
|
64
69
|
} catch (error) {
|
|
65
70
|
latest.current.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
const first = initial.current;
|
|
69
|
-
if (first && mountKeys.some((key) => JSON.stringify(props[key]) !== JSON.stringify(first[key]))) {
|
|
74
|
+
if (first && mountKeys.some((key) => JSON.stringify(key === "editorConfig" ? { ...props.editorConfig, customBlocks: void 0 } : props[key]) !== JSON.stringify(key === "editorConfig" ? { ...first.editorConfig, customBlocks: void 0 } : first[key]))) {
|
|
70
75
|
latest.current.onError?.(new EditorError("invalid_config", "Mount-only props changed. Use a new React key after saving current work."));
|
|
71
76
|
}
|
|
72
77
|
});
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.11",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@weavour/editor": "0.1.
|
|
33
|
+
"@weavour/editor": "0.1.11"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "^18.3.1 || ^19.0.0"
|