@portabletext/editor 1.48.7 → 1.48.9
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 +20 -8
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/behavior.markdown.cjs +5 -5
- package/lib/_chunks-cjs/behavior.markdown.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +99 -68
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +7 -4
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs +41 -45
- package/lib/_chunks-cjs/selector.is-overlapping-selection.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +29 -23
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +3 -3
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs +15 -15
- package/lib/_chunks-cjs/util.selection-point-to-block-offset.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +258 -38
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +21 -10
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/behavior.markdown.js +5 -6
- package/lib/_chunks-es/behavior.markdown.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +75 -45
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +7 -4
- package/lib/_chunks-es/selector.get-text-before.js.map +1 -1
- package/lib/_chunks-es/selector.is-overlapping-selection.js +43 -47
- package/lib/_chunks-es/selector.is-overlapping-selection.js.map +1 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +30 -26
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -1
- package/lib/_chunks-es/util.selection-point-to-block-offset.js +15 -16
- package/lib/_chunks-es/util.selection-point-to-block-offset.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +258 -38
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.cts +5 -5
- package/lib/behaviors/index.d.ts +5 -5
- package/lib/index.cjs +45 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +44 -21
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +16 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.js +16 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +3 -3
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2 -6
- package/lib/selectors/index.d.ts +2 -6
- package/lib/selectors/index.js +5 -5
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +30 -24
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +37 -31
- package/lib/utils/index.d.ts +37 -31
- package/lib/utils/index.js +30 -24
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/behavior-actions/behavior.action.block.unset.ts +1 -1
- package/src/behavior-actions/behavior.action.decorator.add.ts +20 -5
- package/src/behaviors/behavior.abstract.decorator.ts +1 -1
- package/src/behaviors/behavior.abstract.delete.ts +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +2 -2
- package/src/behaviors/behavior.abstract.select.ts +16 -4
- package/src/behaviors/behavior.abstract.split.ts +9 -6
- package/src/behaviors/behavior.core.block-objects.ts +5 -5
- package/src/behaviors/behavior.core.insert-break.ts +16 -4
- package/src/behaviors/behavior.core.lists.ts +4 -6
- package/src/behaviors/behavior.decorator-pair.ts +13 -4
- package/src/behaviors/behavior.default.ts +1 -1
- package/src/behaviors/behavior.markdown.ts +5 -5
- package/src/converters/converter.portable-text.ts +1 -1
- package/src/converters/converter.text-html.ts +1 -1
- package/src/converters/converter.text-plain.ts +4 -4
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +10 -2
- package/src/editor/plugins/createWithSchemaTypes.ts +12 -19
- package/src/internal-utils/__tests__/dmpToOperations.test.ts +13 -12
- package/src/internal-utils/drag-selection.ts +16 -4
- package/src/internal-utils/event-position.ts +20 -8
- package/src/internal-utils/parse-blocks.ts +17 -5
- package/src/internal-utils/validateValue.ts +6 -6
- package/src/plugins/plugin.decorator-shortcut.ts +2 -2
- package/src/selectors/selector.get-active-annotations.ts +5 -2
- package/src/selectors/selector.get-active-list-item.ts +4 -3
- package/src/selectors/selector.get-active-style.ts +4 -3
- package/src/selectors/selector.get-anchor-text-block.ts +3 -6
- package/src/selectors/selector.get-block-offsets.ts +2 -2
- package/src/selectors/selector.get-caret-word-selection.ts +11 -5
- package/src/selectors/selector.get-selected-slice.ts +1 -1
- package/src/selectors/selector.get-selected-spans.ts +11 -15
- package/src/selectors/selector.get-selected-text-blocks.ts +3 -3
- package/src/selectors/selector.get-selection-text.ts +3 -3
- package/src/selectors/selector.get-text-before.ts +5 -2
- package/src/selectors/selector.get-trimmed-selection.ts +20 -14
- package/src/selectors/selector.is-active-annotation.ts +4 -2
- package/src/selectors/selector.is-active-decorator.test.ts +3 -3
- package/src/selectors/selector.is-at-the-end-of-block.ts +4 -1
- package/src/selectors/selector.is-at-the-start-of-block.ts +4 -1
- package/src/selectors/selector.is-point-after-selection.ts +7 -6
- package/src/selectors/selector.is-point-before-selection.ts +7 -6
- package/src/selectors/selector.is-selecting-entire-blocks.ts +8 -2
- package/src/selectors/selectors.ts +25 -28
- package/src/utils/util.block-offset-to-block-selection-point.ts +4 -4
- package/src/utils/util.block-offset-to-selection-point.ts +5 -5
- package/src/utils/util.block-offset.test.ts +219 -156
- package/src/utils/util.block-offset.ts +14 -17
- package/src/utils/util.block-offsets-to-selection.ts +5 -5
- package/src/utils/util.child-selection-point-to-block-offset.ts +7 -10
- package/src/utils/util.get-block-end-point.ts +15 -15
- package/src/utils/util.get-block-start-point.ts +13 -12
- package/src/utils/util.is-empty-text-block.ts +9 -8
- package/src/utils/util.selection-point-to-block-offset.ts +4 -4
- package/src/utils/util.slice-blocks.test.ts +178 -121
- package/src/utils/util.slice-blocks.ts +25 -24
- package/src/utils/util.split-text-block.ts +18 -12
- package/lib/_chunks-cjs/parse-blocks.cjs +0 -205
- package/lib/_chunks-cjs/parse-blocks.cjs.map +0 -1
- package/lib/_chunks-es/parse-blocks.js +0 -206
- package/lib/_chunks-es/parse-blocks.js.map +0 -1
- package/src/behavior-actions/behavior.guards.ts +0 -24
|
@@ -8,19 +8,18 @@ import isEqual from "lodash/isEqual.js";
|
|
|
8
8
|
import { Element, Text, Editor, Operation, Transforms, Path, Node, Range, Point, createEditor } from "slate";
|
|
9
9
|
import { setup, stateIn, fromCallback, assign, enqueueActions, emit, assertEvent, and, not, createActor } from "xstate";
|
|
10
10
|
import { unset, set, setIfMissing, insert, diffMatchPatch as diffMatchPatch$1, applyAll } from "@portabletext/patches";
|
|
11
|
-
import { isPortableTextTextBlock, isKeySegment, isPortableTextSpan as isPortableTextSpan$1, isPortableTextListBlock, defineType, defineField } from "@sanity/types";
|
|
12
11
|
import flatten from "lodash/flatten.js";
|
|
13
12
|
import isPlainObject from "lodash/isPlainObject.js";
|
|
14
13
|
import uniq from "lodash/uniq.js";
|
|
14
|
+
import { isTextBlock, parseBlock, sliceBlocks, parseAnnotation, blockOffsetToSpanSelectionPoint, parseInlineObject, isSpan, isListBlock, isEmptyTextBlock, getBlockEndPoint, getBlockStartPoint, getTextBlockText } from "./util.slice-blocks.js";
|
|
15
15
|
import getRandomValues from "get-random-values-esm";
|
|
16
|
-
import { parseBlock, parseAnnotation, isTextBlock, parseInlineObject } from "./parse-blocks.js";
|
|
17
|
-
import { sliceBlocks, blockOffsetToSpanSelectionPoint, isEmptyTextBlock, getBlockEndPoint, getBlockStartPoint, getTextBlockText } from "./util.slice-blocks.js";
|
|
18
16
|
import { htmlToBlocks } from "@portabletext/block-tools";
|
|
19
17
|
import { toHTML } from "@portabletext/to-html";
|
|
20
18
|
import { Schema } from "@sanity/schema";
|
|
21
19
|
import get from "lodash/get.js";
|
|
22
20
|
import isUndefined from "lodash/isUndefined.js";
|
|
23
21
|
import omitBy from "lodash/omitBy.js";
|
|
22
|
+
import { isKeySegment, defineType, defineField, isPortableTextSpan as isPortableTextSpan$1 } from "@sanity/types";
|
|
24
23
|
import omit from "lodash/omit.js";
|
|
25
24
|
import { selectionPointToBlockOffset, blockOffsetsToSelection } from "./util.selection-point-to-block-offset.js";
|
|
26
25
|
import { getTrimmedSelection, isActiveAnnotation, isActiveDecorator, getSelectedTextBlocks, isActiveListItem, isActiveStyle, isSelectingEntireBlocks, getActiveAnnotations } from "./selector.is-selecting-entire-blocks.js";
|
|
@@ -381,7 +380,9 @@ function validateValue(value, types, keyGenerator) {
|
|
|
381
380
|
}
|
|
382
381
|
}, !0;
|
|
383
382
|
}
|
|
384
|
-
return !blk._type &&
|
|
383
|
+
return !blk._type && isTextBlock({
|
|
384
|
+
schema: types
|
|
385
|
+
}, {
|
|
385
386
|
...blk,
|
|
386
387
|
_type: types.block.name
|
|
387
388
|
}) ? (resolution = {
|
|
@@ -2229,8 +2230,7 @@ const converterJson = {
|
|
|
2229
2230
|
snapshot,
|
|
2230
2231
|
event
|
|
2231
2232
|
}) => {
|
|
2232
|
-
|
|
2233
|
-
if (!selection)
|
|
2233
|
+
if (!(snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection))
|
|
2234
2234
|
return {
|
|
2235
2235
|
type: "serialization.failure",
|
|
2236
2236
|
mimeType: "application/x-portable-text",
|
|
@@ -2238,8 +2238,8 @@ const converterJson = {
|
|
|
2238
2238
|
reason: "No selection"
|
|
2239
2239
|
};
|
|
2240
2240
|
const blocks = sliceBlocks({
|
|
2241
|
-
|
|
2242
|
-
|
|
2241
|
+
context: snapshot.context,
|
|
2242
|
+
blocks: snapshot.context.value
|
|
2243
2243
|
});
|
|
2244
2244
|
return blocks.length === 0 ? {
|
|
2245
2245
|
type: "serialization.failure",
|
|
@@ -2296,8 +2296,7 @@ function createConverterTextHtml(legacySchema) {
|
|
|
2296
2296
|
snapshot,
|
|
2297
2297
|
event
|
|
2298
2298
|
}) => {
|
|
2299
|
-
|
|
2300
|
-
if (!selection)
|
|
2299
|
+
if (!(snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection))
|
|
2301
2300
|
return {
|
|
2302
2301
|
type: "serialization.failure",
|
|
2303
2302
|
mimeType: "text/html",
|
|
@@ -2305,8 +2304,8 @@ function createConverterTextHtml(legacySchema) {
|
|
|
2305
2304
|
reason: "No selection"
|
|
2306
2305
|
};
|
|
2307
2306
|
const blocks = sliceBlocks({
|
|
2308
|
-
|
|
2309
|
-
|
|
2307
|
+
context: snapshot.context,
|
|
2308
|
+
blocks: snapshot.context.value
|
|
2310
2309
|
}), html = toHTML(blocks, {
|
|
2311
2310
|
onMissingComponent: !1,
|
|
2312
2311
|
components: {
|
|
@@ -2362,24 +2361,21 @@ function createConverterTextPlain(legacySchema) {
|
|
|
2362
2361
|
serialize: ({
|
|
2363
2362
|
snapshot,
|
|
2364
2363
|
event
|
|
2365
|
-
}) => {
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
selection
|
|
2372
|
-
}).map((block) => isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
|
|
2364
|
+
}) => snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection ? {
|
|
2365
|
+
type: "serialization.success",
|
|
2366
|
+
data: sliceBlocks({
|
|
2367
|
+
context: snapshot.context,
|
|
2368
|
+
blocks: snapshot.context.value
|
|
2369
|
+
}).map((block) => isTextBlock(snapshot.context, block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
|
|
2373
2370
|
|
|
2374
2371
|
`),
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
};
|
|
2372
|
+
mimeType: "text/plain",
|
|
2373
|
+
originEvent: event.originEvent
|
|
2374
|
+
} : {
|
|
2375
|
+
type: "serialization.failure",
|
|
2376
|
+
mimeType: "text/plain",
|
|
2377
|
+
originEvent: event.originEvent,
|
|
2378
|
+
reason: "No selection"
|
|
2383
2379
|
},
|
|
2384
2380
|
deserialize: ({
|
|
2385
2381
|
snapshot,
|
|
@@ -3379,7 +3375,7 @@ const blockSetBehaviorActionImplementation = ({
|
|
|
3379
3375
|
const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(action.editor)).at(0);
|
|
3380
3376
|
if (!parsedBlock)
|
|
3381
3377
|
throw new Error(`Unable to parse block at ${JSON.stringify(action.at)}`);
|
|
3382
|
-
if (isTextBlock(context
|
|
3378
|
+
if (isTextBlock(context, parsedBlock)) {
|
|
3383
3379
|
const propsToRemove = action.props.filter((prop) => prop !== "_type"), updatedTextBlock = parseBlock({
|
|
3384
3380
|
context,
|
|
3385
3381
|
block: omit(parsedBlock, propsToRemove),
|
|
@@ -3625,11 +3621,17 @@ const decoratorAddActionImplementation = ({
|
|
|
3625
3621
|
action
|
|
3626
3622
|
}) => {
|
|
3627
3623
|
const editor = action.editor, mark = action.decorator, value = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), manualAnchor = action.at?.anchor ? blockOffsetToSpanSelectionPoint({
|
|
3628
|
-
|
|
3624
|
+
context: {
|
|
3625
|
+
...context,
|
|
3626
|
+
value
|
|
3627
|
+
},
|
|
3629
3628
|
blockOffset: action.at.anchor,
|
|
3630
3629
|
direction: "backward"
|
|
3631
3630
|
}) : void 0, manualFocus = action.at?.focus ? blockOffsetToSpanSelectionPoint({
|
|
3632
|
-
|
|
3631
|
+
context: {
|
|
3632
|
+
...context,
|
|
3633
|
+
value
|
|
3634
|
+
},
|
|
3633
3635
|
blockOffset: action.at.focus,
|
|
3634
3636
|
direction: "forward"
|
|
3635
3637
|
}) : void 0, manualSelection = manualAnchor && manualFocus ? {
|
|
@@ -3643,10 +3645,16 @@ const decoratorAddActionImplementation = ({
|
|
|
3643
3645
|
editor,
|
|
3644
3646
|
range: selection
|
|
3645
3647
|
}), anchorOffset = editorSelection ? selectionPointToBlockOffset({
|
|
3646
|
-
|
|
3648
|
+
context: {
|
|
3649
|
+
...context,
|
|
3650
|
+
value
|
|
3651
|
+
},
|
|
3647
3652
|
selectionPoint: editorSelection.anchor
|
|
3648
3653
|
}) : void 0, focusOffset = editorSelection ? selectionPointToBlockOffset({
|
|
3649
|
-
|
|
3654
|
+
context: {
|
|
3655
|
+
...context,
|
|
3656
|
+
value
|
|
3657
|
+
},
|
|
3650
3658
|
selectionPoint: editorSelection.focus
|
|
3651
3659
|
}) : void 0;
|
|
3652
3660
|
if (!anchorOffset || !focusOffset)
|
|
@@ -3659,7 +3667,10 @@ const decoratorAddActionImplementation = ({
|
|
|
3659
3667
|
hanging: !0
|
|
3660
3668
|
});
|
|
3661
3669
|
const newValue = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), newSelection = blockOffsetsToSelection({
|
|
3662
|
-
|
|
3670
|
+
context: {
|
|
3671
|
+
...context,
|
|
3672
|
+
value: newValue
|
|
3673
|
+
},
|
|
3663
3674
|
offsets: {
|
|
3664
3675
|
anchor: anchorOffset,
|
|
3665
3676
|
focus: focusOffset
|
|
@@ -4958,7 +4969,7 @@ function createWithSchemaTypes({
|
|
|
4958
4969
|
editorActor
|
|
4959
4970
|
}) {
|
|
4960
4971
|
return function(editor) {
|
|
4961
|
-
editor.isTextBlock = (value) =>
|
|
4972
|
+
editor.isTextBlock = (value) => isTextBlock(editorActor.getSnapshot().context, value), editor.isTextSpan = (value) => isSpan(editorActor.getSnapshot().context, value), editor.isListBlock = (value) => isListBlock(editorActor.getSnapshot().context, value), editor.isVoid = (element) => editorActor.getSnapshot().context.schema.block.name !== element._type && (editorActor.getSnapshot().context.schema.blockObjects.map((obj) => obj.name).includes(element._type) || editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type)), editor.isInline = (element) => editorActor.getSnapshot().context.schema.inlineObjects.map((obj) => obj.name).includes(element._type) && "__inline" in element && element.__inline === !0;
|
|
4962
4973
|
const {
|
|
4963
4974
|
normalizeNode
|
|
4964
4975
|
} = editor;
|
|
@@ -5866,7 +5877,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5866
5877
|
event
|
|
5867
5878
|
}) => {
|
|
5868
5879
|
const manualSelection = event.at ? blockOffsetsToSelection({
|
|
5869
|
-
|
|
5880
|
+
context: snapshot.context,
|
|
5870
5881
|
offsets: event.at
|
|
5871
5882
|
}) : null;
|
|
5872
5883
|
return manualSelection ? !isActiveDecorator(event.decorator)({
|
|
@@ -5890,7 +5901,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5890
5901
|
event
|
|
5891
5902
|
}) => {
|
|
5892
5903
|
const selection = blockOffsetsToSelection({
|
|
5893
|
-
|
|
5904
|
+
context: snapshot.context,
|
|
5894
5905
|
offsets: event.at
|
|
5895
5906
|
});
|
|
5896
5907
|
if (!selection)
|
|
@@ -5956,6 +5967,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5956
5967
|
} : !1;
|
|
5957
5968
|
},
|
|
5958
5969
|
actions: [({
|
|
5970
|
+
snapshot,
|
|
5959
5971
|
event
|
|
5960
5972
|
}, {
|
|
5961
5973
|
focusTextBlock
|
|
@@ -5964,7 +5976,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5964
5976
|
block: event.blocks[0],
|
|
5965
5977
|
placement: "auto",
|
|
5966
5978
|
select: "end"
|
|
5967
|
-
})] : isEmptyTextBlock(focusTextBlock.node) ? event.blocks.map((block, index) => raise({
|
|
5979
|
+
})] : isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => raise({
|
|
5968
5980
|
type: "insert.block",
|
|
5969
5981
|
block,
|
|
5970
5982
|
placement: index === 0 ? "auto" : "after",
|
|
@@ -6152,7 +6164,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6152
6164
|
const previousBlock = getPreviousBlock(snapshot);
|
|
6153
6165
|
if (!previousBlock)
|
|
6154
6166
|
return !1;
|
|
6155
|
-
const point = event.select === "end" ? getBlockEndPoint(
|
|
6167
|
+
const point = event.select === "end" ? getBlockEndPoint({
|
|
6168
|
+
context: snapshot.context,
|
|
6169
|
+
block: previousBlock
|
|
6170
|
+
}) : getBlockStartPoint({
|
|
6171
|
+
context: snapshot.context,
|
|
6172
|
+
block: previousBlock
|
|
6173
|
+
});
|
|
6156
6174
|
return {
|
|
6157
6175
|
selection: {
|
|
6158
6176
|
anchor: point,
|
|
@@ -6175,7 +6193,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6175
6193
|
const nextBlock = getNextBlock(snapshot);
|
|
6176
6194
|
if (!nextBlock)
|
|
6177
6195
|
return !1;
|
|
6178
|
-
const point = event.select === "end" ? getBlockEndPoint(
|
|
6196
|
+
const point = event.select === "end" ? getBlockEndPoint({
|
|
6197
|
+
context: snapshot.context,
|
|
6198
|
+
block: nextBlock
|
|
6199
|
+
}) : getBlockStartPoint({
|
|
6200
|
+
context: snapshot.context,
|
|
6201
|
+
block: nextBlock
|
|
6202
|
+
});
|
|
6179
6203
|
return {
|
|
6180
6204
|
selection: {
|
|
6181
6205
|
anchor: point,
|
|
@@ -6206,20 +6230,26 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6206
6230
|
}
|
|
6207
6231
|
});
|
|
6208
6232
|
if (focusTextBlock) {
|
|
6209
|
-
const blockEndPoint = getBlockEndPoint(
|
|
6233
|
+
const blockEndPoint = getBlockEndPoint({
|
|
6234
|
+
context: snapshot.context,
|
|
6235
|
+
block: focusTextBlock
|
|
6236
|
+
}), newTextBlockSelection = {
|
|
6210
6237
|
anchor: selectionEndPoint,
|
|
6211
6238
|
focus: blockEndPoint
|
|
6212
6239
|
}, newTextBlock = parseBlock({
|
|
6213
6240
|
block: sliceBlocks({
|
|
6214
|
-
|
|
6215
|
-
|
|
6241
|
+
context: {
|
|
6242
|
+
...snapshot.context,
|
|
6243
|
+
selection: newTextBlockSelection
|
|
6244
|
+
},
|
|
6245
|
+
blocks: [focusTextBlock.node]
|
|
6216
6246
|
}).at(0),
|
|
6217
6247
|
context: snapshot.context,
|
|
6218
6248
|
options: {
|
|
6219
6249
|
refreshKeys: !0
|
|
6220
6250
|
}
|
|
6221
6251
|
});
|
|
6222
|
-
return !newTextBlock || !isTextBlock(snapshot.context
|
|
6252
|
+
return !newTextBlock || !isTextBlock(snapshot.context, newTextBlock) ? !1 : {
|
|
6223
6253
|
newTextBlock,
|
|
6224
6254
|
newTextBlockSelection,
|
|
6225
6255
|
selection: {
|
|
@@ -6572,7 +6602,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6572
6602
|
return {
|
|
6573
6603
|
activeAnnotations: getActiveAnnotations(snapshot),
|
|
6574
6604
|
activeDecorators,
|
|
6575
|
-
textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context
|
|
6605
|
+
textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context, block) ? [getTextBlockText(block)] : [])
|
|
6576
6606
|
};
|
|
6577
6607
|
}
|
|
6578
6608
|
return !1;
|