@portabletext/editor 1.52.8 → 1.53.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/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +144 -6
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs +6 -140
- package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +148 -10
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/selector.is-selection-expanded.js +6 -140
- package/lib/_chunks-es/selector.is-selection-expanded.js.map +1 -1
- package/lib/index.cjs +143 -97
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +123 -77
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +10 -10
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +11 -11
- package/lib/selectors/index.d.ts +11 -11
- package/lib/selectors/index.js +4 -4
- package/lib/selectors/index.js.map +1 -1
- package/package.json +13 -13
- package/src/behaviors/behavior.abstract.keyboard.ts +10 -0
- package/src/behaviors/behavior.abstract.split.ts +105 -87
- package/src/behaviors/behavior.core.insert-break.ts +14 -0
- package/src/behaviors/behavior.core.ts +1 -0
- package/src/internal-utils/key-is.ts +1 -0
- package/src/selectors/index.ts +13 -1
- package/src/selectors/selector.get-active-annotations.ts +2 -1
- package/src/selectors/selector.get-active-list-item.ts +1 -1
- package/src/selectors/selector.get-active-style.ts +1 -1
- package/src/selectors/selector.get-caret-word-selection.ts +1 -1
- package/src/selectors/selector.get-first-block.ts +14 -0
- package/src/selectors/selector.get-focus-block-object.ts +18 -0
- package/src/selectors/selector.get-focus-block.ts +23 -0
- package/src/selectors/selector.get-focus-child.ts +39 -0
- package/src/selectors/selector.get-focus-inline-object.ts +1 -1
- package/src/selectors/selector.get-focus-list-block.ts +18 -0
- package/src/selectors/selector.get-focus-span.ts +18 -0
- package/src/selectors/selector.get-focus-text-block.ts +18 -0
- package/src/selectors/selector.get-last-block.ts +16 -0
- package/src/selectors/selector.get-list-state.ts +2 -1
- package/src/selectors/selector.get-next-block.ts +38 -0
- package/src/selectors/selector.get-next-inline-object.ts +1 -1
- package/src/selectors/selector.get-previous-block.ts +35 -0
- package/src/selectors/selector.get-previous-inline-object.ts +1 -1
- package/src/selectors/selector.get-selected-blocks.ts +50 -0
- package/src/selectors/selector.get-selection-end-block.ts +4 -1
- package/src/selectors/selector.get-selection-start-block.ts +4 -1
- package/src/selectors/selector.get-text-before.ts +1 -1
- package/src/selectors/selector.get-trimmed-selection.ts +1 -1
- package/src/selectors/selector.is-active-annotation.ts +1 -1
- package/src/selectors/selector.is-selecting-entire-blocks.ts +2 -1
- package/src/selectors/selectors.ts +0 -299
package/lib/index.cjs
CHANGED
|
@@ -687,9 +687,9 @@ function getDragSelection({
|
|
|
687
687
|
block: draggedTextBlock
|
|
688
688
|
})
|
|
689
689
|
});
|
|
690
|
-
const selectedBlocks =
|
|
690
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot);
|
|
691
691
|
if (snapshot.context.selection && selector_isSelectionExpanded.isSelectionExpanded(snapshot) && selectedBlocks.length > 1) {
|
|
692
|
-
const selectionStartBlock =
|
|
692
|
+
const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
693
693
|
if (!selectionStartBlock || !selectionEndBlock)
|
|
694
694
|
return dragSelection;
|
|
695
695
|
const selectionStartPoint = selectionPoint.getBlockStartPoint({
|
|
@@ -770,7 +770,7 @@ function createCoreBlockElementBehaviorsConfig({
|
|
|
770
770
|
eventSelection: dragOrigin.selection,
|
|
771
771
|
snapshot
|
|
772
772
|
});
|
|
773
|
-
return
|
|
773
|
+
return selector_isSelectingEntireBlocks.getSelectedBlocks({
|
|
774
774
|
context: {
|
|
775
775
|
...snapshot.context,
|
|
776
776
|
selection: dragSelection
|
|
@@ -5208,7 +5208,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5208
5208
|
}) => {
|
|
5209
5209
|
if (!isHotkey("ArrowDown", event.originEvent) || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
5210
5210
|
return !1;
|
|
5211
|
-
const focusBlockObject =
|
|
5211
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
5212
5212
|
return focusBlockObject && !nextBlock;
|
|
5213
5213
|
},
|
|
5214
5214
|
actions: [({
|
|
@@ -5228,7 +5228,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5228
5228
|
}) => {
|
|
5229
5229
|
if (!isHotkey("ArrowUp", event.originEvent) || !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
5230
5230
|
return !1;
|
|
5231
|
-
const focusBlockObject =
|
|
5231
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
5232
5232
|
return focusBlockObject && !previousBlock;
|
|
5233
5233
|
},
|
|
5234
5234
|
actions: [({
|
|
@@ -5245,7 +5245,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5245
5245
|
guard: ({
|
|
5246
5246
|
snapshot
|
|
5247
5247
|
}) => {
|
|
5248
|
-
const focusBlockObject =
|
|
5248
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot);
|
|
5249
5249
|
return selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && focusBlockObject !== void 0;
|
|
5250
5250
|
},
|
|
5251
5251
|
actions: [({
|
|
@@ -5265,12 +5265,12 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5265
5265
|
}) => {
|
|
5266
5266
|
if (snapshot.context.readOnly || snapshot.context.selection && !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
5267
5267
|
return !1;
|
|
5268
|
-
const focusBlockObject =
|
|
5268
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject({
|
|
5269
5269
|
context: {
|
|
5270
5270
|
...snapshot.context,
|
|
5271
5271
|
selection: event.position.selection
|
|
5272
5272
|
}
|
|
5273
|
-
}), previousBlock =
|
|
5273
|
+
}), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock({
|
|
5274
5274
|
context: {
|
|
5275
5275
|
...snapshot.context,
|
|
5276
5276
|
selection: event.position.selection
|
|
@@ -5300,12 +5300,12 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5300
5300
|
}) => {
|
|
5301
5301
|
if (snapshot.context.readOnly || snapshot.context.selection && !selector_isSelectionExpanded.isSelectionCollapsed(snapshot))
|
|
5302
5302
|
return !1;
|
|
5303
|
-
const focusBlockObject =
|
|
5303
|
+
const focusBlockObject = selector_isSelectingEntireBlocks.getFocusBlockObject({
|
|
5304
5304
|
context: {
|
|
5305
5305
|
...snapshot.context,
|
|
5306
5306
|
selection: event.position.selection
|
|
5307
5307
|
}
|
|
5308
|
-
}), nextBlock =
|
|
5308
|
+
}), nextBlock = selector_isSelectingEntireBlocks.getNextBlock({
|
|
5309
5309
|
context: {
|
|
5310
5310
|
...snapshot.context,
|
|
5311
5311
|
selection: event.position.selection
|
|
@@ -5332,7 +5332,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5332
5332
|
guard: ({
|
|
5333
5333
|
snapshot
|
|
5334
5334
|
}) => {
|
|
5335
|
-
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), previousBlock =
|
|
5335
|
+
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
5336
5336
|
return !focusTextBlock || !selectionCollapsed || !previousBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !selectionPoint.isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
5337
5337
|
focusTextBlock,
|
|
5338
5338
|
previousBlock
|
|
@@ -5362,7 +5362,7 @@ const arrowDownOnLonelyBlockObject = behaviors_index.defineBehavior({
|
|
|
5362
5362
|
guard: ({
|
|
5363
5363
|
snapshot
|
|
5364
5364
|
}) => {
|
|
5365
|
-
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), nextBlock =
|
|
5365
|
+
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
5366
5366
|
return !focusTextBlock || !selectionCollapsed || !nextBlock ? !1 : util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusTextBlock.node) && !selectionPoint.isTextBlock(snapshot.context, nextBlock.node) ? {
|
|
5367
5367
|
focusTextBlock,
|
|
5368
5368
|
nextBlock
|
|
@@ -5664,7 +5664,7 @@ const coreDndBehaviors = [
|
|
|
5664
5664
|
...snapshot.context,
|
|
5665
5665
|
selection: dragSelection
|
|
5666
5666
|
}
|
|
5667
|
-
}), draggedBlocks =
|
|
5667
|
+
}), draggedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks({
|
|
5668
5668
|
context: {
|
|
5669
5669
|
...snapshot.context,
|
|
5670
5670
|
selection: dragSelection
|
|
@@ -5782,7 +5782,7 @@ const coreDndBehaviors = [
|
|
|
5782
5782
|
}) => {
|
|
5783
5783
|
if (!snapshot.context.selection || !selector_isSelectionExpanded.isSelectionExpanded(snapshot))
|
|
5784
5784
|
return !1;
|
|
5785
|
-
const firstBlock =
|
|
5785
|
+
const firstBlock = selector_isSelectingEntireBlocks.getFirstBlock(snapshot), lastBlock = selector_isSelectingEntireBlocks.getLastBlock(snapshot);
|
|
5786
5786
|
if (!firstBlock || !lastBlock)
|
|
5787
5787
|
return !1;
|
|
5788
5788
|
const firstBlockStartPoint = selectionPoint.getBlockStartPoint({
|
|
@@ -5809,7 +5809,7 @@ const coreDndBehaviors = [
|
|
|
5809
5809
|
}) => {
|
|
5810
5810
|
if (!snapshot.context.selection || !selector_isSelectionExpanded.isSelectionExpanded(snapshot))
|
|
5811
5811
|
return !1;
|
|
5812
|
-
const selectedBlocks =
|
|
5812
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
5813
5813
|
if (!selectionStartBlock || !selectionEndBlock)
|
|
5814
5814
|
return !1;
|
|
5815
5815
|
const startBlockStartPoint = selectionPoint.getBlockStartPoint({
|
|
@@ -5843,11 +5843,26 @@ const coreDndBehaviors = [
|
|
|
5843
5843
|
type: "delete.block",
|
|
5844
5844
|
at: block.path
|
|
5845
5845
|
}))]]
|
|
5846
|
+
}), breakingInlineObject = behaviors_index.defineBehavior({
|
|
5847
|
+
on: "insert.break",
|
|
5848
|
+
guard: ({
|
|
5849
|
+
snapshot
|
|
5850
|
+
}) => {
|
|
5851
|
+
const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusInlineObject = selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot);
|
|
5852
|
+
return selectionCollapsed && focusInlineObject;
|
|
5853
|
+
},
|
|
5854
|
+
actions: [() => [behaviors_index.raise({
|
|
5855
|
+
type: "move.forward",
|
|
5856
|
+
distance: 1
|
|
5857
|
+
}), behaviors_index.raise({
|
|
5858
|
+
type: "split"
|
|
5859
|
+
})]]
|
|
5846
5860
|
}), coreInsertBreakBehaviors = {
|
|
5847
5861
|
breakingAtTheEndOfTextBlock,
|
|
5848
5862
|
breakingAtTheStartOfTextBlock,
|
|
5849
5863
|
breakingEntireDocument,
|
|
5850
|
-
breakingEntireBlocks
|
|
5864
|
+
breakingEntireBlocks,
|
|
5865
|
+
breakingInlineObject
|
|
5851
5866
|
}, MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior({
|
|
5852
5867
|
on: "delete.backward",
|
|
5853
5868
|
guard: ({
|
|
@@ -5891,7 +5906,7 @@ const coreDndBehaviors = [
|
|
|
5891
5906
|
guard: ({
|
|
5892
5907
|
snapshot
|
|
5893
5908
|
}) => {
|
|
5894
|
-
const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusListBlock =
|
|
5909
|
+
const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusListBlock = selector_isSelectingEntireBlocks.getFocusListBlock(snapshot);
|
|
5895
5910
|
return !selectionCollapsed || !focusListBlock || !util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
|
|
5896
5911
|
focusListBlock
|
|
5897
5912
|
};
|
|
@@ -5911,7 +5926,7 @@ const coreDndBehaviors = [
|
|
|
5911
5926
|
}) => {
|
|
5912
5927
|
if (!isHotkey("Tab", event.originEvent))
|
|
5913
5928
|
return !1;
|
|
5914
|
-
const selectedBlocks =
|
|
5929
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => selectionPoint.isListBlock(snapshot.context, block.node) ? [{
|
|
5915
5930
|
node: block.node,
|
|
5916
5931
|
path: block.path
|
|
5917
5932
|
}] : []);
|
|
@@ -5936,7 +5951,7 @@ const coreDndBehaviors = [
|
|
|
5936
5951
|
}) => {
|
|
5937
5952
|
if (!isHotkey("Shift+Tab", event.originEvent))
|
|
5938
5953
|
return !1;
|
|
5939
|
-
const selectedBlocks =
|
|
5954
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => selectionPoint.isListBlock(snapshot.context, block.node) ? [{
|
|
5940
5955
|
node: block.node,
|
|
5941
5956
|
path: block.path
|
|
5942
5957
|
}] : []);
|
|
@@ -5959,7 +5974,7 @@ const coreDndBehaviors = [
|
|
|
5959
5974
|
clearListOnEnter,
|
|
5960
5975
|
indentListOnTab,
|
|
5961
5976
|
unindentListOnShiftTab
|
|
5962
|
-
}, 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) => ({
|
|
5977
|
+
}, 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, coreInsertBreakBehaviors.breakingInlineObject].map((behavior) => ({
|
|
5963
5978
|
behavior,
|
|
5964
5979
|
priority: corePriority
|
|
5965
5980
|
}));
|
|
@@ -6254,8 +6269,19 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6254
6269
|
`
|
|
6255
6270
|
})]]
|
|
6256
6271
|
})], keyIs = {
|
|
6272
|
+
break: (event) => event.key === "Enter" && !event.shiftKey,
|
|
6257
6273
|
lineBreak: (event) => event.key === "Enter" && event.shiftKey
|
|
6258
6274
|
}, abstractKeyboardBehaviors = [
|
|
6275
|
+
behaviors_index.defineBehavior({
|
|
6276
|
+
on: "keyboard.keydown",
|
|
6277
|
+
guard: ({
|
|
6278
|
+
snapshot,
|
|
6279
|
+
event
|
|
6280
|
+
}) => keyIs.break(event.originEvent) && selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
|
|
6281
|
+
actions: [() => [behaviors_index.raise({
|
|
6282
|
+
type: "insert.break"
|
|
6283
|
+
})]]
|
|
6284
|
+
}),
|
|
6259
6285
|
/**
|
|
6260
6286
|
* On WebKit, Shift+Enter results in an `insertParagraph` input event rather
|
|
6261
6287
|
* than an `insertLineBreak` input event. This Behavior makes sure we catch
|
|
@@ -6333,7 +6359,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6333
6359
|
snapshot,
|
|
6334
6360
|
event
|
|
6335
6361
|
}) => {
|
|
6336
|
-
const previousBlock =
|
|
6362
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock({
|
|
6337
6363
|
context: {
|
|
6338
6364
|
...snapshot.context,
|
|
6339
6365
|
selection: {
|
|
@@ -6367,7 +6393,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6367
6393
|
snapshot,
|
|
6368
6394
|
event
|
|
6369
6395
|
}) => {
|
|
6370
|
-
const nextBlock =
|
|
6396
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock({
|
|
6371
6397
|
context: {
|
|
6372
6398
|
...snapshot.context,
|
|
6373
6399
|
selection: {
|
|
@@ -6401,7 +6427,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6401
6427
|
snapshot,
|
|
6402
6428
|
event
|
|
6403
6429
|
}) => {
|
|
6404
|
-
const previousBlock =
|
|
6430
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
6405
6431
|
if (!previousBlock)
|
|
6406
6432
|
return !1;
|
|
6407
6433
|
const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
|
|
@@ -6430,7 +6456,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6430
6456
|
snapshot,
|
|
6431
6457
|
event
|
|
6432
6458
|
}) => {
|
|
6433
|
-
const nextBlock =
|
|
6459
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
6434
6460
|
if (!nextBlock)
|
|
6435
6461
|
return !1;
|
|
6436
6462
|
const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
|
|
@@ -6453,28 +6479,82 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6453
6479
|
type: "select",
|
|
6454
6480
|
at: selection
|
|
6455
6481
|
})]]
|
|
6456
|
-
})], abstractSplitBehaviors = [
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6482
|
+
})], abstractSplitBehaviors = [
|
|
6483
|
+
/**
|
|
6484
|
+
* You can't split an inline object.
|
|
6485
|
+
*/
|
|
6486
|
+
behaviors_index.defineBehavior({
|
|
6487
|
+
on: "split",
|
|
6488
|
+
guard: ({
|
|
6489
|
+
snapshot
|
|
6490
|
+
}) => selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusInlineObject(snapshot),
|
|
6491
|
+
actions: []
|
|
6492
|
+
}),
|
|
6493
|
+
/**
|
|
6494
|
+
* You can't split a block object.
|
|
6495
|
+
*/
|
|
6496
|
+
behaviors_index.defineBehavior({
|
|
6497
|
+
on: "split",
|
|
6498
|
+
guard: ({
|
|
6499
|
+
snapshot
|
|
6500
|
+
}) => selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot),
|
|
6501
|
+
actions: []
|
|
6502
|
+
}),
|
|
6503
|
+
behaviors_index.defineBehavior({
|
|
6504
|
+
on: "split",
|
|
6505
|
+
guard: ({
|
|
6506
|
+
snapshot
|
|
6507
|
+
}) => {
|
|
6508
|
+
const selection = snapshot.context.selection;
|
|
6509
|
+
if (!selection || util_selectionPointToBlockOffset.isSelectionCollapsed(selection))
|
|
6510
|
+
return !1;
|
|
6511
|
+
const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
6512
|
+
return !selectionStartBlock || !selectionEndBlock ? !1 : !selectionPoint.isTextBlock(snapshot.context, selectionStartBlock.node) && selectionPoint.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
|
|
6513
|
+
selection
|
|
6514
|
+
} : !1;
|
|
6515
|
+
},
|
|
6516
|
+
actions: [(_, {
|
|
6517
|
+
selection
|
|
6518
|
+
}) => [behaviors_index.raise({
|
|
6519
|
+
type: "delete",
|
|
6520
|
+
at: selection
|
|
6521
|
+
})]]
|
|
6522
|
+
}),
|
|
6523
|
+
behaviors_index.defineBehavior({
|
|
6524
|
+
on: "split",
|
|
6525
|
+
guard: ({
|
|
6526
|
+
snapshot
|
|
6527
|
+
}) => {
|
|
6528
|
+
const selection = snapshot.context.selection;
|
|
6529
|
+
return !selection || util_selectionPointToBlockOffset.isSelectionCollapsed(selection) ? !1 : {
|
|
6530
|
+
selection
|
|
6531
|
+
};
|
|
6532
|
+
},
|
|
6533
|
+
actions: [(_, {
|
|
6534
|
+
selection
|
|
6535
|
+
}) => [behaviors_index.raise({
|
|
6536
|
+
type: "delete",
|
|
6537
|
+
at: selection
|
|
6538
|
+
}), behaviors_index.raise({
|
|
6539
|
+
type: "split"
|
|
6540
|
+
})]]
|
|
6541
|
+
}),
|
|
6542
|
+
behaviors_index.defineBehavior({
|
|
6543
|
+
on: "split",
|
|
6544
|
+
guard: ({
|
|
6545
|
+
snapshot
|
|
6546
|
+
}) => {
|
|
6547
|
+
const selection = snapshot.context.selection;
|
|
6548
|
+
if (!selection || !util_selectionPointToBlockOffset.isSelectionCollapsed(selection))
|
|
6549
|
+
return !1;
|
|
6550
|
+
const selectionStartPoint = selectionPoint.getSelectionStartPoint(selection), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
6551
|
+
if (!focusTextBlock)
|
|
6552
|
+
return !1;
|
|
6473
6553
|
const blockEndPoint = util_isEqualSelectionPoints.getBlockEndPoint({
|
|
6474
6554
|
context: snapshot.context,
|
|
6475
6555
|
block: focusTextBlock
|
|
6476
6556
|
}), newTextBlockSelection = {
|
|
6477
|
-
anchor:
|
|
6557
|
+
anchor: selectionStartPoint,
|
|
6478
6558
|
focus: blockEndPoint
|
|
6479
6559
|
}, newTextBlock = selectionPoint.parseBlock({
|
|
6480
6560
|
block: selectionPoint.sliceBlocks({
|
|
@@ -6490,64 +6570,30 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6490
6570
|
validateFields: !0
|
|
6491
6571
|
}
|
|
6492
6572
|
});
|
|
6493
|
-
return !newTextBlock || !selectionPoint.isTextBlock(snapshot.context, newTextBlock) ? !1 : {
|
|
6494
|
-
newTextBlock,
|
|
6495
|
-
newTextBlockSelection,
|
|
6496
|
-
selection: {
|
|
6497
|
-
anchor: selectionStartPoint,
|
|
6498
|
-
focus: blockEndPoint
|
|
6499
|
-
}
|
|
6500
|
-
};
|
|
6501
|
-
}
|
|
6502
|
-
if (selector_isSelectionExpanded.getFocusBlockObject({
|
|
6503
|
-
context: {
|
|
6504
|
-
...snapshot.context,
|
|
6505
|
-
selection: {
|
|
6506
|
-
anchor: selectionStartPoint,
|
|
6507
|
-
focus: selectionEndPoint
|
|
6508
|
-
}
|
|
6509
|
-
}
|
|
6510
|
-
})) {
|
|
6511
|
-
const newTextBlock = selectionPoint.parseBlock({
|
|
6512
|
-
block: {
|
|
6513
|
-
_type: snapshot.context.schema.block.name,
|
|
6514
|
-
children: []
|
|
6515
|
-
},
|
|
6516
|
-
context: snapshot.context,
|
|
6517
|
-
options: {
|
|
6518
|
-
refreshKeys: !0,
|
|
6519
|
-
validateFields: !0
|
|
6520
|
-
}
|
|
6521
|
-
});
|
|
6522
6573
|
return newTextBlock ? {
|
|
6523
6574
|
newTextBlock,
|
|
6524
|
-
newTextBlockSelection
|
|
6525
|
-
anchor: selectionEndPoint,
|
|
6526
|
-
focus: selectionEndPoint
|
|
6527
|
-
},
|
|
6528
|
-
selection: snapshot.context.selection
|
|
6575
|
+
newTextBlockSelection
|
|
6529
6576
|
} : !1;
|
|
6530
|
-
}
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
})], abstractStyleBehaviors = [behaviors_index.defineBehavior({
|
|
6577
|
+
},
|
|
6578
|
+
actions: [(_, {
|
|
6579
|
+
newTextBlock,
|
|
6580
|
+
newTextBlockSelection
|
|
6581
|
+
}) => util_selectionPointToBlockOffset.isSelectionCollapsed(newTextBlockSelection) ? [behaviors_index.raise({
|
|
6582
|
+
type: "insert.block",
|
|
6583
|
+
block: newTextBlock,
|
|
6584
|
+
placement: "after",
|
|
6585
|
+
select: "start"
|
|
6586
|
+
})] : [behaviors_index.raise({
|
|
6587
|
+
type: "delete",
|
|
6588
|
+
at: newTextBlockSelection
|
|
6589
|
+
}), behaviors_index.raise({
|
|
6590
|
+
type: "insert.block",
|
|
6591
|
+
block: newTextBlock,
|
|
6592
|
+
placement: "after",
|
|
6593
|
+
select: "start"
|
|
6594
|
+
})]]
|
|
6595
|
+
})
|
|
6596
|
+
], abstractStyleBehaviors = [behaviors_index.defineBehavior({
|
|
6551
6597
|
on: "style.add",
|
|
6552
6598
|
guard: ({
|
|
6553
6599
|
snapshot
|