@portabletext/editor 2.8.3 → 2.9.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/lib/index.js CHANGED
@@ -3698,19 +3698,17 @@ function toInt(num) {
3698
3698
  return parseInt(num, 10);
3699
3699
  }
3700
3700
  const CURRENT_UNDO_STEP = /* @__PURE__ */ new WeakMap();
3701
- function withUndoStep(editor, fn) {
3702
- const current = CURRENT_UNDO_STEP.get(editor);
3703
- if (current) {
3704
- fn();
3705
- return;
3706
- }
3707
- CURRENT_UNDO_STEP.set(editor, current ?? {
3708
- undoStepId: defaultKeyGenerator()
3709
- }), fn(), CURRENT_UNDO_STEP.set(editor, void 0);
3710
- }
3711
3701
  function getCurrentUndoStepId(editor) {
3712
3702
  return CURRENT_UNDO_STEP.get(editor)?.undoStepId;
3713
3703
  }
3704
+ function createUndoStep(editor) {
3705
+ CURRENT_UNDO_STEP.set(editor, {
3706
+ undoStepId: defaultKeyGenerator()
3707
+ });
3708
+ }
3709
+ function clearUndoStep(editor) {
3710
+ CURRENT_UNDO_STEP.set(editor, void 0);
3711
+ }
3714
3712
  const debug$b = debugWithName("plugin:withUndoRedo"), SAVING = /* @__PURE__ */ new WeakMap(), REMOTE_PATCHES = /* @__PURE__ */ new WeakMap(), UNDO_STEP_LIMIT = 1e3, isSaving = (editor) => {
3715
3713
  const state = SAVING.get(editor);
3716
3714
  return state === void 0 ? !0 : state;
@@ -8271,28 +8269,104 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
8271
8269
  on: "insert.blocks",
8272
8270
  guard: ({
8273
8271
  event
8274
- }) => event.placement === "before",
8272
+ }) => {
8273
+ const onlyBlock = event.blocks.length === 1 ? event.blocks.at(0) : void 0;
8274
+ return onlyBlock ? {
8275
+ onlyBlock
8276
+ } : !1;
8277
+ },
8275
8278
  actions: [({
8276
8279
  event
8277
- }) => event.blocks.map((block, index) => raise({
8280
+ }, {
8281
+ onlyBlock
8282
+ }) => [raise({
8283
+ type: "insert.block",
8284
+ block: onlyBlock,
8285
+ placement: event.placement,
8286
+ select: event.select ?? "end"
8287
+ })]]
8288
+ }), defineBehavior({
8289
+ on: "insert.blocks",
8290
+ guard: ({
8291
+ snapshot,
8292
+ event
8293
+ }) => {
8294
+ if (event.placement !== "before")
8295
+ return !1;
8296
+ const firstBlockKey = event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(), lastBlockKey = event.blocks.at(-1)?._key ?? snapshot.context.keyGenerator();
8297
+ return {
8298
+ firstBlockKey,
8299
+ lastBlockKey
8300
+ };
8301
+ },
8302
+ actions: [({
8303
+ snapshot,
8304
+ event
8305
+ }, {
8306
+ firstBlockKey,
8307
+ lastBlockKey
8308
+ }) => [...event.blocks.map((block, index) => raise({
8278
8309
  type: "insert.block",
8279
8310
  block,
8280
8311
  placement: index === 0 ? "before" : "after",
8281
- select: event.select ?? "end"
8282
- }))]
8312
+ select: index !== event.blocks.length - 1 ? "end" : "none"
8313
+ })), ...event.select === "none" ? [raise({
8314
+ type: "select",
8315
+ at: snapshot.context.selection
8316
+ })] : event.select === "start" ? [raise({
8317
+ type: "select.block",
8318
+ at: [{
8319
+ _key: firstBlockKey
8320
+ }],
8321
+ select: "start"
8322
+ })] : [raise({
8323
+ type: "select.block",
8324
+ at: [{
8325
+ _key: lastBlockKey
8326
+ }],
8327
+ select: "end"
8328
+ })]]]
8283
8329
  }), defineBehavior({
8284
8330
  on: "insert.blocks",
8285
8331
  guard: ({
8332
+ snapshot,
8286
8333
  event
8287
- }) => event.placement === "after",
8334
+ }) => {
8335
+ if (event.placement !== "after")
8336
+ return !1;
8337
+ const firstBlockKey = event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(), lastBlockKey = event.blocks.at(-1)?._key ?? snapshot.context.keyGenerator();
8338
+ return {
8339
+ firstBlockKey,
8340
+ lastBlockKey
8341
+ };
8342
+ },
8288
8343
  actions: [({
8344
+ snapshot,
8289
8345
  event
8290
- }) => event.blocks.map((block) => raise({
8346
+ }, {
8347
+ firstBlockKey,
8348
+ lastBlockKey
8349
+ }) => [...event.blocks.map((block, index) => raise({
8291
8350
  type: "insert.block",
8292
8351
  block,
8293
8352
  placement: "after",
8294
- select: event.select ?? "end"
8295
- }))]
8353
+ select: index !== event.blocks.length - 1 ? "end" : "none"
8354
+ })), ...event.select === "none" ? [raise({
8355
+ type: "select",
8356
+ at: snapshot.context.selection
8357
+ })] : event.select === "start" ? [raise({
8358
+ type: "select.block",
8359
+ at: [{
8360
+ _key: firstBlockKey
8361
+ }],
8362
+ select: "start"
8363
+ })] : [raise({
8364
+ type: "select.block",
8365
+ at: [{
8366
+ _key: lastBlockKey
8367
+ }],
8368
+ select: "end"
8369
+ })]]]
8296
8370
  }), defineBehavior({
8297
8371
  on: "insert.blocks",
8298
8372
  guard: ({
@@ -8302,49 +8376,123 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
8302
8376
  if (event.placement !== "auto")
8303
8377
  return !1;
8304
8378
  const focusTextBlock = getFocusTextBlock(snapshot);
8305
- return focusTextBlock ? {
8306
- focusTextBlock
8307
- } : !1;
8379
+ if (!focusTextBlock || !isEmptyTextBlock(snapshot.context, focusTextBlock.node))
8380
+ return !1;
8381
+ const firstBlockKey = event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(), lastBlockKey = event.blocks.at(-1)?._key ?? snapshot.context.keyGenerator();
8382
+ return {
8383
+ focusTextBlock,
8384
+ firstBlockKey,
8385
+ lastBlockKey
8386
+ };
8308
8387
  },
8309
8388
  actions: [({
8310
- snapshot,
8311
8389
  event
8312
8390
  }, {
8313
- focusTextBlock
8314
- }) => event.blocks.length === 1 ? [raise({
8315
- type: "insert.block",
8316
- block: event.blocks[0],
8317
- placement: "auto",
8318
- select: event.select ?? "end"
8319
- })] : isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => raise({
8391
+ firstBlockKey,
8392
+ lastBlockKey
8393
+ }) => [...event.blocks.map((block, index) => raise({
8320
8394
  type: "insert.block",
8321
8395
  block,
8322
8396
  placement: index === 0 ? "auto" : "after",
8323
- select: event.select ?? "end"
8324
- })) : event.blocks.flatMap((block, index) => index === 0 ? [raise({
8325
- type: "split"
8326
- }), raise({
8327
- type: "select.previous block",
8397
+ select: index !== event.blocks.length - 1 ? "end" : "none"
8398
+ })), ...event.select === "none" || event.select === "start" ? [raise({
8399
+ type: "select.block",
8400
+ at: [{
8401
+ _key: firstBlockKey
8402
+ }],
8403
+ select: "start"
8404
+ })] : [raise({
8405
+ type: "select.block",
8406
+ at: [{
8407
+ _key: lastBlockKey
8408
+ }],
8328
8409
  select: "end"
8329
- }), raise({
8410
+ })]]]
8411
+ }), defineBehavior({
8412
+ on: "insert.blocks",
8413
+ guard: ({
8414
+ snapshot,
8415
+ event
8416
+ }) => {
8417
+ if (event.placement !== "auto")
8418
+ return !1;
8419
+ const focusTextBlock = getFocusTextBlock(snapshot);
8420
+ if (!focusTextBlock || !snapshot.context.selection)
8421
+ return !1;
8422
+ const focusBlockStartPoint = getBlockStartPoint({
8423
+ context: snapshot.context,
8424
+ block: focusTextBlock
8425
+ }), focusBlockEndPoint = getBlockEndPoint({
8426
+ context: snapshot.context,
8427
+ block: focusTextBlock
8428
+ }), focusTextBlockAfter = sliceTextBlock({
8429
+ context: {
8430
+ schema: snapshot.context.schema,
8431
+ selection: {
8432
+ anchor: snapshot.context.selection.focus,
8433
+ focus: focusBlockEndPoint
8434
+ }
8435
+ },
8436
+ block: focusTextBlock.node
8437
+ });
8438
+ return {
8439
+ firstBlockKey: event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(),
8440
+ focusBlockStartPoint,
8441
+ focusBlockEndPoint,
8442
+ focusTextBlockAfter,
8443
+ selection: snapshot.context.selection
8444
+ };
8445
+ },
8446
+ actions: [({
8447
+ event
8448
+ }, {
8449
+ focusBlockEndPoint,
8450
+ focusTextBlockAfter,
8451
+ selection,
8452
+ firstBlockKey,
8453
+ focusBlockStartPoint
8454
+ }) => [...event.blocks.flatMap((block, index) => index === 0 ? [...isEqualSelectionPoints(selection.focus, focusBlockEndPoint) ? [] : [raise({
8455
+ type: "delete",
8456
+ at: {
8457
+ anchor: selection.focus,
8458
+ focus: focusBlockEndPoint
8459
+ }
8460
+ })], raise({
8330
8461
  type: "insert.block",
8331
8462
  block,
8332
8463
  placement: "auto",
8333
- select: event.select ?? "end"
8464
+ select: "end"
8334
8465
  })] : index === event.blocks.length - 1 ? [raise({
8335
- type: "select.next block",
8336
- select: "start"
8337
- }), raise({
8338
8466
  type: "insert.block",
8339
8467
  block,
8468
+ placement: "after",
8469
+ select: "end"
8470
+ }), raise({
8471
+ type: "insert.block",
8472
+ block: focusTextBlockAfter,
8340
8473
  placement: "auto",
8341
- select: event.select ?? "end"
8474
+ select: event.select === "end" ? "none" : "end"
8342
8475
  })] : [raise({
8343
8476
  type: "insert.block",
8344
8477
  block,
8345
8478
  placement: "after",
8346
- select: event.select ?? "end"
8347
- })])]
8479
+ select: "end"
8480
+ })]), ...event.select === "none" ? [raise({
8481
+ type: "select",
8482
+ at: selection
8483
+ })] : event.select === "start" ? [isEqualSelectionPoints(selection.focus, focusBlockStartPoint) ? raise({
8484
+ type: "select.block",
8485
+ at: [{
8486
+ _key: firstBlockKey
8487
+ }],
8488
+ select: "start"
8489
+ }) : raise({
8490
+ type: "select",
8491
+ at: {
8492
+ anchor: selection.focus,
8493
+ focus: selection.focus
8494
+ }
8495
+ })] : []]]
8348
8496
  }), defineBehavior({
8349
8497
  on: "insert.blocks",
8350
8498
  guard: ({
@@ -8600,62 +8748,99 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
8600
8748
  to: nextBlock.path
8601
8749
  })]]
