@lexion-rte/react 0.1.7 → 0.1.8
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/LexionEditorView.tsx +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lexion-rte/react
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Preserve undo history when a controlled editor value is synced back into the adapter without any actual document change. This also keeps the rendered editor state and status bar aligned when React, Vue, or the web adapter receives the current document again.
|
|
8
|
+
|
|
3
9
|
## 0.1.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
package/src/LexionEditorView.tsx
CHANGED
|
@@ -81,8 +81,11 @@ export const LexionEditorView = ({
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (isControlled && value !== undefined) {
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const nextValue = serializeJSON(value);
|
|
85
|
+
if (nextValue !== serializeJSON(activeEditor.getJSON())) {
|
|
86
|
+
activeEditor.setJSON(value);
|
|
87
|
+
}
|
|
88
|
+
lastAppliedValueRef.current = nextValue;
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
const view = new EditorView(containerRef.current, {
|
|
@@ -125,7 +128,10 @@ export const LexionEditorView = ({
|
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
const nextValue = serializeJSON(value);
|
|
128
|
-
if (nextValue === lastAppliedValueRef.current) {
|
|
131
|
+
if (nextValue === lastAppliedValueRef.current || nextValue === serializeJSON(activeEditor.getJSON())) {
|
|
132
|
+
lastAppliedValueRef.current = nextValue;
|
|
133
|
+
viewRef.current?.updateState(activeEditor.state);
|
|
134
|
+
setStatusBarItems(activeEditor.getStatusBarItems());
|
|
129
135
|
return;
|
|
130
136
|
}
|
|
131
137
|
|