@portabletext/editor 1.51.0 → 1.52.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.
- package/lib/_chunks-cjs/selection-point.cjs +2 -25
- package/lib/_chunks-cjs/selection-point.cjs.map +1 -1
- package/lib/_chunks-es/selection-point.js +2 -25
- package/lib/_chunks-es/selection-point.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js +1 -1
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +26 -5
- package/lib/behaviors/index.d.ts +26 -5
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +465 -384
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +360 -31
- package/lib/index.d.ts +360 -31
- package/lib/index.js +486 -405
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +26 -5
- package/lib/plugins/index.d.ts +26 -5
- package/lib/selectors/index.d.cts +0 -14
- package/lib/selectors/index.d.ts +0 -14
- package/lib/utils/index.d.cts +0 -14
- package/lib/utils/index.d.ts +0 -14
- package/package.json +11 -11
- package/src/behaviors/behavior.abstract.delete.ts +0 -1
- package/src/behaviors/behavior.abstract.ts +0 -113
- package/src/behaviors/behavior.core.block-element.ts +9 -3
- package/src/behaviors/behavior.core.dnd.ts +328 -1
- package/src/behaviors/behavior.perform-event.ts +10 -0
- package/src/behaviors/behavior.types.action.ts +2 -0
- package/src/behaviors/behavior.types.event.ts +4 -0
- package/src/behaviors/behavior.types.guard.ts +2 -0
- package/src/converters/converter.portable-text.ts +2 -7
- package/src/converters/converter.text-html.ts +1 -3
- package/src/converters/converter.text-plain.ts +3 -5
- package/src/editor/Editable.tsx +6 -133
- package/src/editor/components/render-element.tsx +27 -46
- package/src/editor/editor-machine.ts +15 -8
- package/src/editor/editor-selector.ts +0 -1
- package/src/editor/editor-snapshot.ts +0 -13
- package/src/editor/plugins/createWithSchemaTypes.ts +21 -1
- package/src/internal-utils/create-test-snapshot.ts +0 -1
- package/src/internal-utils/event-position.ts +41 -27
- package/src/internal-utils/parse-blocks.ts +26 -15
- package/src/internal-utils/selection-elements.ts +108 -0
- package/src/operations/behavior.operation.decorator.add.ts +0 -1
package/lib/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$h = require("debug"),
|
|
3
|
+
var reactCompilerRuntime = require("react-compiler-runtime"), React = require("react"), useEffectEvent = require("use-effect-event"), useEditor = require("./_chunks-cjs/use-editor.cjs"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), noop = require("lodash/noop.js"), slate = require("slate"), slateReact = require("slate-react"), debug$h = require("debug"), slateDom = require("slate-dom"), selectionPoint = require("./_chunks-cjs/selection-point.cjs"), util_isEqualSelectionPoints = require("./_chunks-cjs/util.is-equal-selection-points.cjs"), util_selectionPointToBlockOffset = require("./_chunks-cjs/util.selection-point-to-block-offset.cjs"), isEqual = require("lodash/isEqual.js"), types = require("@sanity/types"), selector_isSelectionExpanded = require("./_chunks-cjs/selector.is-selection-expanded.cjs"), selector_isSelectingEntireBlocks = require("./_chunks-cjs/selector.is-selecting-entire-blocks.cjs"), getRandomValues = require("get-random-values-esm"), behaviors_index = require("./behaviors/index.cjs"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), xstate = require("xstate"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), schema = require("@sanity/schema"), flatten = require("lodash/flatten.js"), omit = require("lodash/omit.js"), util_childSelectionPointToBlockOffset = require("./_chunks-cjs/util.child-selection-point-to-block-offset.cjs"), patches = require("@portabletext/patches"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), immer = require("immer"), startCase = require("lodash.startcase"), isPlainObject = require("lodash/isPlainObject.js");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -17,91 +17,12 @@ function EditorEventListener(props) {
|
|
|
17
17
|
let t1;
|
|
18
18
|
return $[3] !== editor ? (t1 = [editor], $[3] = editor, $[4] = t1) : t1 = $[4], React.useEffect(t0, t1), null;
|
|
19
19
|
}
|
|
20
|
-
function getCompoundClientRect(nodes) {
|
|
21
|
-
if (nodes.length === 0)
|
|
22
|
-
return new DOMRect(0, 0, 0, 0);
|
|
23
|
-
const elements = nodes.filter((node) => node instanceof Element), firstRect = elements.at(0)?.getBoundingClientRect();
|
|
24
|
-
if (!firstRect)
|
|
25
|
-
return new DOMRect(0, 0, 0, 0);
|
|
26
|
-
let left = firstRect.left, top = firstRect.top, right = firstRect.right, bottom = firstRect.bottom;
|
|
27
|
-
for (let i = 1; i < elements.length; i++) {
|
|
28
|
-
const rect = elements[i].getBoundingClientRect();
|
|
29
|
-
left = Math.min(left, rect.left), top = Math.min(top, rect.top), right = Math.max(right, rect.right), bottom = Math.max(bottom, rect.bottom);
|
|
30
|
-
}
|
|
31
|
-
return new DOMRect(left, top, right - left, bottom - top);
|
|
32
|
-
}
|
|
33
20
|
const rootName = "sanity-pte:";
|
|
34
21
|
debug__default.default(rootName);
|
|
35
22
|
function debugWithName(name) {
|
|
36
23
|
const namespace = `${rootName}${name}`;
|
|
37
24
|
return debug__default.default && debug__default.default.enabled(namespace) ? debug__default.default(namespace) : debug__default.default(rootName);
|
|
38
25
|
}
|
|
39
|
-
function getDragSelection({
|
|
40
|
-
eventSelection,
|
|
41
|
-
snapshot
|
|
42
|
-
}) {
|
|
43
|
-
let dragSelection = eventSelection;
|
|
44
|
-
if (selector_isSelectingEntireBlocks.getFocusInlineObject({
|
|
45
|
-
context: {
|
|
46
|
-
...snapshot.context,
|
|
47
|
-
selection: eventSelection
|
|
48
|
-
}
|
|
49
|
-
}))
|
|
50
|
-
return dragSelection;
|
|
51
|
-
const draggingCollapsedSelection = selector_isSelectionExpanded.isSelectionCollapsed({
|
|
52
|
-
context: {
|
|
53
|
-
...snapshot.context,
|
|
54
|
-
selection: eventSelection
|
|
55
|
-
}
|
|
56
|
-
}), draggedTextBlock = selector_isSelectionExpanded.getFocusTextBlock({
|
|
57
|
-
context: {
|
|
58
|
-
...snapshot.context,
|
|
59
|
-
selection: eventSelection
|
|
60
|
-
}
|
|
61
|
-
}), draggedSpan = selector_isSelectionExpanded.getFocusSpan({
|
|
62
|
-
context: {
|
|
63
|
-
...snapshot.context,
|
|
64
|
-
selection: eventSelection
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
draggingCollapsedSelection && draggedTextBlock && draggedSpan && (dragSelection = {
|
|
68
|
-
anchor: selectionPoint.getBlockStartPoint({
|
|
69
|
-
context: snapshot.context,
|
|
70
|
-
block: draggedTextBlock
|
|
71
|
-
}),
|
|
72
|
-
focus: util_isEqualSelectionPoints.getBlockEndPoint({
|
|
73
|
-
context: snapshot.context,
|
|
74
|
-
block: draggedTextBlock
|
|
75
|
-
})
|
|
76
|
-
});
|
|
77
|
-
const selectedBlocks = selector_isSelectionExpanded.getSelectedBlocks(snapshot);
|
|
78
|
-
if (snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
|
|
79
|
-
const selectionStartBlock = selector_isSelectionExpanded.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectionExpanded.getSelectionEndBlock(snapshot);
|
|
80
|
-
if (!selectionStartBlock || !selectionEndBlock)
|
|
81
|
-
return dragSelection;
|
|
82
|
-
const selectionStartPoint = selectionPoint.getBlockStartPoint({
|
|
83
|
-
context: snapshot.context,
|
|
84
|
-
block: selectionStartBlock
|
|
85
|
-
}), selectionEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
86
|
-
context: snapshot.context,
|
|
87
|
-
block: selectionEndBlock
|
|
88
|
-
});
|
|
89
|
-
selector_isSelectingEntireBlocks.isOverlappingSelection(eventSelection)({
|
|
90
|
-
...snapshot,
|
|
91
|
-
context: {
|
|
92
|
-
...snapshot.context,
|
|
93
|
-
selection: {
|
|
94
|
-
anchor: selectionStartPoint,
|
|
95
|
-
focus: selectionEndPoint
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}) && (dragSelection = {
|
|
99
|
-
anchor: selectionStartPoint,
|
|
100
|
-
focus: selectionEndPoint
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
return dragSelection;
|
|
104
|
-
}
|
|
105
26
|
const VOID_CHILD_KEY = "void-child";
|
|
106
27
|
function keepObjectEquality(object, keyMap) {
|
|
107
28
|
const value = keyMap[object._key];
|
|
@@ -462,81 +383,81 @@ function getEventPosition({
|
|
|
462
383
|
setup: "setting up"
|
|
463
384
|
}))
|
|
464
385
|
return;
|
|
465
|
-
const
|
|
386
|
+
const eventNode = getEventNode({
|
|
466
387
|
slateEditor,
|
|
467
388
|
event
|
|
468
389
|
});
|
|
469
|
-
if (!
|
|
390
|
+
if (!eventNode)
|
|
470
391
|
return;
|
|
471
|
-
const
|
|
392
|
+
const eventBlock = getNodeBlock({
|
|
472
393
|
editor: slateEditor,
|
|
473
394
|
schema: editorActor.getSnapshot().context.schema,
|
|
474
|
-
node
|
|
475
|
-
}),
|
|
476
|
-
node,
|
|
395
|
+
node: eventNode
|
|
396
|
+
}), eventPositionBlock = getEventPositionBlock({
|
|
397
|
+
node: eventNode,
|
|
477
398
|
slateEditor,
|
|
478
399
|
event
|
|
479
|
-
}),
|
|
400
|
+
}), eventSelection = getEventSelection({
|
|
480
401
|
schema: editorActor.getSnapshot().context.schema,
|
|
481
402
|
slateEditor,
|
|
482
403
|
event
|
|
483
404
|
});
|
|
484
|
-
if (
|
|
405
|
+
if (eventBlock && eventPositionBlock && !eventSelection && !slate.Editor.isEditor(eventNode))
|
|
485
406
|
return {
|
|
486
|
-
block:
|
|
407
|
+
block: eventPositionBlock,
|
|
487
408
|
isEditor: !1,
|
|
488
409
|
selection: {
|
|
489
410
|
anchor: selectionPoint.getBlockStartPoint({
|
|
490
411
|
context: editorActor.getSnapshot().context,
|
|
491
412
|
block: {
|
|
492
|
-
node:
|
|
413
|
+
node: eventBlock,
|
|
493
414
|
path: [{
|
|
494
|
-
_key:
|
|
415
|
+
_key: eventBlock._key
|
|
495
416
|
}]
|
|
496
417
|
}
|
|
497
418
|
}),
|
|
498
419
|
focus: util_isEqualSelectionPoints.getBlockEndPoint({
|
|
499
420
|
context: editorActor.getSnapshot().context,
|
|
500
421
|
block: {
|
|
501
|
-
node:
|
|
422
|
+
node: eventBlock,
|
|
502
423
|
path: [{
|
|
503
|
-
_key:
|
|
424
|
+
_key: eventBlock._key
|
|
504
425
|
}]
|
|
505
426
|
}
|
|
506
427
|
})
|
|
507
428
|
}
|
|
508
429
|
};
|
|
509
|
-
if (!
|
|
430
|
+
if (!eventPositionBlock || !eventSelection)
|
|
510
431
|
return;
|
|
511
|
-
const
|
|
512
|
-
if (
|
|
513
|
-
return util_selectionPointToBlockOffset.isSelectionCollapsed(
|
|
514
|
-
block:
|
|
432
|
+
const eventSelectionFocusBlockKey = selectionPoint.getBlockKeyFromSelectionPoint(eventSelection.focus);
|
|
433
|
+
if (eventSelectionFocusBlockKey !== void 0)
|
|
434
|
+
return util_selectionPointToBlockOffset.isSelectionCollapsed(eventSelection) && eventBlock && eventSelectionFocusBlockKey !== eventBlock._key ? {
|
|
435
|
+
block: eventPositionBlock,
|
|
515
436
|
isEditor: !1,
|
|
516
437
|
selection: {
|
|
517
438
|
anchor: selectionPoint.getBlockStartPoint({
|
|
518
439
|
context: editorActor.getSnapshot().context,
|
|
519
440
|
block: {
|
|
520
|
-
node:
|
|
441
|
+
node: eventBlock,
|
|
521
442
|
path: [{
|
|
522
|
-
_key:
|
|
443
|
+
_key: eventBlock._key
|
|
523
444
|
}]
|
|
524
445
|
}
|
|
525
446
|
}),
|
|
526
447
|
focus: util_isEqualSelectionPoints.getBlockEndPoint({
|
|
527
448
|
context: editorActor.getSnapshot().context,
|
|
528
449
|
block: {
|
|
529
|
-
node:
|
|
450
|
+
node: eventBlock,
|
|
530
451
|
path: [{
|
|
531
|
-
_key:
|
|
452
|
+
_key: eventBlock._key
|
|
532
453
|
}]
|
|
533
454
|
}
|
|
534
455
|
})
|
|
535
456
|
}
|
|
536
457
|
} : {
|
|
537
|
-
block:
|
|
538
|
-
isEditor: slate.Editor.isEditor(
|
|
539
|
-
selection
|
|
458
|
+
block: eventPositionBlock,
|
|
459
|
+
isEditor: slate.Editor.isEditor(eventNode),
|
|
460
|
+
selection: eventSelection
|
|
540
461
|
};
|
|
541
462
|
}
|
|
542
463
|
function getEventNode({
|
|
@@ -700,35 +621,6 @@ function normalizeSelection(selection, value) {
|
|
|
700
621
|
backward: selection.backward
|
|
701
622
|
} : null;
|
|
702
623
|
}
|
|
703
|
-
function getSelectionDomNodes({
|
|
704
|
-
slateEditor,
|
|
705
|
-
snapshot
|
|
706
|
-
}) {
|
|
707
|
-
if (!snapshot.context.selection)
|
|
708
|
-
return {
|
|
709
|
-
blockNodes: [],
|
|
710
|
-
childNodes: []
|
|
711
|
-
};
|
|
712
|
-
const range = toSlateRange(snapshot.context.selection, slateEditor);
|
|
713
|
-
if (!range)
|
|
714
|
-
return {
|
|
715
|
-
blockNodes: [],
|
|
716
|
-
childNodes: []
|
|
717
|
-
};
|
|
718
|
-
const blockEntries = Array.from(slate.Editor.nodes(slateEditor, {
|
|
719
|
-
at: range,
|
|
720
|
-
mode: "highest",
|
|
721
|
-
match: (n) => !slate.Editor.isEditor(n)
|
|
722
|
-
})), childEntries = Array.from(slate.Editor.nodes(slateEditor, {
|
|
723
|
-
at: range,
|
|
724
|
-
mode: "lowest",
|
|
725
|
-
match: (n) => !slate.Editor.isEditor(n) && slateEditor.isTextSpan(n) || !slateEditor.isBlock(n)
|
|
726
|
-
}));
|
|
727
|
-
return {
|
|
728
|
-
blockNodes: blockEntries.map(([blockNode]) => slateDom.DOMEditor.toDOMNode(slateEditor, blockNode)),
|
|
729
|
-
childNodes: childEntries.map(([childNode]) => slateDom.DOMEditor.toDOMNode(slateEditor, childNode))
|
|
730
|
-
};
|
|
731
|
-
}
|
|
732
624
|
const IS_PROCESSING_REMOTE_CHANGES = /* @__PURE__ */ new WeakMap(), KEY_TO_SLATE_ELEMENT = /* @__PURE__ */ new WeakMap(), KEY_TO_VALUE_ELEMENT = /* @__PURE__ */ new WeakMap(), SLATE_TO_PORTABLE_TEXT_RANGE = /* @__PURE__ */ new WeakMap(), EditorActorContext = React.createContext({});
|
|
733
625
|
function DropIndicator() {
|
|
734
626
|
const $ = reactCompilerRuntime.c(1);
|
|
@@ -771,6 +663,72 @@ function RenderDefaultInlineObject(props) {
|
|
|
771
663
|
"]"
|
|
772
664
|
] }), $[1] = props.inlineObject._key, $[2] = props.inlineObject._type, $[3] = t1) : t1 = $[3], t1;
|
|
773
665
|
}
|
|
666
|
+
function getDragSelection({
|
|
667
|
+
eventSelection,
|
|
668
|
+
snapshot
|
|
669
|
+
}) {
|
|
670
|
+
let dragSelection = eventSelection;
|
|
671
|
+
if (selector_isSelectingEntireBlocks.getFocusInlineObject({
|
|
672
|
+
context: {
|
|
673
|
+
...snapshot.context,
|
|
674
|
+
selection: eventSelection
|
|
675
|
+
}
|
|
676
|
+
}))
|
|
677
|
+
return dragSelection;
|
|
678
|
+
const draggingCollapsedSelection = selector_isSelectionExpanded.isSelectionCollapsed({
|
|
679
|
+
context: {
|
|
680
|
+
...snapshot.context,
|
|
681
|
+
selection: eventSelection
|
|
682
|
+
}
|
|
683
|
+
}), draggedTextBlock = selector_isSelectionExpanded.getFocusTextBlock({
|
|
684
|
+
context: {
|
|
685
|
+
...snapshot.context,
|
|
686
|
+
selection: eventSelection
|
|
687
|
+
}
|
|
688
|
+
}), draggedSpan = selector_isSelectionExpanded.getFocusSpan({
|
|
689
|
+
context: {
|
|
690
|
+
...snapshot.context,
|
|
691
|
+
selection: eventSelection
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
draggingCollapsedSelection && draggedTextBlock && draggedSpan && (dragSelection = {
|
|
695
|
+
anchor: selectionPoint.getBlockStartPoint({
|
|
696
|
+
context: snapshot.context,
|
|
697
|
+
block: draggedTextBlock
|
|
698
|
+
}),
|
|
699
|
+
focus: util_isEqualSelectionPoints.getBlockEndPoint({
|
|
700
|
+
context: snapshot.context,
|
|
701
|
+
block: draggedTextBlock
|
|
702
|
+
})
|
|
703
|
+
});
|
|
704
|
+
const selectedBlocks = selector_isSelectionExpanded.getSelectedBlocks(snapshot);
|
|
705
|
+
if (snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
|
|
706
|
+
const selectionStartBlock = selector_isSelectionExpanded.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectionExpanded.getSelectionEndBlock(snapshot);
|
|
707
|
+
if (!selectionStartBlock || !selectionEndBlock)
|
|
708
|
+
return dragSelection;
|
|
709
|
+
const selectionStartPoint = selectionPoint.getBlockStartPoint({
|
|
710
|
+
context: snapshot.context,
|
|
711
|
+
block: selectionStartBlock
|
|
712
|
+
}), selectionEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
713
|
+
context: snapshot.context,
|
|
714
|
+
block: selectionEndBlock
|
|
715
|
+
});
|
|
716
|
+
selector_isSelectingEntireBlocks.isOverlappingSelection(eventSelection)({
|
|
717
|
+
...snapshot,
|
|
718
|
+
context: {
|
|
719
|
+
...snapshot.context,
|
|
720
|
+
selection: {
|
|
721
|
+
anchor: selectionStartPoint,
|
|
722
|
+
focus: selectionEndPoint
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}) && (dragSelection = {
|
|
726
|
+
anchor: selectionStartPoint,
|
|
727
|
+
focus: selectionEndPoint
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
return dragSelection;
|
|
731
|
+
}
|
|
774
732
|
const defaultKeyGenerator = () => randomKey(12), getByteHexTable = /* @__PURE__ */ (() => {
|
|
775
733
|
let table;
|
|
776
734
|
return () => {
|
|
@@ -819,16 +777,22 @@ function createCoreBlockElementBehaviorsConfig({
|
|
|
819
777
|
});
|
|
820
778
|
if (!dropFocusBlock || dropFocusBlock.node._key !== key)
|
|
821
779
|
return !1;
|
|
822
|
-
const dragOrigin =
|
|
823
|
-
|
|
780
|
+
const dragOrigin = event.dragOrigin;
|
|
781
|
+
if (!dragOrigin)
|
|
782
|
+
return !1;
|
|
783
|
+
const dragSelection = getDragSelection({
|
|
784
|
+
eventSelection: dragOrigin.selection,
|
|
785
|
+
snapshot
|
|
786
|
+
});
|
|
787
|
+
return selector_isSelectionExpanded.getSelectedBlocks({
|
|
824
788
|
context: {
|
|
825
789
|
...snapshot.context,
|
|
826
|
-
selection:
|
|
790
|
+
selection: dragSelection
|
|
827
791
|
}
|
|
828
792
|
}).some((draggedBlock) => draggedBlock.node._key === key) ? !1 : selector_isSelectingEntireBlocks.isSelectingEntireBlocks({
|
|
829
793
|
context: {
|
|
830
794
|
...snapshot.context,
|
|
831
|
-
selection:
|
|
795
|
+
selection: dragSelection
|
|
832
796
|
}
|
|
833
797
|
});
|
|
834
798
|
},
|
|
@@ -1020,93 +984,49 @@ function RenderTextBlock(props) {
|
|
|
1020
984
|
] });
|
|
1021
985
|
}
|
|
1022
986
|
function RenderElement(props) {
|
|
1023
|
-
const $ = reactCompilerRuntime.c(
|
|
987
|
+
const $ = reactCompilerRuntime.c(43), editorActor = React.useContext(EditorActorContext), schema2 = react.useSelector(editorActor, _temp$1);
|
|
1024
988
|
if ("__inline" in props.element && props.element.__inline === !0) {
|
|
1025
989
|
let t02;
|
|
1026
|
-
|
|
1027
|
-
let t13;
|
|
1028
|
-
$[3] !== props.element ? (t13 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[3] = props.element, $[4] = t13) : t13 = $[4], t02 = selectionPoint.parseInlineObject({
|
|
1029
|
-
context: {
|
|
1030
|
-
keyGenerator: _temp2,
|
|
1031
|
-
schema: schema2
|
|
1032
|
-
},
|
|
1033
|
-
options: {
|
|
1034
|
-
refreshKeys: !1,
|
|
1035
|
-
validateFields: !1
|
|
1036
|
-
},
|
|
1037
|
-
inlineObject: {
|
|
1038
|
-
_key: props.element._key,
|
|
1039
|
-
_type: props.element._type,
|
|
1040
|
-
...t13
|
|
1041
|
-
}
|
|
1042
|
-
}), $[0] = props.element, $[1] = schema2, $[2] = t02;
|
|
1043
|
-
} else
|
|
1044
|
-
t02 = $[2];
|
|
1045
|
-
const inlineObject = t02;
|
|
1046
|
-
inlineObject || console.error(`Unable to find Inline Object "${props.element._type}" in Schema`);
|
|
990
|
+
$[0] !== props.element ? (t02 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[0] = props.element, $[1] = t02) : t02 = $[1];
|
|
1047
991
|
let t12;
|
|
1048
|
-
$[
|
|
992
|
+
$[2] !== props.element._key || $[3] !== props.element._type || $[4] !== t02 ? (t12 = {
|
|
1049
993
|
_key: props.element._key,
|
|
1050
|
-
_type: props.element._type
|
|
1051
|
-
|
|
994
|
+
_type: props.element._type,
|
|
995
|
+
...t02
|
|
996
|
+
}, $[2] = props.element._key, $[3] = props.element._type, $[4] = t02, $[5] = t12) : t12 = $[5];
|
|
997
|
+
const inlineObject = t12;
|
|
998
|
+
schema2.inlineObjects.find((inlineObject_0) => inlineObject_0.name === props.element._type) || console.error(`Unable to find Inline Object "${props.element._type}" in Schema`);
|
|
1052
999
|
let t22;
|
|
1053
|
-
|
|
1000
|
+
$[6] !== inlineObject || $[7] !== props.element._key || $[8] !== props.element._type ? (t22 = inlineObject ?? {
|
|
1001
|
+
_key: props.element._key,
|
|
1002
|
+
_type: props.element._type
|
|
1003
|
+
}, $[6] = inlineObject, $[7] = props.element._key, $[8] = props.element._type, $[9] = t22) : t22 = $[9];
|
|
1004
|
+
let t32;
|
|
1005
|
+
return $[10] !== props.attributes || $[11] !== props.children || $[12] !== props.element || $[13] !== props.readOnly || $[14] !== props.renderChild || $[15] !== t22 ? (t32 = /* @__PURE__ */ jsxRuntime.jsx(RenderInlineObject, { attributes: props.attributes, element: props.element, inlineObject: t22, readOnly: props.readOnly, renderChild: props.renderChild, children: props.children }), $[10] = props.attributes, $[11] = props.children, $[12] = props.element, $[13] = props.readOnly, $[14] = props.renderChild, $[15] = t22, $[16] = t32) : t32 = $[16], t32;
|
|
1054
1006
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
},
|
|
1061
|
-
options: {
|
|
1062
|
-
refreshKeys: !1,
|
|
1063
|
-
validateFields: !1
|
|
1064
|
-
},
|
|
1065
|
-
block: props.element
|
|
1066
|
-
}), $[16] = props.element, $[17] = schema2, $[18] = t0) : t0 = $[18];
|
|
1067
|
-
const textBlock = t0;
|
|
1068
|
-
if (textBlock) {
|
|
1069
|
-
let t12;
|
|
1070
|
-
return $[19] !== props.attributes || $[20] !== props.children || $[21] !== props.element || $[22] !== props.readOnly || $[23] !== props.renderBlock || $[24] !== props.renderListItem || $[25] !== props.renderStyle || $[26] !== props.spellCheck || $[27] !== textBlock ? (t12 = /* @__PURE__ */ jsxRuntime.jsx(RenderTextBlock, { attributes: props.attributes, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, renderListItem: props.renderListItem, renderStyle: props.renderStyle, spellCheck: props.spellCheck, textBlock, children: props.children }), $[19] = props.attributes, $[20] = props.children, $[21] = props.element, $[22] = props.readOnly, $[23] = props.renderBlock, $[24] = props.renderListItem, $[25] = props.renderStyle, $[26] = props.spellCheck, $[27] = textBlock, $[28] = t12) : t12 = $[28], t12;
|
|
1007
|
+
if (selectionPoint.isTextBlock({
|
|
1008
|
+
schema: schema2
|
|
1009
|
+
}, props.element)) {
|
|
1010
|
+
let t02;
|
|
1011
|
+
return $[17] !== props.attributes || $[18] !== props.children || $[19] !== props.element || $[20] !== props.readOnly || $[21] !== props.renderBlock || $[22] !== props.renderListItem || $[23] !== props.renderStyle || $[24] !== props.spellCheck ? (t02 = /* @__PURE__ */ jsxRuntime.jsx(RenderTextBlock, { attributes: props.attributes, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, renderListItem: props.renderListItem, renderStyle: props.renderStyle, spellCheck: props.spellCheck, textBlock: props.element, children: props.children }), $[17] = props.attributes, $[18] = props.children, $[19] = props.element, $[20] = props.readOnly, $[21] = props.renderBlock, $[22] = props.renderListItem, $[23] = props.renderStyle, $[24] = props.spellCheck, $[25] = t02) : t02 = $[25], t02;
|
|
1071
1012
|
}
|
|
1013
|
+
let t0;
|
|
1014
|
+
$[26] !== props.element ? (t0 = "value" in props.element && typeof props.element.value == "object" ? props.element.value : {}, $[26] = props.element, $[27] = t0) : t0 = $[27];
|
|
1072
1015
|
let t1;
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
schema: schema2
|
|
1079
|
-
},
|
|
1080
|
-
options: {
|
|
1081
|
-
refreshKeys: !1,
|
|
1082
|
-
validateFields: !1
|
|
1083
|
-
},
|
|
1084
|
-
blockObject: {
|
|
1085
|
-
_key: props.element._key,
|
|
1086
|
-
_type: props.element._type,
|
|
1087
|
-
...t22
|
|
1088
|
-
}
|
|
1089
|
-
}), $[29] = props.element, $[30] = schema2, $[31] = t1;
|
|
1090
|
-
} else
|
|
1091
|
-
t1 = $[31];
|
|
1016
|
+
$[28] !== props.element._key || $[29] !== props.element._type || $[30] !== t0 ? (t1 = {
|
|
1017
|
+
_key: props.element._key,
|
|
1018
|
+
_type: props.element._type,
|
|
1019
|
+
...t0
|
|
1020
|
+
}, $[28] = props.element._key, $[29] = props.element._type, $[30] = t0, $[31] = t1) : t1 = $[31];
|
|
1092
1021
|
const blockObject = t1;
|
|
1093
|
-
|
|
1022
|
+
schema2.blockObjects.find((blockObject_0) => blockObject_0.name === props.element._type) || console.error(`Unable to find Block Object "${props.element._type}" in Schema`);
|
|
1094
1023
|
let t2;
|
|
1095
|
-
$[
|
|
1024
|
+
$[32] !== blockObject || $[33] !== props.element._key || $[34] !== props.element._type ? (t2 = blockObject ?? {
|
|
1096
1025
|
_key: props.element._key,
|
|
1097
1026
|
_type: props.element._type
|
|
1098
|
-
}, $[
|
|
1027
|
+
}, $[32] = blockObject, $[33] = props.element._key, $[34] = props.element._type, $[35] = t2) : t2 = $[35];
|
|
1099
1028
|
let t3;
|
|
1100
|
-
return $[
|
|
1101
|
-
}
|
|
1102
|
-
function _temp4() {
|
|
1103
|
-
return "";
|
|
1104
|
-
}
|
|
1105
|
-
function _temp3() {
|
|
1106
|
-
return "";
|
|
1107
|
-
}
|
|
1108
|
-
function _temp2() {
|
|
1109
|
-
return "";
|
|
1029
|
+
return $[36] !== props.attributes || $[37] !== props.children || $[38] !== props.element || $[39] !== props.readOnly || $[40] !== props.renderBlock || $[41] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(RenderBlockObject, { attributes: props.attributes, blockObject: t2, element: props.element, readOnly: props.readOnly, renderBlock: props.renderBlock, children: props.children }), $[36] = props.attributes, $[37] = props.children, $[38] = props.element, $[39] = props.readOnly, $[40] = props.renderBlock, $[41] = t2, $[42] = t3) : t3 = $[42], t3;
|
|
1110
1030
|
}
|
|
1111
1031
|
function _temp$1(s) {
|
|
1112
1032
|
return s.context.schema;
|
|
@@ -1177,7 +1097,7 @@ const converterJson = {
|
|
|
1177
1097
|
snapshot,
|
|
1178
1098
|
event
|
|
1179
1099
|
}) => {
|
|
1180
|
-
const selection = snapshot.
|
|
1100
|
+
const selection = snapshot.context.selection;
|
|
1181
1101
|
if (!selection)
|
|
1182
1102
|
return {
|
|
1183
1103
|
type: "serialization.failure",
|
|
@@ -1220,11 +1140,7 @@ const converterJson = {
|
|
|
1220
1140
|
context: snapshot.context,
|
|
1221
1141
|
block,
|
|
1222
1142
|
options: {
|
|
1223
|
-
|
|
1224
|
-
* If we are dragging internally then we would like to keep the
|
|
1225
|
-
* dropped portable text as is.
|
|
1226
|
-
*/
|
|
1227
|
-
refreshKeys: !snapshot.beta.internalDrag,
|
|
1143
|
+
refreshKeys: !0,
|
|
1228
1144
|
validateFields: !1
|
|
1229
1145
|
}
|
|
1230
1146
|
});
|
|
@@ -1248,7 +1164,7 @@ function createConverterTextHtml(legacySchema) {
|
|
|
1248
1164
|
snapshot,
|
|
1249
1165
|
event
|
|
1250
1166
|
}) => {
|
|
1251
|
-
const selection = snapshot.
|
|
1167
|
+
const selection = snapshot.context.selection;
|
|
1252
1168
|
if (!selection)
|
|
1253
1169
|
return {
|
|
1254
1170
|
type: "serialization.failure",
|
|
@@ -1319,7 +1235,7 @@ function createConverterTextPlain(legacySchema) {
|
|
|
1319
1235
|
snapshot,
|
|
1320
1236
|
event
|
|
1321
1237
|
}) => {
|
|
1322
|
-
const selection = snapshot.
|
|
1238
|
+
const selection = snapshot.context.selection;
|
|
1323
1239
|
return selection ? {
|
|
1324
1240
|
type: "serialization.success",
|
|
1325
1241
|
data: selectionPoint.sliceBlocks({
|
|
@@ -1328,7 +1244,7 @@ function createConverterTextPlain(legacySchema) {
|
|
|
1328
1244
|
schema: snapshot.context.schema
|
|
1329
1245
|
},
|
|
1330
1246
|
blocks: snapshot.context.value
|
|
1331
|
-
}).map((block) => selectionPoint.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text :
|
|
1247
|
+
}).map((block) => selectionPoint.isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : event.originEvent === "drag.dragstart" ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
|
|
1332
1248
|
|
|
1333
1249
|
`),
|
|
1334
1250
|
mimeType: "text/plain",
|
|
@@ -1563,8 +1479,7 @@ function getEditorSnapshot({
|
|
|
1563
1479
|
decoratorState: slateEditorInstance.decoratorState,
|
|
1564
1480
|
markState: slateEditorInstance.markState,
|
|
1565
1481
|
schema: editorActorSnapshot.context.schema
|
|
1566
|
-
})
|
|
1567
|
-
internalDrag: editorActorSnapshot.context.internalDrag
|
|
1482
|
+
})
|
|
1568
1483
|
}
|
|
1569
1484
|
};
|
|
1570
1485
|
}
|
|
@@ -4695,7 +4610,7 @@ function createWithSchemaTypes({
|
|
|
4695
4610
|
editorActor
|
|
4696
4611
|
}) {
|
|
4697
4612
|
return function(editor) {
|
|
4698
|
-
editor.isTextBlock = (value) => selectionPoint.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => selectionPoint.isSpan$1(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => selectionPoint.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4613
|
+
editor.isTextBlock = (value) => slate.Editor.isEditor(value) ? !1 : selectionPoint.isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => slate.Editor.isEditor(value) ? !1 : selectionPoint.isSpan$1(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => slate.Editor.isEditor(value) ? !1 : selectionPoint.isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => slate.Editor.isEditor(element) ? !1 : editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4699
4614
|
const {
|
|
4700
4615
|
normalizeNode
|
|
4701
4616
|
} = editor;
|
|
@@ -5551,7 +5466,131 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5551
5466
|
decorator: "code"
|
|
5552
5467
|
})]]
|
|
5553
5468
|
})
|
|
5554
|
-
}
|
|
5469
|
+
};
|
|
5470
|
+
function getCompoundClientRect(nodes) {
|
|
5471
|
+
if (nodes.length === 0)
|
|
5472
|
+
return new DOMRect(0, 0, 0, 0);
|
|
5473
|
+
const elements = nodes.filter((node) => node instanceof Element), firstRect = elements.at(0)?.getBoundingClientRect();
|
|
5474
|
+
if (!firstRect)
|
|
5475
|
+
return new DOMRect(0, 0, 0, 0);
|
|
5476
|
+
let left = firstRect.left, top = firstRect.top, right = firstRect.right, bottom = firstRect.bottom;
|
|
5477
|
+
for (let i = 1; i < elements.length; i++) {
|
|
5478
|
+
const rect = elements[i].getBoundingClientRect();
|
|
5479
|
+
left = Math.min(left, rect.left), top = Math.min(top, rect.top), right = Math.max(right, rect.right), bottom = Math.max(bottom, rect.bottom);
|
|
5480
|
+
}
|
|
5481
|
+
return new DOMRect(left, top, right - left, bottom - top);
|
|
5482
|
+
}
|
|
5483
|
+
const coreDndBehaviors = [
|
|
5484
|
+
/**
|
|
5485
|
+
* Core Behavior that:
|
|
5486
|
+
* 1. Calculates and selects a "drag selection"
|
|
5487
|
+
* 2. Constructs and sets a drag ghost element
|
|
5488
|
+
* 3. Forwards the dragstart event
|
|
5489
|
+
*/
|
|
5490
|
+
behaviors_index.defineBehavior({
|
|
5491
|
+
on: "drag.dragstart",
|
|
5492
|
+
guard: ({
|
|
5493
|
+
snapshot,
|
|
5494
|
+
dom,
|
|
5495
|
+
event
|
|
5496
|
+
}) => {
|
|
5497
|
+
const dragSelection = getDragSelection({
|
|
5498
|
+
snapshot,
|
|
5499
|
+
eventSelection: event.position.selection
|
|
5500
|
+
}), selectingEntireBlocks = selector_isSelectingEntireBlocks.isSelectingEntireBlocks({
|
|
5501
|
+
context: {
|
|
5502
|
+
...snapshot.context,
|
|
5503
|
+
selection: dragSelection
|
|
5504
|
+
}
|
|
5505
|
+
}), draggedDomNodes = {
|
|
5506
|
+
blockNodes: dom.getBlockNodes({
|
|
5507
|
+
...snapshot,
|
|
5508
|
+
context: {
|
|
5509
|
+
...snapshot.context,
|
|
5510
|
+
selection: dragSelection
|
|
5511
|
+
}
|
|
5512
|
+
}),
|
|
5513
|
+
childNodes: dom.getChildNodes({
|
|
5514
|
+
...snapshot,
|
|
5515
|
+
context: {
|
|
5516
|
+
...snapshot.context,
|
|
5517
|
+
selection: dragSelection
|
|
5518
|
+
}
|
|
5519
|
+
})
|
|
5520
|
+
};
|
|
5521
|
+
return {
|
|
5522
|
+
dragSelection,
|
|
5523
|
+
draggedDomNodes,
|
|
5524
|
+
selectingEntireBlocks
|
|
5525
|
+
};
|
|
5526
|
+
},
|
|
5527
|
+
actions: [({
|
|
5528
|
+
dom,
|
|
5529
|
+
event
|
|
5530
|
+
}, {
|
|
5531
|
+
dragSelection,
|
|
5532
|
+
draggedDomNodes,
|
|
5533
|
+
selectingEntireBlocks
|
|
5534
|
+
}) => {
|
|
5535
|
+
const dragGhost = document.createElement("div");
|
|
5536
|
+
if (selectingEntireBlocks) {
|
|
5537
|
+
const clonedBlockNodes = draggedDomNodes.blockNodes.map((node) => node.cloneNode(!0));
|
|
5538
|
+
for (const block of clonedBlockNodes)
|
|
5539
|
+
block instanceof HTMLElement && (block.style.position = "relative"), dragGhost.appendChild(block);
|
|
5540
|
+
const customGhost = dragGhost.querySelector("[data-pt-drag-ghost-element]");
|
|
5541
|
+
if (customGhost && dragGhost.replaceChildren(customGhost), dragGhost.setAttribute("data-dragged", ""), dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost), customGhost) {
|
|
5542
|
+
const customGhostRect = customGhost.getBoundingClientRect(), x = event.originEvent.clientX - customGhostRect.left, y = event.originEvent.clientY - customGhostRect.top;
|
|
5543
|
+
return dragGhost.style.width = `${customGhostRect.width}px`, dragGhost.style.height = `${customGhostRect.height}px`, [behaviors_index.raise({
|
|
5544
|
+
type: "select",
|
|
5545
|
+
at: dragSelection
|
|
5546
|
+
}), behaviors_index.effect(() => {
|
|
5547
|
+
dom.setDragGhost({
|
|
5548
|
+
event,
|
|
5549
|
+
ghost: {
|
|
5550
|
+
element: dragGhost,
|
|
5551
|
+
x,
|
|
5552
|
+
y
|
|
5553
|
+
}
|
|
5554
|
+
});
|
|
5555
|
+
}), behaviors_index.forward(event)];
|
|
5556
|
+
} else {
|
|
5557
|
+
const blocksDomRect = getCompoundClientRect(draggedDomNodes.blockNodes), x = event.originEvent.clientX - blocksDomRect.left, y = event.originEvent.clientY - blocksDomRect.top;
|
|
5558
|
+
return dragGhost.style.width = `${blocksDomRect.width}px`, dragGhost.style.height = `${blocksDomRect.height}px`, [behaviors_index.raise({
|
|
5559
|
+
type: "select",
|
|
5560
|
+
at: dragSelection
|
|
5561
|
+
}), behaviors_index.effect(() => {
|
|
5562
|
+
dom.setDragGhost({
|
|
5563
|
+
event,
|
|
5564
|
+
ghost: {
|
|
5565
|
+
element: dragGhost,
|
|
5566
|
+
x,
|
|
5567
|
+
y
|
|
5568
|
+
}
|
|
5569
|
+
});
|
|
5570
|
+
}), behaviors_index.forward(event)];
|
|
5571
|
+
}
|
|
5572
|
+
} else {
|
|
5573
|
+
const clonedChildNodes = draggedDomNodes.childNodes.map((node) => node.cloneNode(!0));
|
|
5574
|
+
for (const child of clonedChildNodes)
|
|
5575
|
+
dragGhost.appendChild(child);
|
|
5576
|
+
dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost);
|
|
5577
|
+
const childrenDomRect = getCompoundClientRect(draggedDomNodes.childNodes), x = event.originEvent.clientX - childrenDomRect.left, y = event.originEvent.clientY - childrenDomRect.top;
|
|
5578
|
+
return dragGhost.style.width = `${childrenDomRect.width}px`, dragGhost.style.height = `${childrenDomRect.height}px`, [behaviors_index.raise({
|
|
5579
|
+
type: "select",
|
|
5580
|
+
at: dragSelection
|
|
5581
|
+
}), behaviors_index.effect(() => {
|
|
5582
|
+
dom.setDragGhost({
|
|
5583
|
+
event,
|
|
5584
|
+
ghost: {
|
|
5585
|
+
element: dragGhost,
|
|
5586
|
+
x,
|
|
5587
|
+
y
|
|
5588
|
+
}
|
|
5589
|
+
});
|
|
5590
|
+
}), behaviors_index.forward(event)];
|
|
5591
|
+
}
|
|
5592
|
+
}]
|
|
5593
|
+
}),
|
|
5555
5594
|
/**
|
|
5556
5595
|
* When dragging over the drag origin, we don't want to show the caret in the
|
|
5557
5596
|
* text.
|
|
@@ -5562,7 +5601,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5562
5601
|
snapshot,
|
|
5563
5602
|
event
|
|
5564
5603
|
}) => {
|
|
5565
|
-
const dragOrigin =
|
|
5604
|
+
const dragOrigin = event.dragOrigin;
|
|
5566
5605
|
return dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(event.position.selection)({
|
|
5567
5606
|
...snapshot,
|
|
5568
5607
|
context: {
|
|
@@ -5572,6 +5611,121 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5572
5611
|
}) : !1;
|
|
5573
5612
|
},
|
|
5574
5613
|
actions: []
|
|
5614
|
+
}),
|
|
5615
|
+
/**
|
|
5616
|
+
* If the drop position overlaps the drag origin, then the event should be
|
|
5617
|
+
* cancelled.
|
|
5618
|
+
*/
|
|
5619
|
+
behaviors_index.defineBehavior({
|
|
5620
|
+
on: "drag.drop",
|
|
5621
|
+
guard: ({
|
|
5622
|
+
snapshot,
|
|
5623
|
+
event
|
|
5624
|
+
}) => {
|
|
5625
|
+
const dragOrigin = event.dragOrigin, dropPosition = event.position.selection;
|
|
5626
|
+
return dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(dropPosition)({
|
|
5627
|
+
...snapshot,
|
|
5628
|
+
context: {
|
|
5629
|
+
...snapshot.context,
|
|
5630
|
+
selection: dragOrigin.selection
|
|
5631
|
+
}
|
|
5632
|
+
}) : !1;
|
|
5633
|
+
},
|
|
5634
|
+
actions: []
|
|
5635
|
+
}),
|
|
5636
|
+
/**
|
|
5637
|
+
* If we drop and have access to a drag origin, then we can deserialize
|
|
5638
|
+
* without creating a new selection.
|
|
5639
|
+
*/
|
|
5640
|
+
behaviors_index.defineBehavior({
|
|
5641
|
+
on: "drag.drop",
|
|
5642
|
+
guard: ({
|
|
5643
|
+
event
|
|
5644
|
+
}) => event.dragOrigin !== void 0,
|
|
5645
|
+
actions: [({
|
|
5646
|
+
event
|
|
5647
|
+
}) => [behaviors_index.raise({
|
|
5648
|
+
type: "deserialize",
|
|
5649
|
+
originEvent: event
|
|
5650
|
+
})]]
|
|
5651
|
+
}),
|
|
5652
|
+
/**
|
|
5653
|
+
* Otherwise, we should to create a new selection.
|
|
5654
|
+
*/
|
|
5655
|
+
behaviors_index.defineBehavior({
|
|
5656
|
+
on: "drag.drop",
|
|
5657
|
+
actions: [({
|
|
5658
|
+
event
|
|
5659
|
+
}) => [behaviors_index.raise({
|
|
5660
|
+
type: "select",
|
|
5661
|
+
at: event.position.selection
|
|
5662
|
+
}), behaviors_index.raise({
|
|
5663
|
+
type: "deserialize",
|
|
5664
|
+
originEvent: event
|
|
5665
|
+
})]]
|
|
5666
|
+
}),
|
|
5667
|
+
/**
|
|
5668
|
+
* Core Behavior that uses the drag origin to mimic a move operation during
|
|
5669
|
+
* internal dragging.
|
|
5670
|
+
*/
|
|
5671
|
+
behaviors_index.defineBehavior({
|
|
5672
|
+
on: "deserialization.success",
|
|
5673
|
+
guard: ({
|
|
5674
|
+
snapshot,
|
|
5675
|
+
event
|
|
5676
|
+
}) => {
|
|
5677
|
+
if (event.originEvent.type !== "drag.drop" || event.originEvent.dragOrigin === void 0)
|
|
5678
|
+
return !1;
|
|
5679
|
+
const dragOrigin = event.originEvent.dragOrigin, dragSelection = getDragSelection({
|
|
5680
|
+
eventSelection: dragOrigin.selection,
|
|
5681
|
+
snapshot
|
|
5682
|
+
}), dropPosition = event.originEvent.position.selection, droppingOnDragOrigin = dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(dropPosition)({
|
|
5683
|
+
...snapshot,
|
|
5684
|
+
context: {
|
|
5685
|
+
...snapshot.context,
|
|
5686
|
+
selection: dragSelection
|
|
5687
|
+
}
|
|
5688
|
+
}) : !1, draggingEntireBlocks = selector_isSelectingEntireBlocks.isSelectingEntireBlocks({
|
|
5689
|
+
context: {
|
|
5690
|
+
...snapshot.context,
|
|
5691
|
+
selection: dragSelection
|
|
5692
|
+
}
|
|
5693
|
+
}), draggedBlocks = selector_isSelectionExpanded.getSelectedBlocks({
|
|
5694
|
+
context: {
|
|
5695
|
+
...snapshot.context,
|
|
5696
|
+
selection: dragSelection
|
|
5697
|
+
}
|
|
5698
|
+
});
|
|
5699
|
+
return droppingOnDragOrigin ? !1 : {
|
|
5700
|
+
dropPosition,
|
|
5701
|
+
draggingEntireBlocks,
|
|
5702
|
+
draggedBlocks,
|
|
5703
|
+
dragOrigin,
|
|
5704
|
+
originEvent: event.originEvent
|
|
5705
|
+
};
|
|
5706
|
+
},
|
|
5707
|
+
actions: [({
|
|
5708
|
+
event
|
|
5709
|
+
}, {
|
|
5710
|
+
draggingEntireBlocks,
|
|
5711
|
+
draggedBlocks,
|
|
5712
|
+
dragOrigin,
|
|
5713
|
+
dropPosition,
|
|
5714
|
+
originEvent
|
|
5715
|
+
}) => [...draggingEntireBlocks ? draggedBlocks.map((block) => behaviors_index.raise({
|
|
5716
|
+
type: "delete.block",
|
|
5717
|
+
at: block.path
|
|
5718
|
+
})) : [behaviors_index.raise({
|
|
5719
|
+
type: "delete",
|
|
5720
|
+
at: dragOrigin.selection
|
|
5721
|
+
})], behaviors_index.raise({
|
|
5722
|
+
type: "select",
|
|
5723
|
+
at: dropPosition
|
|
5724
|
+
}), behaviors_index.raise({
|
|
5725
|
+
type: "insert.blocks",
|
|
5726
|
+
blocks: event.data,
|
|
5727
|
+
placement: draggingEntireBlocks ? originEvent.position.block === "start" ? "before" : originEvent.position.block === "end" ? "after" : "auto" : "auto"
|
|
5728
|
+
})]]
|
|
5575
5729
|
})
|
|
5576
5730
|
], breakingAtTheEndOfTextBlock = behaviors_index.defineBehavior({
|
|
5577
5731
|
on: "insert.break",
|
|
@@ -5834,7 +5988,52 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5834
5988
|
}, coreBehaviorsConfig = [coreAnnotationBehaviors.addAnnotationOnCollapsedSelection, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, ...coreDndBehaviors, coreBlockObjectBehaviors.clickingAboveLonelyBlockObject, coreBlockObjectBehaviors.clickingBelowLonelyBlockObject, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab, coreInsertBreakBehaviors.breakingAtTheEndOfTextBlock, coreInsertBreakBehaviors.breakingAtTheStartOfTextBlock, coreInsertBreakBehaviors.breakingEntireDocument, coreInsertBreakBehaviors.breakingEntireBlocks].map((behavior) => ({
|
|
5835
5989
|
behavior,
|
|
5836
5990
|
priority: corePriority
|
|
5837
|
-
}))
|
|
5991
|
+
}));
|
|
5992
|
+
function createEditorDom(sendBack, slateEditor) {
|
|
5993
|
+
return {
|
|
5994
|
+
getBlockNodes: (snapshot) => getBlockNodes(slateEditor, snapshot),
|
|
5995
|
+
getChildNodes: (snapshot) => getChildNodes(slateEditor, snapshot),
|
|
5996
|
+
setDragGhost: ({
|
|
5997
|
+
event,
|
|
5998
|
+
ghost
|
|
5999
|
+
}) => setDragGhost({
|
|
6000
|
+
sendBack,
|
|
6001
|
+
event,
|
|
6002
|
+
ghost
|
|
6003
|
+
})
|
|
6004
|
+
};
|
|
6005
|
+
}
|
|
6006
|
+
function getBlockNodes(slateEditor, snapshot) {
|
|
6007
|
+
if (!snapshot.context.selection)
|
|
6008
|
+
return [];
|
|
6009
|
+
const range = toSlateRange(snapshot.context.selection, slateEditor);
|
|
6010
|
+
return range ? Array.from(slate.Editor.nodes(slateEditor, {
|
|
6011
|
+
at: range,
|
|
6012
|
+
mode: "highest",
|
|
6013
|
+
match: (n) => !slate.Editor.isEditor(n)
|
|
6014
|
+
})).map(([blockNode]) => slateDom.DOMEditor.toDOMNode(slateEditor, blockNode)) : [];
|
|
6015
|
+
}
|
|
6016
|
+
function getChildNodes(slateEditor, snapshot) {
|
|
6017
|
+
if (!snapshot.context.selection)
|
|
6018
|
+
return [];
|
|
6019
|
+
const range = toSlateRange(snapshot.context.selection, slateEditor);
|
|
6020
|
+
return range ? Array.from(slate.Editor.nodes(slateEditor, {
|
|
6021
|
+
at: range,
|
|
6022
|
+
mode: "lowest",
|
|
6023
|
+
match: (n) => !slate.Editor.isEditor(n)
|
|
6024
|
+
})).map(([childNode]) => slateDom.DOMEditor.toDOMNode(slateEditor, childNode)) : [];
|
|
6025
|
+
}
|
|
6026
|
+
function setDragGhost({
|
|
6027
|
+
sendBack,
|
|
6028
|
+
event,
|
|
6029
|
+
ghost
|
|
6030
|
+
}) {
|
|
6031
|
+
event.originEvent.dataTransfer.setDragImage(ghost.element, ghost.x, ghost.y), sendBack({
|
|
6032
|
+
type: "set drag ghost",
|
|
6033
|
+
ghost: ghost.element
|
|
6034
|
+
});
|
|
6035
|
+
}
|
|
6036
|
+
const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
5838
6037
|
on: "annotation.toggle",
|
|
5839
6038
|
guard: ({
|
|
5840
6039
|
snapshot,
|
|
@@ -6570,86 +6769,6 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
6570
6769
|
}
|
|
6571
6770
|
}]]
|
|
6572
6771
|
}),
|
|
6573
|
-
behaviors_index.defineBehavior({
|
|
6574
|
-
on: "drag.drop",
|
|
6575
|
-
guard: ({
|
|
6576
|
-
snapshot,
|
|
6577
|
-
event
|
|
6578
|
-
}) => {
|
|
6579
|
-
const dragOrigin = snapshot.beta.internalDrag?.origin, dropPosition = event.position.selection;
|
|
6580
|
-
return dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(dropPosition)({
|
|
6581
|
-
...snapshot,
|
|
6582
|
-
context: {
|
|
6583
|
-
...snapshot.context,
|
|
6584
|
-
selection: dragOrigin.selection
|
|
6585
|
-
}
|
|
6586
|
-
}) : !1;
|
|
6587
|
-
},
|
|
6588
|
-
actions: []
|
|
6589
|
-
}),
|
|
6590
|
-
behaviors_index.defineBehavior({
|
|
6591
|
-
on: "drag.drop",
|
|
6592
|
-
actions: [({
|
|
6593
|
-
event
|
|
6594
|
-
}) => [behaviors_index.raise({
|
|
6595
|
-
type: "select",
|
|
6596
|
-
at: event.position.selection
|
|
6597
|
-
}), behaviors_index.raise({
|
|
6598
|
-
type: "deserialize",
|
|
6599
|
-
originEvent: event
|
|
6600
|
-
})]]
|
|
6601
|
-
}),
|
|
6602
|
-
behaviors_index.defineBehavior({
|
|
6603
|
-
on: "deserialization.success",
|
|
6604
|
-
guard: ({
|
|
6605
|
-
snapshot,
|
|
6606
|
-
event
|
|
6607
|
-
}) => {
|
|
6608
|
-
if (event.originEvent.type !== "drag.drop" || snapshot.beta.internalDrag === void 0)
|
|
6609
|
-
return !1;
|
|
6610
|
-
const dragOrigin = snapshot.beta.internalDrag.origin, dropPosition = event.originEvent.position.selection, droppingOnDragOrigin = dragOrigin ? selector_isSelectingEntireBlocks.isOverlappingSelection(dropPosition)({
|
|
6611
|
-
...snapshot,
|
|
6612
|
-
context: {
|
|
6613
|
-
...snapshot.context,
|
|
6614
|
-
selection: dragOrigin.selection
|
|
6615
|
-
}
|
|
6616
|
-
}) : !1, draggingEntireBlocks = selector_isSelectingEntireBlocks.isSelectingEntireBlocks({
|
|
6617
|
-
context: {
|
|
6618
|
-
...snapshot.context,
|
|
6619
|
-
selection: dragOrigin.selection
|
|
6620
|
-
}
|
|
6621
|
-
}), draggedBlocks = selector_isSelectionExpanded.getSelectedBlocks({
|
|
6622
|
-
context: {
|
|
6623
|
-
...snapshot.context,
|
|
6624
|
-
selection: dragOrigin.selection
|
|
6625
|
-
}
|
|
6626
|
-
});
|
|
6627
|
-
return droppingOnDragOrigin ? !1 : {
|
|
6628
|
-
draggingEntireBlocks,
|
|
6629
|
-
draggedBlocks,
|
|
6630
|
-
dragOrigin,
|
|
6631
|
-
originEvent: event.originEvent
|
|
6632
|
-
};
|
|
6633
|
-
},
|
|
6634
|
-
actions: [({
|
|
6635
|
-
event
|
|
6636
|
-
}, {
|
|
6637
|
-
draggingEntireBlocks,
|
|
6638
|
-
draggedBlocks,
|
|
6639
|
-
dragOrigin,
|
|
6640
|
-
originEvent
|
|
6641
|
-
}) => [...draggingEntireBlocks ? draggedBlocks.map((block) => behaviors_index.raise({
|
|
6642
|
-
type: "delete.block",
|
|
6643
|
-
at: block.path
|
|
6644
|
-
})) : [behaviors_index.raise({
|
|
6645
|
-
type: "delete",
|
|
6646
|
-
at: dragOrigin.selection
|
|
6647
|
-
})], behaviors_index.raise({
|
|
6648
|
-
type: "insert.blocks",
|
|
6649
|
-
blocks: event.data,
|
|
6650
|
-
placement: draggingEntireBlocks ? originEvent.position.block === "start" ? "before" : originEvent.position.block === "end" ? "after" : "auto" : "auto"
|
|
6651
|
-
})]]
|
|
6652
|
-
}),
|
|
6653
6772
|
/**
|
|
6654
6773
|
* If we are pasting text/plain into a text block then we can probably
|
|
6655
6774
|
* assume that the intended behavior is that the pasted text inherits
|
|
@@ -6801,7 +6920,8 @@ function performEvent({
|
|
|
6801
6920
|
keyGenerator,
|
|
6802
6921
|
schema: schema2,
|
|
6803
6922
|
getSnapshot,
|
|
6804
|
-
nativeEvent
|
|
6923
|
+
nativeEvent,
|
|
6924
|
+
sendBack
|
|
6805
6925
|
}) {
|
|
6806
6926
|
debug$9(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
|
|
6807
6927
|
const eventBehaviors = [...remainingEventBehaviors, ...abstractBehaviors].filter((behavior) => {
|
|
@@ -6833,7 +6953,8 @@ function performEvent({
|
|
|
6833
6953
|
try {
|
|
6834
6954
|
shouldRun = eventBehavior.guard === void 0 || eventBehavior.guard({
|
|
6835
6955
|
snapshot: guardSnapshot,
|
|
6836
|
-
event
|
|
6956
|
+
event,
|
|
6957
|
+
dom: createEditorDom(sendBack, editor)
|
|
6837
6958
|
});
|
|
6838
6959
|
} catch (error) {
|
|
6839
6960
|
console.error(new Error(`Evaluating guard for "${event.type}" failed due to: ${error.message}`));
|
|
@@ -6846,7 +6967,8 @@ function performEvent({
|
|
|
6846
6967
|
try {
|
|
6847
6968
|
actions = actionSet({
|
|
6848
6969
|
snapshot: actionsSnapshot,
|
|
6849
|
-
event
|
|
6970
|
+
event,
|
|
6971
|
+
dom: createEditorDom(sendBack, editor)
|
|
6850
6972
|
}, shouldRun);
|
|
6851
6973
|
} catch (error) {
|
|
6852
6974
|
console.error(new Error(`Evaluating actions for "${event.type}" failed due to: ${error.message}`));
|
|
@@ -6875,7 +6997,8 @@ function performEvent({
|
|
|
6875
6997
|
keyGenerator,
|
|
6876
6998
|
schema: schema2,
|
|
6877
6999
|
getSnapshot,
|
|
6878
|
-
nativeEvent
|
|
7000
|
+
nativeEvent,
|
|
7001
|
+
sendBack
|
|
6879
7002
|
});
|
|
6880
7003
|
continue;
|
|
6881
7004
|
}
|
|
@@ -6889,7 +7012,8 @@ function performEvent({
|
|
|
6889
7012
|
keyGenerator,
|
|
6890
7013
|
schema: schema2,
|
|
6891
7014
|
getSnapshot,
|
|
6892
|
-
nativeEvent
|
|
7015
|
+
nativeEvent,
|
|
7016
|
+
sendBack
|
|
6893
7017
|
});
|
|
6894
7018
|
continue;
|
|
6895
7019
|
}
|
|
@@ -6902,7 +7026,8 @@ function performEvent({
|
|
|
6902
7026
|
keyGenerator,
|
|
6903
7027
|
schema: schema2,
|
|
6904
7028
|
getSnapshot,
|
|
6905
|
-
nativeEvent: void 0
|
|
7029
|
+
nativeEvent: void 0,
|
|
7030
|
+
sendBack
|
|
6906
7031
|
});
|
|
6907
7032
|
}
|
|
6908
7033
|
});
|
|
@@ -6929,7 +7054,8 @@ function performEvent({
|
|
|
6929
7054
|
keyGenerator,
|
|
6930
7055
|
schema: schema2,
|
|
6931
7056
|
getSnapshot,
|
|
6932
|
-
nativeEvent
|
|
7057
|
+
nativeEvent,
|
|
7058
|
+
sendBack
|
|
6933
7059
|
});
|
|
6934
7060
|
continue;
|
|
6935
7061
|
}
|
|
@@ -6943,7 +7069,8 @@ function performEvent({
|
|
|
6943
7069
|
keyGenerator,
|
|
6944
7070
|
schema: schema2,
|
|
6945
7071
|
getSnapshot,
|
|
6946
|
-
nativeEvent
|
|
7072
|
+
nativeEvent,
|
|
7073
|
+
sendBack
|
|
6947
7074
|
});
|
|
6948
7075
|
continue;
|
|
6949
7076
|
}
|
|
@@ -7015,8 +7142,7 @@ function createEditorSnapshot({
|
|
|
7015
7142
|
editor,
|
|
7016
7143
|
keyGenerator,
|
|
7017
7144
|
readOnly,
|
|
7018
|
-
schema: schema2
|
|
7019
|
-
internalDrag
|
|
7145
|
+
schema: schema2
|
|
7020
7146
|
}) {
|
|
7021
7147
|
const selection = editor.selection ? slateRangeToSelection({
|
|
7022
7148
|
schema: schema2,
|
|
@@ -7041,8 +7167,7 @@ function createEditorSnapshot({
|
|
|
7041
7167
|
decoratorState: editor.decoratorState,
|
|
7042
7168
|
markState: editor.markState,
|
|
7043
7169
|
schema: schema2
|
|
7044
|
-
})
|
|
7045
|
-
internalDrag
|
|
7170
|
+
})
|
|
7046
7171
|
}
|
|
7047
7172
|
};
|
|
7048
7173
|
}
|
|
@@ -7164,10 +7289,10 @@ const debug$8 = debugWithName("editor machine"), editorMachine = xstate.setup({
|
|
|
7164
7289
|
readOnly: self.getSnapshot().matches({
|
|
7165
7290
|
"edit mode": "read only"
|
|
7166
7291
|
}),
|
|
7167
|
-
schema: context.schema
|
|
7168
|
-
internalDrag: context.internalDrag
|
|
7292
|
+
schema: context.schema
|
|
7169
7293
|
}),
|
|
7170
|
-
nativeEvent: event.nativeEvent
|
|
7294
|
+
nativeEvent: event.nativeEvent,
|
|
7295
|
+
sendBack: (event2) => self.send(event2)
|
|
7171
7296
|
});
|
|
7172
7297
|
} catch (error) {
|
|
7173
7298
|
console.error(new Error(`Raising "${event.behaviorEvent.type}" failed due to: ${error.message}`));
|
|
@@ -7221,6 +7346,13 @@ const debug$8 = debugWithName("editor machine"), editorMachine = xstate.setup({
|
|
|
7221
7346
|
...event,
|
|
7222
7347
|
type: "selection"
|
|
7223
7348
|
}))]
|
|
7349
|
+
},
|
|
7350
|
+
"set drag ghost": {
|
|
7351
|
+
actions: xstate.assign({
|
|
7352
|
+
dragGhost: ({
|
|
7353
|
+
event
|
|
7354
|
+
}) => event.ghost
|
|
7355
|
+
})
|
|
7224
7356
|
}
|
|
7225
7357
|
},
|
|
7226
7358
|
type: "parallel",
|
|
@@ -7315,7 +7447,6 @@ const debug$8 = debugWithName("editor machine"), editorMachine = xstate.setup({
|
|
|
7315
7447
|
internalDrag: ({
|
|
7316
7448
|
event
|
|
7317
7449
|
}) => ({
|
|
7318
|
-
ghost: event.ghost,
|
|
7319
7450
|
origin: event.origin
|
|
7320
7451
|
})
|
|
7321
7452
|
})],
|
|
@@ -7365,13 +7496,15 @@ const debug$8 = debugWithName("editor machine"), editorMachine = xstate.setup({
|
|
|
7365
7496
|
}, ({
|
|
7366
7497
|
context
|
|
7367
7498
|
}) => {
|
|
7368
|
-
if (context.
|
|
7499
|
+
if (context.dragGhost)
|
|
7369
7500
|
try {
|
|
7370
|
-
context.
|
|
7501
|
+
context.dragGhost.parentNode?.removeChild(context.dragGhost);
|
|
7371
7502
|
} catch (error) {
|
|
7372
|
-
console.error(new Error(`Removing the
|
|
7503
|
+
console.error(new Error(`Removing the drag ghost failed due to: ${error.message}`));
|
|
7373
7504
|
}
|
|
7374
7505
|
}, xstate.assign({
|
|
7506
|
+
dragGhost: void 0
|
|
7507
|
+
}), xstate.assign({
|
|
7375
7508
|
internalDrag: void 0
|
|
7376
7509
|
})],
|
|
7377
7510
|
tags: ["dragging internally"],
|
|
@@ -10752,73 +10885,19 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = React.
|
|
|
10752
10885
|
console.warn("Could not find position for dragstart event");
|
|
10753
10886
|
return;
|
|
10754
10887
|
}
|
|
10755
|
-
const snapshot = getEditorSnapshot({
|
|
10756
|
-
editorActorSnapshot: editorActor.getSnapshot(),
|
|
10757
|
-
slateEditorInstance: slateEditor
|
|
10758
|
-
}), dragSelection = getDragSelection({
|
|
10759
|
-
eventSelection: position_4.selection,
|
|
10760
|
-
snapshot
|
|
10761
|
-
}), selectingEntireBlocks = selector_isSelectingEntireBlocks.isSelectingEntireBlocks({
|
|
10762
|
-
context: {
|
|
10763
|
-
...snapshot.context,
|
|
10764
|
-
selection: dragSelection
|
|
10765
|
-
}
|
|
10766
|
-
}), dragGhost = document.createElement("div"), draggedDomNodes = getSelectionDomNodes({
|
|
10767
|
-
snapshot: {
|
|
10768
|
-
context: {
|
|
10769
|
-
...snapshot.context,
|
|
10770
|
-
selection: dragSelection
|
|
10771
|
-
}
|
|
10772
|
-
},
|
|
10773
|
-
slateEditor
|
|
10774
|
-
});
|
|
10775
|
-
if (selectingEntireBlocks) {
|
|
10776
|
-
const clonedBlockNodes = draggedDomNodes.blockNodes.map((node) => node.cloneNode(!0));
|
|
10777
|
-
for (const block of clonedBlockNodes)
|
|
10778
|
-
block instanceof HTMLElement && (block.style.position = "relative"), dragGhost.appendChild(block);
|
|
10779
|
-
const customGhost = dragGhost.querySelector("[data-pt-drag-ghost-element]");
|
|
10780
|
-
if (customGhost && dragGhost.replaceChildren(customGhost), dragGhost.setAttribute("data-dragged", ""), dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost), customGhost) {
|
|
10781
|
-
const customGhostRect = customGhost.getBoundingClientRect(), x = event_8.clientX - customGhostRect.left, y = event_8.clientY - customGhostRect.top;
|
|
10782
|
-
dragGhost.style.width = `${customGhostRect.width}px`, dragGhost.style.height = `${customGhostRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x, y);
|
|
10783
|
-
} else {
|
|
10784
|
-
const blocksDomRect = getCompoundClientRect(draggedDomNodes.blockNodes), x_0 = event_8.clientX - blocksDomRect.left, y_0 = event_8.clientY - blocksDomRect.top;
|
|
10785
|
-
dragGhost.style.width = `${blocksDomRect.width}px`, dragGhost.style.height = `${blocksDomRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x_0, y_0);
|
|
10786
|
-
}
|
|
10787
|
-
} else {
|
|
10788
|
-
const clonedChildNodes = draggedDomNodes.childNodes.map((node_0) => node_0.cloneNode(!0));
|
|
10789
|
-
for (const child of clonedChildNodes)
|
|
10790
|
-
dragGhost.appendChild(child);
|
|
10791
|
-
dragGhost.style.position = "absolute", dragGhost.style.left = "-99999px", dragGhost.style.boxSizing = "border-box", document.body.appendChild(dragGhost);
|
|
10792
|
-
const childrenDomRect = getCompoundClientRect(draggedDomNodes.childNodes), x_1 = event_8.clientX - childrenDomRect.left, y_1 = event_8.clientY - childrenDomRect.top;
|
|
10793
|
-
dragGhost.style.width = `${childrenDomRect.width}px`, dragGhost.style.height = `${childrenDomRect.height}px`, event_8.dataTransfer.setDragImage(dragGhost, x_1, y_1);
|
|
10794
|
-
}
|
|
10795
10888
|
return editorActor.send({
|
|
10796
|
-
type: "behavior event",
|
|
10797
|
-
behaviorEvent: {
|
|
10798
|
-
type: "select",
|
|
10799
|
-
at: util_selectionPointToBlockOffset.isSelectionCollapsed(dragSelection) ? dragSelection : {
|
|
10800
|
-
anchor: selectionPoint.getSelectionEndPoint(dragSelection),
|
|
10801
|
-
focus: selectionPoint.getSelectionEndPoint(dragSelection),
|
|
10802
|
-
backward: !1
|
|
10803
|
-
}
|
|
10804
|
-
},
|
|
10805
|
-
editor: slateEditor
|
|
10806
|
-
}), editorActor.send({
|
|
10807
10889
|
type: "dragstart",
|
|
10808
|
-
origin:
|
|
10809
|
-
selection: dragSelection
|
|
10810
|
-
},
|
|
10811
|
-
ghost: dragGhost
|
|
10890
|
+
origin: position_4
|
|
10812
10891
|
}), editorActor.send({
|
|
10813
10892
|
type: "behavior event",
|
|
10814
10893
|
behaviorEvent: {
|
|
10815
10894
|
type: "drag.dragstart",
|
|
10816
10895
|
originEvent: {
|
|
10896
|
+
clientX: event_8.clientX,
|
|
10897
|
+
clientY: event_8.clientY,
|
|
10817
10898
|
dataTransfer: event_8.dataTransfer
|
|
10818
10899
|
},
|
|
10819
|
-
position:
|
|
10820
|
-
selection: dragSelection
|
|
10821
|
-
}
|
|
10900
|
+
position: position_4
|
|
10822
10901
|
},
|
|
10823
10902
|
editor: slateEditor
|
|
10824
10903
|
}), !0;
|
|
@@ -10886,6 +10965,7 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = React.
|
|
|
10886
10965
|
originEvent: {
|
|
10887
10966
|
dataTransfer: event_12.dataTransfer
|
|
10888
10967
|
},
|
|
10968
|
+
dragOrigin: editorActor.getSnapshot().context.internalDrag?.origin,
|
|
10889
10969
|
position: position_7
|
|
10890
10970
|
},
|
|
10891
10971
|
editor: slateEditor,
|
|
@@ -10910,6 +10990,7 @@ const debug = debugWithName("component:Editable"), PortableTextEditable = React.
|
|
|
10910
10990
|
originEvent: {
|
|
10911
10991
|
dataTransfer: event_13.dataTransfer
|
|
10912
10992
|
},
|
|
10993
|
+
dragOrigin: editorActor.getSnapshot().context.internalDrag?.origin,
|
|
10913
10994
|
position: position_8
|
|
10914
10995
|
},
|
|
10915
10996
|
editor: slateEditor,
|