docx-diff-editor 1.0.33 → 1.0.35
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -725,17 +725,11 @@ var DocxDiffEditor = forwardRef(
|
|
|
725
725
|
const editorId = `dde-editor-${instanceId.current}`;
|
|
726
726
|
const toolbarId = `dde-toolbar-${instanceId.current}`;
|
|
727
727
|
const setEditorContent = useCallback((editor, json) => {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
const { state, view } = editor;
|
|
734
|
-
if (state?.doc && view && json.content) {
|
|
735
|
-
const newDoc = state.schema.nodeFromJSON(json);
|
|
736
|
-
const tr = state.tr.replaceWith(0, state.doc.content.size, newDoc.content);
|
|
737
|
-
view.dispatch(tr);
|
|
738
|
-
}
|
|
728
|
+
const { state, view } = editor;
|
|
729
|
+
if (state?.doc && view && json.content) {
|
|
730
|
+
const newDoc = state.schema.nodeFromJSON(json);
|
|
731
|
+
const tr = state.tr.replaceWith(0, state.doc.content.size, newDoc.content);
|
|
732
|
+
view.dispatch(tr);
|
|
739
733
|
}
|
|
740
734
|
}, []);
|
|
741
735
|
const enableReviewMode = useCallback((sd) => {
|
|
@@ -917,9 +911,26 @@ var DocxDiffEditor = forwardRef(
|
|
|
917
911
|
useImperativeHandle(
|
|
918
912
|
ref,
|
|
919
913
|
() => ({
|
|
914
|
+
/**
|
|
915
|
+
* Update content in the existing editor without recreating SuperDoc instance.
|
|
916
|
+
* Preserves the DOCX template/styling. Ideal for replacing content with translated JSON.
|
|
917
|
+
*/
|
|
918
|
+
updateContent(json) {
|
|
919
|
+
const editor = superdocRef.current?.activeEditor;
|
|
920
|
+
if (!editor) {
|
|
921
|
+
throw new Error("Editor not ready");
|
|
922
|
+
}
|
|
923
|
+
setEditorContent(editor, json);
|
|
924
|
+
setSourceJson(json);
|
|
925
|
+
setMergedJson(null);
|
|
926
|
+
setDiffResult(null);
|
|
927
|
+
onSourceLoaded?.(json);
|
|
928
|
+
},
|
|
920
929
|
/**
|
|
921
930
|
* Set the source/base document.
|
|
922
931
|
* Accepts File (DOCX), HTML string, or ProseMirror JSON.
|
|
932
|
+
* Note: This destroys and recreates the SuperDoc instance.
|
|
933
|
+
* For JSON content updates, prefer updateContent() to preserve the existing template.
|
|
923
934
|
*/
|
|
924
935
|
async setSource(content) {
|
|
925
936
|
if (!SuperDocRef.current) {
|