dragble-react-editor 1.0.1
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/LICENSE +21 -0
- package/README.md +533 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.esm.js +304 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +310 -0
- package/dist/index.js.map +1 -0
- package/package.json +135 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useRef, useState, useMemo, useEffect, useImperativeHandle } from 'react';
|
|
3
|
+
|
|
4
|
+
const SDK_CDN_URL = "https://sdk.dragble.com/latest/dragble-sdk.min.js";
|
|
5
|
+
// Map of URL -> Promise for caching SDK loads per URL
|
|
6
|
+
const sdkLoadPromises = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Get the SDK URL to use.
|
|
9
|
+
* @param customUrl - Optional custom SDK URL override
|
|
10
|
+
* @param sdkVersion - Optional SDK version to load
|
|
11
|
+
* @returns The SDK URL to load
|
|
12
|
+
*/
|
|
13
|
+
function getSDKUrl(customUrl, sdkVersion) {
|
|
14
|
+
if (customUrl && sdkVersion !== undefined) {
|
|
15
|
+
console.warn("[DragbleEditor] sdkVersion is ignored when sdkUrl is provided.");
|
|
16
|
+
}
|
|
17
|
+
return customUrl ?? `https://sdk.dragble.com/${sdkVersion ?? "latest"}/dragble-sdk.min.js`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create an SDK module from the global dragble object.
|
|
21
|
+
* The UMD bundle exposes window.DragbleSDK (named exports) and
|
|
22
|
+
* window.dragble (singleton). Use DragbleSDK.createEditor for
|
|
23
|
+
* multi-instance support, falling back to manual instantiation.
|
|
24
|
+
*/
|
|
25
|
+
function createSDKModuleFromGlobal() {
|
|
26
|
+
const globalSDK = window.DragbleSDK;
|
|
27
|
+
const globalDragble = window.dragble;
|
|
28
|
+
// Prefer the named export createEditor from the UMD module
|
|
29
|
+
const factoryFn = globalSDK?.createEditor ||
|
|
30
|
+
globalDragble?.createEditor ||
|
|
31
|
+
((config) => {
|
|
32
|
+
const instance = new globalDragble.constructor();
|
|
33
|
+
instance.init(config);
|
|
34
|
+
return instance;
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
dragble: globalDragble,
|
|
38
|
+
createEditor: factoryFn,
|
|
39
|
+
DragbleSDK: globalSDK?.DragbleSDK || globalDragble?.constructor,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Load the SDK from a URL.
|
|
44
|
+
* Supports custom SDK URLs for enterprise self-hosted or specific versions.
|
|
45
|
+
* @param customUrl - Optional custom SDK URL
|
|
46
|
+
*/
|
|
47
|
+
function loadSDK(customUrl, sdkVersion) {
|
|
48
|
+
const sdkUrl = getSDKUrl(customUrl, sdkVersion);
|
|
49
|
+
// Check cache for this specific URL
|
|
50
|
+
const cachedPromise = sdkLoadPromises.get(sdkUrl);
|
|
51
|
+
if (cachedPromise)
|
|
52
|
+
return cachedPromise;
|
|
53
|
+
// Check if already loaded globally (only for default URL to avoid conflicts)
|
|
54
|
+
if (sdkUrl === SDK_CDN_URL && typeof window !== "undefined" && window.dragble) {
|
|
55
|
+
return Promise.resolve(createSDKModuleFromGlobal());
|
|
56
|
+
}
|
|
57
|
+
return loadSDKScript(sdkUrl);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Load the SDK script from a specific URL.
|
|
61
|
+
* Each unique URL is cached separately to support multiple SDK sources.
|
|
62
|
+
* @param sdkUrl - The SDK URL to load
|
|
63
|
+
*/
|
|
64
|
+
function loadSDKScript(sdkUrl) {
|
|
65
|
+
// Check cache for this specific URL
|
|
66
|
+
const cachedPromise = sdkLoadPromises.get(sdkUrl);
|
|
67
|
+
if (cachedPromise)
|
|
68
|
+
return cachedPromise;
|
|
69
|
+
const loadPromise = new Promise((resolve, reject) => {
|
|
70
|
+
const script = document.createElement("script");
|
|
71
|
+
script.src = sdkUrl;
|
|
72
|
+
script.async = true;
|
|
73
|
+
script.onload = () => {
|
|
74
|
+
if (window.dragble) {
|
|
75
|
+
// Resolve with SDK module interface
|
|
76
|
+
resolve(createSDKModuleFromGlobal());
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
sdkLoadPromises.delete(sdkUrl);
|
|
80
|
+
reject(new Error("Failed to load Dragble SDK - createEditor not found"));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
script.onerror = () => {
|
|
84
|
+
sdkLoadPromises.delete(sdkUrl);
|
|
85
|
+
reject(new Error(`Failed to load Dragble SDK from ${sdkUrl}`));
|
|
86
|
+
};
|
|
87
|
+
document.head.appendChild(script);
|
|
88
|
+
});
|
|
89
|
+
// Cache the promise for this URL
|
|
90
|
+
sdkLoadPromises.set(sdkUrl, loadPromise);
|
|
91
|
+
return loadPromise;
|
|
92
|
+
}
|
|
93
|
+
const DragbleEditor = forwardRef((props, ref) => {
|
|
94
|
+
const { editorKey, design, editorMode, contentType, options = {}, popup, collaboration, user, designMode, height, callbacks, className, style, minHeight = "600px", sdkUrl, sdkVersion, editorVersion, editorUrl, onReady, onLoad, onChange, onError, onComment, } = props;
|
|
95
|
+
const containerRef = useRef(null);
|
|
96
|
+
const [editor, setEditor] = useState(null);
|
|
97
|
+
const [hasLoadedSDK, setHasLoadedSDK] = useState(false);
|
|
98
|
+
const [isEditorReady, setIsEditorReady] = useState(false);
|
|
99
|
+
// Refs to track current editor and cleanup for proper lifecycle management
|
|
100
|
+
const editorRef = useRef(null);
|
|
101
|
+
const cleanupRef = useRef(null);
|
|
102
|
+
// Stable container ID using useMemo
|
|
103
|
+
const containerId = useMemo(() => `dragble-editor-${Math.random().toString(36).substr(2, 9)}`, []);
|
|
104
|
+
// Ref for config to ensure async init always uses the latest config
|
|
105
|
+
const editorOptionsRef = useRef(null);
|
|
106
|
+
// Refs for callbacks to avoid dependency issues
|
|
107
|
+
const onReadyRef = useRef(onReady);
|
|
108
|
+
const onLoadRef = useRef(onLoad);
|
|
109
|
+
const onChangeRef = useRef(onChange);
|
|
110
|
+
const onErrorRef = useRef(onError);
|
|
111
|
+
const onCommentRef = useRef(onComment);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
onReadyRef.current = onReady;
|
|
114
|
+
}, [onReady]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
onLoadRef.current = onLoad;
|
|
117
|
+
}, [onLoad]);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
onChangeRef.current = onChange;
|
|
120
|
+
}, [onChange]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
onErrorRef.current = onError;
|
|
123
|
+
}, [onError]);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
onCommentRef.current = onComment;
|
|
126
|
+
}, [onComment]);
|
|
127
|
+
// Build config object (memoized for comparison)
|
|
128
|
+
const editorOptions = useMemo(() => {
|
|
129
|
+
// Build editor behavior config for module mode
|
|
130
|
+
const editorBehavior = contentType === "module"
|
|
131
|
+
? {
|
|
132
|
+
...options.editor,
|
|
133
|
+
contentType: "module",
|
|
134
|
+
minRows: 1,
|
|
135
|
+
maxRows: 1,
|
|
136
|
+
}
|
|
137
|
+
: options.editor;
|
|
138
|
+
// Build collaboration feature config
|
|
139
|
+
let featuresConfig = options.features;
|
|
140
|
+
if (collaboration !== undefined) {
|
|
141
|
+
const collaborationWithCallback = typeof collaboration === "object"
|
|
142
|
+
? {
|
|
143
|
+
...collaboration,
|
|
144
|
+
...(onCommentRef.current && {
|
|
145
|
+
onComment: onCommentRef.current,
|
|
146
|
+
}),
|
|
147
|
+
}
|
|
148
|
+
: collaboration;
|
|
149
|
+
featuresConfig = {
|
|
150
|
+
...featuresConfig,
|
|
151
|
+
collaboration: collaborationWithCallback,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// Build the EditorOptions (nested under options)
|
|
155
|
+
const editorOpts = {
|
|
156
|
+
...options,
|
|
157
|
+
...(user !== undefined && { user }),
|
|
158
|
+
...(featuresConfig !== undefined && { features: featuresConfig }),
|
|
159
|
+
...(editorBehavior && { editor: editorBehavior }),
|
|
160
|
+
};
|
|
161
|
+
// Build the top-level DragbleConfig
|
|
162
|
+
return {
|
|
163
|
+
containerId,
|
|
164
|
+
editorKey,
|
|
165
|
+
...(design !== undefined && { design }),
|
|
166
|
+
...(editorMode !== undefined && { editorMode }),
|
|
167
|
+
...(popup !== undefined && { popup }),
|
|
168
|
+
...(designMode !== undefined && { designMode }),
|
|
169
|
+
...(editorVersion !== undefined && { editorVersion }),
|
|
170
|
+
...(editorUrl !== undefined && { editorUrl }),
|
|
171
|
+
callbacks: callbacks || {},
|
|
172
|
+
options: editorOpts,
|
|
173
|
+
};
|
|
174
|
+
}, [
|
|
175
|
+
containerId,
|
|
176
|
+
editorKey,
|
|
177
|
+
design,
|
|
178
|
+
editorMode,
|
|
179
|
+
popup,
|
|
180
|
+
collaboration,
|
|
181
|
+
user,
|
|
182
|
+
designMode,
|
|
183
|
+
contentType,
|
|
184
|
+
options,
|
|
185
|
+
callbacks,
|
|
186
|
+
editorVersion,
|
|
187
|
+
editorUrl,
|
|
188
|
+
]);
|
|
189
|
+
// Keep the ref in sync so async callbacks always use the latest config
|
|
190
|
+
editorOptionsRef.current = editorOptions;
|
|
191
|
+
// 1. Cleanup effect - runs only on final unmount
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
return () => {
|
|
194
|
+
cleanupRef.current?.();
|
|
195
|
+
cleanupRef.current = null;
|
|
196
|
+
editorRef.current?.destroy();
|
|
197
|
+
editorRef.current = null;
|
|
198
|
+
};
|
|
199
|
+
}, []); // Empty deps - only runs on unmount
|
|
200
|
+
// 2. SDK loading effect
|
|
201
|
+
const resolvedSdkUrl = useMemo(() => getSDKUrl(sdkUrl, sdkVersion), [sdkUrl, sdkVersion]);
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
setHasLoadedSDK(false);
|
|
204
|
+
loadSDK(resolvedSdkUrl)
|
|
205
|
+
.then(() => setHasLoadedSDK(true))
|
|
206
|
+
.catch((err) => onErrorRef.current?.(err));
|
|
207
|
+
}, [resolvedSdkUrl]); // Re-load SDK if URL changes
|
|
208
|
+
// 3. Editor creation effect - ONLY on core props change
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (!hasLoadedSDK || !containerRef.current)
|
|
211
|
+
return;
|
|
212
|
+
// Clean up previous event listeners before creating new editor
|
|
213
|
+
cleanupRef.current?.();
|
|
214
|
+
cleanupRef.current = null;
|
|
215
|
+
// Destroy previous editor BEFORE creating new one
|
|
216
|
+
editorRef.current?.destroy();
|
|
217
|
+
editorRef.current = null;
|
|
218
|
+
const initEditor = async () => {
|
|
219
|
+
try {
|
|
220
|
+
// Import createEditor for multiple instance support
|
|
221
|
+
const { createEditor } = await loadSDK(resolvedSdkUrl);
|
|
222
|
+
// Use the ref to always get the latest config (avoids stale closure)
|
|
223
|
+
const config = editorOptionsRef.current || editorOptions;
|
|
224
|
+
// Create a new editor instance (not singleton)
|
|
225
|
+
const editorInstance = createEditor(config);
|
|
226
|
+
editorRef.current = editorInstance;
|
|
227
|
+
setEditor(editorInstance);
|
|
228
|
+
// Set up event listeners
|
|
229
|
+
const unsubscribeReady = editorInstance.addEventListener("editor:ready", () => {
|
|
230
|
+
setIsEditorReady(true);
|
|
231
|
+
onReadyRef.current?.(editorInstance);
|
|
232
|
+
});
|
|
233
|
+
const unsubscribeLoad = editorInstance.addEventListener("design:loaded", () => {
|
|
234
|
+
onLoadRef.current?.();
|
|
235
|
+
});
|
|
236
|
+
const unsubscribeChange = editorInstance.addEventListener("design:updated", (data) => {
|
|
237
|
+
onChangeRef.current?.(data);
|
|
238
|
+
});
|
|
239
|
+
// Store cleanup function for later use by re-init or unmount
|
|
240
|
+
cleanupRef.current = () => {
|
|
241
|
+
unsubscribeReady();
|
|
242
|
+
unsubscribeLoad();
|
|
243
|
+
unsubscribeChange();
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
248
|
+
console.error("Initialization error:", error.message, error);
|
|
249
|
+
onErrorRef.current?.(error);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
initEditor();
|
|
253
|
+
}, [
|
|
254
|
+
// Only re-init on core props that MUST trigger re-initialization
|
|
255
|
+
containerId,
|
|
256
|
+
editorKey,
|
|
257
|
+
hasLoadedSDK,
|
|
258
|
+
]);
|
|
259
|
+
// 4. Update options effect - update without re-init
|
|
260
|
+
useEffect(() => {
|
|
261
|
+
if (!editor || !isEditorReady)
|
|
262
|
+
return;
|
|
263
|
+
// Update modules without re-initialization
|
|
264
|
+
if (editorOptions.options?.modules) {
|
|
265
|
+
editor.setModules(editorOptions.options.modules);
|
|
266
|
+
}
|
|
267
|
+
// Note: Most options can't be updated after init, only modules can be updated
|
|
268
|
+
}, [editor, isEditorReady, editorOptions.options?.modules]);
|
|
269
|
+
useImperativeHandle(ref, () => ({
|
|
270
|
+
editor: editor,
|
|
271
|
+
isReady: () => isEditorReady,
|
|
272
|
+
}), [editor, isEditorReady]);
|
|
273
|
+
const effectiveHeight = height ?? minHeight;
|
|
274
|
+
const containerStyle = {
|
|
275
|
+
width: "100%",
|
|
276
|
+
height: typeof effectiveHeight === "number"
|
|
277
|
+
? `${effectiveHeight}px`
|
|
278
|
+
: effectiveHeight,
|
|
279
|
+
...style,
|
|
280
|
+
};
|
|
281
|
+
return (jsx("div", { className: className, style: containerStyle, children: jsx("div", { id: containerId, ref: containerRef, style: { width: "100%", height: "100%" } }) }));
|
|
282
|
+
});
|
|
283
|
+
DragbleEditor.displayName = "DragbleEditor";
|
|
284
|
+
function useDragbleEditor() {
|
|
285
|
+
const ref = useRef(null);
|
|
286
|
+
const [isReady, setIsReady] = useState(false);
|
|
287
|
+
useEffect(() => {
|
|
288
|
+
const checkReady = () => {
|
|
289
|
+
const ready = ref.current?.isReady() ?? false;
|
|
290
|
+
setIsReady(ready);
|
|
291
|
+
};
|
|
292
|
+
checkReady();
|
|
293
|
+
const interval = setInterval(checkReady, 100);
|
|
294
|
+
return () => clearInterval(interval);
|
|
295
|
+
}, []);
|
|
296
|
+
return {
|
|
297
|
+
ref,
|
|
298
|
+
editor: ref.current?.editor ?? null,
|
|
299
|
+
isReady,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export { DragbleEditor, DragbleEditor as default, useDragbleEditor };
|
|
304
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;AAsCA,MAAM,WAAW,GAAG,mDAAmD;AAQvE;AACA,MAAM,eAAe,GAAoC,IAAI,GAAG,EAAE;AAElE;;;;;AAKG;AACH,SAAS,SAAS,CAAC,SAAkB,EAAE,UAAmB,EAAA;AACxD,IAAA,IAAI,SAAS,IAAI,UAAU,KAAK,SAAS,EAAE;AACzC,QAAA,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC;IAChF;AAEA,IAAA,OAAO,SAAS,IAAI,CAAA,wBAAA,EAA2B,UAAU,IAAI,QAAQ,qBAAqB;AAC5F;AAEA;;;;;AAKG;AACH,SAAS,yBAAyB,GAAA;AAChC,IAAA,MAAM,SAAS,GAAI,MAAc,CAAC,UAAU;AAC5C,IAAA,MAAM,aAAa,GAAI,MAAc,CAAC,OAAO;;AAG7C,IAAA,MAAM,SAAS,GACb,SAAS,EAAE,YAAY;AACvB,QAAA,aAAa,EAAE,YAAY;SAC1B,CAAC,MAAW,KAAI;AACf,YAAA,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,WAAW,EAAE;AAChD,YAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;AACrB,YAAA,OAAO,QAAQ;AACjB,QAAA,CAAC,CAAC;IAEJ,OAAO;AACL,QAAA,OAAO,EAAE,aAAa;AACtB,QAAA,YAAY,EAAE,SAAS;AACvB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QAAA,CAAC;AAED,QAAA,UAAU,EAAE;QACZ,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC;AAC7C,QAAA,OAAO,MAAM,aAAa,CAAC,QAAQ,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC;IAEN,OAAO;QACL,GAAG;AACH,QAAA,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,IAAI,IAAI;QACnC,OAAO;KACR;AACH;;;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
|
|
8
|
+
const SDK_CDN_URL = "https://sdk.dragble.com/latest/dragble-sdk.min.js";
|
|
9
|
+
// Map of URL -> Promise for caching SDK loads per URL
|
|
10
|
+
const sdkLoadPromises = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Get the SDK URL to use.
|
|
13
|
+
* @param customUrl - Optional custom SDK URL override
|
|
14
|
+
* @param sdkVersion - Optional SDK version to load
|
|
15
|
+
* @returns The SDK URL to load
|
|
16
|
+
*/
|
|
17
|
+
function getSDKUrl(customUrl, sdkVersion) {
|
|
18
|
+
if (customUrl && sdkVersion !== undefined) {
|
|
19
|
+
console.warn("[DragbleEditor] sdkVersion is ignored when sdkUrl is provided.");
|
|
20
|
+
}
|
|
21
|
+
return customUrl ?? `https://sdk.dragble.com/${sdkVersion ?? "latest"}/dragble-sdk.min.js`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create an SDK module from the global dragble object.
|
|
25
|
+
* The UMD bundle exposes window.DragbleSDK (named exports) and
|
|
26
|
+
* window.dragble (singleton). Use DragbleSDK.createEditor for
|
|
27
|
+
* multi-instance support, falling back to manual instantiation.
|
|
28
|
+
*/
|
|
29
|
+
function createSDKModuleFromGlobal() {
|
|
30
|
+
const globalSDK = window.DragbleSDK;
|
|
31
|
+
const globalDragble = window.dragble;
|
|
32
|
+
// Prefer the named export createEditor from the UMD module
|
|
33
|
+
const factoryFn = globalSDK?.createEditor ||
|
|
34
|
+
globalDragble?.createEditor ||
|
|
35
|
+
((config) => {
|
|
36
|
+
const instance = new globalDragble.constructor();
|
|
37
|
+
instance.init(config);
|
|
38
|
+
return instance;
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
dragble: globalDragble,
|
|
42
|
+
createEditor: factoryFn,
|
|
43
|
+
DragbleSDK: globalSDK?.DragbleSDK || globalDragble?.constructor,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Load the SDK from a URL.
|
|
48
|
+
* Supports custom SDK URLs for enterprise self-hosted or specific versions.
|
|
49
|
+
* @param customUrl - Optional custom SDK URL
|
|
50
|
+
*/
|
|
51
|
+
function loadSDK(customUrl, sdkVersion) {
|
|
52
|
+
const sdkUrl = getSDKUrl(customUrl, sdkVersion);
|
|
53
|
+
// Check cache for this specific URL
|
|
54
|
+
const cachedPromise = sdkLoadPromises.get(sdkUrl);
|
|
55
|
+
if (cachedPromise)
|
|
56
|
+
return cachedPromise;
|
|
57
|
+
// Check if already loaded globally (only for default URL to avoid conflicts)
|
|
58
|
+
if (sdkUrl === SDK_CDN_URL && typeof window !== "undefined" && window.dragble) {
|
|
59
|
+
return Promise.resolve(createSDKModuleFromGlobal());
|
|
60
|
+
}
|
|
61
|
+
return loadSDKScript(sdkUrl);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Load the SDK script from a specific URL.
|
|
65
|
+
* Each unique URL is cached separately to support multiple SDK sources.
|
|
66
|
+
* @param sdkUrl - The SDK URL to load
|
|
67
|
+
*/
|
|
68
|
+
function loadSDKScript(sdkUrl) {
|
|
69
|
+
// Check cache for this specific URL
|
|
70
|
+
const cachedPromise = sdkLoadPromises.get(sdkUrl);
|
|
71
|
+
if (cachedPromise)
|
|
72
|
+
return cachedPromise;
|
|
73
|
+
const loadPromise = new Promise((resolve, reject) => {
|
|
74
|
+
const script = document.createElement("script");
|
|
75
|
+
script.src = sdkUrl;
|
|
76
|
+
script.async = true;
|
|
77
|
+
script.onload = () => {
|
|
78
|
+
if (window.dragble) {
|
|
79
|
+
// Resolve with SDK module interface
|
|
80
|
+
resolve(createSDKModuleFromGlobal());
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
sdkLoadPromises.delete(sdkUrl);
|
|
84
|
+
reject(new Error("Failed to load Dragble SDK - createEditor not found"));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
script.onerror = () => {
|
|
88
|
+
sdkLoadPromises.delete(sdkUrl);
|
|
89
|
+
reject(new Error(`Failed to load Dragble SDK from ${sdkUrl}`));
|
|
90
|
+
};
|
|
91
|
+
document.head.appendChild(script);
|
|
92
|
+
});
|
|
93
|
+
// Cache the promise for this URL
|
|
94
|
+
sdkLoadPromises.set(sdkUrl, loadPromise);
|
|
95
|
+
return loadPromise;
|
|
96
|
+
}
|
|
97
|
+
const DragbleEditor = react.forwardRef((props, ref) => {
|
|
98
|
+
const { editorKey, design, editorMode, contentType, options = {}, popup, collaboration, user, designMode, height, callbacks, className, style, minHeight = "600px", sdkUrl, sdkVersion, editorVersion, editorUrl, onReady, onLoad, onChange, onError, onComment, } = props;
|
|
99
|
+
const containerRef = react.useRef(null);
|
|
100
|
+
const [editor, setEditor] = react.useState(null);
|
|
101
|
+
const [hasLoadedSDK, setHasLoadedSDK] = react.useState(false);
|
|
102
|
+
const [isEditorReady, setIsEditorReady] = react.useState(false);
|
|
103
|
+
// Refs to track current editor and cleanup for proper lifecycle management
|
|
104
|
+
const editorRef = react.useRef(null);
|
|
105
|
+
const cleanupRef = react.useRef(null);
|
|
106
|
+
// Stable container ID using useMemo
|
|
107
|
+
const containerId = react.useMemo(() => `dragble-editor-${Math.random().toString(36).substr(2, 9)}`, []);
|
|
108
|
+
// Ref for config to ensure async init always uses the latest config
|
|
109
|
+
const editorOptionsRef = react.useRef(null);
|
|
110
|
+
// Refs for callbacks to avoid dependency issues
|
|
111
|
+
const onReadyRef = react.useRef(onReady);
|
|
112
|
+
const onLoadRef = react.useRef(onLoad);
|
|
113
|
+
const onChangeRef = react.useRef(onChange);
|
|
114
|
+
const onErrorRef = react.useRef(onError);
|
|
115
|
+
const onCommentRef = react.useRef(onComment);
|
|
116
|
+
react.useEffect(() => {
|
|
117
|
+
onReadyRef.current = onReady;
|
|
118
|
+
}, [onReady]);
|
|
119
|
+
react.useEffect(() => {
|
|
120
|
+
onLoadRef.current = onLoad;
|
|
121
|
+
}, [onLoad]);
|
|
122
|
+
react.useEffect(() => {
|
|
123
|
+
onChangeRef.current = onChange;
|
|
124
|
+
}, [onChange]);
|
|
125
|
+
react.useEffect(() => {
|
|
126
|
+
onErrorRef.current = onError;
|
|
127
|
+
}, [onError]);
|
|
128
|
+
react.useEffect(() => {
|
|
129
|
+
onCommentRef.current = onComment;
|
|
130
|
+
}, [onComment]);
|
|
131
|
+
// Build config object (memoized for comparison)
|
|
132
|
+
const editorOptions = react.useMemo(() => {
|
|
133
|
+
// Build editor behavior config for module mode
|
|
134
|
+
const editorBehavior = contentType === "module"
|
|
135
|
+
? {
|
|
136
|
+
...options.editor,
|
|
137
|
+
contentType: "module",
|
|
138
|
+
minRows: 1,
|
|
139
|
+
maxRows: 1,
|
|
140
|
+
}
|
|
141
|
+
: options.editor;
|
|
142
|
+
// Build collaboration feature config
|
|
143
|
+
let featuresConfig = options.features;
|
|
144
|
+
if (collaboration !== undefined) {
|
|
145
|
+
const collaborationWithCallback = typeof collaboration === "object"
|
|
146
|
+
? {
|
|
147
|
+
...collaboration,
|
|
148
|
+
...(onCommentRef.current && {
|
|
149
|
+
onComment: onCommentRef.current,
|
|
150
|
+
}),
|
|
151
|
+
}
|
|
152
|
+
: collaboration;
|
|
153
|
+
featuresConfig = {
|
|
154
|
+
...featuresConfig,
|
|
155
|
+
collaboration: collaborationWithCallback,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
// Build the EditorOptions (nested under options)
|
|
159
|
+
const editorOpts = {
|
|
160
|
+
...options,
|
|
161
|
+
...(user !== undefined && { user }),
|
|
162
|
+
...(featuresConfig !== undefined && { features: featuresConfig }),
|
|
163
|
+
...(editorBehavior && { editor: editorBehavior }),
|
|
164
|
+
};
|
|
165
|
+
// Build the top-level DragbleConfig
|
|
166
|
+
return {
|
|
167
|
+
containerId,
|
|
168
|
+
editorKey,
|
|
169
|
+
...(design !== undefined && { design }),
|
|
170
|
+
...(editorMode !== undefined && { editorMode }),
|
|
171
|
+
...(popup !== undefined && { popup }),
|
|
172
|
+
...(designMode !== undefined && { designMode }),
|
|
173
|
+
...(editorVersion !== undefined && { editorVersion }),
|
|
174
|
+
...(editorUrl !== undefined && { editorUrl }),
|
|
175
|
+
callbacks: callbacks || {},
|
|
176
|
+
options: editorOpts,
|
|
177
|
+
};
|
|
178
|
+
}, [
|
|
179
|
+
containerId,
|
|
180
|
+
editorKey,
|
|
181
|
+
design,
|
|
182
|
+
editorMode,
|
|
183
|
+
popup,
|
|
184
|
+
collaboration,
|
|
185
|
+
user,
|
|
186
|
+
designMode,
|
|
187
|
+
contentType,
|
|
188
|
+
options,
|
|
189
|
+
callbacks,
|
|
190
|
+
editorVersion,
|
|
191
|
+
editorUrl,
|
|
192
|
+
]);
|
|
193
|
+
// Keep the ref in sync so async callbacks always use the latest config
|
|
194
|
+
editorOptionsRef.current = editorOptions;
|
|
195
|
+
// 1. Cleanup effect - runs only on final unmount
|
|
196
|
+
react.useEffect(() => {
|
|
197
|
+
return () => {
|
|
198
|
+
cleanupRef.current?.();
|
|
199
|
+
cleanupRef.current = null;
|
|
200
|
+
editorRef.current?.destroy();
|
|
201
|
+
editorRef.current = null;
|
|
202
|
+
};
|
|
203
|
+
}, []); // Empty deps - only runs on unmount
|
|
204
|
+
// 2. SDK loading effect
|
|
205
|
+
const resolvedSdkUrl = react.useMemo(() => getSDKUrl(sdkUrl, sdkVersion), [sdkUrl, sdkVersion]);
|
|
206
|
+
react.useEffect(() => {
|
|
207
|
+
setHasLoadedSDK(false);
|
|
208
|
+
loadSDK(resolvedSdkUrl)
|
|
209
|
+
.then(() => setHasLoadedSDK(true))
|
|
210
|
+
.catch((err) => onErrorRef.current?.(err));
|
|
211
|
+
}, [resolvedSdkUrl]); // Re-load SDK if URL changes
|
|
212
|
+
// 3. Editor creation effect - ONLY on core props change
|
|
213
|
+
react.useEffect(() => {
|
|
214
|
+
if (!hasLoadedSDK || !containerRef.current)
|
|
215
|
+
return;
|
|
216
|
+
// Clean up previous event listeners before creating new editor
|
|
217
|
+
cleanupRef.current?.();
|
|
218
|
+
cleanupRef.current = null;
|
|
219
|
+
// Destroy previous editor BEFORE creating new one
|
|
220
|
+
editorRef.current?.destroy();
|
|
221
|
+
editorRef.current = null;
|
|
222
|
+
const initEditor = async () => {
|
|
223
|
+
try {
|
|
224
|
+
// Import createEditor for multiple instance support
|
|
225
|
+
const { createEditor } = await loadSDK(resolvedSdkUrl);
|
|
226
|
+
// Use the ref to always get the latest config (avoids stale closure)
|
|
227
|
+
const config = editorOptionsRef.current || editorOptions;
|
|
228
|
+
// Create a new editor instance (not singleton)
|
|
229
|
+
const editorInstance = createEditor(config);
|
|
230
|
+
editorRef.current = editorInstance;
|
|
231
|
+
setEditor(editorInstance);
|
|
232
|
+
// Set up event listeners
|
|
233
|
+
const unsubscribeReady = editorInstance.addEventListener("editor:ready", () => {
|
|
234
|
+
setIsEditorReady(true);
|
|
235
|
+
onReadyRef.current?.(editorInstance);
|
|
236
|
+
});
|
|
237
|
+
const unsubscribeLoad = editorInstance.addEventListener("design:loaded", () => {
|
|
238
|
+
onLoadRef.current?.();
|
|
239
|
+
});
|
|
240
|
+
const unsubscribeChange = editorInstance.addEventListener("design:updated", (data) => {
|
|
241
|
+
onChangeRef.current?.(data);
|
|
242
|
+
});
|
|
243
|
+
// Store cleanup function for later use by re-init or unmount
|
|
244
|
+
cleanupRef.current = () => {
|
|
245
|
+
unsubscribeReady();
|
|
246
|
+
unsubscribeLoad();
|
|
247
|
+
unsubscribeChange();
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
252
|
+
console.error("Initialization error:", error.message, error);
|
|
253
|
+
onErrorRef.current?.(error);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
initEditor();
|
|
257
|
+
}, [
|
|
258
|
+
// Only re-init on core props that MUST trigger re-initialization
|
|
259
|
+
containerId,
|
|
260
|
+
editorKey,
|
|
261
|
+
hasLoadedSDK,
|
|
262
|
+
]);
|
|
263
|
+
// 4. Update options effect - update without re-init
|
|
264
|
+
react.useEffect(() => {
|
|
265
|
+
if (!editor || !isEditorReady)
|
|
266
|
+
return;
|
|
267
|
+
// Update modules without re-initialization
|
|
268
|
+
if (editorOptions.options?.modules) {
|
|
269
|
+
editor.setModules(editorOptions.options.modules);
|
|
270
|
+
}
|
|
271
|
+
// Note: Most options can't be updated after init, only modules can be updated
|
|
272
|
+
}, [editor, isEditorReady, editorOptions.options?.modules]);
|
|
273
|
+
react.useImperativeHandle(ref, () => ({
|
|
274
|
+
editor: editor,
|
|
275
|
+
isReady: () => isEditorReady,
|
|
276
|
+
}), [editor, isEditorReady]);
|
|
277
|
+
const effectiveHeight = height ?? minHeight;
|
|
278
|
+
const containerStyle = {
|
|
279
|
+
width: "100%",
|
|
280
|
+
height: typeof effectiveHeight === "number"
|
|
281
|
+
? `${effectiveHeight}px`
|
|
282
|
+
: effectiveHeight,
|
|
283
|
+
...style,
|
|
284
|
+
};
|
|
285
|
+
return (jsxRuntime.jsx("div", { className: className, style: containerStyle, children: jsxRuntime.jsx("div", { id: containerId, ref: containerRef, style: { width: "100%", height: "100%" } }) }));
|
|
286
|
+
});
|
|
287
|
+
DragbleEditor.displayName = "DragbleEditor";
|
|
288
|
+
function useDragbleEditor() {
|
|
289
|
+
const ref = react.useRef(null);
|
|
290
|
+
const [isReady, setIsReady] = react.useState(false);
|
|
291
|
+
react.useEffect(() => {
|
|
292
|
+
const checkReady = () => {
|
|
293
|
+
const ready = ref.current?.isReady() ?? false;
|
|
294
|
+
setIsReady(ready);
|
|
295
|
+
};
|
|
296
|
+
checkReady();
|
|
297
|
+
const interval = setInterval(checkReady, 100);
|
|
298
|
+
return () => clearInterval(interval);
|
|
299
|
+
}, []);
|
|
300
|
+
return {
|
|
301
|
+
ref,
|
|
302
|
+
editor: ref.current?.editor ?? null,
|
|
303
|
+
isReady,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
exports.DragbleEditor = DragbleEditor;
|
|
308
|
+
exports.default = DragbleEditor;
|
|
309
|
+
exports.useDragbleEditor = useDragbleEditor;
|
|
310
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":[null],"names":["forwardRef","useRef","useState","useMemo","useEffect","useImperativeHandle","_jsx"],"mappings":";;;;;;;AAsCA,MAAM,WAAW,GAAG,mDAAmD;AAQvE;AACA,MAAM,eAAe,GAAoC,IAAI,GAAG,EAAE;AAElE;;;;;AAKG;AACH,SAAS,SAAS,CAAC,SAAkB,EAAE,UAAmB,EAAA;AACxD,IAAA,IAAI,SAAS,IAAI,UAAU,KAAK,SAAS,EAAE;AACzC,QAAA,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC;IAChF;AAEA,IAAA,OAAO,SAAS,IAAI,CAAA,wBAAA,EAA2B,UAAU,IAAI,QAAQ,qBAAqB;AAC5F;AAEA;;;;;AAKG;AACH,SAAS,yBAAyB,GAAA;AAChC,IAAA,MAAM,SAAS,GAAI,MAAc,CAAC,UAAU;AAC5C,IAAA,MAAM,aAAa,GAAI,MAAc,CAAC,OAAO;;AAG7C,IAAA,MAAM,SAAS,GACb,SAAS,EAAE,YAAY;AAC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