@domternal/react 0.12.0 → 0.13.0
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 +4 -0
- package/dist/index.js.map +1 -1
- package/dist/useEditor.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ function useEditor(options = {}, deps) {
|
|
|
26
26
|
contentRef.current = content;
|
|
27
27
|
const formatRef = useRef(outputFormat);
|
|
28
28
|
formatRef.current = outputFormat;
|
|
29
|
+
const syncedContentRef = useRef(null);
|
|
29
30
|
const extensionsRef = useRef(extensions);
|
|
30
31
|
const depsRef = useRef(deps);
|
|
31
32
|
function wireEvents(ed) {
|
|
@@ -58,6 +59,7 @@ function useEditor(options = {}, deps) {
|
|
|
58
59
|
instanceRef.current = ed;
|
|
59
60
|
extensionsRef.current = extensions;
|
|
60
61
|
depsRef.current = deps;
|
|
62
|
+
syncedContentRef.current = contentRef.current;
|
|
61
63
|
return ed;
|
|
62
64
|
}
|
|
63
65
|
function createEditorInstance(element, initialContent, focus) {
|
|
@@ -138,6 +140,8 @@ function useEditor(options = {}, deps) {
|
|
|
138
140
|
useEffect(() => {
|
|
139
141
|
const ed = instanceRef.current;
|
|
140
142
|
if (!ed || ed.isDestroyed) return;
|
|
143
|
+
if (syncedContentRef.current === content) return;
|
|
144
|
+
syncedContentRef.current = content;
|
|
141
145
|
const format = formatRef.current;
|
|
142
146
|
if (format === "html") {
|
|
143
147
|
if (content !== ed.getHTML()) {
|