@portabletext/editor 2.3.8 → 2.4.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
@@ -12,7 +12,7 @@ import { getBlockStartPoint, getBlockKeyFromSelectionPoint, isTextBlock, getChil
12
12
  import { getBlockEndPoint, isSelectionCollapsed, isEqualSelectionPoints, isEmptyTextBlock } from "./_chunks-es/util.is-selection-collapsed.js";
13
13
  import isEqual from "lodash/isEqual.js";
14
14
  import { isSelectionCollapsed as isSelectionCollapsed$1, getFocusTextBlock, getFocusSpan as getFocusSpan$1, isSelectionExpanded, getFocusBlock as getFocusBlock$1, getSelectedValue, getSelectionStartPoint as getSelectionStartPoint$1, getFocusChild as getFocusChild$1 } from "./_chunks-es/selector.is-selection-expanded.js";
15
- import { getFocusInlineObject, getSelectedBlocks, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, isOverlappingSelection, isSelectingEntireBlocks, getMarkState, getActiveDecorators, getActiveAnnotationsMarks, getTrimmedSelection, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, getSelectionEndPoint as getSelectionEndPoint$1, isActiveAnnotation, isActiveDecorator, getSelectedTextBlocks, isActiveListItem, isActiveStyle, getActiveAnnotations } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
15
+ import { getFocusInlineObject, getSelectedBlocks, getSelectionStartBlock as getSelectionStartBlock$1, getSelectionEndBlock as getSelectionEndBlock$1, isOverlappingSelection, isSelectingEntireBlocks, getMarkState, getActiveDecorators, getActiveAnnotationsMarks, getTrimmedSelection, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, getSelectionEndPoint as getSelectionEndPoint$1, isActiveAnnotation, isActiveDecorator, getActiveAnnotations, getSelectedTextBlocks, isActiveListItem, isActiveStyle } from "./_chunks-es/selector.is-selecting-entire-blocks.js";
16
16
  import getRandomValues from "get-random-values-esm";
17
17
  import { defineBehavior, forward, raise, effect } from "./behaviors/index.js";
18
18
  import uniq from "lodash/uniq.js";
@@ -6872,7 +6872,193 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
6872
6872
  type: "delete",
6873
6873
  at: selection
6874
6874
  })]]
