@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.cjs CHANGED
@@ -6842,7 +6842,193 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
6842
6842
  type: "delete",
6843
6843
  at: selection
6844
6844
  })]]
6845
- })], abstractInsertBehaviors = [behaviors_index.defineBehavior({
6845
+ })], abstractDeserializeBehaviors = [
6846
+ behaviors_index.defineBehavior({
6847
+ on: "deserialize",
6848
+ guard: ({
6849
+ event
6850
+ }) => {
6851
+ const portableText = event.originEvent.originEvent.dataTransfer.getData("application/x-portable-text");
6852
+ if (portableText)
6853
+ return {
6854
+ type: "deserialize.data",
6855
+ mimeType: "application/x-portable-text",
6856
+ data: portableText,
6857
+ originEvent: event.originEvent
6858
+ };
6859
+ const json = event.originEvent.originEvent.dataTransfer.getData("application/json");
6860
+ if (json)
6861
+ return {
6862
+ type: "deserialize.data",
6863
+ mimeType: "application/json",
6864
+ data: json,
6865
+ originEvent: event.originEvent
6866
+ };
6867
+ const html = event.originEvent.originEvent.dataTransfer.getData("text/html");
6868
+ if (html)
6869
+ return {
6870
+ type: "deserialize.data",
6871
+ mimeType: "text/html",
6872
+ data: html,
6873
+ originEvent: event.originEvent
6874
+ };
6875
+ const text = event.originEvent.originEvent.dataTransfer.getData("text/plain");
6876
+ return text ? {
6877
+ type: "deserialize.data",
6878
+ mimeType: "text/plain",
6879
+ data: text,
6880
+ originEvent: event.originEvent
6881
+ } : !1;
6882
+ },
6883
+ actions: [(_, deserializeEvent) => [behaviors_index.raise(deserializeEvent)]]
6884
+ }),
6885
+ behaviors_index.defineBehavior({
6886
+ on: "deserialize",
6887
+ actions: [({
6888
+ event
6889
+ }) => [behaviors_index.raise({
6890
+ type: "deserialization.failure",
6891
+ mimeType: "*/*",
6892
+ reason: "No Behavior was able to handle the incoming data",
6893
+ originEvent: event.originEvent
6894
+ })]]
6895
+ }),
6896
+ behaviors_index.defineBehavior({
6897
+ on: "deserialize.data",
6898
+ guard: ({
6899
+ snapshot,
6900
+ event
6901
+ }) => {
6902
+ const converter = snapshot.context.converters.find((converter2) => converter2.mimeType === event.mimeType);
6903
+ return converter ? converter.deserialize({
6904
+ snapshot,
6905
+ event: {
6906
+ type: "deserialize",
6907
+ data: event.data
6908
+ }
6909
+ }) : !1;
6910
+ },
6911
+ actions: [({
6912
+ event
6913
+ }, deserializeEvent) => [behaviors_index.raise({
6914
+ ...deserializeEvent,
6915
+ originEvent: event.originEvent
6916
+ })]]
6917
+ }),
6918
+ /**
6919
+ * If we are pasting text/plain into a text block then we can probably
6920
+ * assume that the intended behavior is that the pasted text inherits
6921
+ * formatting from the text it's pasted into.
6922
+ */
6923
+ behaviors_index.defineBehavior({
6924
+ on: "deserialization.success",
6925
+ guard: ({
6926
+ snapshot,
6927
+ event
6928
+ }) => {
6929
+ if (selector_isSelectionExpanded.getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
6930
+ const activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot);
6931
+ return {
6932
+ activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
6933
+ activeDecorators,
6934
+ textRuns: event.data.flatMap((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? [util_sliceBlocks.getTextBlockText(block)] : [])
6935
+ };
6936
+ }
6937
+ return !1;
6938
+ },
6939
+ actions: [(_, {
6940
+ activeAnnotations,
6941
+ activeDecorators,
6942
+ textRuns
6943
+ }) => textRuns.flatMap((textRun, index) => index !== textRuns.length - 1 ? [behaviors_index.raise({
6944
+ type: "insert.span",
6945
+ text: textRun,
6946
+ decorators: activeDecorators,
6947
+ annotations: activeAnnotations.map(({
6948
+ _key,
6949
+ _type,
6950
+ ...value
6951
+ }) => ({
6952
+ name: _type,
6953
+ value
6954
+ }))
6955
+ }), behaviors_index.raise({
6956
+ type: "insert.break"
6957
+ })] : [behaviors_index.raise({
6958
+ type: "insert.span",
6959
+ text: textRun,
6960
+ decorators: activeDecorators,
6961
+ annotations: activeAnnotations.map(({
6962
+ _key,
6963
+ _type,
6964
+ ...value
6965
+ }) => ({
6966
+ name: _type,
6967
+ value
6968
+ }))
6969
+ })])]
6970
+ }),
6971
+ behaviors_index.defineBehavior({
6972
+ on: "deserialization.success",
6973
+ actions: [({
6974
+ event
6975
+ }) => [behaviors_index.raise({
6976
+ type: "insert.blocks",
6977
+ blocks: event.data,
6978
+ placement: "auto"
6979
+ })]]
6980
+ }),
6981
+ behaviors_index.defineBehavior({
6982
+ on: "deserialization.failure",
6983
+ guard: ({
6984
+ event
6985
+ }) => {
6986
+ if (event.mimeType === "application/x-portable-text") {
6987
+ const json = event.originEvent.originEvent.dataTransfer.getData("application/json");
6988
+ if (json)
6989
+ return {
6990
+ type: "deserialize.data",
6991
+ mimeType: "application/json",
6992
+ data: json,
6993
+ originEvent: event.originEvent
6994
+ };
6995
+ }
6996
+ if (event.mimeType === "application/json") {
6997
+ const html = event.originEvent.originEvent.dataTransfer.getData("text/html");
6998
+ if (html)
6999
+ return {
7000
+ type: "deserialize.data",
7001
+ mimeType: "text/html",
7002
+ data: html,
7003
+ originEvent: event.originEvent
7004
+ };
7005
+ }
7006
+ if (event.mimeType === "text/html") {
7007
+ const text = event.originEvent.originEvent.dataTransfer.getData("text/plain");
7008
+ if (text)
7009
+ return {
7010
+ type: "deserialize.data",
7011
+ mimeType: "text/plain",
7012
+ data: text,
7013
+ originEvent: event.originEvent
7014
+ };
7015
+ }
7016
+ return !1;
7017
+ },
7018
+ actions: [(_, deserializeDataEvent) => [behaviors_index.raise(deserializeDataEvent)]]
7019
+ }),
7020
+ behaviors_index.defineBehavior({
7021
+ on: "deserialization.failure",
7022
+ actions: [({
7023
+ event
7024
+ }) => [{
7025
+ type: "effect",
7026
+ effect: () => {
7027
+ console.warn(`Deserialization of ${event.mimeType} failed with reason "${event.reason}"`);
7028
+ }
7029
+ }]]
7030
+ })
7031
+ ], abstractInsertBehaviors = [behaviors_index.defineBehavior({
6846
7032
  on: "insert.blocks",
6847
7033
  guard: ({
6848
7034
  event
@@ -7184,6 +7370,68 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7184
7370
  type: "select",
7185
7371
  at: selection
7186
7372
  })]]
7373
+ })], abstractSerializeBehaviors = [behaviors_index.defineBehavior({
7374
+ on: "serialize",
7375
+ actions: [({
7376
+ event
7377
+ }) => [behaviors_index.raise({
7378
+ type: "serialize.data",
7379
+ mimeType: "application/x-portable-text",
7380
+ originEvent: event.originEvent
7381
+ }), behaviors_index.raise({
7382
+ type: "serialize.data",
7383
+ mimeType: "application/json",
7384
+ originEvent: event.originEvent
7385
+ }), behaviors_index.raise({
7386
+ type: "serialize.data",
7387
+ mimeType: "text/html",
7388
+ originEvent: event.originEvent
7389
+ }), behaviors_index.raise({
7390
+ type: "serialize.data",
7391
+ mimeType: "text/plain",
7392
+ originEvent: event.originEvent
7393
+ })]]
7394
+ }), behaviors_index.defineBehavior({
7395
+ on: "serialize.data",
7396
+ guard: ({
7397
+ snapshot,
7398
+ event
7399
+ }) => {
7400
+ const converter = snapshot.context.converters.find((converter2) => converter2.mimeType === event.mimeType);
7401
+ return converter ? converter.serialize({
7402
+ snapshot,
7403
+ event: {
7404
+ type: "serialize",
7405
+ originEvent: event.originEvent.type
7406
+ }
7407
+ }) : !1;
7408
+ },
7409
+ actions: [({
7410
+ event
7411
+ }, serializeEvent) => [behaviors_index.raise({
7412
+ ...serializeEvent,
7413
+ originEvent: event.originEvent
7414
+ })]]
7415
+ }), behaviors_index.defineBehavior({
7416
+ on: "serialization.success",
7417
+ actions: [({
7418
+ event
7419
+ }) => [{
7420
+ type: "effect",
7421
+ effect: () => {
7422
+ event.originEvent.originEvent.dataTransfer.setData(event.mimeType, event.data);
7423
+ }
7424
+ }]]
7425
+ }), behaviors_index.defineBehavior({
7426
+ on: "serialization.failure",
7427
+ actions: [({
7428
+ event
7429
+ }) => [{
7430
+ type: "effect",
7431
+ effect: () => {
7432
+ console.warn(`Serialization of ${event.mimeType} failed with reason "${event.reason}"`);
7433
+ }
7434
+ }]]
7187
7435
  })], abstractSplitBehaviors = [
7188
7436
  /**
7189
7437
  * You can't split an inline object.
@@ -7405,274 +7653,97 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
7405
7653
  type: "style.add",
7406
7654
  style: event.style
7407
7655
  })]]
7408
- })], raiseDeserializationSuccessOrFailure = behaviors_index.defineBehavior({
7409
- on: "deserialize",
7656
+ })], abstractBehaviors = [behaviors_index.defineBehavior({
7657
+ on: "clipboard.copy",
7410
7658
  guard: ({
7411
- snapshot,
7412
- event
7659
+ snapshot
7413
7660
  }) => {
7414
- let success;
7415
- const failures = [];
7416
- for (const converter of snapshot.context.converters) {
7417
- const data = event.originEvent.originEvent.dataTransfer.getData(converter.mimeType);
7418
- if (!data)
7419
- continue;
7420
- const deserializeEvent = converter.deserialize({
7421
- snapshot,
7422
- event: {
7423
- type: "deserialize",
7424
- data
7425
- }
7426
- });
7427
- if (deserializeEvent.type === "deserialization.success") {
7428
- success = deserializeEvent;
7429
- break;
7430
- } else
7431
- failures.push(deserializeEvent);
7432
- }
7433
- return success || {
7434
- type: "deserialization.failure",
7435
- mimeType: "*/*",
7436
- reason: failures.map((failure) => failure.reason).join(", ")
7437
- };
7661
+ const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
7662
+ return focusSpan && selectionCollapsed;
7438
7663
  },
