@portabletext/editor 7.3.3 → 7.3.4

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.
@@ -1476,13 +1476,13 @@ type InsertOperation = {
1476
1476
  inverse?: UnsetOperationData;
1477
1477
  };
1478
1478
  type InsertTextOperation = {
1479
- type: 'insert_text';
1479
+ type: 'insert.text';
1480
1480
  path: Path$1;
1481
1481
  offset: number;
1482
1482
  text: string;
1483
1483
  };
1484
1484
  type RemoveTextOperation = {
1485
- type: 'remove_text';
1485
+ type: 'remove.text';
1486
1486
  path: Path$1;
1487
1487
  offset: number;
1488
1488
  text: string;
@@ -1537,15 +1537,15 @@ type UnsetOperation = {
1537
1537
  inverse?: SetOperationData | InsertOperationData;
1538
1538
  };
1539
1539
  type SetSelectionOperation = {
1540
- type: 'set_selection';
1540
+ type: 'set.selection';
1541
1541
  properties: null;
1542
1542
  newProperties: Range;
1543
1543
  } | {
1544
- type: 'set_selection';
1544
+ type: 'set.selection';
1545
1545
  properties: Partial<Range>;
1546
1546
  newProperties: Partial<Range>;
1547
1547
  } | {
1548
- type: 'set_selection';
1548
+ type: 'set.selection';
1549
1549
  properties: Range;
1550
1550
  newProperties: null;
1551
1551
  };
package/lib/index.js CHANGED
@@ -655,7 +655,7 @@ function collapse(editor, options = {}) {
655
655
  function deselect(editor) {
656
656
  const selection = editor.snapshot.context.selection;
657
657
  selection && editor.apply({
658
- type: "set_selection",
658
+ type: "set.selection",
659
659
  properties: selection,
660
660
  newProperties: null
661
661
  });
@@ -1337,12 +1337,12 @@ function transformPoint$1(point2, op, options = {}) {
1337
1337
  affinity = "forward"
1338
1338
  } = options;
1339
1339
  switch (op.type) {
1340
- case "insert_text":
1340
+ case "insert.text":
1341
1341
  return pathEquals(op.path, point2.path) && (op.offset < point2.offset || op.offset === point2.offset && affinity === "forward") ? {
1342
1342
  path: point2.path,
1343
1343
  offset: point2.offset + op.text.length
1344
1344
  } : point2;
1345
- case "remove_text":
1345
+ case "remove.text":
1346
1346
  return pathEquals(op.path, point2.path) && op.offset <= point2.offset ? {
1347
1347
  path: point2.path,
1348
1348
  offset: point2.offset - Math.min(point2.offset - op.offset, op.text.length)
@@ -1378,7 +1378,7 @@ function transformPoint$1(point2, op, options = {}) {
1378
1378
  offset: 0
1379
1379
  } : point2;
1380
1380
  }
1381
- // set_selection: no transform needed
1381
+ // set.selection: no transform needed
1382
1382
  default:
1383
1383
  return point2;
1384
1384
  }
@@ -1564,7 +1564,7 @@ function transformTextDiff(textDiff, op) {
1564
1564
  id
1565
1565
  } = textDiff;
1566
1566
  switch (op.type) {
1567
- case "insert_text":
1567
+ case "insert.text":
1568
1568
  return !pathEquals(op.path, path2) || op.offset >= diff2.end ? textDiff : op.offset <= diff2.start ? {
1569
1569
  diff: {
1570
1570
  start: op.text.length + diff2.start,
@@ -1582,7 +1582,7 @@ function transformTextDiff(textDiff, op) {
1582
1582
  id,
1583
1583
  path: path2
1584
1584
  };
1585
- case "remove_text":
1585
+ case "remove.text":
1586
1586
  return !pathEquals(op.path, path2) || op.offset >= diff2.end ? textDiff : op.offset + op.text.length <= diff2.start ? {
1587
1587
  diff: {
1588
1588
  start: diff2.start - op.text.length,
@@ -4016,13 +4016,13 @@ function applySelect(editor, target) {
4016
4016
  if (selection) {
4017
4017
  const oldProps = {}, newProps = {};
4018
4018
  range2.anchor != null && !pointEquals(range2.anchor, selection.anchor) && (oldProps.anchor = selection.anchor, newProps.anchor = range2.anchor), range2.focus != null && !pointEquals(range2.focus, selection.focus) && (oldProps.focus = selection.focus, newProps.focus = range2.focus), Object.keys(oldProps).length > 0 && editor.apply({
4019
- type: "set_selection",
4019
+ type: "set.selection",
4020
4020
  properties: oldProps,
4021
4021
  newProperties: newProps
4022
4022
  });
4023
4023
  } else
4024
4024
  editor.apply({
4025
- type: "set_selection",
4025
+ type: "set.selection",
4026
4026
  properties: null,
4027
4027
  newProperties: range2
4028
4028
  });
@@ -4030,7 +4030,7 @@ function applySelect(editor, target) {
4030
4030
  function applyDeselect(editor) {
4031
4031
  const selection = editor.snapshot.context.selection;
4032
4032
  selection && editor.apply({
4033
- type: "set_selection",
4033
+ type: "set.selection",
4034
4034
  properties: selection,
4035
4035
  newProperties: null
4036
4036
  });
@@ -4450,7 +4450,7 @@ const engineOperationCallback = ({
4450
4450
  input,
4451
4451
  sendBack
4452
4452
  }) => subscribeToOperations(input.editorEngine, (event) => {
4453
- event.operation.type !== "set_selection" && sendBack({
4453
+ event.operation.type !== "set.selection" && sendBack({
4454
4454
  type: "engine operation",
4455
4455
  operation: event.operation
4456
4456
  });
@@ -6580,7 +6580,7 @@ function _temp3(props_0) {
6580
6580
  return /* @__PURE__ */ jsx(RenderText, { ...props_0 });
6581
6581
  }
6582
6582
  function _temp4(o) {
6583
- return o.type === "set_selection";
6583
+ return o.type === "set.selection";
6584
6584
  }
6585
6585
  function _temp5(error) {
6586
6586
  return console.warn(error), error;
@@ -7331,8 +7331,8 @@ function collectDescendantPaths(context, node, parentPath2, paths, parent) {
7331
7331
  }
7332
7332
  function getDirtyPaths(context, op) {
7333
7333
  switch (op.type) {
7334
- case "insert_text":
7335
- case "remove_text":
7334
+ case "insert.text":
7335
+ case "remove.text":
7336
7336
  return pathLevels(op.path);
7337
7337
  case "set": {
7338
7338
  if (op.path.length === 0) {
@@ -7717,7 +7717,7 @@ function applyOperation(editor, op) {
7717
7717
  transformSelection = !0;
7718
7718
  break;
7719
7719
  }
7720
- case "insert_text": {
7720
+ case "insert.text": {
7721
7721
  const {
7722
7722
  path: path2,
7723
7723
  offset,
@@ -7734,7 +7734,7 @@ function applyOperation(editor, op) {
7734
7734
  }), transformSelection = !0;
7735
7735
  break;
7736
7736
  }
7737
- case "remove_text": {
7737
+ case "remove.text": {
7738
7738
  const {
7739
7739
  path: path2,
7740
7740
  offset,
@@ -7941,7 +7941,7 @@ function applyOperation(editor, op) {
7941
7941
  transformSelection = !0;
7942
7942
  break;
7943
7943
  }
7944
- case "set_selection": {
7944
+ case "set.selection": {
7945
7945
  const {
7946
7946
  newProperties
7947
7947
  } = op;
@@ -7951,7 +7951,7 @@ function applyOperation(editor, op) {
7951
7951
  }
7952
7952
  if (editor.snapshot.context.selection == null) {
7953
7953
  if (!isRange(newProperties))
7954
- throw new Error(`Cannot apply an incomplete "set_selection" operation properties ${safeStringify(newProperties)} when there is no current selection.`);
7954
+ throw new Error(`Cannot apply an incomplete "set.selection" operation properties ${safeStringify(newProperties)} when there is no current selection.`);
7955
7955
  editor.snapshot.context.selection = {
7956
7956
  ...newProperties,
7957
7957
  backward: isBackwardRange(newProperties, editor.snapshot.context)
@@ -8113,7 +8113,7 @@ const apply$1 = (editor, op) => {
8113
8113
  transformRangeRef(ref, op, editor.snapshot.context);
8114
8114
  if (applyOperation(editor, op), updateDirtyPaths(editor, getDirtyPaths(editor.snapshot.context, op)), editor.operations.push(op), normalize(editor, {
8115
8115
  operation: op
8116
- }), op.type === "set_selection")
8116
+ }), op.type === "set.selection")
8117
8117
  if (op.properties && op.newProperties && op.properties.anchor && op.properties.focus && op.newProperties.anchor && op.newProperties.focus) {
8118
8118
  const previousSelectionIsCollapsed = isCollapsedRange({
8119
8119
  anchor: op.properties.anchor,
@@ -8231,7 +8231,7 @@ function applySplitNode(editor, path2, position) {
8231
8231
  text: afterText
8232
8232
  };
8233
8233
  editor.apply({
8234
- type: "remove_text",
8234
+ type: "remove.text",
8235
8235
  path: path2,
8236
8236
  offset: position,
8237
8237
  text: afterText
@@ -8429,7 +8429,7 @@ function applyMergeNode(editor, path2, position) {
8429
8429
  schema: editor.snapshot.context.schema
8430
8430
  }, node))
8431
8431
  node.text.length > 0 && editor.apply({
8432
- type: "insert_text",
8432
+ type: "insert.text",
8433
8433
  path: prevPath,
8434
8434
  offset: position,
8435
8435
  text: node.text
@@ -9113,7 +9113,7 @@ function select(editor, target) {
9113
9113
  if (!isRange(target))
9114
9114
  throw new Error(`When setting the selection and the current selection is \`null\` you must provide at least an \`anchor\` and \`focus\`, but you passed: ${safeStringify(target)}`);
9115
9115
  editor.apply({
9116
- type: "set_selection",
9116
+ type: "set.selection",
9117
9117
  properties: selection,
9118
9118
  newProperties: target
9119
9119
  });
@@ -9124,7 +9124,7 @@ function setSelection(editor, props) {
9124
9124
  for (const k in props)
9125
9125
  (k === "anchor" && props.anchor != null && !pointEquals(props.anchor, selection.anchor) || k === "focus" && props.focus != null && !pointEquals(props.focus, selection.focus) || k !== "anchor" && k !== "focus" && props[k] !== selection[k]) && (oldProps[k] = selection[k], newProps[k] = props[k]);
9126
9126
  Object.keys(oldProps).length > 0 && editor.apply({
9127
- type: "set_selection",
9127
+ type: "set.selection",
9128
9128
  properties: oldProps,
9129
9129
  newProperties: newProps
9130
9130
  });
@@ -9186,16 +9186,16 @@ const shouldNormalize = (_editor, {
9186
9186
  at
9187
9187
  } : null;
9188
9188
  }
9189
- operation.type === "set_selection" && (e.userSelection?.unref(), e.userSelection = null);
9189
+ operation.type === "set.selection" && (e.userSelection?.unref(), e.userSelection = null);
9190
9190
  }, {
9191
9191
  phase: "before"
9192
9192
  }), subscribeToOperations(e, (event) => {
9193
9193
  switch (event.operation.type) {
9194
9194
  case "insert":
9195
9195
  case "unset":
9196
- case "insert_text":
9197
- case "remove_text":
9198
- case "set_selection":
9196
+ case "insert.text":
9197
+ case "remove.text":
9198
+ case "set.selection":
9199
9199
  e.isNodeMapDirty = !0;
9200
9200
  }
9201
9201
  }), e.onChange = (options) => {
@@ -10008,12 +10008,12 @@ function diffMatchPatch(editor, patch) {
10008
10008
  let offset = 0;
10009
10009
  for (const [op, text] of diff$1)
10010
10010
  op === DIFF_INSERT ? (editor.apply({
10011
- type: "insert_text",
10011
+ type: "insert.text",
10012
10012
  path: spanEntry.path,
10013
10013
  offset,
10014
10014
  text
10015
10015
  }), offset += text.length) : op === DIFF_DELETE ? editor.apply({
10016
- type: "remove_text",
10016
+ type: "remove.text",
10017
10017
  path: spanEntry.path,
10018
10018
  offset,
10019
10019
  text
@@ -10133,29 +10133,29 @@ function createUndoSteps({
10133
10133
  return createNewStep(steps, op, selectionBeforeApply);
10134
10134
  if (operationsInProgress)
10135
10135
  return currentUndoStepId === previousUndoStepId || isNormalizingNode ? mergeIntoLastStep(steps, lastStep, op) : createNewStep(steps, op, selectionBeforeApply);
10136
- if (op.type === "set_selection" && currentUndoStepId === void 0 && previousUndoStepId !== void 0 || op.type === "set_selection" && currentUndoStepId !== void 0 && previousUndoStepId !== void 0 && previousUndoStepId !== currentUndoStepId)
10136
+ if (op.type === "set.selection" && currentUndoStepId === void 0 && previousUndoStepId !== void 0 || op.type === "set.selection" && currentUndoStepId !== void 0 && previousUndoStepId !== void 0 && previousUndoStepId !== currentUndoStepId)
10137
10137
  return mergeIntoLastStep(steps, lastStep, op);
10138
10138
  if (currentUndoStepId === void 0 && previousUndoStepId === void 0) {
10139
- if (op.type === "set_selection")
10139
+ if (op.type === "set.selection")
10140
10140
  return mergeIntoLastStep(steps, lastStep, op);
10141
10141
  const lastOp = lastStep.operations.at(-1);
10142
- return lastOp && op.type === "insert_text" && lastOp.type === "insert_text" && op.offset === lastOp.offset + lastOp.text.length && pathEquals(op.path, lastOp.path) && op.text !== " " || lastOp && op.type === "remove_text" && lastOp.type === "remove_text" && op.offset + op.text.length === lastOp.offset && pathEquals(op.path, lastOp.path) ? mergeIntoLastStep(steps, lastStep, op) : createNewStep(steps, op, selectionBeforeApply);
10142
+ return lastOp && op.type === "insert.text" && lastOp.type === "insert.text" && op.offset === lastOp.offset + lastOp.text.length && pathEquals(op.path, lastOp.path) && op.text !== " " || lastOp && op.type === "remove.text" && lastOp.type === "remove.text" && op.offset + op.text.length === lastOp.offset && pathEquals(op.path, lastOp.path) ? mergeIntoLastStep(steps, lastStep, op) : createNewStep(steps, op, selectionBeforeApply);
10143
10143
  }
10144
10144
  if (currentUndoStepId !== void 0 && previousUndoStepId !== void 0 && currentUndoStepId !== previousUndoStepId) {
10145
10145
  const lastOp = lastStep.operations.at(-1);
10146
- if (lastOp && op.type === "insert_text" && lastOp.type === "insert_text" && op.offset === lastOp.offset + lastOp.text.length && pathEquals(op.path, lastOp.path) && op.text !== " " || lastOp && op.type === "remove_text" && lastOp.type === "remove_text" && op.offset + op.text.length === lastOp.offset && pathEquals(op.path, lastOp.path))
10146
+ if (lastOp && op.type === "insert.text" && lastOp.type === "insert.text" && op.offset === lastOp.offset + lastOp.text.length && pathEquals(op.path, lastOp.path) && op.text !== " " || lastOp && op.type === "remove.text" && lastOp.type === "remove.text" && op.offset + op.text.length === lastOp.offset && pathEquals(op.path, lastOp.path))
10147
10147
  return mergeIntoLastStep(steps, lastStep, op);
10148
10148
  }
10149
10149
  if (currentUndoStepId === void 0 && previousUndoStepId !== void 0) {
10150
10150
  const lastOp = lastStep.operations.at(-1);
10151
- if (lastOp && op.type === "insert_text" && lastOp.type === "insert_text" && op.offset === lastOp.offset + lastOp.text.length && pathEquals(op.path, lastOp.path) && op.text !== " ")
10151
+ if (lastOp && op.type === "insert.text" && lastOp.type === "insert.text" && op.offset === lastOp.offset + lastOp.text.length && pathEquals(op.path, lastOp.path) && op.text !== " ")
10152
10152
  return mergeIntoLastStep(steps, lastStep, op);
10153
10153
  }
10154
10154
  return createNewStep(steps, op, selectionBeforeApply);
10155
10155
  }
10156
10156
  function createNewStep(steps, op, selectionBeforeApply) {
10157
10157
  const operations = selectionBeforeApply === null ? [op] : [{
10158
- type: "set_selection",
10158
+ type: "set.selection",
10159
10159
  properties: {
10160
10160
  ...selectionBeforeApply
10161
10161
  },
@@ -10216,11 +10216,11 @@ function subscribeHistory({
10216
10216
  return;
10217
10217
  }
10218
10218
  const operation = event.operation;
10219
- if ((operation.type === "set" || operation.type === "unset" || operation.type === "insert") && !operation.inverse || (operation.type === "insert_text" || operation.type === "remove_text") && operation.text.length === 0) {
10219
+ if ((operation.type === "set" || operation.type === "unset" || operation.type === "insert") && !operation.inverse || (operation.type === "insert.text" || operation.type === "remove.text") && operation.text.length === 0) {
10220
10220
  previousUndoStepId = currentUndoStepId;
10221
10221
  return;
10222
10222
  }
10223
- for (operation.type !== "set_selection" && editor.history.redos.length > 0 && (editor.history.redos = []), editor.history.undos = createUndoSteps({
10223
+ for (operation.type !== "set.selection" && editor.history.redos.length > 0 && (editor.history.redos = []), editor.history.undos = createUndoSteps({
10224
10224
  steps: editor.history.undos,
10225
10225
  op: operation,
10226
10226
  currentUndoStepId,
@@ -10264,11 +10264,11 @@ function subscribePatchGeneration({
10264
10264
  initialValue,
10265
10265
  schema
10266
10266
  } = snapshot.context, editorWasEmpty = previousValue.length === 1 && isEqualToEmptyEditor(initialValue, previousValue, schema), editorIsEmpty = editor.snapshot.context.value.length === 1 && isEqualToEmptyEditor(initialValue, editor.snapshot.context.value, schema);
10267
- switch (editorWasEmpty && !editorIsEmpty && operation.type !== "set_selection" && patches.push(insert(previousValue, "before", [0])), operation.type) {
10268
- case "insert_text":
10267
+ switch (editorWasEmpty && !editorIsEmpty && operation.type !== "set.selection" && patches.push(insert(previousValue, "before", [0])), operation.type) {
10268
+ case "insert.text":
10269
10269
  patches = [...patches, ...textPatch(editor.snapshot, operation, previousValue)];
10270
10270
  break;
10271
- case "remove_text":
10271
+ case "remove.text":
10272
10272
  patches = [...patches, ...textPatch(editor.snapshot, operation, previousValue)];
10273
10273
  break;
10274
10274
  case "insert":
@@ -10281,7 +10281,7 @@ function subscribePatchGeneration({
10281
10281
  patches = [...patches, unset(operation.path)];
10282
10282
  break;
10283
10283
  }
10284
- if (!editorWasEmpty && editorIsEmpty && ["set", "unset", "remove_text"].includes(operation.type) && (patches = [...patches, unset([])]), editorWasEmpty && patches.length > 0 && (patches = [setIfMissing([], []), ...patches]), patches.length > 0)
10284
+ if (!editorWasEmpty && editorIsEmpty && ["set", "unset", "remove.text"].includes(operation.type) && (patches = [...patches, unset([])]), editorWasEmpty && patches.length > 0 && (patches = [setIfMissing([], []), ...patches]), patches.length > 0)
10285
10285
  for (const patch of patches)
10286
10286
  editorActor.send({
10287
10287
  type: "internal.patch",
@@ -10302,7 +10302,7 @@ ${safeStringify(event.operation, 2)}`);
10302
10302
  phase: "before"
10303
10303
  }) : void 0, unsubscribeIndexMaps = subscribeToOperations(editor, (event) => {
10304
10304
  const operation = event.operation;
10305
- operation.type !== "set_selection" && (operation.type === "insert_text" || operation.type === "remove_text" || operation.path.length <= 2 && buildIndexMaps({
10305
+ operation.type !== "set.selection" && (operation.type === "insert.text" || operation.type === "remove.text" || operation.path.length <= 2 && buildIndexMaps({
10306
10306
  schema: context.schema,
10307
10307
  value: editor.snapshot.context.value
10308
10308
  }, {
@@ -12349,12 +12349,12 @@ const childSetOperationImplementation = ({
12349
12349
  }, childPath);
12350
12350
  const newKey = rest._key, textPath = typeof newKey == "string" && newKey !== child._key ? siblingPath(childPath, newKey) : childPath;
12351
12351
  typeof text == "string" && child.text !== text && (operation.editor.apply({
12352
- type: "remove_text",
12352
+ type: "remove.text",
12353
12353
  path: textPath,
12354
12354
  offset: 0,
12355
12355
  text: child.text
12356
12356
  }), operation.editor.apply({
12357
- type: "insert_text",
12357
+ type: "insert.text",
12358
12358
  path: textPath,
12359
12359
  offset: 0,
12360
12360
  text
@@ -12726,7 +12726,7 @@ function applyDelete(editor, range2, options) {
12726
12726
  offset
12727
12727
  } = editor.snapshot.context.selection.anchor;
12728
12728
  editor.apply({
12729
- type: "insert_text",
12729
+ type: "insert.text",
12730
12730
  path: path2,
12731
12731
  offset,
12732
12732
  text: reinsert
@@ -12841,7 +12841,7 @@ function removeTextRange(editor, path2, startOffset, endOffset, capture) {
12841
12841
  return null;
12842
12842
  const text = span.node.text.slice(startOffset, endOffset);
12843
12843
  return text.length === 0 ? null : (editor.apply({
12844
- type: "remove_text",
12844
+ type: "remove.text",
12845
12845
  path: path2,
12846
12846
  offset: startOffset,
12847
12847
  text
@@ -12853,7 +12853,7 @@ function removeTextFromOffset(editor, path2, offset, capture) {
12853
12853
  return null;
12854
12854
  const text = span.node.text.slice(offset);
12855
12855
  return editor.apply({
12856
- type: "remove_text",
12856
+ type: "remove.text",
12857
12857
  path: path2,
12858
12858
  offset,
12859
12859
  text
@@ -12864,7 +12864,7 @@ function removeTextUpToOffset(editor, path2, offset) {
12864
12864
  return;
12865
12865
  const span = getSpan(editor.snapshot, path2);
12866
12866
  span && editor.apply({
12867
- type: "remove_text",
12867
+ type: "remove.text",
12868
12868
  path: path2,
12869
12869
  offset: 0,
12870
12870
  text: span.node.text.slice(0, offset)
@@ -13159,7 +13159,7 @@ function unwrapContainer(editor, originPath, position) {
13159
13159
  }), previousSelection) {
13160
13160
  const anchor = transformPoint(previousSelection.anchor, innerPrefix), focus = transformPoint(previousSelection.focus, innerPrefix);
13161
13161
  editor.apply({
13162
- type: "set_selection",
13162
+ type: "set.selection",
13163
13163
  properties: editor.snapshot.context.selection,
13164
13164
  newProperties: {
13165
13165
  anchor,
@@ -13270,7 +13270,7 @@ function transformOperation(editor, patch, operation) {
13270
13270
  if (diffs.forEach((diff2, index) => {
13271
13271
  const [diffType, text] = diff2;
13272
13272
  diffType === DIFF_INSERT ? (adjustOffsetBy += text.length, changedOffset += text.length) : diffType === DIFF_DELETE ? (adjustOffsetBy -= text.length, changedOffset -= text.length) : diffType === DIFF_EQUAL && (diffs.slice(index).every(([dType]) => dType === DIFF_EQUAL) || (changedOffset += text.length));
13273
- }), transformedOperation.type === "insert_text" && changedOffset < transformedOperation.offset && (transformedOperation.offset += adjustOffsetBy), transformedOperation.type === "remove_text" && changedOffset <= transformedOperation.offset - transformedOperation.text.length && (transformedOperation.offset += adjustOffsetBy), transformedOperation.type === "set_selection") {
13273
+ }), transformedOperation.type === "insert.text" && changedOffset < transformedOperation.offset && (transformedOperation.offset += adjustOffsetBy), transformedOperation.type === "remove.text" && changedOffset <= transformedOperation.offset - transformedOperation.text.length && (transformedOperation.offset += adjustOffsetBy), transformedOperation.type === "set.selection") {
13274
13274
  const currentFocus = transformedOperation.properties?.focus ? {
13275
13275
  ...transformedOperation.properties.focus
13276
13276
  } : void 0, currentAnchor = transformedOperation?.properties?.anchor ? {
@@ -13295,7 +13295,7 @@ function transformOperation(editor, patch, operation) {
13295
13295
  return [transformedOperation];
13296
13296
  }
13297
13297
  function findOperationTargetBlock(snapshot, editor, operation) {
13298
- if (operation.type === "set_selection" && editor.snapshot.context.selection)
13298
+ if (operation.type === "set.selection" && editor.snapshot.context.selection)
13299
13299
  return getEnclosingBlock(snapshot, editor.snapshot.context.selection.focus.path)?.node;
13300
13300
  if ("path" in operation)
13301
13301
  return getEnclosingBlock(snapshot, operation.path)?.node;
@@ -13349,15 +13349,15 @@ function inverseOperation(op) {
13349
13349
  path: op.inverse.path
13350
13350
  };
13351
13351
  }
13352
- case "insert_text":
13352
+ case "insert.text":
13353
13353
  return {
13354
13354
  ...op,
13355
- type: "remove_text"
13355
+ type: "remove.text"
13356
13356
  };
13357
- case "remove_text":
13357
+ case "remove.text":
13358
13358
  return {
13359
13359
  ...op,
13360
- type: "insert_text"
13360
+ type: "insert.text"
13361
13361
  };
13362
13362
  case "set": {
13363
13363
  if (!op.inverse)
@@ -13399,7 +13399,7 @@ function inverseOperation(op) {
13399
13399
  }
13400
13400
  };
13401
13401
  }
13402
- case "set_selection": {
13402
+ case "set.selection": {
13403
13403
  const {
13404
13404
  properties,
13405
13405
  newProperties
@@ -13725,7 +13725,7 @@ function applyPostInsertSelection(editor, insertedBlockPath, select2, selectionA
13725
13725
  return;
13726
13726
  }
13727
13727
  editor.snapshot.context.selection && editor.apply({
13728
- type: "set_selection",
13728
+ type: "set.selection",
13729
13729
  properties: editor.snapshot.context.selection,
13730
13730
  newProperties: null
13731
13731
  });
@@ -13887,7 +13887,7 @@ function insertFragmentChildren(editor, block, at) {
13887
13887
  schema: editor.snapshot.context.schema
13888
13888
  }, firstChild))
13889
13889
  return firstChild.text.length > 0 && editor.apply({
13890
- type: "insert_text",
13890
+ type: "insert.text",
13891
13891
  path: at.path,
13892
13892
  offset: 0,
13893
13893
  text: firstChild.text
@@ -14006,7 +14006,7 @@ const insertChildOperationImplementation = ({
14006
14006
  if (operation.text.length === 0)
14007
14007
  return;
14008
14008
  operation.editor.apply({
14009
- type: "insert_text",
14009
+ type: "insert.text",
14010
14010
  path: operation.at,
14011
14011
  offset: operation.offset,
14012
14012
  text: operation.text
@@ -14042,7 +14042,7 @@ const insertChildOperationImplementation = ({
14042
14042
  return;
14043
14043
  }
14044
14044
  operation.text.length > 0 && editor.apply({
14045
- type: "insert_text",
14045
+ type: "insert.text",
14046
14046
  path: path2,
14047
14047
  offset,
14048
14048
  text: operation.text
@@ -14087,7 +14087,7 @@ const moveBackwardOperationImplementation = ({
14087
14087
  operation
14088
14088
  }) => {
14089
14089
  operation.editor.apply({
14090
- type: "remove_text",
14090
+ type: "remove.text",
14091
14091
  path: operation.at,
14092
14092
  offset: operation.offset,
14093
14093
  text: operation.text
@@ -17107,7 +17107,7 @@ function createMutationBatcher({
17107
17107
  });
17108
17108
  }
17109
17109
  function handleOperation(operationType) {
17110
- if (operationType === "insert_text" || operationType === "remove_text") {
17110
+ if (operationType === "insert.text" || operationType === "remove.text") {
17111
17111
  isTyping = !0, typeDebounce !== void 0 && clearTimeout(typeDebounce), typeDebounce = setTimeout(() => {
17112
17112
  isTyping = !1, typeDebounce = void 0, flush();
17113
17113
  }, TYPE_DEBOUNCE);
@@ -17135,11 +17135,18 @@ function createRelay() {
17135
17135
  const typeListeners = listeners.get(event.type);
17136
17136
  if (typeListeners)
17137
17137
  for (let index = 0; index < typeListeners.length; index++)
17138
- typeListeners[index]?.(event);
17138
+ callListener(typeListeners[index], event);
17139
17139
  const everyEventListeners = listeners.get("*");
17140
17140
  if (everyEventListeners)
17141
17141
  for (let index = 0; index < everyEventListeners.length; index++)
17142
- everyEventListeners[index]?.(event);
17142
+ callListener(everyEventListeners[index], event);
17143
+ }
17144
+ function callListener(listener, event) {
17145
+ try {
17146
+ listener?.(event);
17147
+ } catch (error) {
17148
+ console.error(error);
17149
+ }
17143
17150
  }
17144
17151
  function dispatch(event) {
17145
17152
  if (event.type === "focused") {
@@ -18113,7 +18120,7 @@ function updateBlock({
18113
18120
  selection: "preserve",
18114
18121
  removeEmptyStartBlock: !0
18115
18122
  }), editorEngine.apply({
18116
- type: "insert_text",
18123
+ type: "insert.text",
18117
18124
  path: path2,
18118
18125
  offset: 0,
18119
18126
  text: currentBlockChild.text