8602
8750
  })], abstractSelectBehaviors = [defineBehavior({
8603
- on: "select.previous block",
8751
+ on: "select.block",
8604
8752
  guard: ({
8605
8753
  snapshot,
8606
8754
  event
8607
8755
  }) => {
8608
- const previousBlock = getPreviousBlock(snapshot);
8609
- if (!previousBlock)
8756
+ if (event.select !== "end")
8610
8757
  return !1;
8611
- const point = event.select === "end" ? getBlockEndPoint({
8612
- context: snapshot.context,
8613
- block: previousBlock
8614
- }) : getBlockStartPoint({
8615
- context: snapshot.context,
8616
- block: previousBlock
8617
- });
8618
- return {
8619
- selection: {
8620
- anchor: point,
8621
- focus: point
8758
+ const block = getFocusBlock$1({
8759
+ ...snapshot,
8760
+ context: {
8761
+ ...snapshot.context,
8762
+ selection: {
8763
+ anchor: {
8764
+ path: event.at,
8765
+ offset: 0
8766
+ },
8767
+ focus: {
8768
+ path: event.at,
8769
+ offset: 0
8770
+ }
8771
+ }
8622
8772
  }
8623
- };
8773
+ });
8774
+ return block ? {
8775
+ blockEndPoint: getBlockEndPoint({
8776
+ context: snapshot.context,
8777
+ block
8778
+ })
8779
+ } : !1;
8624
8780
  },
8625
8781
  actions: [(_, {
8626
- selection
8782
+ blockEndPoint
8627
8783
  }) => [raise({
8628
8784
  type: "select",
8629
- at: selection
8785
+ at: {
8786
+ anchor: blockEndPoint,
8787
+ focus: blockEndPoint
8788
+ }
8630
8789
  })]]
8631
8790
  }), defineBehavior({
8632
- on: "select.next block",
8791
+ on: "select.block",
8792
+ actions: [({
8793
+ event
8794
+ }) => [raise({
8795
+ type: "select",
8796
+ at: {
8797
+ anchor: {
8798
+ path: event.at,
8799
+ offset: 0
8800
+ },
8801
+ focus: {
8802
+ path: event.at,
8803
+ offset: 0
8804
+ }
8805
+ }
8806
+ })]]
8807
+ }), defineBehavior({
8808
+ on: "select.previous block",
8633
8809
  guard: ({
8634
- snapshot,
8810
+ snapshot
8811
+ }) => {
8812
+ const previousBlock = getPreviousBlock(snapshot);
8813
+ return previousBlock ? {
8814
+ previousBlock
8815
+ } : !1;
8816
+ },
8817
+ actions: [({
8635
8818
  event
8819
+ }, {
8820
+ previousBlock
8821
+ }) => [raise({
8822
+ type: "select.block",
8823
+ at: previousBlock.path,
8824
+ select: event.select
8825
+ })]]
8826
+ }), defineBehavior({
8827
+ on: "select.next block",
8828
+ guard: ({
8829
+ snapshot
8636
8830
  }) => {
8637
8831
  const nextBlock = getNextBlock(snapshot);
8638
- if (!nextBlock)
8639
- return !1;
8640
- const point = event.select === "end" ? getBlockEndPoint({
8641
- context: snapshot.context,
8642
- block: nextBlock
8643
- }) : getBlockStartPoint({
8644
- context: snapshot.context,
8645
- block: nextBlock
8646
- });
8647
- return {
8648
- selection: {
8649
- anchor: point,
8650
- focus: point
8651
- }
8652
- };
8832
+ return nextBlock ? {
8833
+ nextBlock
8834
+ } : !1;
8653
8835
  },
8654
- actions: [(_, {
8655
- selection
8836
+ actions: [({
8837
+ event
8838
+ }, {
8839
+ nextBlock
8656
8840
  }) => [raise({
8657
- type: "select",
8658
- at: selection
8841
+ type: "select.block",
8842
+ at: nextBlock.path,
8843
+ select: event.select
8659
8844
  })]]
8660
8845
  })], abstractSerializeBehaviors = [defineBehavior({
8661
8846
  on: "serialize",
@@ -9029,7 +9214,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
9029
9214
  function isSyntheticBehaviorEvent(event) {
9030
9215
  return !isCustomBehaviorEvent(event) && !isNativeBehaviorEvent(event) && !isAbstractBehaviorEvent(event);
9031
9216
  }
9032
- const abstractBehaviorEventTypes = ["annotation.set", "annotation.toggle", "decorator.toggle", "delete.backward", "delete.block", "delete.child", "delete.forward", "delete.text", "deserialize", "deserialize.data", "deserialization.success", "deserialization.failure", "insert.blocks", "insert.break", "insert.inline object", "insert.soft break", "insert.span", "list item.add", "list item.remove", "list item.toggle", "move.block down", "move.block up", "select.previous block", "select.next block", "serialize", "serialize.data", "serialization.success", "serialization.failure", "split", "style.add", "style.remove", "style.toggle"];
9217
+ const abstractBehaviorEventTypes = ["annotation.set", "annotation.toggle", "decorator.toggle", "delete.backward", "delete.block", "delete.child", "delete.forward", "delete.text", "deserialize", "deserialize.data", "deserialization.success", "deserialization.failure", "insert.blocks", "insert.break", "insert.inline object", "insert.soft break", "insert.span", "list item.add", "list item.remove", "list item.toggle", "move.block down", "move.block up", "select.block", "select.previous block", "select.next block", "serialize", "serialize.data", "serialization.success", "serialization.failure", "split", "style.add", "style.remove", "style.toggle"];
9033
9218
  function isAbstractBehaviorEvent(event) {
9034
9219
  return abstractBehaviorEventTypes.includes(event.type);
9035
9220
  }
@@ -9056,7 +9241,7 @@ function performEvent({
9056
9241
  nativeEvent,
9057
9242
  sendBack
9058
9243
  }) {
9059
- debug$6(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
9244
+ mode === "send" && !isNativeBehaviorEvent(event) && createUndoStep(editor), debug$6(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
9060
9245
  const eventBehaviors = [...remainingEventBehaviors, ...abstractBehaviors].filter((behavior) => {
9061
9246
  if (behavior.on === "*")
9062
9247
  return !0;
@@ -9064,7 +9249,7 @@ function performEvent({
9064
9249
  return listenedNamespace !== void 0 && eventNamespace !== void 0 && listenedNamespace === eventNamespace || listenedNamespace !== void 0 && eventNamespace === void 0 && listenedNamespace === event.type ? !0 : behavior.on === event.type;
9065
9250
  });
9066
9251
  if (eventBehaviors.length === 0 && isSyntheticBehaviorEvent(event)) {
9067
- nativeEvent?.preventDefault(), withApplyingBehaviorOperations(editor, () => {
9252
+ nativeEvent?.preventDefault(), mode === "send" && clearUndoStep(editor), withApplyingBehaviorOperations(editor, () => {
9068
9253
  debug$6(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
9069
9254
  context: {
9070
9255
  keyGenerator,
@@ -9108,63 +9293,63 @@ function performEvent({
9108
9293
  }
9109
9294
  if (actions.length !== 0) {
9110
9295
  if (nativeEventPrevented = actions.some((action) => action.type === "raise" || action.type === "execute") || !actions.some((action) => action.type === "forward"), actions.some((action) => action.type === "execute")) {
9111
- withUndoStep(editor, () => {
9112
- for (const action of actions) {
9113
- if (action.type === "effect") {
9114
- try {
9115
- action.effect({
9116
- send: sendBack
9117
- });
9118
- } catch (error) {
9119
- console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
9120
- }
9121
- continue;
9122
- }
9123
- if (action.type === "forward") {
9124
- const remainingEventBehaviors2 = eventBehaviors.slice(eventBehaviorIndex + 1);
9125
- performEvent({
9126
- mode: "forward",
9127
- behaviors,
9128
- remainingEventBehaviors: remainingEventBehaviors2,
9129
- event: action.event,
9130
- editor,
9131
- keyGenerator,
9132
- schema,
9133
- getSnapshot,
9134
- nativeEvent,
9135
- sendBack
9136
- });
9137
- continue;
9138
- }
9139
- if (action.type === "raise") {
9140
- performEvent({
9141
- mode: "raise",
9142
- behaviors,
9143
- remainingEventBehaviors: behaviors,
9144
- event: action.event,
9145
- editor,
9146
- keyGenerator,
9147
- schema,
9148
- getSnapshot,
9149
- nativeEvent,
9150
- sendBack
9296
+ createUndoStep(editor);
9297
+ for (const action of actions) {
9298
+ if (action.type === "effect") {
9299
+ try {
9300
+ action.effect({
9301
+ send: sendBack
9151
9302
  });
9152
- continue;
9303
+ } catch (error) {
9304
+ console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
9153
9305
  }
9306
+ continue;
9307
+ }
9308
+ if (action.type === "forward") {
9309
+ const remainingEventBehaviors2 = eventBehaviors.slice(eventBehaviorIndex + 1);
9154
9310
  performEvent({
9155
- mode: "execute",
9311
+ mode: "forward",
9156
9312
  behaviors,
9157
- remainingEventBehaviors: [],
9313
+ remainingEventBehaviors: remainingEventBehaviors2,
9158
9314
  event: action.event,
9159
9315
  editor,
9160
9316
  keyGenerator,
9161
9317
  schema,
9162
9318
  getSnapshot,
9163
- nativeEvent: void 0,
9319
+ nativeEvent,
9164
9320
  sendBack
9165
9321
  });
9322
+ continue;
9166
9323
  }
9167
- });
9324
+ if (action.type === "raise") {
9325
+ performEvent({
9326
+ mode: "raise",
9327
+ behaviors,
9328
+ remainingEventBehaviors: behaviors,
9329
+ event: action.event,
9330
+ editor,
9331
+ keyGenerator,
9332
+ schema,
9333
+ getSnapshot,
9334
+ nativeEvent,
9335
+ sendBack
9336
+ });
9337
+ continue;
9338
+ }
9339
+ performEvent({
9340
+ mode: "execute",
9341
+ behaviors,
9342
+ remainingEventBehaviors: [],
9343
+ event: action.event,
9344
+ editor,
9345
+ keyGenerator,
9346
+ schema,
9347
+ getSnapshot,
9348
+ nativeEvent: void 0,
9349
+ sendBack
9350
+ });
9351
+ }
9352
+ clearUndoStep(editor);
9168
9353
  continue;
9169
9354
  }
9170
9355
  for (const action of actions) {
@@ -9216,7 +9401,7 @@ function performEvent({
9216
9401
  break;
9217
9402
  }
9218
9403
  }
9219
- !defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), withApplyingBehaviorOperations(editor, () => {
9404
+ !defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), mode === "send" && clearUndoStep(editor), withApplyingBehaviorOperations(editor, () => {
9220
9405
  debug$6(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
9221
9406
  context: {
9222
9407
  keyGenerator,
@@ -9297,7 +9482,44 @@ function createEditorSnapshot({
9297
9482
  decoratorState: editor.decoratorState
9298
9483
  };
9299
9484
  }
9300
- const debug$5 = debugWithName("editor machine"), editorMachine = setup({
9485
+ const debug$5 = debugWithName("editor machine");
9486
+ function rerouteExternalBehaviorEvent({
9487
+ event,
9488
+ slateEditor
9489
+ }) {
9490
+ switch (event.type) {
9491
+ case "blur":
9492
+ return {
9493
+ type: "blur",
9494
+ editor: slateEditor
9495
+ };
9496
+ case "focus":
9497
+ return {
9498
+ type: "focus",
9499
+ editor: slateEditor
9500
+ };
9501
+ case "insert.block object":
9502
+ return {
9503
+ type: "behavior event",
9504
+ behaviorEvent: {
9505
+ type: "insert.block",
9506
+ block: {
9507
+ _type: event.blockObject.name,
9508
+ ...event.blockObject.value ?? {}
9509
+ },
9510
+ placement: event.placement
9511
+ },
9512
+ editor: slateEditor
9513
+ };
9514
+ default:
9515
+ return {
9516
+ type: "behavior event",
9517
+ behaviorEvent: event,
9518
+ editor: slateEditor
9519
+ };
9520
+ }
9521
+ }
9522
+ const editorMachine = setup({
9301
9523
  types: {
9302
9524
  context: {},
9303
9525
  events: {},
@@ -9399,7 +9621,7 @@ const debug$5 = debugWithName("editor machine"), editorMachine = setup({
9399
9621
  try {
9400
9622
  const behaviors = [...context.behaviors.values()].map((config) => config.behavior);
9401
9623
  performEvent({
9402
- mode: "raise",
9624
+ mode: "send",
9403
9625
  behaviors,
9404
9626
  remainingEventBehaviors: behaviors,
9405
9627
  event: event.behaviorEvent,
@@ -9421,11 +9643,10 @@ const debug$5 = debugWithName("editor machine"), editorMachine = setup({
9421
9643
  self.send(eventSentBack);
9422
9644
  return;
9423
9645
  }
9424
- self.send({
9425
- type: "behavior event",
9426
- behaviorEvent: eventSentBack,
9427
- editor: event.editor
9428
- });
9646
+ self.send(rerouteExternalBehaviorEvent({
9647
+ event: eventSentBack,
9648
+ slateEditor: event.editor
9649
+ }));
9429
9650
  }
9430
9651
  });
9431
9652
  } catch (error) {
@@ -11371,38 +11592,11 @@ function createInternalEditor(config) {
11371
11592
  case "update maxBlocks":
11372
11593
  editorActor.send(event);
11373
11594
  break;
11374
- case "blur":
11375
- editorActor.send({
11376
- type: "blur",
11377
- editor: slateEditor.instance
11378
- });
11379
- break;
11380
- case "focus":
11381
- editorActor.send({
11382
- type: "focus",
11383
- editor: slateEditor.instance
11384
- });
11385
- break;
11386
- case "insert.block object":
11387
- editorActor.send({
11388
- type: "behavior event",
11389
- behaviorEvent: {
11390
- type: "insert.block",
11391
- block: {
11392
- _type: event.blockObject.name,
11393
- ...event.blockObject.value ?? {}
11394
- },
11395
- placement: event.placement
11396
- },
11397
- editor: slateEditor.instance
11398
- });
11399
- break;
11400
11595
  default:
11401
- editorActor.send({
11402
- type: "behavior event",
11403
- behaviorEvent: event,
11404
- editor: slateEditor.instance
11405
- });
11596
+ editorActor.send(rerouteExternalBehaviorEvent({
11597
+ event,
11598
+ slateEditor: slateEditor.instance
11599
+ }));
11406
11600
  }
11407
11601
  },
11408
11602
  on: (event, listener) => relayActor.on(event, (event2) => {