7664
+ actions: []
7665
+ }), behaviors_index.defineBehavior({
7666
+ on: "clipboard.copy",
7439
7667
  actions: [({
7440
7668
  event
7441
- }, deserializeEvent) => [behaviors_index.raise({
7442
- ...deserializeEvent,
7443
- originEvent: event.originEvent
7669
+ }) => [behaviors_index.raise({
7670
+ type: "serialize",
7671
+ originEvent: event
7444
7672
  })]]
7445
- }), raiseSerializationSuccessOrFailure = behaviors_index.defineBehavior({
7446
- on: "serialize",
7673
+ }), behaviors_index.defineBehavior({
7674
+ on: "clipboard.cut",
7447
7675
  guard: ({
7448
- snapshot,
7449
- event
7676
+ snapshot
7450
7677
  }) => {
7451
- if (snapshot.context.converters.length === 0)
7452
- return !1;
7453
- const serializeEvents = snapshot.context.converters.map((converter) => converter.serialize({
7454
- snapshot,
7455
- event: {
7456
- ...event,
7457
- originEvent: event.originEvent.type
7458
- }
7459
- }));
7460
- return serializeEvents.length === 0 ? !1 : serializeEvents;
7678
+ const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
7679
+ return focusSpan && selectionCollapsed;
7461
7680
  },
7681
+ actions: []
7682
+ }), behaviors_index.defineBehavior({
7683
+ on: "clipboard.cut",
7684
+ guard: ({
7685
+ snapshot
7686
+ }) => snapshot.context.selection ? {
7687
+ selection: snapshot.context.selection
7688
+ } : !1,
7462
7689
  actions: [({
7463
7690
  event
7464
- }, serializeEvents) => serializeEvents.map((serializeEvent) => behaviors_index.raise({
7465
- ...serializeEvent,
7466
- originEvent: event.originEvent
7467
- }))]
7468
- }), abstractBehaviors = [
7469
- behaviors_index.defineBehavior({
7470
- on: "clipboard.copy",
7471
- guard: ({
7472
- snapshot
7473
- }) => {
7474
- const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
7475
- return focusSpan && selectionCollapsed;
7476
- },
7477
- actions: []
7478
- }),
7479
- behaviors_index.defineBehavior({
7480
- on: "clipboard.copy",
7481
- actions: [({
7482
- event
7483
- }) => [behaviors_index.raise({
7484
- type: "serialize",
7485
- originEvent: event
7486
- })]]
7487
- }),
7488
- behaviors_index.defineBehavior({
7489
- on: "clipboard.cut",
7490
- guard: ({
7491
- snapshot
7492
- }) => {
7493
- const focusSpan = selector_isSelectionExpanded.getFocusSpan(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot);
7494
- return focusSpan && selectionCollapsed;
7495
- },
7496
- actions: []
7497
- }),
7498
- behaviors_index.defineBehavior({
7499
- on: "clipboard.cut",
7500
- guard: ({
7501
- snapshot
7502
- }) => snapshot.context.selection ? {
7503
- selection: snapshot.context.selection
7504
- } : !1,
7505
- actions: [({
7506
- event
7507
- }, {
7508
- selection
7509
- }) => [behaviors_index.raise({
7510
- type: "serialize",
7511
- originEvent: event
7512
- }), behaviors_index.raise({
7513
- type: "delete",
7514
- at: selection
7515
- })]]
7516
- }),
7517
- behaviors_index.defineBehavior({
7518
- on: "drag.dragstart",
7519
- actions: [({
7520
- event
7521
- }) => [behaviors_index.raise({
7522
- type: "serialize",
7523
- originEvent: event
7524
- })]]
7525
- }),
7526
- behaviors_index.defineBehavior({
7527
- on: "serialization.success",
7528
- actions: [({
7529
- event
7530
- }) => [{
7531
- type: "effect",
7532
- effect: () => {
7533
- event.originEvent.originEvent.dataTransfer.setData(event.mimeType, event.data);
7534
- }
7535
- }]]
7536
- }),
7537
- behaviors_index.defineBehavior({
7538
- on: "serialization.failure",
7539
- actions: [({
7540
- event
7541
- }) => [{
7542
- type: "effect",
7543
- effect: () => {
7544
- console.warn(`Serialization of ${event.mimeType} failed with reason "${event.reason}"`);
7545
- }
7546
- }]]
7547
- }),
7548
- /**
7549
- * If we are pasting text/plain into a text block then we can probably
7550
- * assume that the intended behavior is that the pasted text inherits
7551
- * formatting from the text it's pasted into.
7552
- */
7553
- behaviors_index.defineBehavior({
7554
- on: "deserialization.success",
7555
- guard: ({
7556
- snapshot,
7557
- event
7558
- }) => {
7559
- if (selector_isSelectionExpanded.getFocusTextBlock(snapshot) && event.mimeType === "text/plain" && event.originEvent.type === "clipboard.paste") {
7560
- const activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot);
7561
- return {
7562
- activeAnnotations: selector_isSelectingEntireBlocks.getActiveAnnotations(snapshot),
7563
- activeDecorators,
7564
- textRuns: event.data.flatMap((block) => util_sliceBlocks.isTextBlock(snapshot.context, block) ? [util_sliceBlocks.getTextBlockText(block)] : [])
7565
- };
7566
- }
7567
- return !1;
7568
- },
7569
- actions: [(_, {
7570
- activeAnnotations,
7571
- activeDecorators,
7572
- textRuns
7573
- }) => textRuns.flatMap((textRun, index) => index !== textRuns.length - 1 ? [behaviors_index.raise({
7574
- type: "insert.span",
7575
- text: textRun,
7576
- decorators: activeDecorators,
7577
- annotations: activeAnnotations.map(({
7578
- _key,
7579
- _type,
7580
- ...value
7581
- }) => ({
7582
- name: _type,
7583
- value
7584
- }))
7585
- }), behaviors_index.raise({
7586
- type: "insert.break"
7587
- })] : [behaviors_index.raise({
7588
- type: "insert.span",
7589
- text: textRun,
7590
- decorators: activeDecorators,
7591
- annotations: activeAnnotations.map(({
7592
- _key,
7593
- _type,
7594
- ...value
7595
- }) => ({
7596
- name: _type,
7597
- value
7598
- }))
7599
- })])]
7600
- }),
7601
- behaviors_index.defineBehavior({
7602
- on: "deserialization.success",
7603
- actions: [({
7604
- event
7605
- }) => [behaviors_index.raise({
7606
- type: "insert.blocks",
7607
- blocks: event.data,
7608
- placement: "auto"
7609
- })]]
7610
- }),
7611
- behaviors_index.defineBehavior({
7612
- on: "deserialization.failure",
7613
- actions: [({
7614
- event
7615
- }) => [{
7616
- type: "effect",
7617
- effect: () => {
7618
- console.warn(`Deserialization of ${event.mimeType} failed with reason "${event.reason}"`);
7619
- }
7620
- }]]
7621
- }),
7622
- behaviors_index.defineBehavior({
7623
- on: "clipboard.paste",
7624
- guard: ({
7625
- snapshot
7626
- }) => snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) ? {
7627
- selection: snapshot.context.selection
7628
- } : !1,
7629
- actions: [({
7630
- event
7631
- }, {
7632
- selection
7633
- }) => [behaviors_index.raise({
7634
- type: "delete",
7635
- at: selection
7636
- }), behaviors_index.raise({
7637
- type: "deserialize",
7638
- originEvent: event
7639
- })]]
7640
- }),
7641
- behaviors_index.defineBehavior({
7642
- on: "clipboard.paste",
7643
- actions: [({
7644
- event
7645
- }) => [behaviors_index.raise({
7646
- type: "deserialize",
7647
- originEvent: event
7648
- })]]
7649
- }),
7650
- behaviors_index.defineBehavior({
7651
- on: "input.*",
7652
- actions: [({
7653
- event
7654
- }) => [behaviors_index.raise({
7655
- type: "deserialize",
7656
- originEvent: event
7657
- })]]
7658
- }),
7659
- ...abstractAnnotationBehaviors,
7660
- ...abstractDecoratorBehaviors,
7661
- ...abstractDeleteBehaviors,
7662
- ...abstractInsertBehaviors,
7663
- ...abstractKeyboardBehaviors,
7664
- ...abstractListItemBehaviors,
7665
- ...abstractMoveBehaviors,
7666
- ...abstractStyleBehaviors,
7667
- ...abstractSelectBehaviors,
7668
- ...abstractSplitBehaviors,
7669
- raiseDeserializationSuccessOrFailure,
7670
- raiseSerializationSuccessOrFailure
7671
- ];
7691
+ }, {
7692
+ selection
7693
+ }) => [behaviors_index.raise({
7694
+ type: "serialize",
7695
+ originEvent: event
7696
+ }), behaviors_index.raise({
7697
+ type: "delete",
7698
+ at: selection
7699
+ })]]
7700
+ }), behaviors_index.defineBehavior({
7701
+ on: "drag.dragstart",
7702
+ actions: [({
7703
+ event
7704
+ }) => [behaviors_index.raise({
7705
+ type: "serialize",
7706
+ originEvent: event
7707
+ })]]
7708
+ }), behaviors_index.defineBehavior({
7709
+ on: "clipboard.paste",
7710
+ guard: ({
7711
+ snapshot
7712
+ }) => snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) ? {
7713
+ selection: snapshot.context.selection
7714
+ } : !1,
7715
+ actions: [({
7716
+ event
7717
+ }, {
7718
+ selection
7719
+ }) => [behaviors_index.raise({
7720
+ type: "delete",
7721
+ at: selection
7722
+ }), behaviors_index.raise({
7723
+ type: "deserialize",
7724
+ originEvent: event
7725
+ })]]
7726
+ }), behaviors_index.defineBehavior({
7727
+ on: "clipboard.paste",
7728
+ actions: [({
7729
+ event
7730
+ }) => [behaviors_index.raise({
7731
+ type: "deserialize",
7732
+ originEvent: event
7733
+ })]]
7734
+ }), behaviors_index.defineBehavior({
7735
+ on: "input.*",
7736
+ actions: [({
7737
+ event
7738
+ }) => [behaviors_index.raise({
7739
+ type: "deserialize",
7740
+ originEvent: event
7741
+ })]]
7742
+ }), ...abstractAnnotationBehaviors, ...abstractDecoratorBehaviors, ...abstractDeleteBehaviors, ...abstractDeserializeBehaviors, ...abstractInsertBehaviors, ...abstractKeyboardBehaviors, ...abstractListItemBehaviors, ...abstractMoveBehaviors, ...abstractStyleBehaviors, ...abstractSelectBehaviors, ...abstractSerializeBehaviors, ...abstractSplitBehaviors];
7672
7743
  function isSyntheticBehaviorEvent(event) {
7673
7744
  return !isCustomBehaviorEvent(event) && !isNativeBehaviorEvent(event) && !isAbstractBehaviorEvent(event);
7674
7745
  }
