@slate-yjs/core 0.2.5 → 0.2.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.
@@ -9926,9 +9926,6 @@ var SlateYjsCore = (() => {
9926
9926
  return CONNECTED.has(editor);
9927
9927
  },
9928
9928
  connect(editor) {
9929
- if (YjsEditor.connected(editor)) {
9930
- throw new Error("already connected");
9931
- }
9932
9929
  editor.connect();
9933
9930
  },
9934
9931
  disconnect(editor) {
@@ -10005,7 +10002,10 @@ var SlateYjsCore = (() => {
10005
10002
  });
10006
10003
  }
10007
10004
  e.connect = () => {
10008
- sharedRoot.observeDeep(handleYEvents);
10005
+ if (YjsEditor.connected(e)) {
10006
+ throw new Error("already connected");
10007
+ }
10008
+ e.sharedRoot.observeDeep(handleYEvents);
10009
10009
  const content = yTextToSlateElement(e.sharedRoot);
10010
10010
  e.children = content.children;
10011
10011
  CONNECTED.add(e);
@@ -10016,7 +10016,7 @@ var SlateYjsCore = (() => {
10016
10016
  clearTimeout(autoConnectTimeoutId);
10017
10017
  }
10018
10018
  YjsEditor.flushLocalChanges(e);
10019
- sharedRoot.unobserveDeep(handleYEvents);
10019
+ e.sharedRoot.unobserveDeep(handleYEvents);
10020
10020
  CONNECTED.delete(e);
10021
10021
  };
10022
10022
  e.storeLocalChange = (op) => {
@@ -10118,7 +10118,7 @@ var SlateYjsCore = (() => {
10118
10118
  stackItem,
10119
10119
  type
10120
10120
  }) => {
10121
- const inverseStack = type === "undo" ? undoManager.redoStack : undoManager.undoStack;
10121
+ const inverseStack = type === "undo" ? e.undoManager.redoStack : e.undoManager.undoStack;
10122
10122
  const inverseItem = inverseStack[inverseStack.length - 1];
10123
10123
  if (inverseItem) {
10124
10124
  inverseItem.meta.set("selection", stackItem.meta.get("selectionBefore"));
@@ -10137,14 +10137,14 @@ var SlateYjsCore = (() => {
10137
10137
  const { connect, disconnect } = e;
10138
10138
  e.connect = () => {
10139
10139
  connect();
10140
- undoManager.on("stack-item-added", handleStackItemAdded);
10141
- undoManager.on("stack-item-popped", handleStackItemPopped);
10142
- undoManager.on("stack-item-updated", handleStackItemUpdated);
10140
+ e.undoManager.on("stack-item-added", handleStackItemAdded);
10141
+ e.undoManager.on("stack-item-popped", handleStackItemPopped);
10142
+ e.undoManager.on("stack-item-updated", handleStackItemUpdated);
10143
10143
  };
10144
10144
  e.disconnect = () => {
10145
- undoManager.off("stack-item-added", handleStackItemAdded);
10146
- undoManager.off("stack-item-popped", handleStackItemPopped);
10147
- undoManager.off("stack-item-updated", handleStackItemUpdated);
10145
+ e.undoManager.off("stack-item-added", handleStackItemAdded);
10146
+ e.undoManager.off("stack-item-popped", handleStackItemPopped);
10147
+ e.undoManager.off("stack-item-updated", handleStackItemUpdated);
10148
10148
  disconnect();
10149
10149
  };
10150
10150
  e.undo = () => {
@@ -10346,17 +10346,17 @@ var SlateYjsCore = (() => {
10346
10346
  e.awareness.setLocalStateField(e.cursorDataField, cursorData);
10347
10347
  };
10348
10348
  e.sendCursorPosition = (range) => {
10349
- const localState = awareness.getLocalState();
10349
+ const localState = e.awareness.getLocalState();
10350
10350
  const currentRange = localState == null ? void 0 : localState[selectionStateField];
10351
10351
  if (!range) {
10352
10352
  if (currentRange) {
10353
- awareness.setLocalStateField(e.selectionStateField, null);
10353
+ e.awareness.setLocalStateField(e.selectionStateField, null);
10354
10354
  }
10355
10355
  return;
10356
10356
  }
10357
10357
  const { anchor, focus } = slateRangeToRelativeRange(e.sharedRoot, e, range);
10358
10358
  if (!currentRange || !compareRelativePositions(anchor, currentRange) || !compareRelativePositions(focus, currentRange)) {
10359
- awareness.setLocalStateField(e.selectionStateField, { anchor, focus });
10359
+ e.awareness.setLocalStateField(e.selectionStateField, { anchor, focus });
10360
10360
  }
10361
10361
  };
10362
10362
  const awarenessChangeListener = (yEvent) => {
@@ -10380,7 +10380,7 @@ var SlateYjsCore = (() => {
10380
10380
  e.awareness.on("change", awarenessChangeListener);
10381
10381
  awarenessChangeListener({
10382
10382
  removed: [],
10383
- added: Array.from(awareness.getStates().keys()),
10383
+ added: Array.from(e.awareness.getStates().keys()),
10384
10384
  updated: []
10385
10385
  });
10386
10386
  if (autoSend) {
@@ -10399,7 +10399,7 @@ var SlateYjsCore = (() => {
10399
10399
  e.disconnect = () => {
10400
10400
  e.awareness.off("change", awarenessChangeListener);
10401
10401
  awarenessChangeListener({
10402
- removed: Array.from(awareness.getStates().keys()),
10402
+ removed: Array.from(e.awareness.getStates().keys()),
10403
10403
  added: [],
10404
10404
  updated: []
10405
10405
  });