6875
- })], abstractInsertBehaviors = [defineBehavior({
6875
+ })], abstractDeserializeBehaviors = [
6876
+ defineBehavior({
6877
+ on: "deserialize",
6878
+ guard: ({
6879
+ event
6880
+ }) => {
6881
+ const portableText = event.originEvent.originEvent.dataTransfer.getData("application/x-portable-text");
6882
+ if (portableText)
6883
+ return {
6884
+ type: "deserialize.data",
6885
+ mimeType: "application/x-portable-text",
6886
+ data: portableText,
6887
+ originEvent: event.originEvent
6888
+ };
6889
+ const json = event.originEvent.originEvent.dataTransfer.getData("application/json");
6890
+ if (json)
6891
+ return {
6892
+ type: "deserialize.data",
6893
+ mimeType: "application/json",
6894
+ data: json,
6895
+ originEvent: event.originEvent
6896
+ };
6897
+ const html = event.originEvent.originEvent.dataTransfer.getData("text/html");
6898
+ if (html)
6899
+ return {
6900
+ type: "deserialize.data",
6901
+ mimeType: "text/html",
6902
+ data: html,
6903
+ originEvent: event.originEvent
6904
+ };
6905
+ const text = event.originEvent.originEvent.dataTransfer.getData("text/plain");
6906
+ return text ? {
6907
+ type: "deserialize.data",
6908
+ mimeType: "text/plain",
6909
+ data: text,
6910
+ originEvent: event.originEvent
6911
+ } : !1;
6912
+ },
6913
+ actions: [(_, deserializeEvent) => [raise(deserializeEvent)]]
6914
+ }),
6915
+ defineBehavior({
6916
+ on: "deserialize",
6917
+ actions: [({
6918
+ event
6919
+ }) => [raise({
6920
+ type: "deserialization.failure",
6921
+ mimeType: "*/*",
6922
+ reason: "No Behavior was able to handle the incoming data",
6923
+ originEvent: event.originEvent
6924
+ })]]
6925
+ }),
6926
+ defineBehavior({
6927
+ on: "deserialize.data",
6928
+ guard: ({
6929
+ snapshot,
6930
+ event
6931
+ }) => {
6932
+ const converter = snapshot.context.converters.find((converter2) => converter2.mimeType === event.mimeType);
6933
+ return converter ? converter.deserialize({
6934
+ snapshot,
6935
+ event: {
6936
+ type: "deserialize",
6937
+ data: event.data
6938
+ }
6939
+ }) : !1;
6940
+ },
6941
+ actions: [({
6942
+ event
6943
+ }, deserializeEvent) => [raise({
6944
+ ...deserializeEvent,
6945
+ originEvent: event.originEvent
6946
+ })]]
6947
+ }),
6948
+ /**
6949
+ * If we are pasting text/plain into a text block then we can probably
6950
+ * assume that the intended behavior is that the pasted text inherits
6951
+ * formatting from the text it's pasted into.
6952
+ */
6953
+ defineBehavior({
6954
+ on: "deserialization.success",
6955
+ guard: ({
6956
+ snapshot,
6957
+ event
6958
+ }) => {
6959
+ if (getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
6960
+ const activeDecorators = getActiveDecorators(snapshot);
6961
+ return {
6962
+ activeAnnotations: getActiveAnnotations(snapshot),
6963
+ activeDecorators,
6964
+ textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context, block) ? [getTextBlockText(block)] : [])
6965
+ };
6966
+ }
6967
+ return !1;
6968
+ },
6969
+ actions: [(_, {
6970
+ activeAnnotations,
6971
+ activeDecorators,
6972
+ textRuns
6973
+ }) => textRuns.flatMap((textRun, index) => index !== textRuns.length - 1 ? [raise({
6974
+ type: "insert.span",
6975
+ text: textRun,
6976
+ decorators: activeDecorators,
6977
+ annotations: activeAnnotations.map(({
6978
+ _key,
6979
+ _type,
6980
+ ...value
6981
+ }) => ({
6982
+ name: _type,
6983
+ value
6984
+ }))
6985
+ }), raise({
6986
+ type: "insert.break"
6987
+ })] : [raise({
6988
+ type: "insert.span",
6989
+ text: textRun,
6990
+ decorators: activeDecorators,
6991
+ annotations: activeAnnotations.map(({
6992
+ _key,
6993
+ _type,
6994
+ ...value
6995
+ }) => ({
6996
+ name: _type,
6997
+ value
6998
+ }))
6999
+ })])]
7000
+ }),
7001
+ defineBehavior({
7002
+ on: "deserialization.success",
7003
+ actions: [({
7004
+ event
7005
+ }) => [raise({
7006
+ type: "insert.blocks",
7007
+ blocks: event.data,
7008
+ placement: "auto"
7009
+ })]]
7010
+ }),
7011
+ defineBehavior({
7012
+ on: "deserialization.failure",
7013
+ guard: ({
7014
+ event
7015
+ }) => {
7016
+ if (event.mimeType === "application/x-portable-text") {
7017
+ const json = event.originEvent.originEvent.dataTransfer.getData("application/json");
7018
+ if (json)
7019
+ return {
7020
+ type: "deserialize.data",
7021
+ mimeType: "application/json",
7022
+ data: json,
7023
+ originEvent: event.originEvent
7024
+ };
7025
+ }
7026
+ if (event.mimeType === "application/json") {
7027
+ const html = event.originEvent.originEvent.dataTransfer.getData("text/html");
7028
+ if (html)
7029
+ return {
7030
+ type: "deserialize.data",
7031
+ mimeType: "text/html",
7032
+ data: html,
7033
+ originEvent: event.originEvent
7034
+ };
7035
+ }
7036
+ if (event.mimeType === "text/html") {
7037
+ const text = event.originEvent.originEvent.dataTransfer.getData("text/plain");
7038
+ if (text)
7039
+ return {
7040
+ type: "deserialize.data",
7041
+ mimeType: "text/plain",
7042
+ data: text,
7043
+ originEvent: event.originEvent
7044
+ };
7045
+ }
7046
+ return !1;
7047
+ },
7048
+ actions: [(_, deserializeDataEvent) => [raise(deserializeDataEvent)]]
7049
+ }),
7050
+ defineBehavior({
7051
+ on: "deserialization.failure",
7052
+ actions: [({
7053
+ event
7054
+ }) => [{
7055
+ type: "effect",
7056
+ effect: () => {
7057
+ console.warn(`Deserialization of ${event.mimeType} failed with reason "${event.reason}"`);
7058
+ }
7059
+ }]]
7060
+ })
7061
+ ], abstractInsertBehaviors = [defineBehavior({
6876
7062
  on: "insert.blocks",
6877
7063
  guard: ({
6878
7064
  event
@@ -7214,6 +7400,68 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
7214
7400
  type: "select",
7215
7401
  at: selection
7216
7402
  })]]
7403
+ })], abstractSerializeBehaviors = [defineBehavior({
7404
+ on: "serialize",
7405
+ actions: [({
7406
+ event
7407
+ }) => [raise({
7408
+ type: "serialize.data",
7409
+ mimeType: "application/x-portable-text",
7410
+ originEvent: event.originEvent
7411
+ }), raise({
7412
+ type: "serialize.data",
7413
+ mimeType: "application/json",
7414
+ originEvent: event.originEvent
7415
+ }), raise({
7416
+ type: "serialize.data",
7417
+ mimeType: "text/html",
7418
+ originEvent: event.originEvent
7419
+ }), raise({
7420
+ type: "serialize.data",
7421
+ mimeType: "text/plain",
7422
+ originEvent: event.originEvent
7423
+ })]]
7424
+ }), defineBehavior({
7425
+ on: "serialize.data",
7426
+ guard: ({
7427
+ snapshot,
7428
+ event
7429
+ }) => {
7430
+ const converter = snapshot.context.converters.find((converter2) => converter2.mimeType === event.mimeType);
7431
+ return converter ? converter.serialize({
7432
+ snapshot,
7433
+ event: {
7434
+ type: "serialize",
7435
+ originEvent: event.originEvent.type
7436
+ }
7437
+ }) : !1;
7438
+ },
7439
+ actions: [({
7440
+ event
7441
+ }, serializeEvent) => [raise({
7442
+ ...serializeEvent,
7443
+ originEvent: event.originEvent
7444
+ })]]
7445
+ }), defineBehavior({
7446
+ on: "serialization.success",
7447
+ actions: [({
7448
+ event
7449
+ }) => [{
7450
+ type: "effect",
7451
+ effect: () => {
7452
+ event.originEvent.originEvent.dataTransfer.setData(event.mimeType, event.data);
7453
+ }
7454
+ }]]
7455
+ }), defineBehavior({
7456
+ on: "serialization.failure",
7457
+ actions: [({
7458
+ event
7459
+ }) => [{
7460
+ type: "effect",
7461
+ effect: () => {
7462
+ console.warn(`Serialization of ${event.mimeType} failed with reason "${event.reason}"`);
7463
+ }
7464
+ }]]
7217
7465
  })], abstractSplitBehaviors = [
7218
7466
  /**
7219
7467
  * You can't split an inline object.
@@ -7435,274 +7683,97 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
7435
7683
  type: "style.add",
7436
7684
  style: event.style
7437
7685
  })]]
7438
- })], raiseDeserializationSuccessOrFailure = defineBehavior({
7439
- on: "deserialize",
7686
+ })], abstractBehaviors = [defineBehavior({
7687
+ on: "clipboard.copy",
7440
7688
  guard: ({
7441
- snapshot,
7442
- event
7689
+ snapshot
7443
7690
  }) => {
7444
- let success;
7445
- const failures = [];
7446
- for (const converter of snapshot.context.converters) {
7447
- const data = event.originEvent.originEvent.dataTransfer.getData(converter.mimeType);
7448
- if (!data)
7449
- continue;
7450
- const deserializeEvent = converter.deserialize({
7451
- snapshot,
7452
- event: {
7453
- type: "deserialize",
7454
- data
7455
- }
7456
- });
7457
- if (deserializeEvent.type === "deserialization.success") {
7458
- success = deserializeEvent;
7459
- break;
7460
- } else
7461
- failures.push(deserializeEvent);
7462
- }
7463
- return success || {
7464
- type: "deserialization.failure",
7465
- mimeType: "*/*",
7466
- reason: failures.map((failure) => failure.reason).join(", ")
7467
- };
7691
+ const focusSpan = getFocusSpan$1(snapshot), selectionCollapsed = isSelectionCollapsed$1(snapshot);
7692
+ return focusSpan && selectionCollapsed;
7468
7693
  },
