slate-react 0.72.0 → 0.72.1

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.
@@ -8,7 +8,7 @@ export interface ReactEditor extends BaseEditor {
8
8
  insertData: (data: DataTransfer) => void;
9
9
  insertFragmentData: (data: DataTransfer) => boolean;
10
10
  insertTextData: (data: DataTransfer) => boolean;
11
- setFragmentData: (data: DataTransfer) => void;
11
+ setFragmentData: (data: DataTransfer, originEvent?: 'drag' | 'copy' | 'cut') => void;
12
12
  hasRange: (editor: ReactEditor, range: Range) => boolean;
13
13
  }
14
14
  export declare const ReactEditor: {
@@ -69,7 +69,7 @@ export declare const ReactEditor: {
69
69
  /**
70
70
  * Sets data from the currently selected fragment on a `DataTransfer`.
71
71
  */
72
- setFragmentData(editor: ReactEditor, data: DataTransfer): void;
72
+ setFragmentData(editor: ReactEditor, data: DataTransfer, originEvent?: "drag" | "copy" | "cut" | undefined): void;
73
73
  /**
74
74
  * Find the native DOM element from a Slate node.
75
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"react-editor.d.ts","sourceRoot":"","sources":["../packages/slate-react/src/plugin/react-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AAEhF,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAYlC,OAAO,EAEL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,cAAc,EAKf,MAAM,cAAc,CAAA;AAGrB;;GAEG;AAEH,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IACxC,kBAAkB,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAA;IACnD,cAAc,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAA;IAC/C,eAAe,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I;IAenC;;OAEG;uBAGO,WAAW,UACX,OAAO,YACN;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9B,OAAO;IAoCV;;OAEG;uBAEgB,WAAW,QAAQ,YAAY,GAAG,IAAI;IAIzD;;OAEG;+BAEwB,WAAW,QAAQ,YAAY,GAAG,OAAO;IAIpE;;OAEG;2BAEoB,WAAW,QAAQ,YAAY,GAAG,OAAO;IAIhE;;OAEG;4BAGO,WAAW,QACb,YAAY,sDAEjB,IAAI;IAIP;;OAEG;sBAEe,WAAW,QAAQ,IAAI,GAAG,WAAW;IAevD;;OAEG;uBAEgB,WAAW,SAAS,KAAK;IAgD5C;;;;;;;OAOG;uBAEgB,WAAW,SAAS,KAAK,GAAG,QAAQ;IA8BvD;;OAEG;wBAEiB,WAAW,WAAW,OAAO,GAAG,IAAI;IAgBxD;;OAEG;2BAEoB,WAAW,SAAS,GAAG,GAAG,KAAK;IAiEtD;;OAEG;4CAGO,WAAW;;;;IAuGrB;;OAEG;8CAGO,WAAW,YACT,QAAQ,GAAG,cAAc,GAAG,YAAY;;;;;;qBAyFnC,WAAW,SAAS,KAAK,GAAG,OAAO;CAMrD,CAAA"}
@@ -2261,8 +2261,8 @@
2261
2261
 
2262
2262
  var anchorNode = domSelection.anchorNode,
2263
2263
  focusNode = domSelection.focusNode;
2264
- var anchorNodeSelectable = hasEditableTarget(editor, anchorNode) || isTargetInsideVoid(editor, anchorNode);
2265
- var focusNodeSelectable = hasEditableTarget(editor, focusNode) || isTargetInsideVoid(editor, focusNode);
2264
+ var anchorNodeSelectable = hasEditableTarget(editor, anchorNode) || isTargetInsideNonReadonlyVoid(editor, anchorNode);
2265
+ var focusNodeSelectable = hasEditableTarget(editor, focusNode) || isTargetInsideNonReadonlyVoid(editor, focusNode);
2266
2266
 
2267
2267
  if (anchorNodeSelectable && focusNodeSelectable) {
2268
2268
  var range = ReactEditor.toSlateRange(editor, domSelection, {
@@ -2766,13 +2766,13 @@
2766
2766
  onCopy: React.useCallback(function (event) {
2767
2767
  if (hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onCopy)) {
2768
2768
  event.preventDefault();
2769
- ReactEditor.setFragmentData(editor, event.clipboardData);
2769
+ ReactEditor.setFragmentData(editor, event.clipboardData, 'copy');
2770
2770
  }
2771
2771
  }, [attributes.onCopy]),
2772
2772
  onCut: React.useCallback(function (event) {
2773
2773
  if (!readOnly && hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onCut)) {
2774
2774
  event.preventDefault();
2775
- ReactEditor.setFragmentData(editor, event.clipboardData);
2775
+ ReactEditor.setFragmentData(editor, event.clipboardData, 'cut');
2776
2776
  var selection = editor.selection;
2777
2777
 
2778
2778
  if (selection) {
@@ -2816,7 +2816,7 @@
2816
2816
  }
2817
2817
 
2818
2818
  state.isDraggingInternally = true;
2819
- ReactEditor.setFragmentData(editor, event.dataTransfer);
2819
+ ReactEditor.setFragmentData(editor, event.dataTransfer, 'drag');
2820
2820
  }
2821
2821
  }, [readOnly, attributes.onDragStart]),
2822
2822
  onDrop: React.useCallback(function (event) {
@@ -3212,10 +3212,11 @@
3212
3212
  });
3213
3213
  };
3214
3214
  /**
3215
- * Check if the target is inside void and in the editor.
3215
+ * Check if the target is inside void and in an non-readonly editor.
3216
3216
  */
3217
3217
 
3218
- var isTargetInsideVoid = function isTargetInsideVoid(editor, target) {
3218
+ var isTargetInsideNonReadonlyVoid = function isTargetInsideNonReadonlyVoid(editor, target) {
3219
+ if (IS_READ_ONLY.get(editor)) return false;
3219
3220
  var slateNode = hasTarget(editor, target) && ReactEditor.toSlateNode(editor, target);
3220
3221
  return slate.Editor.isVoid(editor, slateNode);
3221
3222
  };
@@ -3517,8 +3518,8 @@
3517
3518
  /**
3518
3519
  * Sets data from the currently selected fragment on a `DataTransfer`.
3519
3520
  */
3520
- setFragmentData: function setFragmentData(editor, data) {
3521
- editor.setFragmentData(data);
3521
+ setFragmentData: function setFragmentData(editor, data, originEvent) {
3522
+ editor.setFragmentData(data, originEvent);
3522
3523
  },
3523
3524
 
3524
3525
  /**
@@ -4779,8 +4780,8 @@
4779
4780
 
4780
4781
  var anchorNode = domSelection.anchorNode,
4781
4782
  focusNode = domSelection.focusNode;
4782
- var anchorNodeSelectable = hasEditableTarget(editor, anchorNode) || isTargetInsideVoid(editor, anchorNode);
4783
- var focusNodeSelectable = hasEditableTarget(editor, focusNode) || isTargetInsideVoid(editor, focusNode);
4783
+ var anchorNodeSelectable = hasEditableTarget(editor, anchorNode) || isTargetInsideNonReadonlyVoid(editor, anchorNode);
4784
+ var focusNodeSelectable = hasEditableTarget(editor, focusNode) || isTargetInsideNonReadonlyVoid(editor, focusNode);
4784
4785
 
4785
4786
  if (anchorNodeSelectable && focusNodeSelectable) {
4786
4787
  var range = ReactEditor.toSlateRange(editor, domSelection, {
@@ -4845,13 +4846,13 @@
4845
4846
  onCopy: React.useCallback(function (event) {
4846
4847
  if (hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onCopy)) {
4847
4848
  event.preventDefault();
4848
- ReactEditor.setFragmentData(editor, event.clipboardData);
4849
+ ReactEditor.setFragmentData(editor, event.clipboardData, 'copy');
4849
4850
  }
4850
4851
  }, [attributes.onCopy]),
4851
4852
  onCut: React.useCallback(function (event) {
4852
4853
  if (!readOnly && hasEditableTarget(editor, event.target) && !isEventHandled(event, attributes.onCut)) {
4853
4854
  event.preventDefault();
4854
- ReactEditor.setFragmentData(editor, event.clipboardData);
4855
+ ReactEditor.setFragmentData(editor, event.clipboardData, 'cut');
4855
4856
  var selection = editor.selection;
4856
4857
 
4857
4858
  if (selection) {