@portabletext/editor 1.48.7 → 1.48.8
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 +121 -90
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-focus-inline-object.cjs +2 -2
- package/lib/_chunks-cjs/selector.get-focus-inline-object.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 +63 -47
- 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 -46
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/_chunks-es/selector.get-focus-inline-object.js +1 -2
- package/lib/_chunks-es/selector.get-focus-inline-object.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 +61 -46
- 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 +2552 -251
- package/lib/behaviors/index.d.ts +2552 -251
- package/lib/index.cjs +45 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2350 -51
- package/lib/index.d.ts +2350 -51
- 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.d.cts +2324 -24
- package/lib/plugins/index.d.ts +2324 -24
- package/lib/plugins/index.js +16 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.cjs +5 -5
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +2321 -28
- package/lib/selectors/index.d.ts +2321 -28
- package/lib/selectors/index.js +5 -6
- 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 +2350 -44
- package/lib/utils/index.d.ts +2350 -44
- package/lib/utils/index.js +30 -24
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -2
- 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,26 +8,24 @@ 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, getFocusTextBlock, getPreviousBlock, getNextBlock, getFocusBlockObject, getFocusSpan, isSelectionCollapsed, isOverlappingSelection, getSelectedBlocks, isSelectionExpanded } from "./selector.is-overlapping-selection.js";
|
|
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";
|
|
27
26
|
import { DOMEditor } from "slate-dom";
|
|
28
27
|
import startCase from "lodash.startcase";
|
|
29
28
|
import { defineBehavior, raise, coreBehaviors } from "./behavior.core.js";
|
|
30
|
-
import { getFocusTextBlock, getPreviousBlock, getNextBlock, getFocusBlockObject, getFocusSpan, isSelectionCollapsed, isOverlappingSelection, getSelectedBlocks, isSelectionExpanded } from "./selector.is-overlapping-selection.js";
|
|
31
29
|
import { getSelectionStartPoint, getSelectionEndPoint } from "./util.get-selection-start-point.js";
|
|
32
30
|
import { Subject } from "rxjs";
|
|
33
31
|
import { useEffectEvent } from "use-effect-event";
|
|
@@ -381,7 +379,9 @@ function validateValue(value, types, keyGenerator) {
|
|
|
381
379
|
}
|
|
382
380
|
}, !0;
|
|
383
381
|
}
|
|
384
|
-
return !blk._type &&
|
|
382
|
+
return !blk._type && isTextBlock({
|
|
383
|
+
schema: types
|
|
384
|
+
}, {
|
|
385
385
|
...blk,
|
|
386
386
|
_type: types.block.name
|
|
387
387
|
}) ? (resolution = {
|
|
@@ -2229,8 +2229,7 @@ const converterJson = {
|
|
|
2229
2229
|
snapshot,
|
|
2230
2230
|
event
|
|
2231
2231
|
}) => {
|
|
2232
|
-
|
|
2233
|
-
if (!selection)
|
|
2232
|
+
if (!(snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection))
|
|
2234
2233
|
return {
|
|
2235
2234
|
type: "serialization.failure",
|
|
2236
2235
|
mimeType: "application/x-portable-text",
|
|
@@ -2238,8 +2237,8 @@ const converterJson = {
|
|
|
2238
2237
|
reason: "No selection"
|
|
2239
2238
|
};
|
|
2240
2239
|
const blocks = sliceBlocks({
|
|
2241
|
-
|
|
2242
|
-
|
|
2240
|
+
context: snapshot.context,
|
|
2241
|
+
blocks: snapshot.context.value
|
|
2243
2242
|
});
|
|
2244
2243
|
return blocks.length === 0 ? {
|
|
2245
2244
|
type: "serialization.failure",
|
|
@@ -2296,8 +2295,7 @@ function createConverterTextHtml(legacySchema) {
|
|
|
2296
2295
|
snapshot,
|
|
2297
2296
|
event
|
|
2298
2297
|
}) => {
|
|
2299
|
-
|
|
2300
|
-
if (!selection)
|
|
2298
|
+
if (!(snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection))
|
|
2301
2299
|
return {
|
|
2302
2300
|
type: "serialization.failure",
|
|
2303
2301
|
mimeType: "text/html",
|
|
@@ -2305,8 +2303,8 @@ function createConverterTextHtml(legacySchema) {
|
|
|
2305
2303
|
reason: "No selection"
|
|
2306
2304
|
};
|
|
2307
2305
|
const blocks = sliceBlocks({
|
|
2308
|
-
|
|
2309
|
-
|
|
2306
|
+
context: snapshot.context,
|
|
2307
|
+
blocks: snapshot.context.value
|
|
2310
2308
|
}), html = toHTML(blocks, {
|
|
2311
2309
|
onMissingComponent: !1,
|
|
2312
2310
|
components: {
|
|
@@ -2362,24 +2360,21 @@ function createConverterTextPlain(legacySchema) {
|
|
|
2362
2360
|
serialize: ({
|
|
2363
2361
|
snapshot,
|
|
2364
2362
|
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(`
|
|
2363
|
+
}) => snapshot.beta.internalDrag?.origin.selection ?? snapshot.context.selection ? {
|
|
2364
|
+
type: "serialization.success",
|
|
2365
|
+
data: sliceBlocks({
|
|
2366
|
+
context: snapshot.context,
|
|
2367
|
+
blocks: snapshot.context.value
|
|
2368
|
+
}).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
2369
|
|
|
2374
2370
|
`),
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
};
|
|
2371
|
+
mimeType: "text/plain",
|
|
2372
|
+
originEvent: event.originEvent
|
|
2373
|
+
} : {
|
|
2374
|
+
type: "serialization.failure",
|
|
2375
|
+
mimeType: "text/plain",
|
|
2376
|
+
originEvent: event.originEvent,
|
|
2377
|
+
reason: "No selection"
|
|
2383
2378
|
},
|
|
2384
2379
|
deserialize: ({
|
|
2385
2380
|
snapshot,
|
|
@@ -3379,7 +3374,7 @@ const blockSetBehaviorActionImplementation = ({
|
|
|
3379
3374
|
const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(action.editor)).at(0);
|
|
3380
3375
|
if (!parsedBlock)
|
|
3381
3376
|
throw new Error(`Unable to parse block at ${JSON.stringify(action.at)}`);
|
|
3382
|
-
if (isTextBlock(context
|
|
3377
|
+
if (isTextBlock(context, parsedBlock)) {
|
|
3383
3378
|
const propsToRemove = action.props.filter((prop) => prop !== "_type"), updatedTextBlock = parseBlock({
|
|
3384
3379
|
context,
|
|
3385
3380
|
block: omit(parsedBlock, propsToRemove),
|
|
@@ -3625,11 +3620,17 @@ const decoratorAddActionImplementation = ({
|
|
|
3625
3620
|
action
|
|
3626
3621
|
}) => {
|
|
3627
3622
|
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
|
-
|
|
3623
|
+
context: {
|
|
3624
|
+
...context,
|
|
3625
|
+
value
|
|
3626
|
+
},
|
|
3629
3627
|
blockOffset: action.at.anchor,
|
|
3630
3628
|
direction: "backward"
|
|
3631
3629
|
}) : void 0, manualFocus = action.at?.focus ? blockOffsetToSpanSelectionPoint({
|
|
3632
|
-
|
|
3630
|
+
context: {
|
|
3631
|
+
...context,
|
|
3632
|
+
value
|
|
3633
|
+
},
|
|
3633
3634
|
blockOffset: action.at.focus,
|
|
3634
3635
|
direction: "forward"
|
|
3635
3636
|
}) : void 0, manualSelection = manualAnchor && manualFocus ? {
|
|
@@ -3643,10 +3644,16 @@ const decoratorAddActionImplementation = ({
|
|
|
3643
3644
|
editor,
|
|
3644
3645
|
range: selection
|
|
3645
3646
|
}), anchorOffset = editorSelection ? selectionPointToBlockOffset({
|
|
3646
|
-
|
|
3647
|
+
context: {
|
|
3648
|
+
...context,
|
|
3649
|
+
value
|
|
3650
|
+
},
|
|
3647
3651
|
selectionPoint: editorSelection.anchor
|
|
3648
3652
|
}) : void 0, focusOffset = editorSelection ? selectionPointToBlockOffset({
|
|
3649
|
-
|
|
3653
|
+
context: {
|
|
3654
|
+
...context,
|
|
3655
|
+
value
|
|
3656
|
+
},
|
|
3650
3657
|
selectionPoint: editorSelection.focus
|
|
3651
3658
|
}) : void 0;
|
|
3652
3659
|
if (!anchorOffset || !focusOffset)
|
|
@@ -3659,7 +3666,10 @@ const decoratorAddActionImplementation = ({
|
|
|
3659
3666
|
hanging: !0
|
|
3660
3667
|
});
|
|
3661
3668
|
const newValue = fromSlateValue(editor.children, context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(editor)), newSelection = blockOffsetsToSelection({
|
|
3662
|
-
|
|
3669
|
+
context: {
|
|
3670
|
+
...context,
|
|
3671
|
+
value: newValue
|
|
3672
|
+
},
|
|
3663
3673
|
offsets: {
|
|
3664
3674
|
anchor: anchorOffset,
|
|
3665
3675
|
focus: focusOffset
|
|
@@ -4958,7 +4968,7 @@ function createWithSchemaTypes({
|
|
|
4958
4968
|
editorActor
|
|
4959
4969
|
}) {
|
|
4960
4970
|
return function(editor) {
|
|
4961
|
-
editor.isTextBlock = (value) =>
|
|
4971
|
+
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
4972
|
const {
|
|
4963
4973
|
normalizeNode
|
|
4964
4974
|
} = editor;
|
|
@@ -5866,7 +5876,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5866
5876
|
event
|
|
5867
5877
|
}) => {
|
|
5868
5878
|
const manualSelection = event.at ? blockOffsetsToSelection({
|
|
5869
|
-
|
|
5879
|
+
context: snapshot.context,
|
|
5870
5880
|
offsets: event.at
|
|
5871
5881
|
}) : null;
|
|
5872
5882
|
return manualSelection ? !isActiveDecorator(event.decorator)({
|
|
@@ -5890,7 +5900,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5890
5900
|
event
|
|
5891
5901
|
}) => {
|
|
5892
5902
|
const selection = blockOffsetsToSelection({
|
|
5893
|
-
|
|
5903
|
+
context: snapshot.context,
|
|
5894
5904
|
offsets: event.at
|
|
5895
5905
|
});
|
|
5896
5906
|
if (!selection)
|
|
@@ -5956,6 +5966,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5956
5966
|
} : !1;
|
|
5957
5967
|
},
|
|
5958
5968
|
actions: [({
|
|
5969
|
+
snapshot,
|
|
5959
5970
|
event
|
|
5960
5971
|
}, {
|
|
5961
5972
|
focusTextBlock
|
|
@@ -5964,7 +5975,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
5964
5975
|
block: event.blocks[0],
|
|
5965
5976
|
placement: "auto",
|
|
5966
5977
|
select: "end"
|
|
5967
|
-
})] : isEmptyTextBlock(focusTextBlock.node) ? event.blocks.map((block, index) => raise({
|
|
5978
|
+
})] : isEmptyTextBlock(snapshot.context, focusTextBlock.node) ? event.blocks.map((block, index) => raise({
|
|
5968
5979
|
type: "insert.block",
|
|
5969
5980
|
block,
|
|
5970
5981
|
placement: index === 0 ? "auto" : "after",
|
|
@@ -6152,7 +6163,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6152
6163
|
const previousBlock = getPreviousBlock(snapshot);
|
|
6153
6164
|
if (!previousBlock)
|
|
6154
6165
|
return !1;
|
|
6155
|
-
const point = event.select === "end" ? getBlockEndPoint(
|
|
6166
|
+
const point = event.select === "end" ? getBlockEndPoint({
|
|
6167
|
+
context: snapshot.context,
|
|
6168
|
+
block: previousBlock
|
|
6169
|
+
}) : getBlockStartPoint({
|
|
6170
|
+
context: snapshot.context,
|
|
6171
|
+
block: previousBlock
|
|
6172
|
+
});
|
|
6156
6173
|
return {
|
|
6157
6174
|
selection: {
|
|
6158
6175
|
anchor: point,
|
|
@@ -6175,7 +6192,13 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6175
6192
|
const nextBlock = getNextBlock(snapshot);
|
|
6176
6193
|
if (!nextBlock)
|
|
6177
6194
|
return !1;
|
|
6178
|
-
const point = event.select === "end" ? getBlockEndPoint(
|
|
6195
|
+
const point = event.select === "end" ? getBlockEndPoint({
|
|
6196
|
+
context: snapshot.context,
|
|
6197
|
+
block: nextBlock
|
|
6198
|
+
}) : getBlockStartPoint({
|
|
6199
|
+
context: snapshot.context,
|
|
6200
|
+
block: nextBlock
|
|
6201
|
+
});
|
|
6179
6202
|
return {
|
|
6180
6203
|
selection: {
|
|
6181
6204
|
anchor: point,
|
|
@@ -6206,20 +6229,26 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6206
6229
|
}
|
|
6207
6230
|
});
|
|
6208
6231
|
if (focusTextBlock) {
|
|
6209
|
-
const blockEndPoint = getBlockEndPoint(
|
|
6232
|
+
const blockEndPoint = getBlockEndPoint({
|
|
6233
|
+
context: snapshot.context,
|
|
6234
|
+
block: focusTextBlock
|
|
6235
|
+
}), newTextBlockSelection = {
|
|
6210
6236
|
anchor: selectionEndPoint,
|
|
6211
6237
|
focus: blockEndPoint
|
|
6212
6238
|
}, newTextBlock = parseBlock({
|
|
6213
6239
|
block: sliceBlocks({
|
|
6214
|
-
|
|
6215
|
-
|
|
6240
|
+
context: {
|
|
6241
|
+
...snapshot.context,
|
|
6242
|
+
selection: newTextBlockSelection
|
|
6243
|
+
},
|
|
6244
|
+
blocks: [focusTextBlock.node]
|
|
6216
6245
|
}).at(0),
|
|
6217
6246
|
context: snapshot.context,
|
|
6218
6247
|
options: {
|
|
6219
6248
|
refreshKeys: !0
|
|
6220
6249
|
}
|
|
6221
6250
|
});
|
|
6222
|
-
return !newTextBlock || !isTextBlock(snapshot.context
|
|
6251
|
+
return !newTextBlock || !isTextBlock(snapshot.context, newTextBlock) ? !1 : {
|
|
6223
6252
|
newTextBlock,
|
|
6224
6253
|
newTextBlockSelection,
|
|
6225
6254
|
selection: {
|
|
@@ -6572,7 +6601,7 @@ const EditorContext = createGloballyScopedContext("@portabletext/editor/context/
|
|
|
6572
6601
|
return {
|
|
6573
6602
|
activeAnnotations: getActiveAnnotations(snapshot),
|
|
6574
6603
|
activeDecorators,
|
|
6575
|
-
textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context
|
|
6604
|
+
textRuns: event.data.flatMap((block) => isTextBlock(snapshot.context, block) ? [getTextBlockText(block)] : [])
|
|
6576
6605
|
};
|
|
6577
6606
|
}
|
|
6578
6607
|
return !1;
|