7694
+ actions: []
7695
+ }), defineBehavior({
7696
+ on: "clipboard.copy",
7469
7697
  actions: [({
7470
7698
  event
7471
- }, deserializeEvent) => [raise({
7472
- ...deserializeEvent,
7473
- originEvent: event.originEvent
7699
+ }) => [raise({
7700
+ type: "serialize",
7701
+ originEvent: event
7474
7702
  })]]
7475
- }), raiseSerializationSuccessOrFailure = defineBehavior({
7476
- on: "serialize",
7703
+ }), defineBehavior({
7704
+ on: "clipboard.cut",
7477
7705
  guard: ({
7478
- snapshot,
7479
- event
7706
+ snapshot
7480
7707
  }) => {
7481
- if (snapshot.context.converters.length === 0)
7482
- return !1;
7483
- const serializeEvents = snapshot.context.converters.map((converter) => converter.serialize({
7484
- snapshot,
7485
- event: {
7486
- ...event,
7487
- originEvent: event.originEvent.type
7488
- }
7489
- }));
7490
- return serializeEvents.length === 0 ? !1 : serializeEvents;
7708
+ const focusSpan = getFocusSpan$1(snapshot), selectionCollapsed = isSelectionCollapsed$1(snapshot);
7709
+ return focusSpan && selectionCollapsed;
7491
7710
  },
7711
+ actions: []
7712
+ }), defineBehavior({
7713
+ on: "clipboard.cut",
7714
+ guard: ({
7715
+ snapshot
7716
+ }) => snapshot.context.selection ? {
7717
+ selection: snapshot.context.selection
7718
+ } : !1,
7492
7719
  actions: [({
7493
7720
  event
7494
- }, serializeEvents) => serializeEvents.map((serializeEvent) => raise({
7495
- ...serializeEvent,
7496
- originEvent: event.originEvent
7497
- }))]
7498
- }), abstractBehaviors = [
7499
- defineBehavior({
7500
- on: "clipboard.copy",
7501
- guard: ({
7502
- snapshot
7503
- }) => {
7504
- const focusSpan = getFocusSpan$1(snapshot), selectionCollapsed = isSelectionCollapsed$1(snapshot);
7505
- return focusSpan && selectionCollapsed;
7506
- },
7507
- actions: []
7508
- }),
7509
- defineBehavior({
7510
- on: "clipboard.copy",
7511
- actions: [({
7512
- event
7513
- }) => [raise({
7514
- type: "serialize",
7515
- originEvent: event
7516
- })]]
7517
- }),
7518
- defineBehavior({
7519
- on: "clipboard.cut",
7520
- guard: ({
7521
- snapshot
7522
- }) => {
7523
- const focusSpan = getFocusSpan$1(snapshot), selectionCollapsed = isSelectionCollapsed$1(snapshot);
7524
- return focusSpan && selectionCollapsed;
7525
- },
7526
- actions: []
7527
- }),
7528
- defineBehavior({
7529
- on: "clipboard.cut",
7530
- guard: ({
7531
- snapshot
7532
- }) => snapshot.context.selection ? {
7533
- selection: snapshot.context.selection
7534
- } : !1,
7535
- actions: [({
7536
- event
7537
- }, {
7538
- selection
7539
- }) => [raise({
7540
- type: "serialize",
7541
- originEvent: event
7542
- }), raise({
7543
- type: "delete",
7544
- at: selection
7545
- })]]
7546
- }),
7547
- defineBehavior({
7548
- on: "drag.dragstart",
7549
- actions: [({
7550
- event
7551
- }) => [raise({
7552
- type: "serialize",
7553
- originEvent: event
7554
- })]]
7555
- }),
7556
- defineBehavior({
7557
- on: "serialization.success",
7558
- actions: [({
7559
- event
7560
- }) => [{
7561
- type: "effect",
7562
- effect: () => {
7563
- event.originEvent.originEvent.dataTransfer.setData(event.mimeType, event.data);
7564
- }
7565
- }]]
7566
- }),
7567
- defineBehavior({
7568
- on: "serialization.failure",
7569
- actions: [({
7570
- event
7571
- }) => [{
7572
- type: "effect",
7573
- effect: () => {
7574
- console.warn(`Serialization of ${event.mimeType} failed with reason "${event.reason}"`);
7575
- }
7576
- }]]
7577
- }),
7578
- /**
7579
- * If we are pasting text/plain into a text block then we can probably
7580
- * assume that the intended behavior is that the pasted text inherits
7581
- * formatting from the text it's pasted into.
7582
- */
7583
- defineBehavior({
7584
- on: "deserialization.success",
7585
- guard: ({
7586
- snapshot,
7587
- event
7588
- }) => {
7589
- if (getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
7590
- const activeDecorators = getActiveDecorators(snapshot);
7591
- return {
7592
- activeAnnotations: getActiveAnnotations(snapshot),
7593
- activeDecorators,
7594
- textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context, block) ? [getTextBlockText(block)] : [])
7595
- };
7596
- }
7597
- return !1;
7598
- },
7599
- actions: [(_, {
7600
- activeAnnotations,
7601
- activeDecorators,
7602
- textRuns
7603
- }) => textRuns.flatMap((textRun, index) => index !== textRuns.length - 1 ? [raise({
7604
- type: "insert.span",
7605
- text: textRun,
7606
- decorators: activeDecorators,
7607
- annotations: activeAnnotations.map(({
7608
- _key,
7609
- _type,
7610
- ...value
7611
- }) => ({
7612
- name: _type,
7613
- value
7614
- }))
7615
- }), raise({
7616
- type: "insert.break"
7617
- })] : [raise({
7618
- type: "insert.span",
7619
- text: textRun,
7620
- decorators: activeDecorators,
7621
- annotations: activeAnnotations.map(({
7622
- _key,
7623
- _type,
7624
- ...value
7625
- }) => ({
7626
- name: _type,
7627
- value
7628
- }))
7629
- })])]
7630
- }),
7631
- defineBehavior({
7632
- on: "deserialization.success",
7633
- actions: [({
7634
- event
7635
- }) => [raise({
7636
- type: "insert.blocks",
7637
- blocks: event.data,
7638
- placement: "auto"
7639
- })]]
7640
- }),
7641
- defineBehavior({
7642
- on: "deserialization.failure",
7643
- actions: [({
7644
- event
7645
- }) => [{
7646
- type: "effect",
7647
- effect: () => {
7648
- console.warn(`Deserialization of ${event.mimeType} failed with reason "${event.reason}"`);
7649
- }
7650
- }]]
7651
- }),
7652
- defineBehavior({
7653
- on: "clipboard.paste",
7654
- guard: ({
7655
- snapshot
7656
- }) => snapshot.context.selection && isSelectionExpanded(snapshot) ? {
7657
- selection: snapshot.context.selection
7658
- } : !1,
7659
- actions: [({
7660
- event
7661
- }, {
7662
- selection
7663
- }) => [raise({
7664
- type: "delete",
7665
- at: selection
7666
- }), raise({
7667
- type: "deserialize",
7668
- originEvent: event
7669
- })]]
7670
- }),
7671
- defineBehavior({
7672
- on: "clipboard.paste",
7673
- actions: [({
7674
- event
7675
- }) => [raise({
7676
- type: "deserialize",
7677
- originEvent: event
7678
- })]]
7679
- }),
7680
- defineBehavior({
7681
- on: "input.*",
7682
- actions: [({
7683
- event
7684
- }) => [raise({
7685
- type: "deserialize",
7686
- originEvent: event
7687
- })]]
7688
- }),
7689
- ...abstractAnnotationBehaviors,
7690
- ...abstractDecoratorBehaviors,
7691
- ...abstractDeleteBehaviors,
7692
- ...abstractInsertBehaviors,
7693
- ...abstractKeyboardBehaviors,
7694
- ...abstractListItemBehaviors,
7695
- ...abstractMoveBehaviors,
7696
- ...abstractStyleBehaviors,
7697
- ...abstractSelectBehaviors,
7698
- ...abstractSplitBehaviors,
7699
- raiseDeserializationSuccessOrFailure,
7700
- raiseSerializationSuccessOrFailure
7701
- ];
7721
+ }, {
7722
+ selection
7723
+ }) => [raise({
7724
+ type: "serialize",
7725
+ originEvent: event
7726
+ }), raise({
7727
+ type: "delete",
7728
+ at: selection
7729
+ })]]
7730
+ }), defineBehavior({
7731
+ on: "drag.dragstart",
7732
+ actions: [({
7733
+ event
7734
+ }) => [raise({
7735
+ type: "serialize",
7736
+ originEvent: event
7737
+ })]]
7738
+ }), defineBehavior({
7739
+ on: "clipboard.paste",
7740
+ guard: ({
7741
+ snapshot
7742
+ }) => snapshot.context.selection && isSelectionExpanded(snapshot) ? {
7743
+ selection: snapshot.context.selection
7744
+ } : !1,
7745
+ actions: [({
7746
+ event
7747
+ }, {
7748
+ selection
7749
+ }) => [raise({
7750
+ type: "delete",
7751
+ at: selection
7752
+ }), raise({
7753
+ type: "deserialize",
7754
+ originEvent: event
7755
+ })]]
7756
+ }), defineBehavior({
7757
+ on: "clipboard.paste",
7758
+ actions: [({
7759
+ event
7760
+ }) => [raise({
7761
+ type: "deserialize",
7762
+ originEvent: event
7763
+ })]]
7764
+ }), defineBehavior({
7765
+ on: "input.*",
7766
+ actions: [({
7767
+ event
7768
+ }) => [raise({
7769
+ type: "deserialize",
7770
+ originEvent: event
7771
+ })]]
7772
+ }), ...abstractAnnotationBehaviors, ...abstractDecoratorBehaviors, ...abstractDeleteBehaviors, ...abstractDeserializeBehaviors, ...abstractInsertBehaviors, ...abstractKeyboardBehaviors, ...abstractListItemBehaviors, ...abstractMoveBehaviors, ...abstractStyleBehaviors, ...abstractSelectBehaviors, ...abstractSerializeBehaviors, ...abstractSplitBehaviors];
7702
7773
  function isSyntheticBehaviorEvent(event) {
7703
7774
  return !isCustomBehaviorEvent(event) && !isNativeBehaviorEvent(event) && !isAbstractBehaviorEvent(event);
7704
7775
  }