7675
- 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"];
7746
+ 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"];
7676
7747
  function isAbstractBehaviorEvent(event) {
7677
7748
  return abstractBehaviorEventTypes.includes(event.type);
7678
7749
  }
@@ -7755,7 +7826,9 @@ function performEvent({
7755
7826
  for (const action of actions) {
7756
7827
  if (action.type === "effect") {
7757
7828
  try {
7758
- action.effect();
7829
+ action.effect({
7830
+ send: sendBack
7831
+ });
7759
7832
  } catch (error) {
7760
7833
  console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
7761
7834
  }
@@ -7811,7 +7884,9 @@ function performEvent({
7811
7884
  for (const action of actions) {
7812
7885
  if (action.type === "effect") {
7813
7886
  try {
7814
- action.effect();
7887
+ action.effect({
7888
+ send: sendBack
7889
+ });
7815
7890
  } catch (error) {
7816
7891
  console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
7817
7892
  }
@@ -7837,7 +7912,7 @@ function performEvent({
7837
7912
  performEvent({
7838
7913
  mode: "raise",
7839
7914
  behaviors,
7840
- remainingEventBehaviors: behaviors,
7915
+ remainingEventBehaviors: mode === "execute" ? remainingEventBehaviors : behaviors,
7841
7916
  event: action.event,
7842
7917
  editor,
7843
7918
  keyGenerator,
@@ -8055,7 +8130,17 @@ const debug$7 = debugWithName("editor machine"), editorMachine = xstate.setup({
8055
8130
  schema: context.schema
8056
8131
  }),
8057
8132
  nativeEvent: event.nativeEvent,
8058
- sendBack: (event2) => self.send(event2)
8133
+ sendBack: (eventSentBack) => {
8134
+ if (eventSentBack.type === "set drag ghost") {
8135
+ self.send(eventSentBack);
8136
+ return;
8137
+ }
8138
+ self.send({
8139
+ type: "behavior event",
8140
+ behaviorEvent: eventSentBack,
8141
+ editor: event.editor
8142
+ });
8143
+ }
8059
8144
  });
8060
8145
  } catch (error) {
8061
8146
  console.error(new Error(`Raising "${event.behaviorEvent.type}" failed due to: ${error.message}`));