@portabletext/editor 1.47.10 → 1.47.12
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/behavior.core.cjs +61 -3
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +167 -105
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/util.get-selection-start-point.cjs +10 -0
- package/lib/_chunks-cjs/util.get-selection-start-point.cjs.map +1 -0
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs +0 -4
- package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +63 -4
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +168 -105
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/util.get-selection-start-point.js +11 -0
- package/lib/_chunks-es/util.get-selection-start-point.js.map +1 -0
- package/lib/_chunks-es/util.is-selection-collapsed.js +0 -4
- package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -1
- package/lib/behaviors/index.d.cts +359 -339
- package/lib/behaviors/index.d.ts +359 -339
- package/lib/behaviors/index.js +1 -1
- package/lib/index.cjs +3 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +4 -4
- package/lib/index.d.ts +4 -4
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +0 -9
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +4 -4
- package/lib/plugins/index.d.ts +4 -4
- package/lib/plugins/index.js +0 -9
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +4 -4
- package/lib/selectors/index.d.ts +4 -4
- package/lib/utils/index.cjs +3 -6
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +4 -4
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/index.js +2 -4
- package/lib/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/src/behavior-actions/behavior.action.insert.block.ts +136 -45
- package/src/behavior-actions/behavior.actions.ts +0 -9
- package/src/behaviors/behavior.abstract.insert.ts +2 -2
- package/src/behaviors/behavior.abstract.split.ts +118 -0
- package/src/behaviors/behavior.core.insert-break.ts +113 -0
- package/src/behaviors/behavior.core.ts +2 -0
- package/src/behaviors/behavior.default.ts +2 -0
- package/src/behaviors/behavior.types.event.ts +4 -4
- package/src/internal-utils/slate-utils.ts +50 -1
- package/src/plugins/plugin.one-line.tsx +0 -7
- package/src/behavior-actions/behavior.action.split.block.ts +0 -146
|
@@ -27,7 +27,8 @@ import { getTrimmedSelection, isActiveAnnotation, isActiveDecorator, getSelected
|
|
|
27
27
|
import { DOMEditor } from "slate-dom";
|
|
28
28
|
import startCase from "lodash.startcase";
|
|
29
29
|
import { defineBehavior, raise, coreBehaviors } from "./behavior.core.js";
|
|
30
|
-
import { getFocusTextBlock, getPreviousBlock, getNextBlock, getFocusSpan, isSelectionCollapsed, isOverlappingSelection, getSelectedBlocks, isSelectionExpanded } from "./selector.is-overlapping-selection.js";
|
|
30
|
+
import { getFocusTextBlock, getPreviousBlock, getNextBlock, getFocusBlockObject, getFocusSpan, isSelectionCollapsed, isOverlappingSelection, getSelectedBlocks, isSelectionExpanded } from "./selector.is-overlapping-selection.js";
|
|
31
|
+
import { getSelectionStartPoint, getSelectionEndPoint } from "./util.get-selection-start-point.js";
|
|
31
32
|
import { Subject } from "rxjs";
|
|
32
33
|
import { useEffectEvent } from "use-effect-event";
|
|
33
34
|
const rootName = "sanity-pte:";
|
|
@@ -3429,13 +3430,35 @@ function getFocusBlock({
|
|
|
3429
3430
|
return [void 0, void 0];
|
|
3430
3431
|
}
|
|
3431
3432
|
}
|
|
3433
|
+
function getSelectionStartBlock({
|
|
3434
|
+
editor
|
|
3435
|
+
}) {
|
|
3436
|
+
if (!editor.selection)
|
|
3437
|
+
return [void 0, void 0];
|
|
3438
|
+
const selectionStartPoint = Range.start(editor.selection);
|
|
3439
|
+
return getPointBlock({
|
|
3440
|
+
editor,
|
|
3441
|
+
point: selectionStartPoint
|
|
3442
|
+
});
|
|
3443
|
+
}
|
|
3444
|
+
function getSelectionEndBlock({
|
|
3445
|
+
editor
|
|
3446
|
+
}) {
|
|
3447
|
+
if (!editor.selection)
|
|
3448
|
+
return [void 0, void 0];
|
|
3449
|
+
const selectionEndPoint = Range.end(editor.selection);
|
|
3450
|
+
return getPointBlock({
|
|
3451
|
+
editor,
|
|
3452
|
+
point: selectionEndPoint
|
|
3453
|
+
});
|
|
3454
|
+
}
|
|
3432
3455
|
function getPointBlock({
|
|
3433
3456
|
editor,
|
|
3434
3457
|
point
|
|
3435
3458
|
}) {
|
|
3436
3459
|
try {
|
|
3437
3460
|
const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
|
|
3438
|
-
return block ? [block, point.path] : [void 0, void 0];
|
|
3461
|
+
return block ? [block, point.path.slice(0, 1)] : [void 0, void 0];
|
|
3439
3462
|
} catch {
|
|
3440
3463
|
return [void 0, void 0];
|
|
3441
3464
|
}
|
|
@@ -3849,10 +3872,12 @@ function insertBlock({
|
|
|
3849
3872
|
editor,
|
|
3850
3873
|
schema
|
|
3851
3874
|
}) {
|
|
3852
|
-
const [
|
|
3875
|
+
const [startBlock, startBlockPath] = getSelectionStartBlock({
|
|
3876
|
+
editor
|
|
3877
|
+
}), [endBlock, endBlockPath] = getSelectionEndBlock({
|
|
3853
3878
|
editor
|
|
3854
3879
|
});
|
|
3855
|
-
if (!editor.selection || !
|
|
3880
|
+
if (!editor.selection || !startBlock || !startBlockPath || !endBlock || !endBlockPath) {
|
|
3856
3881
|
select !== "none" && DOMEditor.focus(editor);
|
|
3857
3882
|
const [lastBlock, lastBlockPath] = getLastBlock({
|
|
3858
3883
|
editor
|
|
@@ -3891,26 +3916,41 @@ function insertBlock({
|
|
|
3891
3916
|
}), select === "start" ? Transforms.select(editor, Editor.start(editor, nextPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, nextPath));
|
|
3892
3917
|
}
|
|
3893
3918
|
} else if (placement === "before") {
|
|
3894
|
-
const currentSelection = editor.selection;
|
|
3919
|
+
const currentSelection = editor.selection, selectionStartPoint = Range.start(currentSelection);
|
|
3895
3920
|
Transforms.insertNodes(editor, [block], {
|
|
3896
|
-
at:
|
|
3921
|
+
at: [selectionStartPoint.path[0]],
|
|
3897
3922
|
select: !1
|
|
3898
|
-
});
|
|
3899
|
-
const adjustedSelection = Range.transform(currentSelection, {
|
|
3900
|
-
type: "move_node",
|
|
3901
|
-
path: focusBlockPath,
|
|
3902
|
-
newPath: [focusBlockPath[0] + 1]
|
|
3903
|
-
});
|
|
3904
|
-
adjustedSelection ? Transforms.select(editor, adjustedSelection) : Transforms.select(editor, currentSelection), select === "start" ? Transforms.select(editor, Editor.start(editor, focusBlockPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, focusBlockPath));
|
|
3923
|
+
}), select === "start" ? Transforms.select(editor, Editor.start(editor, [selectionStartPoint.path[0]])) : select === "end" && Transforms.select(editor, Editor.end(editor, [selectionStartPoint.path[0]]));
|
|
3905
3924
|
} else if (placement === "after") {
|
|
3906
|
-
const nextPath = [
|
|
3925
|
+
const currentSelection = editor.selection, nextPath = [Range.end(currentSelection).path[0] + 1];
|
|
3907
3926
|
Transforms.insertNodes(editor, [block], {
|
|
3908
3927
|
at: nextPath,
|
|
3909
3928
|
select: !1
|
|
3910
|
-
}),
|
|
3929
|
+
}), select === "start" ? Transforms.select(editor, Editor.start(editor, nextPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, nextPath));
|
|
3911
3930
|
} else {
|
|
3912
|
-
const currentSelection = editor.selection,
|
|
3913
|
-
if (
|
|
3931
|
+
const currentSelection = editor.selection, endBlockEndPoint = Editor.start(editor, endBlockPath);
|
|
3932
|
+
if (Range.isExpanded(currentSelection) && !editor.isTextBlock(block)) {
|
|
3933
|
+
Transforms.delete(editor, {
|
|
3934
|
+
at: currentSelection
|
|
3935
|
+
});
|
|
3936
|
+
const newSelection = editor.selection, [focusBlock, focusBlockPath] = getFocusBlock({
|
|
3937
|
+
editor
|
|
3938
|
+
});
|
|
3939
|
+
Transforms.insertNodes(editor, [block], {
|
|
3940
|
+
voids: !0
|
|
3941
|
+
});
|
|
3942
|
+
const adjustedSelection = newSelection.anchor.offset === 0 ? Range.transform(newSelection, {
|
|
3943
|
+
type: "insert_node",
|
|
3944
|
+
node: block,
|
|
3945
|
+
path: [newSelection.anchor.path[0]]
|
|
3946
|
+
}) : newSelection;
|
|
3947
|
+
select === "none" && adjustedSelection && Transforms.select(editor, adjustedSelection), focusBlock && isEqualToEmptyEditor([focusBlock], schema) && Transforms.removeNodes(editor, {
|
|
3948
|
+
at: focusBlockPath
|
|
3949
|
+
});
|
|
3950
|
+
return;
|
|
3951
|
+
}
|
|
3952
|
+
if (editor.isTextBlock(endBlock) && editor.isTextBlock(block)) {
|
|
3953
|
+
const selectionStartPoint = Range.start(currentSelection);
|
|
3914
3954
|
if (select === "end") {
|
|
3915
3955
|
Transforms.insertFragment(editor, [block], {
|
|
3916
3956
|
voids: !0
|
|
@@ -3920,32 +3960,44 @@ function insertBlock({
|
|
|
3920
3960
|
Transforms.insertFragment(editor, [block], {
|
|
3921
3961
|
at: currentSelection,
|
|
3922
3962
|
voids: !0
|
|
3923
|
-
}), select === "start" ?
|
|
3924
|
-
} else if (editor.isTextBlock(
|
|
3925
|
-
const
|
|
3926
|
-
if (Point.equals(
|
|
3963
|
+
}), select === "start" ? Transforms.select(editor, selectionStartPoint) : Point.equals(selectionStartPoint, endBlockEndPoint) || Transforms.select(editor, selectionStartPoint);
|
|
3964
|
+
} else if (editor.isTextBlock(endBlock)) {
|
|
3965
|
+
const endBlockStartPoint = Editor.start(editor, endBlockPath), endBlockEndPoint2 = Editor.end(editor, endBlockPath), selectionStartPoint = Range.start(currentSelection), selectionEndPoint = Range.end(currentSelection);
|
|
3966
|
+
if (Range.isCollapsed(currentSelection) && Point.equals(selectionStartPoint, endBlockStartPoint))
|
|
3927
3967
|
Transforms.insertNodes(editor, [block], {
|
|
3928
|
-
at:
|
|
3968
|
+
at: endBlockPath,
|
|
3929
3969
|
select: !1
|
|
3930
|
-
}), (select === "start" || select === "end") && Transforms.select(editor, Editor.start(editor,
|
|
3931
|
-
at: Path.next(
|
|
3970
|
+
}), (select === "start" || select === "end") && Transforms.select(editor, Editor.start(editor, endBlockPath)), isEqualToEmptyEditor([endBlock], schema) && Transforms.removeNodes(editor, {
|
|
3971
|
+
at: Path.next(endBlockPath)
|
|
3932
3972
|
});
|
|
3933
|
-
else if (Point.equals(
|
|
3934
|
-
const nextPath = [
|
|
3973
|
+
else if (Range.isCollapsed(currentSelection) && Point.equals(selectionEndPoint, endBlockEndPoint2)) {
|
|
3974
|
+
const nextPath = [endBlockPath[0] + 1];
|
|
3935
3975
|
Transforms.insertNodes(editor, [block], {
|
|
3936
3976
|
at: nextPath,
|
|
3937
3977
|
select: !1
|
|
3938
3978
|
}), (select === "start" || select === "end") && Transforms.select(editor, Editor.start(editor, nextPath));
|
|
3939
|
-
} else
|
|
3979
|
+
} else if (Range.isExpanded(currentSelection) && Point.equals(selectionStartPoint, endBlockStartPoint) && Point.equals(selectionEndPoint, endBlockEndPoint2))
|
|
3980
|
+
Transforms.insertFragment(editor, [block], {
|
|
3981
|
+
at: currentSelection
|
|
3982
|
+
}), select === "start" ? Transforms.select(editor, Editor.start(editor, endBlockPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, endBlockPath));
|
|
3983
|
+
else if (Range.isExpanded(currentSelection) && Point.equals(selectionStartPoint, endBlockStartPoint))
|
|
3984
|
+
Transforms.insertFragment(editor, [block], {
|
|
3985
|
+
at: currentSelection
|
|
3986
|
+
}), select === "start" ? Transforms.select(editor, Editor.start(editor, endBlockPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, endBlockPath));
|
|
3987
|
+
else if (Range.isExpanded(currentSelection) && Point.equals(selectionEndPoint, endBlockEndPoint2))
|
|
3988
|
+
Transforms.insertFragment(editor, [block], {
|
|
3989
|
+
at: currentSelection
|
|
3990
|
+
}), select === "start" ? Transforms.select(editor, Editor.start(editor, Path.next(endBlockPath))) : select === "end" && Transforms.select(editor, Editor.end(editor, Path.next(endBlockPath)));
|
|
3991
|
+
else {
|
|
3940
3992
|
const currentSelection2 = editor.selection, [focusChild] = getFocusChild({
|
|
3941
3993
|
editor
|
|
3942
3994
|
});
|
|
3943
3995
|
if (focusChild && editor.isTextSpan(focusChild))
|
|
3944
3996
|
Transforms.insertFragment(editor, [block], {
|
|
3945
3997
|
at: currentSelection2
|
|
3946
|
-
}), select === "start" || select === "end" ? Transforms.select(editor, [
|
|
3998
|
+
}), select === "start" || select === "end" ? Transforms.select(editor, [endBlockPath[0] + 1]) : Transforms.select(editor, currentSelection2);
|
|
3947
3999
|
else {
|
|
3948
|
-
const nextPath = [
|
|
4000
|
+
const nextPath = [endBlockPath[0] + 1];
|
|
3949
4001
|
Transforms.insertNodes(editor, [block], {
|
|
3950
4002
|
at: nextPath,
|
|
3951
4003
|
select: !1
|
|
@@ -3956,7 +4008,7 @@ function insertBlock({
|
|
|
3956
4008
|
Transforms.insertNodes(editor, [block], {
|
|
3957
4009
|
select: !1
|
|
3958
4010
|
});
|
|
3959
|
-
const nextPath = [
|
|
4011
|
+
const nextPath = [endBlockPath[0] + 1];
|
|
3960
4012
|
select === "start" ? Transforms.select(editor, Editor.start(editor, nextPath)) : select === "end" && Transforms.select(editor, Editor.end(editor, nextPath));
|
|
3961
4013
|
}
|
|
3962
4014
|
}
|
|
@@ -3991,69 +4043,6 @@ const moveBackwardActionImplementation = ({
|
|
|
3991
4043
|
}) => {
|
|
3992
4044
|
const newSelection = toSlateRange(action.at, action.editor);
|
|
3993
4045
|
newSelection ? Transforms.select(action.editor, newSelection) : Transforms.deselect(action.editor);
|
|
3994
|
-
}, splitBlockActionImplementation = ({
|
|
3995
|
-
context,
|
|
3996
|
-
action
|
|
3997
|
-
}) => {
|
|
3998
|
-
const keyGenerator = context.keyGenerator, schema = context.schema, editor = action.editor;
|
|
3999
|
-
if (!editor.selection)
|
|
4000
|
-
return;
|
|
4001
|
-
const anchorBlockPath = editor.selection.anchor.path.slice(0, 1), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = Node.descendant(editor, focusBlockPath);
|
|
4002
|
-
if (editor.isTextBlock(focusBlock) && anchorBlockPath[0] === focusBlockPath[0]) {
|
|
4003
|
-
Transforms.splitNodes(editor, {
|
|
4004
|
-
at: editor.selection,
|
|
4005
|
-
always: !0
|
|
4006
|
-
});
|
|
4007
|
-
const [nextBlock, nextBlockPath] = Editor.node(editor, Path.next(focusBlockPath), {
|
|
4008
|
-
depth: 1
|
|
4009
|
-
}), nextChild = Node.child(nextBlock, 0);
|
|
4010
|
-
if (!editor.isTextSpan(nextChild) && Transforms.insertNodes(editor, {
|
|
4011
|
-
_key: context.keyGenerator(),
|
|
4012
|
-
_type: "span",
|
|
4013
|
-
text: "",
|
|
4014
|
-
marks: []
|
|
4015
|
-
}, {
|
|
4016
|
-
at: [nextBlockPath[0], 0]
|
|
4017
|
-
}), Transforms.setSelection(editor, {
|
|
4018
|
-
anchor: {
|
|
4019
|
-
path: [...nextBlockPath, 0],
|
|
4020
|
-
offset: 0
|
|
4021
|
-
},
|
|
4022
|
-
focus: {
|
|
4023
|
-
path: [...nextBlockPath, 0],
|
|
4024
|
-
offset: 0
|
|
4025
|
-
}
|
|
4026
|
-
}), editor.isTextBlock(nextBlock) && nextBlock.markDefs && nextBlock.markDefs.length > 0) {
|
|
4027
|
-
const newMarkDefKeys = /* @__PURE__ */ new Map(), prevNodeSpans = Array.from(Node.children(editor, focusBlockPath)).map((entry) => entry[0]).filter((node) => editor.isTextSpan(node)), children = Node.children(editor, nextBlockPath);
|
|
4028
|
-
for (const [child, childPath] of children) {
|
|
4029
|
-
if (!editor.isTextSpan(child))
|
|
4030
|
-
continue;
|
|
4031
|
-
const marks = child.marks ?? [];
|
|
4032
|
-
for (const mark of marks)
|
|
4033
|
-
schema.decorators.some((decorator) => decorator.name === mark) || prevNodeSpans.some((prevNodeSpan) => prevNodeSpan.marks?.includes(mark)) && !newMarkDefKeys.has(mark) && newMarkDefKeys.set(mark, keyGenerator());
|
|
4034
|
-
const newMarks = marks.map((mark) => newMarkDefKeys.get(mark) ?? mark);
|
|
4035
|
-
isEqual(marks, newMarks) || Transforms.setNodes(editor, {
|
|
4036
|
-
marks: newMarks
|
|
4037
|
-
}, {
|
|
4038
|
-
at: childPath
|
|
4039
|
-
});
|
|
4040
|
-
}
|
|
4041
|
-
const newMarkDefs = nextBlock.markDefs.map((markDef) => ({
|
|
4042
|
-
...markDef,
|
|
4043
|
-
_key: newMarkDefKeys.get(markDef._key) ?? markDef._key
|
|
4044
|
-
}));
|
|
4045
|
-
isEqual(nextBlock.markDefs, newMarkDefs) || Transforms.setNodes(editor, {
|
|
4046
|
-
markDefs: newMarkDefs
|
|
4047
|
-
}, {
|
|
4048
|
-
at: nextBlockPath,
|
|
4049
|
-
match: (node) => editor.isTextBlock(node)
|
|
4050
|
-
});
|
|
4051
|
-
}
|
|
4052
|
-
return;
|
|
4053
|
-
}
|
|
4054
|
-
Transforms.splitNodes(editor, {
|
|
4055
|
-
always: !0
|
|
4056
|
-
});
|
|
4057
4046
|
}, debug$a = debugWithName("behaviors:action"), behaviorActionImplementations = {
|
|
4058
4047
|
"annotation.add": addAnnotationActionImplementation,
|
|
4059
4048
|
"annotation.remove": removeAnnotationActionImplementation,
|
|
@@ -4076,8 +4065,7 @@ const moveBackwardActionImplementation = ({
|
|
|
4076
4065
|
"move.block": moveBlockActionImplementation,
|
|
4077
4066
|
"move.forward": moveForwardActionImplementation,
|
|
4078
4067
|
noop: noopActionImplementation,
|
|
4079
|
-
select: selectActionImplementation
|
|
4080
|
-
"split.block": splitBlockActionImplementation
|
|
4068
|
+
select: selectActionImplementation
|
|
4081
4069
|
};
|
|
4082
4070
|
function performAction({
|
|
4083
4071
|
context,
|
|
@@ -4226,13 +4214,6 @@ function performAction({
|
|
|
4226
4214
|
}
|
|
4227
4215
|
case "noop":
|
|
4228
4216
|
break;
|
|
4229
|
-
case "split.block": {
|
|
4230
|
-
behaviorActionImplementations["split.block"]({
|
|
4231
|
-
context,
|
|
4232
|
-
action
|
|
4233
|
-
});
|
|
4234
|
-
break;
|
|
4235
|
-
}
|
|
4236
4217
|
default: {
|
|
4237
4218
|
behaviorActionImplementations.select({
|
|
4238
4219
|
context,
|
|
@@ -5964,7 +5945,7 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
5964
5945
|
placement: index === 0 ? "auto" : "after",
|
|
5965
5946
|
select: "end"
|
|
5966
5947
|
})) : event.blocks.flatMap((block, index) => index === 0 ? [raise({
|
|
5967
|
-
type: "split
|
|
5948
|
+
type: "split"
|
|
5968
5949
|
}), raise({
|
|
5969
5950
|
type: "select.previous block",
|
|
5970
5951
|
select: "end"
|
|
@@ -6003,7 +5984,7 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
6003
5984
|
}), defineBehavior({
|
|
6004
5985
|
on: "insert.break",
|
|
6005
5986
|
actions: [() => [raise({
|
|
6006
|
-
type: "split
|
|
5987
|
+
type: "split"
|
|
6007
5988
|
})]]
|
|
6008
5989
|
}), defineBehavior({
|
|
6009
5990
|
on: "insert.soft break",
|
|
@@ -6183,6 +6164,87 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
6183
6164
|
type: "select",
|
|
6184
6165
|
at: selection
|
|
6185
6166
|
})]]
|
|
6167
|
+
})], abstractSplitBehaviors = [defineBehavior({
|
|
6168
|
+
on: "split",
|
|
6169
|
+
guard: ({
|
|
6170
|
+
snapshot
|
|
6171
|
+
}) => {
|
|
6172
|
+
if (!snapshot.context.selection)
|
|
6173
|
+
return !1;
|
|
6174
|
+
const selectionStartPoint = getSelectionStartPoint(snapshot.context.selection), selectionEndPoint = getSelectionEndPoint(snapshot.context.selection), focusTextBlock = getFocusTextBlock({
|
|
6175
|
+
context: {
|
|
6176
|
+
...snapshot.context,
|
|
6177
|
+
selection: {
|
|
6178
|
+
anchor: selectionStartPoint,
|
|
6179
|
+
focus: selectionEndPoint
|
|
6180
|
+
}
|
|
6181
|
+
}
|
|
6182
|
+
});
|
|
6183
|
+
if (focusTextBlock) {
|
|
6184
|
+
const blockEndPoint = getBlockEndPoint(focusTextBlock), newTextBlockSelection = {
|
|
6185
|
+
anchor: selectionEndPoint,
|
|
6186
|
+
focus: blockEndPoint
|
|
6187
|
+
}, newTextBlock = parseBlock({
|
|
6188
|
+
block: sliceBlocks({
|
|
6189
|
+
blocks: [focusTextBlock.node],
|
|
6190
|
+
selection: newTextBlockSelection
|
|
6191
|
+
}).at(0),
|
|
6192
|
+
context: snapshot.context,
|
|
6193
|
+
options: {
|
|
6194
|
+
refreshKeys: !0
|
|
6195
|
+
}
|
|
6196
|
+
});
|
|
6197
|
+
return !newTextBlock || !isTextBlock(snapshot.context.schema, newTextBlock) ? !1 : {
|
|
6198
|
+
newTextBlock,
|
|
6199
|
+
newTextBlockSelection,
|
|
6200
|
+
selection: {
|
|
6201
|
+
anchor: selectionStartPoint,
|
|
6202
|
+
focus: blockEndPoint
|
|
6203
|
+
}
|
|
6204
|
+
};
|
|
6205
|
+
}
|
|
6206
|
+
if (getFocusBlockObject({
|
|
6207
|
+
context: {
|
|
6208
|
+
...snapshot.context,
|
|
6209
|
+
selection: {
|
|
6210
|
+
anchor: selectionStartPoint,
|
|
6211
|
+
focus: selectionEndPoint
|
|
6212
|
+
}
|
|
6213
|
+
}
|
|
6214
|
+
})) {
|
|
6215
|
+
const newTextBlock = parseBlock({
|
|
6216
|
+
block: {
|
|
6217
|
+
_type: snapshot.context.schema.block.name,
|
|
6218
|
+
children: []
|
|
6219
|
+
},
|
|
6220
|
+
context: snapshot.context,
|
|
6221
|
+
options: {
|
|
6222
|
+
refreshKeys: !0
|
|
6223
|
+
}
|
|
6224
|
+
});
|
|
6225
|
+
return newTextBlock ? {
|
|
6226
|
+
newTextBlock,
|
|
6227
|
+
newTextBlockSelection: {
|
|
6228
|
+
anchor: selectionEndPoint,
|
|
6229
|
+
focus: selectionEndPoint
|
|
6230
|
+
},
|
|
6231
|
+
selection: snapshot.context.selection
|
|
6232
|
+
} : !1;
|
|
6233
|
+
}
|
|
6234
|
+
return !1;
|
|
6235
|
+
},
|
|
6236
|
+
actions: [(_, {
|
|
6237
|
+
newTextBlock,
|
|
6238
|
+
selection
|
|
6239
|
+
}) => [raise({
|
|
6240
|
+
type: "delete",
|
|
6241
|
+
at: selection
|
|
6242
|
+
}), raise({
|
|
6243
|
+
type: "insert.block",
|
|
6244
|
+
block: newTextBlock,
|
|
6245
|
+
placement: "after",
|
|
6246
|
+
select: "start"
|
|
6247
|
+
})]]
|
|
6186
6248
|
})], abstractStyleBehaviors = [defineBehavior({
|
|
6187
6249
|
on: "style.add",
|
|
6188
6250
|
guard: ({
|
|
@@ -6594,10 +6656,11 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
6594
6656
|
...abstractMoveBehaviors,
|
|
6595
6657
|
...abstractStyleBehaviors,
|
|
6596
6658
|
...abstractSelectBehaviors,
|
|
6659
|
+
...abstractSplitBehaviors,
|
|
6597
6660
|
raiseDeserializationSuccessOrFailure,
|
|
6598
6661
|
raiseSerializationSuccessOrFailure,
|
|
6599
6662
|
raiseInsertSoftBreak
|
|
6600
|
-
], abstractBehaviorEventTypes = ["annotation.toggle", "decorator.toggle", "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", "style.add", "style.remove", "style.toggle"];
|
|
6663
|
+
], abstractBehaviorEventTypes = ["annotation.toggle", "decorator.toggle", "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"];
|
|
6601
6664
|
function isAbstractBehaviorEvent(event) {
|
|
6602
6665
|
return abstractBehaviorEventTypes.includes(event.type);
|
|
6603
6666
|
}
|