7705
- const abstractBehaviorEventTypes = ["annotation.set", "annotation.toggle", "decorator.toggle", "delete.backward", "delete.block", "delete.child", "delete.forward", "delete.text", "deserialize", "deserialization.success", "deserialization.failure", "insert.blocks", "insert.break", "insert.soft break", "list item.add", "list item.remove", "list item.toggle", "move.block down", "move.block up", "select.previous block", "select.next block", "serialize", "serialization.success", "serialization.failure", "split", "style.add", "style.remove", "style.toggle"];
7776
+ 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.soft break", "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"];
7706
7777
  function isAbstractBehaviorEvent(event) {
7707
7778
  return abstractBehaviorEventTypes.includes(event.type);
7708
7779
  }
@@ -7785,7 +7856,9 @@ function performEvent({
7785
7856
  for (const action of actions) {
7786
7857
  if (action.type === "effect") {
7787
7858
  try {
7788
- action.effect();
7859
+ action.effect({
7860
+ send: sendBack
7861
+ });
7789
7862
  } catch (error) {
7790
7863
  console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
7791
7864
  }
@@ -7841,7 +7914,9 @@ function performEvent({
7841
7914
  for (const action of actions) {
7842
7915
  if (action.type === "effect") {
7843
7916
  try {
7844
- action.effect();
7917
+ action.effect({
7918
+ send: sendBack
7919
+ });
7845
7920
  } catch (error) {
7846
7921
  console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
7847
7922
  }
@@ -7867,7 +7942,7 @@ function performEvent({
7867
7942
  performEvent({
7868
7943
  mode: "raise",
7869
7944
  behaviors,
7870
- remainingEventBehaviors: behaviors,
7945
+ remainingEventBehaviors: mode === "execute" ? remainingEventBehaviors : behaviors,
7871
7946
  event: action.event,
7872
7947
  editor,
7873
7948
  keyGenerator,
@@ -8085,7 +8160,17 @@ const debug$7 = debugWithName("editor machine"), editorMachine = setup({
8085
8160
  schema: context.schema
8086
8161
  }),
8087
8162
  nativeEvent: event.nativeEvent,
8088
- sendBack: (event2) => self.send(event2)
8163
+ sendBack: (eventSentBack) => {
8164
+ if (eventSentBack.type === "set drag ghost") {
8165
+ self.send(eventSentBack);
8166
+ return;
8167
+ }
8168
+ self.send({
8169
+ type: "behavior event",
8170
+ behaviorEvent: eventSentBack,
8171
+ editor: event.editor
8172
+ });
8173
+ }
8089
8174
  });
8090
8175
  } catch (error) {
8091
8176
  console.error(new Error(`Raising "${event.behaviorEvent.type}" failed due to: ${error.message}`));