@portabletext/editor 2.17.0 → 2.17.2
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/selector.get-selection-text.cjs +1 -1
- package/lib/_chunks-cjs/selector.get-selection-text.cjs.map +1 -1
- package/lib/_chunks-cjs/util.get-text-block-text.cjs +2 -6
- package/lib/_chunks-cjs/util.get-text-block-text.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +12 -12
- package/lib/_chunks-dts/behavior.types.action.d.ts +2 -2
- package/lib/_chunks-es/selector.get-selection-text.js +1 -1
- package/lib/_chunks-es/selector.get-selection-text.js.map +1 -1
- package/lib/_chunks-es/util.get-text-block-text.js +1 -2
- package/lib/_chunks-es/util.get-text-block-text.js.map +1 -1
- package/lib/index.cjs +485 -511
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +488 -514
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/package.json +9 -10
- package/src/behaviors/behavior.abstract.delete.ts +12 -16
- package/src/behaviors/behavior.abstract.insert.ts +37 -6
- package/src/behaviors/behavior.abstract.split.ts +24 -89
- package/src/behaviors/behavior.core.lists.ts +9 -3
- package/src/behaviors/behavior.types.event.ts +1 -1
- package/src/editor/plugins/create-with-event-listeners.ts +30 -31
- package/src/operations/behavior.operation.delete.ts +76 -80
- package/src/selectors/selector.is-selection-expanded.test.ts +63 -0
- package/src/selectors/selector.is-selection-expanded.ts +1 -1
- package/src/utils/key-generator.ts +1 -3
package/lib/index.cjs
CHANGED
|
@@ -4599,24 +4599,21 @@ const addAnnotationOperationImplementation = ({
|
|
|
4599
4599
|
context,
|
|
4600
4600
|
operation
|
|
4601
4601
|
}) => {
|
|
4602
|
-
const
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
if (endBlockIndex === void 0)
|
|
4615
|
-
throw new Error("Failed to get end block index");
|
|
4616
|
-
const endBlock = operation.editor.value.at(endBlockIndex);
|
|
4617
|
-
if (!endBlock)
|
|
4618
|
-
throw new Error("Failed to get end block");
|
|
4602
|
+
const at = operation.at ? toSlateRange({
|
|
4603
|
+
context: {
|
|
4604
|
+
schema: context.schema,
|
|
4605
|
+
value: operation.editor.value,
|
|
4606
|
+
selection: operation.at
|
|
4607
|
+
},
|
|
4608
|
+
blockIndexMap: operation.editor.blockIndexMap
|
|
4609
|
+
}) : void 0, selection = operation.editor.selection ? slateRangeToSelection({
|
|
4610
|
+
schema: context.schema,
|
|
4611
|
+
editor: operation.editor,
|
|
4612
|
+
range: operation.editor.selection
|
|
4613
|
+
}) : void 0, reverse = operation.direction === "backward", anchorPoint = operation.at?.anchor ?? selection?.anchor, focusPoint = operation.at?.focus ?? selection?.focus, startPoint = reverse ? focusPoint : anchorPoint, endPoint = reverse ? anchorPoint : focusPoint, startBlockKey = startPoint ? util_getTextBlockText.getBlockKeyFromSelectionPoint(startPoint) : void 0, endBlockKey = endPoint ? util_getTextBlockText.getBlockKeyFromSelectionPoint(endPoint) : void 0, startBlockIndex = startBlockKey ? operation.editor.blockIndexMap.get(startBlockKey) : void 0, endBlockIndex = endBlockKey ? operation.editor.blockIndexMap.get(endBlockKey) : void 0, startBlock = startBlockIndex ? operation.editor.value.at(startBlockIndex) : void 0, endBlock = endBlockIndex ? operation.editor.value.at(endBlockIndex) : void 0;
|
|
4619
4614
|
if (operation.unit === "block") {
|
|
4615
|
+
if (startBlockIndex === void 0 || endBlockIndex === void 0)
|
|
4616
|
+
throw new Error("Failed to get start or end block index");
|
|
4620
4617
|
slate.Transforms.removeNodes(operation.editor, {
|
|
4621
4618
|
at: {
|
|
4622
4619
|
anchor: {
|
|
@@ -4632,17 +4629,10 @@ const addAnnotationOperationImplementation = ({
|
|
|
4632
4629
|
}), operation.editor.children.length === 0 && slate.Transforms.insertNodes(operation.editor, createPlaceholderBlock(context));
|
|
4633
4630
|
return;
|
|
4634
4631
|
}
|
|
4635
|
-
const range = toSlateRange({
|
|
4636
|
-
context: {
|
|
4637
|
-
schema: context.schema,
|
|
4638
|
-
value: operation.editor.value,
|
|
4639
|
-
selection: operation.at
|
|
4640
|
-
},
|
|
4641
|
-
blockIndexMap: operation.editor.blockIndexMap
|
|
4642
|
-
});
|
|
4643
|
-
if (!range)
|
|
4644
|
-
throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(operation.at)}`);
|
|
4645
4632
|
if (operation.direction === "backward" && operation.unit === "line") {
|
|
4633
|
+
const range = at ?? operation.editor.selection ?? void 0;
|
|
4634
|
+
if (!range)
|
|
4635
|
+
throw new Error("Unable to delete line without a selection");
|
|
4646
4636
|
const parentBlockEntry = slate.Editor.above(operation.editor, {
|
|
4647
4637
|
match: (n) => slate.Element.isElement(n) && slate.Editor.isBlock(operation.editor, n),
|
|
4648
4638
|
at: range
|
|
@@ -4657,15 +4647,14 @@ const addAnnotationOperationImplementation = ({
|
|
|
4657
4647
|
}
|
|
4658
4648
|
}
|
|
4659
4649
|
}
|
|
4660
|
-
const hanging = schema.isTextBlock(context, endBlock)
|
|
4661
|
-
slate.deleteText(operation.editor, {
|
|
4662
|
-
at
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
focus: operation.editor.selection.focus
|
|
4650
|
+
const hanging = reverse ? endPoint ? schema.isTextBlock(context, endBlock) ? endPoint.offset === 0 : !0 : !1 : startPoint ? schema.isTextBlock(context, startBlock) ? startPoint.offset === 0 : !0 : !1;
|
|
4651
|
+
at ? slate.deleteText(operation.editor, {
|
|
4652
|
+
at,
|
|
4653
|
+
hanging,
|
|
4654
|
+
reverse
|
|
4655
|
+
}) : slate.deleteText(operation.editor, {
|
|
4656
|
+
hanging,
|
|
4657
|
+
reverse
|
|
4669
4658
|
});
|
|
4670
4659
|
};
|
|
4671
4660
|
function findCurrentLineRange(editor, parentRange) {
|
|
@@ -5229,21 +5218,12 @@ function createWithEventListeners(editorActor) {
|
|
|
5229
5218
|
editorDelete(options);
|
|
5230
5219
|
return;
|
|
5231
5220
|
}
|
|
5232
|
-
const
|
|
5233
|
-
if (!at) {
|
|
5234
|
-
console.error("Unexpected call to .delete(...) without `at` option");
|
|
5235
|
-
return;
|
|
5236
|
-
}
|
|
5237
|
-
const range = slate.Editor.range(editor, at), selection = slateRangeToSelection({
|
|
5221
|
+
const range = options?.at ? slate.Editor.range(editor, options.at) : void 0, selection = range ? slateRangeToSelection({
|
|
5238
5222
|
schema: editorActor.getSnapshot().context.schema,
|
|
5239
5223
|
editor,
|
|
5240
5224
|
range
|
|
5241
|
-
});
|
|
5242
|
-
|
|
5243
|
-
console.error("Unexpected call to .delete(...) with invalid `at` option");
|
|
5244
|
-
return;
|
|
5245
|
-
}
|
|
5246
|
-
editorActor.send({
|
|
5225
|
+
}) : void 0;
|
|
5226
|
+
selection ? editorActor.send({
|
|
5247
5227
|
type: "behavior event",
|
|
5248
5228
|
behaviorEvent: {
|
|
5249
5229
|
type: "delete",
|
|
@@ -5252,6 +5232,14 @@ function createWithEventListeners(editorActor) {
|
|
|
5252
5232
|
unit: options?.unit
|
|
5253
5233
|
},
|
|
5254
5234
|
editor
|
|
5235
|
+
}) : editorActor.send({
|
|
5236
|
+
type: "behavior event",
|
|
5237
|
+
behaviorEvent: {
|
|
5238
|
+
type: "delete",
|
|
5239
|
+
direction: options?.reverse ? "backward" : "forward",
|
|
5240
|
+
unit: options?.unit
|
|
5241
|
+
},
|
|
5242
|
+
editor
|
|
5255
5243
|
});
|
|
5256
5244
|
}, editor.deleteBackward = (unit) => {
|
|
5257
5245
|
if (isPerformingBehaviorOperation(editor)) {
|
|
@@ -7870,11 +7858,14 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
7870
7858
|
snapshot,
|
|
7871
7859
|
event
|
|
7872
7860
|
}) => {
|
|
7861
|
+
const at = event.at ?? snapshot.context.selection;
|
|
7862
|
+
if (!at)
|
|
7863
|
+
return !1;
|
|
7873
7864
|
const blocksToDelete = selector_isAtTheStartOfBlock.getSelectedBlocks({
|
|
7874
7865
|
...snapshot,
|
|
7875
7866
|
context: {
|
|
7876
7867
|
...snapshot.context,
|
|
7877
|
-
selection:
|
|
7868
|
+
selection: at
|
|
7878
7869
|
}
|
|
7879
7870
|
});
|
|
7880
7871
|
if (blocksToDelete.length < 2)
|
|
@@ -7885,12 +7876,12 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
7885
7876
|
const deleteStartPoint = selector_getSelectionText.getSelectionStartPoint({
|
|
7886
7877
|
context: {
|
|
7887
7878
|
...snapshot.context,
|
|
7888
|
-
selection:
|
|
7879
|
+
selection: at
|
|
7889
7880
|
}
|
|
7890
7881
|
}), deleteEndPoint = selector_isAtTheStartOfBlock.getSelectionEndPoint({
|
|
7891
7882
|
context: {
|
|
7892
7883
|
...snapshot.context,
|
|
7893
|
-
selection:
|
|
7884
|
+
selection: at
|
|
7894
7885
|
}
|
|
7895
7886
|
});
|
|
7896
7887
|
if (!deleteStartPoint || !deleteEndPoint)
|
|
@@ -8275,18 +8266,13 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
8275
8266
|
on: "delete.backward",
|
|
8276
8267
|
guard: ({
|
|
8277
8268
|
snapshot
|
|
8278
|
-
}) => snapshot.context.selection
|
|
8279
|
-
selection: snapshot.context.selection
|
|
8280
|
-
} : !1,
|
|
8269
|
+
}) => snapshot.context.selection,
|
|
8281
8270
|
actions: [({
|
|
8282
8271
|
event
|
|
8283
|
-
}, {
|
|
8284
|
-
selection
|
|
8285
8272
|
}) => [behaviors_index.raise({
|
|
8286
8273
|
type: "delete",
|
|
8287
8274
|
direction: "backward",
|
|
8288
|
-
unit: event.unit
|
|
8289
|
-
at: selection
|
|
8275
|
+
unit: event.unit
|
|
8290
8276
|
})]]
|
|
8291
8277
|
}), behaviors_index.defineBehavior({
|
|
8292
8278
|
on: "delete",
|
|
@@ -8330,18 +8316,13 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
8330
8316
|
on: "delete.forward",
|
|
8331
8317
|
guard: ({
|
|
8332
8318
|
snapshot
|
|
8333
|
-
}) => snapshot.context.selection
|
|
8334
|
-
selection: snapshot.context.selection
|
|
8335
|
-
} : !1,
|
|
8319
|
+
}) => snapshot.context.selection,
|
|
8336
8320
|
actions: [({
|
|
8337
8321
|
event
|
|
8338
|
-
}, {
|
|
8339
|
-
selection
|
|
8340
8322
|
}) => [behaviors_index.raise({
|
|
8341
8323
|
type: "delete",
|
|
8342
8324
|
direction: "forward",
|
|
8343
|
-
unit: event.unit
|
|
8344
|
-
at: selection
|
|
8325
|
+
unit: event.unit
|
|
8345
8326
|
})]]
|
|
8346
8327
|
}), behaviors_index.defineBehavior({
|
|
8347
8328
|
on: "delete",
|
|
@@ -8351,17 +8332,20 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
8351
8332
|
}) => {
|
|
8352
8333
|
if (event.direction !== "forward")
|
|
8353
8334
|
return !1;
|
|
8335
|
+
const at = event.at ?? snapshot.context.selection;
|
|
8336
|
+
if (!at)
|
|
8337
|
+
return !1;
|
|
8354
8338
|
const nextBlock = selector_isAtTheStartOfBlock.getNextBlock({
|
|
8355
8339
|
...snapshot,
|
|
8356
8340
|
context: {
|
|
8357
8341
|
...snapshot.context,
|
|
8358
|
-
selection:
|
|
8342
|
+
selection: at
|
|
8359
8343
|
}
|
|
8360
8344
|
}), focusTextBlock = selector_getSelectionText.getFocusTextBlock({
|
|
8361
8345
|
...snapshot,
|
|
8362
8346
|
context: {
|
|
8363
8347
|
...snapshot.context,
|
|
8364
|
-
selection:
|
|
8348
|
+
selection: at
|
|
8365
8349
|
}
|
|
8366
8350
|
});
|
|
8367
8351
|
if (!nextBlock || !focusTextBlock || !util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusTextBlock.node))
|
|
@@ -8698,394 +8682,436 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
8698
8682
|
}
|
|
8699
8683
|
}]]
|
|
8700
8684
|
})
|
|
8701
|
-
], abstractInsertBehaviors = [
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8685
|
+
], abstractInsertBehaviors = [
|
|
8686
|
+
behaviors_index.defineBehavior({
|
|
8687
|
+
on: "insert.blocks",
|
|
8688
|
+
guard: ({
|
|
8689
|
+
event
|
|
8690
|
+
}) => {
|
|
8691
|
+
const onlyBlock = event.blocks.length === 1 ? event.blocks.at(0) : void 0;
|
|
8692
|
+
return onlyBlock ? {
|
|
8693
|
+
onlyBlock
|
|
8694
|
+
} : !1;
|
|
8695
|
+
},
|
|
8696
|
+
actions: [({
|
|
8697
|
+
event
|
|
8698
|
+
}, {
|
|
8708
8699
|
onlyBlock
|
|
8709
|
-
}
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
})
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
})
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8700
|
+
}) => [behaviors_index.raise({
|
|
8701
|
+
type: "insert.block",
|
|
8702
|
+
block: onlyBlock,
|
|
8703
|
+
placement: event.placement,
|
|
8704
|
+
select: event.select ?? "end"
|
|
8705
|
+
})]]
|
|
8706
|
+
}),
|
|
8707
|
+
behaviors_index.defineBehavior({
|
|
8708
|
+
on: "insert.blocks",
|
|
8709
|
+
guard: ({
|
|
8710
|
+
snapshot,
|
|
8711
|
+
event
|
|
8712
|
+
}) => {
|
|
8713
|
+
if (event.placement !== "before")
|
|
8714
|
+
return !1;
|
|
8715
|
+
const firstBlockKey = event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(), lastBlockKey = event.blocks.at(-1)?._key ?? snapshot.context.keyGenerator();
|
|
8716
|
+
return {
|
|
8717
|
+
firstBlockKey,
|
|
8718
|
+
lastBlockKey
|
|
8719
|
+
};
|
|
8720
|
+
},
|
|
8721
|
+
actions: [({
|
|
8722
|
+
snapshot,
|
|
8723
|
+
event
|
|
8724
|
+
}, {
|
|
8731
8725
|
firstBlockKey,
|
|
8732
8726
|
lastBlockKey
|
|
8733
|
-
}
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
}]
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8727
|
+
}) => [...event.blocks.map((block, index) => behaviors_index.raise({
|
|
8728
|
+
type: "insert.block",
|
|
8729
|
+
block,
|
|
8730
|
+
placement: index === 0 ? "before" : "after",
|
|
8731
|
+
select: index !== event.blocks.length - 1 ? "end" : "none"
|
|
8732
|
+
})), ...event.select === "none" ? [behaviors_index.raise({
|
|
8733
|
+
type: "select",
|
|
8734
|
+
at: snapshot.context.selection
|
|
8735
|
+
})] : event.select === "start" ? [behaviors_index.raise({
|
|
8736
|
+
type: "select.block",
|
|
8737
|
+
at: [{
|
|
8738
|
+
_key: firstBlockKey
|
|
8739
|
+
}],
|
|
8740
|
+
select: "start"
|
|
8741
|
+
})] : [behaviors_index.raise({
|
|
8742
|
+
type: "select.block",
|
|
8743
|
+
at: [{
|
|
8744
|
+
_key: lastBlockKey
|
|
8745
|
+
}],
|
|
8746
|
+
select: "end"
|
|
8747
|
+
})]]]
|
|
8748
|
+
}),
|
|
8749
|
+
behaviors_index.defineBehavior({
|
|
8750
|
+
on: "insert.blocks",
|
|
8751
|
+
guard: ({
|
|
8752
|
+
snapshot,
|
|
8753
|
+
event
|
|
8754
|
+
}) => {
|
|
8755
|
+
if (event.placement !== "after")
|
|
8756
|
+
return !1;
|
|
8757
|
+
const firstBlockKey = event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(), lastBlockKey = event.blocks.at(-1)?._key ?? snapshot.context.keyGenerator();
|
|
8758
|
+
return {
|
|
8759
|
+
firstBlockKey,
|
|
8760
|
+
lastBlockKey
|
|
8761
|
+
};
|
|
8762
|
+
},
|
|
8763
|
+
actions: [({
|
|
8764
|
+
snapshot,
|
|
8765
|
+
event
|
|
8766
|
+
}, {
|
|
8772
8767
|
firstBlockKey,
|
|
8773
8768
|
lastBlockKey
|
|
8774
|
-
}
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
}]
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8769
|
+
}) => [...event.blocks.map((block, index) => behaviors_index.raise({
|
|
8770
|
+
type: "insert.block",
|
|
8771
|
+
block,
|
|
8772
|
+
placement: "after",
|
|
8773
|
+
select: index !== event.blocks.length - 1 ? "end" : "none"
|
|
8774
|
+
})), ...event.select === "none" ? [behaviors_index.raise({
|
|
8775
|
+
type: "select",
|
|
8776
|
+
at: snapshot.context.selection
|
|
8777
|
+
})] : event.select === "start" ? [behaviors_index.raise({
|
|
8778
|
+
type: "select.block",
|
|
8779
|
+
at: [{
|
|
8780
|
+
_key: firstBlockKey
|
|
8781
|
+
}],
|
|
8782
|
+
select: "start"
|
|
8783
|
+
})] : [behaviors_index.raise({
|
|
8784
|
+
type: "select.block",
|
|
8785
|
+
at: [{
|
|
8786
|
+
_key: lastBlockKey
|
|
8787
|
+
}],
|
|
8788
|
+
select: "end"
|
|
8789
|
+
})]]]
|
|
8790
|
+
}),
|
|
8791
|
+
behaviors_index.defineBehavior({
|
|
8792
|
+
on: "insert.blocks",
|
|
8793
|
+
guard: ({
|
|
8794
|
+
snapshot,
|
|
8795
|
+
event
|
|
8796
|
+
}) => {
|
|
8797
|
+
if (event.placement !== "auto")
|
|
8798
|
+
return !1;
|
|
8799
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
8800
|
+
if (!focusTextBlock || !util_isEmptyTextBlock.isEmptyTextBlock(snapshot.context, focusTextBlock.node))
|
|
8801
|
+
return !1;
|
|
8802
|
+
const firstBlockKey = event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(), lastBlockKey = event.blocks.at(-1)?._key ?? snapshot.context.keyGenerator();
|
|
8803
|
+
return {
|
|
8804
|
+
focusTextBlock,
|
|
8805
|
+
firstBlockKey,
|
|
8806
|
+
lastBlockKey
|
|
8807
|
+
};
|
|
8808
|
+
},
|
|
8809
|
+
actions: [({
|
|
8810
|
+
event
|
|
8811
|
+
}, {
|
|
8817
8812
|
firstBlockKey,
|
|
8818
8813
|
lastBlockKey
|
|
8819
|
-
}
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
})
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8814
|
+
}) => [...event.blocks.map((block, index) => behaviors_index.raise({
|
|
8815
|
+
type: "insert.block",
|
|
8816
|
+
block,
|
|
8817
|
+
placement: index === 0 ? "auto" : "after",
|
|
8818
|
+
select: index !== event.blocks.length - 1 ? "end" : "none"
|
|
8819
|
+
})), ...event.select === "none" || event.select === "start" ? [behaviors_index.raise({
|
|
8820
|
+
type: "select.block",
|
|
8821
|
+
at: [{
|
|
8822
|
+
_key: firstBlockKey
|
|
8823
|
+
}],
|
|
8824
|
+
select: "start"
|
|
8825
|
+
})] : [behaviors_index.raise({
|
|
8826
|
+
type: "select.block",
|
|
8827
|
+
at: [{
|
|
8828
|
+
_key: lastBlockKey
|
|
8829
|
+
}],
|
|
8830
|
+
select: "end"
|
|
8831
|
+
})]]]
|
|
8832
|
+
}),
|
|
8833
|
+
behaviors_index.defineBehavior({
|
|
8834
|
+
on: "insert.blocks",
|
|
8835
|
+
guard: ({
|
|
8836
|
+
snapshot,
|
|
8837
|
+
event
|
|
8838
|
+
}) => {
|
|
8839
|
+
if (event.placement !== "auto")
|
|
8840
|
+
return !1;
|
|
8841
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
8842
|
+
if (!focusTextBlock || !snapshot.context.selection)
|
|
8843
|
+
return !1;
|
|
8844
|
+
const focusBlockStartPoint = util_getTextBlockText.getBlockStartPoint({
|
|
8845
|
+
context: snapshot.context,
|
|
8846
|
+
block: focusTextBlock
|
|
8847
|
+
}), focusBlockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
|
|
8848
|
+
context: snapshot.context,
|
|
8849
|
+
block: focusTextBlock
|
|
8850
|
+
}), focusTextBlockAfter = util_sliceTextBlock.sliceTextBlock({
|
|
8851
|
+
context: {
|
|
8852
|
+
schema: snapshot.context.schema,
|
|
8853
|
+
selection: {
|
|
8854
|
+
anchor: snapshot.context.selection.focus,
|
|
8855
|
+
focus: focusBlockEndPoint
|
|
8856
|
+
}
|
|
8857
|
+
},
|
|
8858
|
+
block: focusTextBlock.node
|
|
8859
|
+
});
|
|
8860
|
+
return {
|
|
8861
|
+
firstBlockKey: event.blocks.at(0)?._key ?? snapshot.context.keyGenerator(),
|
|
8862
|
+
focusBlockStartPoint,
|
|
8863
|
+
focusBlockEndPoint,
|
|
8864
|
+
focusTextBlockAfter,
|
|
8865
|
+
selection: snapshot.context.selection
|
|
8866
|
+
};
|
|
8867
|
+
},
|
|
8868
|
+
actions: [({
|
|
8869
|
+
event
|
|
8870
|
+
}, {
|
|
8874
8871
|
focusBlockEndPoint,
|
|
8875
8872
|
focusTextBlockAfter,
|
|
8876
|
-
selection
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
}]
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
}), behaviors_index.
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
})
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
lastBlockEndPoint: util_isEmptyTextBlock.getBlockEndPoint({
|
|
8955
|
-
context: snapshot.context,
|
|
8956
|
-
block: lastBlock
|
|
8957
|
-
})
|
|
8958
|
-
};
|
|
8959
|
-
},
|
|
8960
|
-
actions: [({
|
|
8961
|
-
event
|
|
8962
|
-
}, {
|
|
8963
|
-
lastBlockEndPoint
|
|
8964
|
-
}) => [behaviors_index.raise({
|
|
8965
|
-
type: "select",
|
|
8966
|
-
at: {
|
|
8967
|
-
anchor: lastBlockEndPoint,
|
|
8968
|
-
focus: lastBlockEndPoint
|
|
8969
|
-
}
|
|
8970
|
-
}), behaviors_index.raise(event)]]
|
|
8971
|
-
}), behaviors_index.defineBehavior({
|
|
8972
|
-
on: "insert.child",
|
|
8973
|
-
guard: ({
|
|
8974
|
-
snapshot
|
|
8975
|
-
}) => {
|
|
8976
|
-
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
8977
|
-
return snapshot.context.selection && !focusTextBlock;
|
|
8978
|
-
},
|
|
8979
|
-
actions: [({
|
|
8980
|
-
snapshot,
|
|
8981
|
-
event
|
|
8982
|
-
}) => [behaviors_index.raise({
|
|
8983
|
-
type: "insert.block",
|
|
8984
|
-
block: {
|
|
8985
|
-
_type: snapshot.context.schema.block.name,
|
|
8986
|
-
children: [{
|
|
8987
|
-
_type: snapshot.context.schema.span.name,
|
|
8988
|
-
text: "",
|
|
8989
|
-
marks: []
|
|
8990
|
-
}]
|
|
8873
|
+
selection,
|
|
8874
|
+
firstBlockKey,
|
|
8875
|
+
focusBlockStartPoint
|
|
8876
|
+
}) => [...event.blocks.flatMap((block, index) => index === 0 ? [...util_isEmptyTextBlock.isEqualSelectionPoints(selection.focus, focusBlockEndPoint) ? [] : [behaviors_index.raise({
|
|
8877
|
+
type: "delete",
|
|
8878
|
+
at: {
|
|
8879
|
+
anchor: selection.focus,
|
|
8880
|
+
focus: focusBlockEndPoint
|
|
8881
|
+
}
|
|
8882
|
+
})], behaviors_index.raise({
|
|
8883
|
+
type: "insert.block",
|
|
8884
|
+
block,
|
|
8885
|
+
placement: "auto",
|
|
8886
|
+
select: "end"
|
|
8887
|
+
})] : index === event.blocks.length - 1 ? [behaviors_index.raise({
|
|
8888
|
+
type: "insert.block",
|
|
8889
|
+
block,
|
|
8890
|
+
placement: "after",
|
|
8891
|
+
select: "end"
|
|
8892
|
+
}), behaviors_index.raise({
|
|
8893
|
+
type: "insert.block",
|
|
8894
|
+
block: focusTextBlockAfter,
|
|
8895
|
+
placement: "auto",
|
|
8896
|
+
select: event.select === "end" ? "none" : "end"
|
|
8897
|
+
})] : [behaviors_index.raise({
|
|
8898
|
+
type: "insert.block",
|
|
8899
|
+
block,
|
|
8900
|
+
placement: "after",
|
|
8901
|
+
select: "end"
|
|
8902
|
+
})]), ...event.select === "none" ? [behaviors_index.raise({
|
|
8903
|
+
type: "select",
|
|
8904
|
+
at: selection
|
|
8905
|
+
})] : event.select === "start" ? [util_isEmptyTextBlock.isEqualSelectionPoints(selection.focus, focusBlockStartPoint) ? behaviors_index.raise({
|
|
8906
|
+
type: "select.block",
|
|
8907
|
+
at: [{
|
|
8908
|
+
_key: firstBlockKey
|
|
8909
|
+
}],
|
|
8910
|
+
select: "start"
|
|
8911
|
+
}) : behaviors_index.raise({
|
|
8912
|
+
type: "select",
|
|
8913
|
+
at: {
|
|
8914
|
+
anchor: selection.focus,
|
|
8915
|
+
focus: selection.focus
|
|
8916
|
+
}
|
|
8917
|
+
})] : []]]
|
|
8918
|
+
}),
|
|
8919
|
+
behaviors_index.defineBehavior({
|
|
8920
|
+
on: "insert.blocks",
|
|
8921
|
+
guard: ({
|
|
8922
|
+
event
|
|
8923
|
+
}) => event.placement === "auto",
|
|
8924
|
+
actions: [({
|
|
8925
|
+
event
|
|
8926
|
+
}) => event.blocks.map((block, index) => behaviors_index.raise({
|
|
8927
|
+
type: "insert.block",
|
|
8928
|
+
block,
|
|
8929
|
+
placement: index === 0 ? "auto" : "after",
|
|
8930
|
+
select: event.select ?? "end"
|
|
8931
|
+
}))]
|
|
8932
|
+
}),
|
|
8933
|
+
behaviors_index.defineBehavior({
|
|
8934
|
+
on: "insert.break",
|
|
8935
|
+
actions: [() => [behaviors_index.raise({
|
|
8936
|
+
type: "split"
|
|
8937
|
+
})]]
|
|
8938
|
+
}),
|
|
8939
|
+
behaviors_index.defineBehavior({
|
|
8940
|
+
on: "insert.child",
|
|
8941
|
+
guard: ({
|
|
8942
|
+
snapshot
|
|
8943
|
+
}) => {
|
|
8944
|
+
const lastBlock = selector_isAtTheStartOfBlock.getLastBlock(snapshot);
|
|
8945
|
+
return !lastBlock || snapshot.context.selection ? !1 : {
|
|
8946
|
+
lastBlockEndPoint: util_isEmptyTextBlock.getBlockEndPoint({
|
|
8947
|
+
context: snapshot.context,
|
|
8948
|
+
block: lastBlock
|
|
8949
|
+
})
|
|
8950
|
+
};
|
|
8991
8951
|
},
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
8952
|
+
actions: [({
|
|
8953
|
+
event
|
|
8954
|
+
}, {
|
|
8955
|
+
lastBlockEndPoint
|
|
8956
|
+
}) => [behaviors_index.raise({
|
|
8957
|
+
type: "select",
|
|
8958
|
+
at: {
|
|
8959
|
+
anchor: lastBlockEndPoint,
|
|
8960
|
+
focus: lastBlockEndPoint
|
|
8961
|
+
}
|
|
8962
|
+
}), behaviors_index.raise(event)]]
|
|
8963
|
+
}),
|
|
8964
|
+
behaviors_index.defineBehavior({
|
|
8965
|
+
on: "insert.child",
|
|
8966
|
+
guard: ({
|
|
8967
|
+
snapshot
|
|
8968
|
+
}) => {
|
|
8969
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
8970
|
+
return snapshot.context.selection && !focusTextBlock;
|
|
8971
|
+
},
|
|
8972
|
+
actions: [({
|
|
8973
|
+
snapshot,
|
|
8974
|
+
event
|
|
8975
|
+
}) => [behaviors_index.raise({
|
|
8976
|
+
type: "insert.block",
|
|
8977
|
+
block: {
|
|
8978
|
+
_type: snapshot.context.schema.block.name,
|
|
8979
|
+
children: [{
|
|
8980
|
+
_type: snapshot.context.schema.span.name,
|
|
8981
|
+
text: "",
|
|
8982
|
+
marks: []
|
|
8983
|
+
}]
|
|
8984
|
+
},
|
|
8985
|
+
placement: "auto",
|
|
8986
|
+
select: "end"
|
|
8987
|
+
}), behaviors_index.raise(event)]]
|
|
8988
|
+
}),
|
|
8989
|
+
behaviors_index.defineBehavior({
|
|
8990
|
+
on: "insert.inline object",
|
|
8991
|
+
actions: [({
|
|
8992
|
+
event
|
|
8993
|
+
}) => [behaviors_index.raise({
|
|
8994
|
+
type: "insert.child",
|
|
8995
|
+
child: {
|
|
8996
|
+
_type: event.inlineObject.name,
|
|
8997
|
+
...event.inlineObject.value
|
|
8998
|
+
}
|
|
8999
|
+
})]]
|
|
9000
|
+
}),
|
|
9001
|
+
behaviors_index.defineBehavior({
|
|
9002
|
+
on: "insert.soft break",
|
|
9003
|
+
actions: [() => [behaviors_index.raise({
|
|
9004
|
+
type: "insert.text",
|
|
9005
|
+
text: `
|
|
9011
9006
|
`
|
|
9012
|
-
|
|
9013
|
-
}),
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9007
|
+
})]]
|
|
9008
|
+
}),
|
|
9009
|
+
behaviors_index.defineBehavior({
|
|
9010
|
+
on: "insert.span",
|
|
9011
|
+
guard: ({
|
|
9012
|
+
snapshot
|
|
9013
|
+
}) => !selector_getSelectionText.getFocusTextBlock(snapshot),
|
|
9014
|
+
actions: [({
|
|
9015
|
+
snapshot,
|
|
9016
|
+
event
|
|
9017
|
+
}) => [behaviors_index.raise({
|
|
9018
|
+
type: "insert.block",
|
|
9019
|
+
block: {
|
|
9020
|
+
_type: snapshot.context.schema.block.name,
|
|
9021
|
+
children: [{
|
|
9022
|
+
_type: snapshot.context.schema.span.name,
|
|
9023
|
+
text: "",
|
|
9024
|
+
marks: []
|
|
9025
|
+
}]
|
|
9026
|
+
},
|
|
9027
|
+
placement: "auto",
|
|
9028
|
+
select: "end"
|
|
9029
|
+
}), behaviors_index.raise(event)]]
|
|
9030
|
+
}),
|
|
9031
|
+
behaviors_index.defineBehavior({
|
|
9032
|
+
on: "insert.span",
|
|
9033
|
+
guard: ({
|
|
9034
|
+
snapshot,
|
|
9035
|
+
event
|
|
9036
|
+
}) => {
|
|
9037
|
+
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
9038
|
+
return {
|
|
9039
|
+
markDefs: event.annotations?.map((annotation) => ({
|
|
9040
|
+
_type: annotation.name,
|
|
9041
|
+
_key: snapshot.context.keyGenerator(),
|
|
9042
|
+
...annotation.value
|
|
9043
|
+
})) ?? [],
|
|
9044
|
+
focusTextBlock
|
|
9045
|
+
};
|
|
9030
9046
|
},
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
}
|
|
9035
|
-
|
|
9036
|
-
guard: ({
|
|
9037
|
-
snapshot,
|
|
9038
|
-
event
|
|
9039
|
-
}) => {
|
|
9040
|
-
const focusTextBlock = selector_getSelectionText.getFocusTextBlock(snapshot);
|
|
9041
|
-
return {
|
|
9042
|
-
markDefs: event.annotations?.map((annotation) => ({
|
|
9043
|
-
_type: annotation.name,
|
|
9044
|
-
_key: snapshot.context.keyGenerator(),
|
|
9045
|
-
...annotation.value
|
|
9046
|
-
})) ?? [],
|
|
9047
|
+
actions: [({
|
|
9048
|
+
snapshot,
|
|
9049
|
+
event
|
|
9050
|
+
}, {
|
|
9051
|
+
markDefs,
|
|
9047
9052
|
focusTextBlock
|
|
9048
|
-
}
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
}
|
|
9062
|
-
})
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9053
|
+
}) => [...focusTextBlock ? [behaviors_index.raise({
|
|
9054
|
+
type: "block.set",
|
|
9055
|
+
at: focusTextBlock.path,
|
|
9056
|
+
props: {
|
|
9057
|
+
markDefs: [...focusTextBlock.node.markDefs ?? [], ...markDefs]
|
|
9058
|
+
}
|
|
9059
|
+
})] : [], behaviors_index.raise({
|
|
9060
|
+
type: "insert.child",
|
|
9061
|
+
child: {
|
|
9062
|
+
_type: snapshot.context.schema.span.name,
|
|
9063
|
+
text: event.text,
|
|
9064
|
+
marks: [...event.decorators ?? [], ...markDefs.map((markDef) => markDef._key)]
|
|
9065
|
+
}
|
|
9066
|
+
})]]
|
|
9067
|
+
}),
|
|
9068
|
+
/**
|
|
9069
|
+
* If there's an expanded selection, then we delete the selection before we
|
|
9070
|
+
* insert the text.
|
|
9071
|
+
*/
|
|
9072
|
+
behaviors_index.defineBehavior({
|
|
9073
|
+
on: "insert.text",
|
|
9074
|
+
guard: ({
|
|
9075
|
+
snapshot
|
|
9076
|
+
}) => selector_getSelectionText.isSelectionExpanded(snapshot),
|
|
9077
|
+
actions: [({
|
|
9078
|
+
event
|
|
9079
|
+
}) => [behaviors_index.raise({
|
|
9080
|
+
type: "delete"
|
|
9081
|
+
}), behaviors_index.raise(event)]]
|
|
9082
|
+
}),
|
|
9083
|
+
/**
|
|
9084
|
+
* If there's no selection, then we select the end of the editor before we
|
|
9085
|
+
* we insert the text.
|
|
9086
|
+
*/
|
|
9087
|
+
behaviors_index.defineBehavior({
|
|
9088
|
+
on: "insert.text",
|
|
9089
|
+
guard: ({
|
|
9090
|
+
snapshot
|
|
9091
|
+
}) => {
|
|
9092
|
+
if (snapshot.context.selection)
|
|
9093
|
+
return !1;
|
|
9094
|
+
const lastBlok = selector_isAtTheStartOfBlock.getLastBlock(snapshot);
|
|
9095
|
+
return lastBlok ? {
|
|
9096
|
+
endPoint: util_isEmptyTextBlock.getBlockEndPoint({
|
|
9097
|
+
context: snapshot.context,
|
|
9098
|
+
block: lastBlok
|
|
9099
|
+
})
|
|
9100
|
+
} : !1;
|
|
9101
|
+
},
|
|
9102
|
+
actions: [({
|
|
9103
|
+
event
|
|
9104
|
+
}, {
|
|
9105
|
+
endPoint
|
|
9106
|
+
}) => [behaviors_index.raise({
|
|
9107
|
+
type: "select",
|
|
9108
|
+
at: {
|
|
9109
|
+
anchor: endPoint,
|
|
9110
|
+
focus: endPoint
|
|
9111
|
+
}
|
|
9112
|
+
}), behaviors_index.raise(event)]]
|
|
9113
|
+
})
|
|
9114
|
+
], shiftLeft = keyboardShortcuts.createKeyboardShortcut({
|
|
9089
9115
|
default: [{
|
|
9090
9116
|
key: "ArrowLeft",
|
|
9091
9117
|
shift: !0,
|
|
@@ -9558,86 +9584,34 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
9558
9584
|
const selection = snapshot.context.selection;
|
|
9559
9585
|
if (!selection || util_isEmptyTextBlock.isSelectionCollapsed(selection))
|
|
9560
9586
|
return !1;
|
|
9561
|
-
const
|
|
9562
|
-
|
|
9563
|
-
selection
|
|
9564
|
-
} : !1;
|
|
9565
|
-
},
|
|
9566
|
-
actions: [(_, {
|
|
9567
|
-
selection
|
|
9568
|
-
}) => [behaviors_index.raise({
|
|
9569
|
-
type: "delete",
|
|
9570
|
-
at: selection
|
|
9571
|
-
})]]
|
|
9572
|
-
}),
|
|
9573
|
-
behaviors_index.defineBehavior({
|
|
9574
|
-
on: "split",
|
|
9575
|
-
guard: ({
|
|
9576
|
-
snapshot
|
|
9577
|
-
}) => {
|
|
9578
|
-
const selection = snapshot.context.selection;
|
|
9579
|
-
if (!selection || util_isEmptyTextBlock.isSelectionCollapsed(selection))
|
|
9587
|
+
const startPoint = util_getTextBlockText.getSelectionStartPoint(selection), endPoint = util_getTextBlockText.getSelectionEndPoint(selection);
|
|
9588
|
+
if (!startPoint || !endPoint)
|
|
9580
9589
|
return !1;
|
|
9581
|
-
const
|
|
9582
|
-
if (!
|
|
9590
|
+
const startBlock = selector_isAtTheStartOfBlock.getSelectionStartBlock(snapshot), endBlock = selector_isAtTheStartOfBlock.getSelectionEndBlock(snapshot);
|
|
9591
|
+
if (!startBlock || !endBlock)
|
|
9583
9592
|
return !1;
|
|
9584
|
-
const
|
|
9593
|
+
const startBlockStartPoint = util_getTextBlockText.getBlockStartPoint({
|
|
9585
9594
|
context: snapshot.context,
|
|
9586
|
-
block:
|
|
9587
|
-
}),
|
|
9595
|
+
block: startBlock
|
|
9596
|
+
}), endBlockEndPoint = util_isEmptyTextBlock.getBlockEndPoint({
|
|
9588
9597
|
context: snapshot.context,
|
|
9589
|
-
block:
|
|
9590
|
-
})
|
|
9591
|
-
return
|
|
9592
|
-
startPoint,
|
|
9593
|
-
startBlockEndPoint,
|
|
9594
|
-
endPoint,
|
|
9595
|
-
endBlockStartPoint,
|
|
9596
|
-
blocksInBetween
|
|
9597
|
-
};
|
|
9598
|
+
block: endBlock
|
|
9599
|
+
});
|
|
9600
|
+
return !!(schema.isTextBlock(snapshot.context, startBlock.node) && schema.isTextBlock(snapshot.context, endBlock.node) && !util_isEmptyTextBlock.isEqualSelectionPoints(startPoint, startBlockStartPoint) && !util_isEmptyTextBlock.isEqualSelectionPoints(endPoint, endBlockEndPoint));
|
|
9598
9601
|
},
|
|
9599
|
-
actions: [(
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
endBlockStartPoint,
|
|
9604
|
-
blocksInBetween
|
|
9605
|
-
}) => [behaviors_index.raise({
|
|
9606
|
-
type: "delete",
|
|
9607
|
-
at: {
|
|
9608
|
-
anchor: startPoint,
|
|
9609
|
-
focus: startBlockEndPoint
|
|
9610
|
-
}
|
|
9611
|
-
}), ...blocksInBetween.map((block) => behaviors_index.raise({
|
|
9612
|
-
type: "delete.block",
|
|
9613
|
-
at: [{
|
|
9614
|
-
_key: block._key
|
|
9615
|
-
}]
|
|
9616
|
-
})), behaviors_index.raise({
|
|
9617
|
-
type: "delete",
|
|
9618
|
-
at: {
|
|
9619
|
-
anchor: endBlockStartPoint,
|
|
9620
|
-
focus: endPoint
|
|
9621
|
-
}
|
|
9602
|
+
actions: [() => [behaviors_index.raise({
|
|
9603
|
+
type: "delete"
|
|
9604
|
+
}), behaviors_index.raise({
|
|
9605
|
+
type: "split"
|
|
9622
9606
|
})]]
|
|
9623
9607
|
}),
|
|
9624
9608
|
behaviors_index.defineBehavior({
|
|
9625
9609
|
on: "split",
|
|
9626
9610
|
guard: ({
|
|
9627
9611
|
snapshot
|
|
9628
|
-
}) =>
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
selection
|
|
9632
|
-
};
|
|
9633
|
-
},
|
|
9634
|
-
actions: [(_, {
|
|
9635
|
-
selection
|
|
9636
|
-
}) => [behaviors_index.raise({
|
|
9637
|
-
type: "delete",
|
|
9638
|
-
at: selection
|
|
9639
|
-
}), behaviors_index.raise({
|
|
9640
|
-
type: "split"
|
|
9612
|
+
}) => selector_getSelectionText.isSelectionExpanded(snapshot),
|
|
9613
|
+
actions: [() => [behaviors_index.raise({
|
|
9614
|
+
type: "delete"
|
|
9641
9615
|
})]]
|
|
9642
9616
|
}),
|
|
9643
9617
|
behaviors_index.defineBehavior({
|