@portabletext/editor 1.49.9 → 1.49.10

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/lib/index.js CHANGED
@@ -4232,8 +4232,8 @@ function insertPatch(editor, patch, schema) {
4232
4232
  const editorWasEmptyBefore = isEqualToEmptyEditor(editor.children, schema);
4233
4233
  return Transforms.insertNodes(editor, blocksToInsert, {
4234
4234
  at: [normalizedIdx2]
4235
- }), editorWasEmptyBefore && Transforms.removeNodes(editor, {
4236
- at: [position2 === "after" ? targetBlockIndex + 1 : targetBlockIndex]
4235
+ }), editorWasEmptyBefore && typeof patch.path[0] == "number" && patch.path[0] === 0 && Transforms.removeNodes(editor, {
4236
+ at: [position2 === "before" ? targetBlockIndex + 1 : targetBlockIndex]
4237
4237
  }), debugState(editor, "after"), !0;
4238
4238
  }
4239
4239
  const {
@@ -8943,8 +8943,8 @@ function createActors(config) {
8943
8943
  subscription.unsubscribe();
8944
8944
  };
8945
8945
  }), config.subscriptions.push(() => {
8946
- const subscription = config.editorActor.on("*", (event) => {
8947
- config.editorActor.getSnapshot().matches({
8946
+ const subscription = config.editorActor.subscribe((snapshot) => {
8947
+ snapshot.matches({
8948
8948
  "edit mode": "read only"
8949
8949
  }) ? syncActor.send({
8950
8950
  type: "update readOnly",
@@ -8952,7 +8952,14 @@ function createActors(config) {
8952
8952
  }) : syncActor.send({
8953
8953
  type: "update readOnly",
8954
8954
  readOnly: !1
8955
- }), event.type === "internal.patch" && mutationActor.send({
8955
+ });
8956
+ });
8957
+ return () => {
8958
+ subscription.unsubscribe();
8959
+ };
8960
+ }), config.subscriptions.push(() => {
8961
+ const subscription = config.editorActor.on("*", (event) => {
8962
+ event.type === "internal.patch" && mutationActor.send({
8956
8963
  ...event,
8957
8964
  type: "patch"
8958
8965
  });