@domternal/react 0.12.1 → 0.14.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/README.md +1 -1
- 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/README.md
CHANGED
|
@@ -19,7 +19,7 @@ and React 19.
|
|
|
19
19
|
pnpm add @domternal/react @domternal/core react react-dom
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
`react` (>=18), `react-dom` (>=18), and `@domternal/core` (>=0.
|
|
22
|
+
`react` (>=18), `react-dom` (>=18), and `@domternal/core` (>=0.14.0) are peer dependencies. Import the theme
|
|
23
23
|
([`@domternal/theme`](https://www.npmjs.com/package/@domternal/theme)) in your entry CSS for default styling:
|
|
24
24
|
|
|
25
25
|
```css
|
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()) {
|