@weavour/react 0.1.8 → 0.1.12
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/README.md +16 -0
- package/dist/index.js +8 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,3 +26,19 @@ Use `enableOrganizationBlocks={false}` to hide organization-block saving and reu
|
|
|
26
26
|
The prop updates live without remounting. It defaults to enabled for organization
|
|
27
27
|
mounts; the saved dashboard disable remains authoritative. Existing email content
|
|
28
28
|
and saved blocks are retained. See the core SDK reference for full configuration.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Optional usage collection (0.1.12)
|
|
32
|
+
|
|
33
|
+
`enableAnalytics` defaults to true. Pass `enableAnalytics: false` at mount or in
|
|
34
|
+
`editorConfig`, call `updateConfig({ enableAnalytics: false })`, or set the React
|
|
35
|
+
prop to suppress browser usage observations. This does not change operational
|
|
36
|
+
counts of successfully created templates. Dashboard and website previews do not
|
|
37
|
+
create embedded visits.
|
|
38
|
+
|
|
39
|
+
The hosted iframe collects visible, usable edit and readonly visits, with a new
|
|
40
|
+
visit after 30 minutes without activity. Hidden tabs and timers do not create
|
|
41
|
+
activity. Preview mode pauses collection. Identity is scoped to the workspace
|
|
42
|
+
resolved from the editor key and the supplied organization/user namespaces. Pass
|
|
43
|
+
individual stable user IDs for useful people counts; an organization-only mount
|
|
44
|
+
normalizes to a personal user namespace and cannot distinguish people.
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// packages/react/src/index.tsx
|
|
4
4
|
import { forwardRef, createElement, useEffect, useImperativeHandle, useRef } from "react";
|
|
5
5
|
import { mount, EditorError } from "@weavour/editor";
|
|
6
|
-
var liveKeys = ["mode", "theme", "locale", "mergeTags", "displayConditions", "allowedBlocks", "enableAi", "enableTemplates", "enableAutosave", "enableEmailAudit", "enableOrganizationBlocks", "enableTestEmail"];
|
|
6
|
+
var liveKeys = ["enableAnalytics", "mode", "theme", "locale", "mergeTags", "displayConditions", "allowedBlocks", "enableAi", "enableTemplates", "enableAutosave", "enableEmailAudit", "enableOrganizationBlocks", "enableTestEmail"];
|
|
7
7
|
var mountKeys = ["editorKey", "userId", "organizationId", "document", "emailDocument", "subject", "preheader", "draftId", "editorUrl", "apiUrl", "editorConfig", "demo"];
|
|
8
8
|
var WeavourEditor = forwardRef(function WeavourEditor2(props, ref) {
|
|
9
9
|
const container = useRef(null);
|
|
@@ -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.12",
|
|
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.12"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "^18.3.1 || ^19.0.0"
|