@portabletext/editor 1.53.0 → 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 +24 -24
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +2 -2
- 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/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({
|
|
@@ -5906,7 +5906,7 @@ const coreDndBehaviors = [
|
|
|
5906
5906
|
guard: ({
|
|
5907
5907
|
snapshot
|
|
5908
5908
|
}) => {
|
|
5909
|
-
const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusListBlock =
|
|
5909
|
+
const selectionCollapsed = selector_isSelectionExpanded.isSelectionCollapsed(snapshot), focusListBlock = selector_isSelectingEntireBlocks.getFocusListBlock(snapshot);
|
|
5910
5910
|
return !selectionCollapsed || !focusListBlock || !util_isEqualSelectionPoints.isEmptyTextBlock(snapshot.context, focusListBlock.node) ? !1 : {
|
|
5911
5911
|
focusListBlock
|
|
5912
5912
|
};
|
|
@@ -5926,7 +5926,7 @@ const coreDndBehaviors = [
|
|
|
5926
5926
|
}) => {
|
|
5927
5927
|
if (!isHotkey("Tab", event.originEvent))
|
|
5928
5928
|
return !1;
|
|
5929
|
-
const selectedBlocks =
|
|
5929
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => selectionPoint.isListBlock(snapshot.context, block.node) ? [{
|
|
5930
5930
|
node: block.node,
|
|
5931
5931
|
path: block.path
|
|
5932
5932
|
}] : []);
|
|
@@ -5951,7 +5951,7 @@ const coreDndBehaviors = [
|
|
|
5951
5951
|
}) => {
|
|
5952
5952
|
if (!isHotkey("Shift+Tab", event.originEvent))
|
|
5953
5953
|
return !1;
|
|
5954
|
-
const selectedBlocks =
|
|
5954
|
+
const selectedBlocks = selector_isSelectingEntireBlocks.getSelectedBlocks(snapshot), selectedListBlocks = selectedBlocks.flatMap((block) => selectionPoint.isListBlock(snapshot.context, block.node) ? [{
|
|
5955
5955
|
node: block.node,
|
|
5956
5956
|
path: block.path
|
|
5957
5957
|
}] : []);
|
|
@@ -6359,7 +6359,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6359
6359
|
snapshot,
|
|
6360
6360
|
event
|
|
6361
6361
|
}) => {
|
|
6362
|
-
const previousBlock =
|
|
6362
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock({
|
|
6363
6363
|
context: {
|
|
6364
6364
|
...snapshot.context,
|
|
6365
6365
|
selection: {
|
|
@@ -6393,7 +6393,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6393
6393
|
snapshot,
|
|
6394
6394
|
event
|
|
6395
6395
|
}) => {
|
|
6396
|
-
const nextBlock =
|
|
6396
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock({
|
|
6397
6397
|
context: {
|
|
6398
6398
|
...snapshot.context,
|
|
6399
6399
|
selection: {
|
|
@@ -6427,7 +6427,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6427
6427
|
snapshot,
|
|
6428
6428
|
event
|
|
6429
6429
|
}) => {
|
|
6430
|
-
const previousBlock =
|
|
6430
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
6431
6431
|
if (!previousBlock)
|
|
6432
6432
|
return !1;
|
|
6433
6433
|
const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
|
|
@@ -6456,7 +6456,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6456
6456
|
snapshot,
|
|
6457
6457
|
event
|
|
6458
6458
|
}) => {
|
|
6459
|
-
const nextBlock =
|
|
6459
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot);
|
|
6460
6460
|
if (!nextBlock)
|
|
6461
6461
|
return !1;
|
|
6462
6462
|
const point = event.select === "end" ? util_isEqualSelectionPoints.getBlockEndPoint({
|
|
@@ -6497,7 +6497,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6497
6497
|
on: "split",
|
|
6498
6498
|
guard: ({
|
|
6499
6499
|
snapshot
|
|
6500
|
-
}) => selector_isSelectionExpanded.isSelectionCollapsed(snapshot) &&
|
|
6500
|
+
}) => selector_isSelectionExpanded.isSelectionCollapsed(snapshot) && selector_isSelectingEntireBlocks.getFocusBlockObject(snapshot),
|
|
6501
6501
|
actions: []
|
|
6502
6502
|
}),
|
|
6503
6503
|
behaviors_index.defineBehavior({
|
|
@@ -6508,7 +6508,7 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
6508
6508
|
const selection = snapshot.context.selection;
|
|
6509
6509
|
if (!selection || util_selectionPointToBlockOffset.isSelectionCollapsed(selection))
|
|
6510
6510
|
return !1;
|
|
6511
|
-
const selectionStartBlock =
|
|
6511
|
+
const selectionStartBlock = selector_isSelectingEntireBlocks.getSelectionStartBlock(snapshot), selectionEndBlock = selector_isSelectingEntireBlocks.getSelectionEndBlock(snapshot);
|
|
6512
6512
|
return !selectionStartBlock || !selectionEndBlock ? !1 : !selectionPoint.isTextBlock(snapshot.context, selectionStartBlock.node) && selectionPoint.isTextBlock(snapshot.context, selectionEndBlock.node) ? {
|
|
6513
6513
|
selection
|
|
6514
6514
|
} : !1;
|