@slate-yjs/core 1.0.8 → 1.1.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/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { translateYjsEvent } from './applyToSlate';
2
+ import { applySlateOp } from './applyToYjs';
1
3
  import { RelativeRange } from './model/types';
2
4
  import {
3
5
  CursorEditor,
@@ -44,4 +46,7 @@ export {
44
46
  relativeRangeToSlateRange,
45
47
  slatePointToRelativePosition,
46
48
  relativePositionToSlatePoint,
49
+ // Low-level translation
50
+ translateYjsEvent,
51
+ applySlateOp,
47
52
  };
@@ -77,6 +77,12 @@ export function withYHistory<T extends YjsEditor>(
77
77
  e.onChange = () => {
78
78
  onChange();
79
79
 
80
+ // Before connect the shared root may not match the Slate tree yet.
81
+ if (!YjsEditor.connected(e)) {
82
+ LAST_SELECTION.delete(e);
83
+ return;
84
+ }
85
+
80
86
  LAST_SELECTION.set(
81
87
  e,
82
88
  e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection)