@portabletext/editor 8.1.1 → 8.1.3
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/README.md +3 -3
- package/lib/{behavior.types.action-C0XDEQnB.d.ts → behavior.types.action-DbwK30_J.d.ts} +52 -25
- package/lib/behavior.types.action-DbwK30_J.d.ts.map +1 -0
- package/lib/behaviors/index.d.ts +1 -1
- package/lib/{get-container-D2pN5Npr.js → get-container-CXdmRdiX.js} +3 -3
- package/lib/{get-container-D2pN5Npr.js.map → get-container-CXdmRdiX.js.map} +1 -1
- package/lib/{get-parent-DgaKcy8-.js → get-parent-BLzi7eLr.js} +39 -14
- package/lib/get-parent-BLzi7eLr.js.map +1 -0
- package/lib/{get-path-sub-schema-Dd0QYZ0m.js → get-path-sub-schema-DsN1qF_l.js} +9 -5
- package/lib/get-path-sub-schema-DsN1qF_l.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +421 -396
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +1 -1
- package/lib/{selector.is-selecting-entire-blocks-BFhnnkHf.js → selector.is-selecting-entire-blocks-BHVYIXbI.js} +8 -5
- package/lib/selector.is-selecting-entire-blocks-BHVYIXbI.js.map +1 -0
- package/lib/selectors/index.d.ts +1 -1
- package/lib/selectors/index.js +4 -4
- package/lib/traversal/index.d.ts +9 -6
- package/lib/traversal/index.d.ts.map +1 -1
- package/lib/traversal/index.js +3 -3
- package/lib/{util.is-equal-selections-BdK98okY.js → util.is-equal-selections-sCQib0IC.js} +2 -2
- package/lib/{util.is-equal-selections-BdK98okY.js.map → util.is-equal-selections-sCQib0IC.js.map} +1 -1
- package/lib/{util.slice-blocks-_ElaB53f.js → util.slice-blocks-B-iKFEG7.js} +43 -56
- package/lib/util.slice-blocks-B-iKFEG7.js.map +1 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +4 -8
- package/lib/utils/index.js.map +1 -1
- package/package.json +2 -3
- package/lib/behavior.types.action-C0XDEQnB.d.ts.map +0 -1
- package/lib/get-parent-DgaKcy8-.js.map +0 -1
- package/lib/get-path-sub-schema-Dd0QYZ0m.js.map +0 -1
- package/lib/selector.is-selecting-entire-blocks-BFhnnkHf.js.map +0 -1
- package/lib/util.slice-blocks-_ElaB53f.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.slice-blocks-B-iKFEG7.js","names":[],"sources":["../src/utils/util.child-text-offset.ts","../src/utils/util.block-offset.ts","../src/utils/util.is-equal-path-segments.ts","../src/utils/util.is-equal-paths.ts","../src/utils/util.is-equal-selection-points.ts","../src/utils/util.selection-point.ts","../src/utils/util.get-block-end-point.ts","../src/utils/util.get-block-start-point.ts","../src/utils/util.is-selection-collapsed.ts","../src/utils/util.get-selection-end-point.ts","../src/utils/util.get-selection-start-point.ts","../src/utils/key-generator.ts","../src/utils/parse-blocks.ts","../src/utils/util.slice-blocks.ts"],"sourcesContent":["/**\n * Pure text-offset arithmetic over a node's children array, shared by\n * the snapshot-aware block-offset utils (`util.block-offset.ts`) and\n * the schema-free point transform (`engine/point/transform-point.ts`).\n * Span-ness is the caller's concern, expressed as an accessor that\n * returns the child's text when the child occupies text offsets and\n * `undefined` when it does not (inline objects, blocks).\n */\n\n/**\n * The text offset of `(childKey, offsetInChild)` within `children`:\n * the total text of the children before that child, plus the offset\n * into it. `undefined` when the child is missing or carries no text.\n */\nexport function textOffsetOfChild(\n children: ReadonlyArray<unknown>,\n getSpanText: (child: unknown) => string | undefined,\n childKey: string,\n offsetInChild: number,\n): number | undefined {\n let precedingTextLength = 0\n\n for (const child of children) {\n const text = getSpanText(child)\n if (keyOf(child) === childKey) {\n return text === undefined\n ? undefined\n : precedingTextLength + offsetInChild\n }\n if (text !== undefined) {\n precedingTextLength += text.length\n }\n }\n\n return undefined\n}\n\n/**\n * The child and child-local offset at `textOffset` within `children`.\n * Forward-boundary convention: an offset landing exactly on a span\n * boundary stays at the end of the earlier span. `undefined` when the\n * offset lies beyond the children's total text.\n */\nexport function childAtTextOffset(\n children: ReadonlyArray<unknown>,\n getSpanText: (child: unknown) => string | undefined,\n textOffset: number,\n): {key: string; offset: number} | undefined {\n let remainingOffset = textOffset\n\n for (const child of children) {\n const text = getSpanText(child)\n if (text === undefined) {\n continue\n }\n if (remainingOffset <= text.length) {\n const key = keyOf(child)\n return key === undefined ? undefined : {key, offset: remainingOffset}\n }\n remainingOffset -= text.length\n }\n\n return undefined\n}\n\nfunction keyOf(child: unknown): string | undefined {\n if (child !== null && typeof child === 'object' && '_key' in child) {\n const key = (child as {_key: unknown})._key\n return typeof key === 'string' ? key : undefined\n }\n return undefined\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport {getNode} from '../traversal/get-node'\nimport {getParent} from '../traversal/get-parent'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport type {ChildPath} from '../types/paths'\nimport {childAtTextOffset, textOffsetOfChild} from './util.child-text-offset'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\n/**\n * @public\n */\nexport function blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}) {\n const blockEntry = getNode(snapshot, blockOffset.path)\n\n if (!blockEntry || !isTextBlock(snapshot.context, blockEntry.node)) {\n return undefined\n }\n\n const block = blockEntry.node\n const blockPath = blockEntry.path\n\n if (direction === 'forward') {\n const placed = childAtTextOffset(\n block.children,\n (child) =>\n isSpan(snapshot.context, child as (typeof block.children)[number])\n ? (child as {text: string}).text\n : undefined,\n blockOffset.offset,\n )\n return placed\n ? {\n path: [\n ...blockPath,\n 'children',\n {_key: placed.key},\n ] satisfies ChildPath,\n offset: placed.offset,\n }\n : undefined\n }\n\n let offsetLeft = blockOffset.offset\n let selectionPoint: {path: ChildPath; offset: number} | undefined\n let skippedInlineObject = false\n\n for (const child of block.children) {\n if (!isSpan(snapshot.context, child)) {\n skippedInlineObject = true\n continue\n }\n\n if (offsetLeft === 0 && selectionPoint && !skippedInlineObject) {\n // A boundary offset stays at the end of the previous span unless an\n // inline object was skipped, in which case falling through to the\n // `offsetLeft <= child.text.length` branch lands the point at the\n // start of this span instead.\n break\n }\n\n if (offsetLeft > child.text.length) {\n offsetLeft -= child.text.length\n continue\n }\n\n if (offsetLeft <= child.text.length) {\n selectionPoint = {\n path: [...blockPath, 'children', {_key: child._key}],\n offset: offsetLeft,\n }\n\n offsetLeft -= child.text.length\n\n if (offsetLeft !== 0) {\n break\n }\n }\n }\n\n return selectionPoint\n}\n\n/**\n * @public\n */\nexport function spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint,\n}: {\n snapshot: TraversalSnapshot\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const spanSegment = selectionPoint.path.at(-1)\n\n if (!isKeyedSegment(spanSegment)) {\n return undefined\n }\n\n const textBlock = getParent(snapshot, selectionPoint.path, {\n match: (node) => isTextBlock({schema: snapshot.context.schema}, node),\n })\n\n if (!textBlock) {\n return undefined\n }\n\n const offset = textOffsetOfChild(\n textBlock.node.children,\n (child) =>\n isSpan(\n snapshot.context,\n child as (typeof textBlock.node.children)[number],\n )\n ? (child as {text: string}).text\n : undefined,\n spanSegment._key,\n selectionPoint.offset,\n )\n\n return offset === undefined ? undefined : {path: textBlock.path, offset}\n}\n","import type {PathSegment} from '../types/paths'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\nexport function isEqualPathSegments(\n segA: PathSegment | undefined,\n segB: PathSegment | undefined,\n): boolean {\n if (segA === segB) {\n return true\n }\n\n if (segA === undefined || segB === undefined) {\n return false\n }\n\n if (\n (typeof segA === 'string' || typeof segA === 'number') &&\n (typeof segB === 'string' || typeof segB === 'number')\n ) {\n return segA === segB\n }\n\n if (isKeyedSegment(segA) && isKeyedSegment(segB)) {\n return segA._key === segB._key\n }\n\n if (Array.isArray(segA) && Array.isArray(segB)) {\n return segA[0] === segB[0] && segA[1] === segB[1]\n }\n\n return false\n}\n","import type {Path} from '../types/paths'\nimport {isEqualPathSegments} from './util.is-equal-path-segments'\n\n/**\n * @public\n */\nexport function isEqualPaths(a: Path, b: Path): boolean {\n if (a.length !== b.length) {\n return false\n }\n\n for (let i = 0; i < a.length; i++) {\n if (!isEqualPathSegments(a[i], b[i])) {\n return false\n }\n }\n\n return true\n}\n","import type {EditorSelectionPoint} from '../types/editor'\nimport {isEqualPaths} from './util.is-equal-paths'\n\n/**\n * @public\n */\nexport function isEqualSelectionPoints(\n a: EditorSelectionPoint,\n b: EditorSelectionPoint,\n) {\n return a.offset === b.offset && isEqualPaths(a.path, b.path)\n}\n","import type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\nexport function getBlockKeyFromSelectionPoint(point: EditorSelectionPoint) {\n const blockPathSegment = point.path.at(0)\n\n if (isKeyedSegment(blockPathSegment)) {\n return blockPathSegment._key\n }\n\n return undefined\n}\n\nexport function getChildKeyFromSelectionPoint(point: EditorSelectionPoint) {\n const childPathSegment = point.path.at(2)\n\n if (isKeyedSegment(childPathSegment)) {\n return childPathSegment._key\n }\n\n return undefined\n}\n","import {isSpan, isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport function getBlockEndPoint({\n context,\n block,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: {\n node: PortableTextBlock\n path: BlockPath\n }\n}): EditorSelectionPoint {\n if (isTextBlock(context, block.node)) {\n const lastChild = block.node.children[block.node.children.length - 1]\n\n if (lastChild) {\n return {\n path: [...block.path, 'children', {_key: lastChild._key}],\n offset: isSpan(context, lastChild) ? lastChild.text.length : 0,\n }\n }\n }\n\n return {\n path: block.path,\n offset: 0,\n }\n}\n","import {isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * @public\n */\nexport function getBlockStartPoint({\n context,\n block,\n}: {\n context: Pick<EditorContext, 'schema'>\n block: {\n node: PortableTextBlock\n path: BlockPath\n }\n}): EditorSelectionPoint {\n if (isTextBlock(context, block.node)) {\n const firstChild = block.node.children[0]\n return {\n path: [...block.path, 'children', {_key: firstChild?._key ?? ''}],\n offset: 0,\n }\n }\n\n return {\n path: block.path,\n offset: 0,\n }\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualPaths} from './util.is-equal-paths'\n\n/**\n * @public\n */\nexport function isSelectionCollapsed(selection: EditorSelection) {\n if (!selection) {\n return false\n }\n\n return (\n isEqualPaths(selection.anchor.path, selection.focus.path) &&\n selection.anchor.offset === selection.focus.offset\n )\n}\n","import type {EditorSelection, EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport function getSelectionEndPoint<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n TEditorSelectionPoint extends EditorSelectionPoint | null =\n TEditorSelection extends NonNullable<EditorSelection>\n ? EditorSelectionPoint\n : null,\n>(selection: TEditorSelection): TEditorSelectionPoint {\n if (!selection) {\n return null as TEditorSelectionPoint\n }\n\n return (\n selection.backward ? selection.anchor : selection.focus\n ) as TEditorSelectionPoint\n}\n","import type {EditorSelection, EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport function getSelectionStartPoint<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n TEditorSelectionPoint extends EditorSelectionPoint | null =\n TEditorSelection extends NonNullable<EditorSelection>\n ? EditorSelectionPoint\n : null,\n>(selection: TEditorSelection): TEditorSelectionPoint {\n if (!selection) {\n return null as TEditorSelectionPoint\n }\n\n return (\n selection.backward ? selection.focus : selection.anchor\n ) as TEditorSelectionPoint\n}\n","/**\n * @public\n */\nexport const defaultKeyGenerator = (): string => randomKey(12)\n\nconst getByteHexTable = (() => {\n let table: any[]\n return () => {\n if (table) {\n return table\n }\n\n table = []\n for (let i = 0; i < 256; ++i) {\n table[i] = (i + 0x100).toString(16).slice(1)\n }\n return table\n }\n})()\n\n// WHATWG crypto RNG - https://w3c.github.io/webcrypto/Overview.html\nfunction whatwgRNG(length = 16) {\n const rnds8 = new Uint8Array(length)\n crypto.getRandomValues(rnds8)\n return rnds8\n}\n\nfunction randomKey(length?: number): string {\n const table = getByteHexTable()\n return whatwgRNG(length)\n .reduce((str, n) => str + table[n], '')\n .slice(0, length)\n}\n","import {\n getSubSchema,\n isSpan,\n type FieldDefinition,\n type OfDefinition,\n type PortableTextBlock,\n type PortableTextObject,\n type PortableTextSpan,\n type PortableTextTextBlock,\n type Schema,\n type TypedObject,\n} from '@portabletext/schema'\nimport {isRecord, isTypedObject} from './asserters'\n\n/**\n * `strict` validates and normalizes against the schema; use it at the\n * operation gate. `lenient` trusts the shape and defers validation to that\n * gate; use it at deserialization boundaries (converters, splitting,\n * slicing, merging).\n */\nexport type ParseProfile = 'strict' | 'lenient'\n\nconst blockProfiles: Record<\n ParseProfile,\n {normalize: boolean; removeUnusedMarkDefs: boolean; validateFields: boolean}\n> = {\n strict: {normalize: true, removeUnusedMarkDefs: true, validateFields: true},\n lenient: {\n normalize: false,\n removeUnusedMarkDefs: true,\n validateFields: false,\n },\n}\n\nconst fieldProfiles: Record<ParseProfile, {validateFields: boolean}> = {\n strict: {validateFields: true},\n lenient: {validateFields: false},\n}\n\nexport function parseBlocks({\n schema,\n keyGenerator,\n blocks,\n profile,\n}: {\n schema: Schema\n keyGenerator: () => string\n blocks: unknown\n profile: ParseProfile\n}): Array<PortableTextBlock> {\n if (!Array.isArray(blocks)) {\n return []\n }\n\n const options = blockProfiles[profile]\n\n return blocks.flatMap((block) => {\n const parsedBlock = parseBlockInternal({\n schema,\n keyGenerator,\n block,\n options,\n })\n\n return parsedBlock ? [parsedBlock] : []\n })\n}\n\nexport function parseBlock({\n schema,\n keyGenerator,\n block,\n profile,\n}: {\n schema: Schema\n keyGenerator: () => string\n block: unknown\n profile: ParseProfile\n}): PortableTextBlock | undefined {\n return parseBlockInternal({\n schema,\n keyGenerator,\n block,\n options: blockProfiles[profile],\n })\n}\n\nexport function parseSpan({\n span,\n schema,\n keyGenerator,\n markDefKeys,\n profile,\n}: {\n span: unknown\n schema: Schema\n keyGenerator: () => string\n markDefKeys: Set<string>\n profile: ParseProfile\n}): PortableTextSpan | undefined {\n return parseSpanInternal({\n span,\n schema,\n keyGenerator,\n markDefKeys,\n options: fieldProfiles[profile],\n })\n}\n\nexport function parseInlineObject({\n inlineObject,\n schema,\n keyGenerator,\n profile,\n}: {\n inlineObject: unknown\n schema: Schema\n keyGenerator: () => string\n profile: ParseProfile\n}): PortableTextObject | undefined {\n return parseInlineObjectInternal({\n inlineObject,\n schema,\n keyGenerator,\n options: fieldProfiles[profile],\n })\n}\n\nexport function parseChild({\n child,\n schema,\n keyGenerator,\n markDefKeys,\n profile,\n}: {\n child: unknown\n schema: Schema\n keyGenerator: () => string\n markDefKeys: Set<string>\n profile: ParseProfile\n}): PortableTextSpan | PortableTextObject | undefined {\n return parseChildInternal({\n child,\n schema,\n keyGenerator,\n markDefKeys,\n options: fieldProfiles[profile],\n })\n}\n\nexport function parseMarkDefs({\n schema,\n keyGenerator,\n markDefs,\n profile,\n}: {\n schema: Schema\n keyGenerator: () => string\n markDefs: unknown\n profile: ParseProfile\n}): {\n markDefs: Array<PortableTextObject>\n markDefKeys: Set<string>\n} {\n return parseMarkDefsInternal({\n schema,\n keyGenerator,\n markDefs,\n options: fieldProfiles[profile],\n })\n}\n\nfunction parseBlockInternal({\n schema,\n keyGenerator,\n block,\n options,\n}: {\n schema: Schema\n keyGenerator: () => string\n block: unknown\n options: {\n normalize: boolean\n removeUnusedMarkDefs: boolean\n validateFields: boolean\n }\n}): PortableTextBlock | undefined {\n return (\n parseTextBlock({block, schema, keyGenerator, options}) ??\n parseBlockObject({blockObject: block, schema, keyGenerator, options})\n )\n}\n\nfunction parseBlockObject({\n blockObject,\n schema,\n keyGenerator,\n options,\n}: {\n blockObject: unknown\n schema: Schema\n keyGenerator: () => string\n options: {validateFields: boolean}\n}): PortableTextObject | undefined {\n if (!isTypedObject(blockObject)) {\n return undefined\n }\n\n const schemaType = schema.blockObjects.find(\n ({name}) => name === blockObject._type,\n )\n\n if (!schemaType) {\n return undefined\n }\n\n return parseObject({\n object: blockObject,\n schema,\n keyGenerator,\n schemaType,\n options,\n })\n}\n\nfunction parseTextBlock({\n block,\n schema,\n keyGenerator,\n options,\n}: {\n block: unknown\n schema: Schema\n keyGenerator: () => string\n options: {\n normalize: boolean\n removeUnusedMarkDefs: boolean\n validateFields: boolean\n }\n}): PortableTextTextBlock | undefined {\n if (!isTypedObject(block)) {\n return undefined\n }\n\n if (block._type !== schema.block.name) {\n return undefined\n }\n\n const customFields: Record<string, unknown> = {}\n\n for (const key of Object.keys(block)) {\n if (\n key === '_type' ||\n key === '_key' ||\n key === 'children' ||\n key === 'markDefs' ||\n key === 'style' ||\n key === 'listItem' ||\n key === 'level'\n ) {\n continue\n }\n\n if (options.validateFields) {\n if ((schema.block.fields ?? []).some((f) => f.name === key)) {\n customFields[key] = block[key]\n }\n } else {\n customFields[key] = block[key]\n }\n }\n\n const _key =\n typeof block['_key'] === 'string' ? block['_key'] : keyGenerator()\n\n const {markDefs, markDefKeys} = parseMarkDefsInternal({\n schema,\n keyGenerator,\n markDefs: block['markDefs'],\n options,\n })\n\n const unparsedChildren: Array<unknown> = Array.isArray(block['children'])\n ? block['children']\n : []\n\n const parsedChildren = unparsedChildren\n .map((child) =>\n parseChildInternal({child, schema, keyGenerator, markDefKeys, options}),\n )\n .filter((child) => child !== undefined)\n const marks = parsedChildren.flatMap((child) => child.marks ?? [])\n\n const children =\n parsedChildren.length > 0\n ? parsedChildren\n : [\n {\n _key: keyGenerator(),\n _type: schema.span.name,\n text: '',\n marks: [],\n },\n ]\n\n const normalizedChildren = options.normalize\n ? // Ensure that inline objects are surrounded by spans\n children.reduce<Array<PortableTextObject | PortableTextSpan>>(\n (normalizedChildren, child, index) => {\n if (isSpan({schema}, child)) {\n return [...normalizedChildren, child]\n }\n\n const previousChild = normalizedChildren.at(-1)\n\n if (!previousChild || !isSpan({schema}, previousChild)) {\n return [\n ...normalizedChildren,\n {\n _key: keyGenerator(),\n _type: schema.span.name,\n text: '',\n marks: [],\n },\n child,\n ...(index === children.length - 1\n ? [\n {\n _key: keyGenerator(),\n _type: schema.span.name,\n text: '',\n marks: [],\n },\n ]\n : []),\n ]\n }\n\n return [...normalizedChildren, child]\n },\n [],\n )\n : children\n\n const parsedBlock: PortableTextTextBlock = {\n _type: schema.block.name,\n _key,\n children: normalizedChildren,\n ...customFields,\n }\n\n if (typeof block['markDefs'] === 'object' && block['markDefs'] !== null) {\n parsedBlock.markDefs = options.removeUnusedMarkDefs\n ? markDefs.filter((markDef) => marks.includes(markDef._key))\n : markDefs\n }\n\n if (\n typeof block['style'] === 'string' &&\n schema.styles.find((style) => style.name === block['style'])\n ) {\n parsedBlock.style = block['style']\n }\n\n if (\n typeof block['listItem'] === 'string' &&\n schema.lists.find((list) => list.name === block['listItem'])\n ) {\n parsedBlock.listItem = block['listItem']\n }\n\n if (typeof block['level'] === 'number') {\n parsedBlock.level = block['level']\n }\n\n return parsedBlock\n}\n\nfunction parseMarkDefsInternal({\n schema,\n keyGenerator,\n markDefs,\n options,\n}: {\n schema: Schema\n keyGenerator: () => string\n markDefs: unknown\n options: {validateFields: boolean}\n}): {\n markDefs: Array<PortableTextObject>\n markDefKeys: Set<string>\n} {\n const unparsedMarkDefs: Array<unknown> = Array.isArray(markDefs)\n ? markDefs\n : []\n const markDefKeys = new Set<string>()\n\n const parsedMarkDefs = unparsedMarkDefs.flatMap((markDef) => {\n if (!isTypedObject(markDef)) {\n return []\n }\n\n const schemaType = schema.annotations.find(\n ({name}) => name === markDef._type,\n )\n\n if (!schemaType) {\n return []\n }\n\n if (typeof markDef['_key'] !== 'string') {\n // If the `markDef` doesn't have a `_key` then we don't know what spans\n // it belongs to and therefore we have to discard it.\n return []\n }\n\n const parsedAnnotation = parseObject({\n object: markDef,\n schema,\n keyGenerator,\n schemaType,\n options,\n })\n\n markDefKeys.add(markDef['_key'])\n\n return [parsedAnnotation]\n })\n\n return {\n markDefs: parsedMarkDefs,\n markDefKeys,\n }\n}\n\nfunction parseChildInternal({\n child,\n schema,\n keyGenerator,\n markDefKeys,\n options,\n}: {\n child: unknown\n schema: Schema\n keyGenerator: () => string\n markDefKeys: Set<string>\n options: {validateFields: boolean}\n}): PortableTextSpan | PortableTextObject | undefined {\n return (\n parseSpanInternal({\n span: child,\n schema,\n keyGenerator,\n markDefKeys,\n options,\n }) ??\n parseInlineObjectInternal({\n inlineObject: child,\n schema,\n keyGenerator,\n options,\n })\n )\n}\n\nfunction parseSpanInternal({\n span,\n schema,\n keyGenerator,\n markDefKeys,\n options,\n}: {\n span: unknown\n schema: Schema\n keyGenerator: () => string\n markDefKeys: Set<string>\n options: {validateFields: boolean}\n}): PortableTextSpan | undefined {\n if (!isRecord(span)) {\n return undefined\n }\n\n const customFields: Record<string, unknown> = {}\n\n for (const key of Object.keys(span)) {\n if (\n key !== '_type' &&\n key !== '_key' &&\n key !== 'text' &&\n key !== 'marks'\n ) {\n customFields[key] = span[key]\n }\n }\n\n const unparsedMarks: Array<unknown> = Array.isArray(span['marks'])\n ? span['marks']\n : []\n const marks = unparsedMarks.flatMap((mark) => {\n if (typeof mark !== 'string') {\n return []\n }\n\n if (markDefKeys.has(mark)) {\n return [mark]\n }\n\n if (schema.decorators.some((decorator) => decorator.name === mark)) {\n return [mark]\n }\n\n return []\n })\n\n if (typeof span['_type'] === 'string' && span['_type'] !== schema.span.name) {\n return undefined\n }\n\n if (typeof span['_type'] !== 'string') {\n if (typeof span['text'] === 'string') {\n return {\n _type: schema.span.name as 'span',\n _key: typeof span['_key'] === 'string' ? span['_key'] : keyGenerator(),\n text: span['text'],\n marks,\n ...(options.validateFields ? {} : customFields),\n }\n }\n\n return undefined\n }\n\n return {\n _type: schema.span.name as 'span',\n _key: typeof span['_key'] === 'string' ? span['_key'] : keyGenerator(),\n text: typeof span['text'] === 'string' ? span['text'] : '',\n marks,\n ...(options.validateFields ? {} : customFields),\n }\n}\n\nfunction parseInlineObjectInternal({\n inlineObject,\n schema,\n keyGenerator,\n options,\n}: {\n inlineObject: unknown\n schema: Schema\n keyGenerator: () => string\n options: {validateFields: boolean}\n}): PortableTextObject | undefined {\n if (!isTypedObject(inlineObject)) {\n return undefined\n }\n\n const schemaType = schema.inlineObjects.find(\n ({name}) => name === inlineObject._type,\n )\n\n if (!schemaType) {\n return undefined\n }\n\n return parseObject({\n object: inlineObject,\n schema,\n keyGenerator,\n schemaType,\n options,\n })\n}\n\nexport function parseAnnotation({\n annotation,\n schema,\n keyGenerator,\n profile,\n}: {\n annotation: TypedObject\n schema: Schema\n keyGenerator: () => string\n profile: ParseProfile\n}): PortableTextObject | undefined {\n if (!isTypedObject(annotation)) {\n return undefined\n }\n\n const schemaType = schema.annotations.find(\n ({name}) => name === annotation._type,\n )\n\n if (!schemaType) {\n return undefined\n }\n\n const options = fieldProfiles[profile]\n\n return parseObject({\n object: annotation,\n schema,\n keyGenerator,\n schemaType,\n options,\n })\n}\n\n/**\n * Resolve an `of` member against a runtime `_type`. Returns the schema-type\n * to use for parsing the item, or `undefined` if no member matches.\n *\n * Three forms (one branch each):\n * - Inline declaration `{type: 'object', name: 'X', fields: [...]}` -- name\n * matches `_type`, fields are inline.\n * - Reference `{type: 'X'}` -- looks up in the ancestor chain first\n * (inline-declared types are visible to descendants), then in the schema's\n * root `blockObjects`. Mirrors `resolve-containers.ts`'s reference\n * resolution.\n * - `{type: 'block'}` -- not a non-PTE object member, returns `undefined`.\n */\nfunction resolveOfMember(\n of: ReadonlyArray<OfDefinition>,\n typeName: string,\n schema: Schema,\n ancestorFields: ReadonlyMap<string, ReadonlyArray<FieldDefinition>>,\n): {name: string; fields: ReadonlyArray<FieldDefinition>} | undefined {\n for (const member of of) {\n if (member.type === 'block') {\n continue\n }\n if (member.type === 'object' && 'name' in member && member.name) {\n if (member.name === typeName && 'fields' in member && member.fields) {\n return {name: member.name, fields: member.fields}\n }\n continue\n }\n if (member.type === typeName) {\n const ancestorMatch = ancestorFields.get(typeName)\n if (ancestorMatch) {\n return {name: typeName, fields: ancestorMatch}\n }\n const rootMatch = schema.blockObjects.find(\n (blockObject) => blockObject.name === typeName,\n )\n if (rootMatch && 'fields' in rootMatch && rootMatch.fields) {\n return {name: rootMatch.name, fields: rootMatch.fields}\n }\n return undefined\n }\n }\n return undefined\n}\n\n/**\n * Parse an object against a `{name, fields}` schema type. Validates top-level\n * fields and recurses into any array field whose `of` contains a block-like\n * member -- parsing the nested blocks against a child `Schema` built from\n * that `of`.\n */\nfunction parseObject({\n object,\n schema,\n keyGenerator,\n schemaType,\n ancestorFields,\n options,\n}: {\n object: TypedObject\n schema: Schema\n keyGenerator: () => string\n schemaType: {\n name: string\n fields: ReadonlyArray<FieldDefinition>\n }\n ancestorFields?: ReadonlyMap<string, ReadonlyArray<FieldDefinition>>\n options: {validateFields: boolean}\n}): PortableTextObject {\n const {_key, ...customFields} = object\n\n const fieldsByName = new Map(\n schemaType.fields.map((field) => [field.name, field]),\n )\n\n const nextAncestors = new Map(ancestorFields ?? [])\n nextAncestors.set(schemaType.name, schemaType.fields)\n\n const values: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(customFields)) {\n if (key === '_type') {\n continue\n }\n\n if (value === undefined) {\n continue\n }\n\n const field = fieldsByName.get(key)\n\n if (options.validateFields && !field) {\n continue\n }\n\n if (field && field.type === 'array' && field.of && Array.isArray(value)) {\n values[key] = parseContainerFieldValue({\n schema,\n keyGenerator,\n of: field.of,\n value,\n ancestorFields: nextAncestors,\n options,\n })\n continue\n }\n\n values[key] = value\n }\n\n return {\n _type: schemaType.name,\n _key: typeof _key === 'string' ? _key : keyGenerator(),\n ...values,\n }\n}\n\n/**\n * Parse the value of an array field whose `of` declares what's allowed at\n * that position. Each item is dispatched per its own type:\n *\n * - Text blocks (`_type === schema.block.name`) are parsed against a child\n * sub-schema derived from the `{type: 'block'}` member of `of` (which\n * carries the styles, decorators, annotations, lists, and inline objects\n * allowed at this position).\n *\n * - Block objects (and structural objects sitting between containers and\n * text blocks) are parsed via `resolveOfMember` against the `of` array,\n * with `ancestorFields` carrying inline type declarations down to bare\n * references like `{type: 'list'}`. This lets nested containers resolve\n * to their inline shapes at any depth.\n *\n * Items that don't resolve are passed through unchanged.\n */\nfunction parseContainerFieldValue({\n schema,\n keyGenerator,\n of,\n value,\n ancestorFields,\n options,\n}: {\n schema: Schema\n keyGenerator: () => string\n of: ReadonlyArray<OfDefinition>\n value: ReadonlyArray<unknown>\n ancestorFields: ReadonlyMap<string, ReadonlyArray<FieldDefinition>>\n options: {validateFields: boolean}\n}): Array<unknown> {\n const hasBlockMember = of.some((member) => member.type === 'block')\n const childBlockSubSchema = hasBlockMember\n ? getSubSchema(schema, of)\n : undefined\n\n return value.flatMap((item) => {\n if (!isTypedObject(item)) {\n return [item]\n }\n\n if (childBlockSubSchema && item._type === childBlockSubSchema.block.name) {\n const parsed = parseTextBlock({\n block: item,\n schema: childBlockSubSchema,\n keyGenerator,\n options: {\n normalize: false,\n removeUnusedMarkDefs: false,\n validateFields: options.validateFields,\n },\n })\n return parsed ? [parsed] : []\n }\n\n const schemaType = resolveOfMember(of, item._type, schema, ancestorFields)\n if (!schemaType) {\n return [item]\n }\n return [\n parseObject({\n object: item,\n schema,\n keyGenerator,\n schemaType: {\n name: schemaType.name,\n fields: schemaType.fields,\n },\n ancestorFields,\n options,\n }),\n ]\n })\n}\n","import {isSpan, isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {defaultKeyGenerator} from './key-generator'\nimport {parseBlock} from './parse-blocks'\nimport {getSelectionEndPoint} from './util.get-selection-end-point'\nimport {getSelectionStartPoint} from './util.get-selection-start-point'\nimport {\n getBlockKeyFromSelectionPoint,\n getChildKeyFromSelectionPoint,\n} from './util.selection-point'\n\n/**\n * @public\n */\nexport function sliceBlocks({\n context,\n blocks,\n}: {\n context: Pick<EditorContext, 'schema' | 'selection'> & {\n keyGenerator?: () => string\n }\n blocks: Array<PortableTextBlock>\n}): Array<PortableTextBlock> {\n const slice: Array<PortableTextBlock> = []\n\n if (!context.selection) {\n return slice\n }\n\n let startBlock: PortableTextBlock | undefined\n const middleBlocks: PortableTextBlock[] = []\n let endBlock: PortableTextBlock | undefined\n\n const startPoint = getSelectionStartPoint(context.selection)\n const endPoint = getSelectionEndPoint(context.selection)\n const startBlockKey = getBlockKeyFromSelectionPoint(startPoint)\n const startChildKey = getChildKeyFromSelectionPoint(startPoint)\n const endBlockKey = getBlockKeyFromSelectionPoint(endPoint)\n const endChildKey = getChildKeyFromSelectionPoint(endPoint)\n\n if (!startBlockKey || !endBlockKey) {\n return slice\n }\n\n for (const block of blocks) {\n if (!isTextBlock(context, block)) {\n if (block._key === startBlockKey && block._key === endBlockKey) {\n startBlock = block\n break\n }\n }\n\n if (block._key === startBlockKey) {\n if (!isTextBlock(context, block)) {\n startBlock = block\n continue\n }\n\n if (startChildKey) {\n for (const child of block.children) {\n if (child._key === startChildKey) {\n if (isSpan(context, child)) {\n const text =\n child._key === endChildKey\n ? child.text.slice(startPoint.offset, endPoint.offset)\n : child.text.slice(startPoint.offset)\n\n startBlock = {\n ...block,\n children: [\n {\n ...child,\n text,\n },\n ],\n }\n } else {\n startBlock = {\n ...block,\n children: [child],\n }\n }\n\n if (block._key === endBlockKey && startChildKey === endChildKey) {\n break\n }\n continue\n }\n\n if (startBlock && isTextBlock(context, startBlock)) {\n if (\n endChildKey &&\n child._key === endChildKey &&\n isSpan(context, child)\n ) {\n startBlock.children.push({\n ...child,\n text: child.text.slice(0, endPoint.offset),\n })\n } else {\n startBlock.children.push(child)\n }\n\n if (\n block._key === endBlockKey &&\n endChildKey &&\n child._key === endChildKey\n ) {\n break\n }\n }\n }\n\n if (startBlockKey === endBlockKey) {\n break\n }\n\n continue\n }\n\n startBlock = block\n\n if (startBlockKey === endBlockKey) {\n break\n }\n }\n\n if (block._key === endBlockKey) {\n if (!isTextBlock(context, block)) {\n endBlock = block\n break\n }\n\n if (endChildKey) {\n endBlock = {\n ...block,\n children: [],\n }\n\n for (const child of block.children) {\n if (endBlock && isTextBlock(context, endBlock)) {\n if (child._key === endChildKey && isSpan(context, child)) {\n endBlock.children.push({\n ...child,\n text: child.text.slice(0, endPoint.offset),\n })\n\n break\n }\n\n endBlock.children.push(child)\n\n if (endChildKey && child._key === endChildKey) {\n break\n }\n }\n }\n\n break\n }\n\n endBlock = block\n\n break\n }\n\n if (startBlock) {\n middleBlocks.push(\n parseBlock({\n keyGenerator: context.keyGenerator ?? defaultKeyGenerator,\n block,\n profile: 'lenient',\n schema: context.schema,\n }) ?? block,\n )\n }\n }\n\n const parsedStartBlock = startBlock\n ? parseBlock({\n keyGenerator: context.keyGenerator ?? defaultKeyGenerator,\n block: startBlock,\n profile: 'lenient',\n schema: context.schema,\n })\n : undefined\n\n const parsedEndBlock = endBlock\n ? parseBlock({\n keyGenerator: context.keyGenerator ?? defaultKeyGenerator,\n block: endBlock,\n profile: 'lenient',\n schema: context.schema,\n })\n : undefined\n\n return [\n ...(parsedStartBlock ? [parsedStartBlock] : []),\n ...middleBlocks,\n ...(parsedEndBlock ? [parsedEndBlock] : []),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAgB,kBACd,UACA,aACA,UACA,eACoB;CACpB,IAAI,sBAAsB;CAE1B,KAAK,IAAM,SAAS,UAAU;EAC5B,IAAM,OAAO,YAAY,KAAK;EAC9B,IAAI,MAAM,KAAK,MAAM,UACnB,OAAO,SAAS,KAAA,IACZ,KAAA,IACA,sBAAsB;EAE5B,AAAI,SAAS,KAAA,MACX,uBAAuB,KAAK;CAEhC;AAGF;;;;;;;AAQA,SAA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AAgB;EACtC,OAAO;EACP,SAAS;EACT,QAAQ,QAAQ;CAClB,CAAC,IACD,KAAA,GAEE,iBAAiB,WACnB,WAAW;EACT,cAAc,QAAQ,gBAAgB;EACtC,OAAO;EACP,SAAS;EACT,QAAQ,QAAQ;CAClB,CAAC,IACD,KAAA;CAEJ,OAAO;EACL,GAAI,mBAAmB,CAAC,gBAAgB,IAAI,CAAC;EAC7C,GAAG;EACH,GAAI,iBAAiB,CAAC,cAAc,IAAI,CAAC;CAC3C;AACF"}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as BlockOffset, at as EditorSelectionPoint, cn as KeyedSegment, et as EditorContext, it as EditorSelection, ln as Path, on as BlockPath, un as PathSegment, xt as TraversalSnapshot } from "../behavior.types.action-
|
|
1
|
+
import { I as BlockOffset, at as EditorSelectionPoint, cn as KeyedSegment, et as EditorContext, it as EditorSelection, ln as Path, on as BlockPath, un as PathSegment, xt as TraversalSnapshot } from "../behavior.types.action-DbwK30_J.js";
|
|
2
2
|
import { PortableTextBlock, PortableTextTextBlock, isSpan, isTextBlock } from "@portabletext/schema";
|
|
3
3
|
/**
|
|
4
4
|
* @public
|
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as
|
|
3
|
-
import { n as isEmptyTextBlock, r as getTextBlockText, t as isEqualSelections } from "../util.is-equal-selections-
|
|
1
|
+
import { p as isKeyedSegment, r as getNode, t as getParent } from "../get-parent-BLzi7eLr.js";
|
|
2
|
+
import { _ as spanSelectionPointToBlockOffset, c as getSelectionStartPoint, d as getBlockStartPoint, f as getBlockEndPoint, g as blockOffsetToSpanSelectionPoint, h as isEqualPaths, l as getSelectionEndPoint, m as isEqualSelectionPoints, r as parseBlock, t as sliceBlocks, u as isSelectionCollapsed } from "../util.slice-blocks-B-iKFEG7.js";
|
|
3
|
+
import { n as isEmptyTextBlock, r as getTextBlockText, t as isEqualSelections } from "../util.is-equal-selections-sCQib0IC.js";
|
|
4
4
|
import { isSpan, isSpan as isSpan$1, isTextBlock, isTextBlock as isTextBlock$1 } from "@portabletext/schema";
|
|
5
5
|
function blockOffsetToBlockSelectionPoint({ snapshot, blockOffset }) {
|
|
6
6
|
let blockEntry = getNode(snapshot, blockOffset.path);
|
|
@@ -62,11 +62,7 @@ function mergeTextBlocks({ context, targetBlock, incomingBlock }) {
|
|
|
62
62
|
let parsedIncomingBlock = parseBlock({
|
|
63
63
|
keyGenerator: context.keyGenerator,
|
|
64
64
|
block: incomingBlock,
|
|
65
|
-
|
|
66
|
-
normalize: !1,
|
|
67
|
-
removeUnusedMarkDefs: !0,
|
|
68
|
-
validateFields: !1
|
|
69
|
-
},
|
|
65
|
+
profile: "lenient",
|
|
70
66
|
schema: context.schema
|
|
71
67
|
});
|
|
72
68
|
return !parsedIncomingBlock || !isTextBlock$1(context, parsedIncomingBlock) ? targetBlock : {
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts"],"sourcesContent":["import {getNode} from '../traversal/get-node'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\n\nexport function blockOffsetToBlockSelectionPoint({\n snapshot,\n blockOffset,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n}): EditorSelectionPoint | undefined {\n const blockEntry = getNode(snapshot, blockOffset.path)\n\n if (!blockEntry) {\n return undefined\n }\n\n return {\n path: blockEntry.path,\n offset: blockOffset.offset,\n }\n}\n","import type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {blockOffsetToSpanSelectionPoint} from './util.block-offset'\nimport {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-selection-point'\n\nexport function blockOffsetToSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}): EditorSelectionPoint | undefined {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n })\n\n if (!spanSelectionPoint) {\n return blockOffsetToBlockSelectionPoint({\n snapshot,\n blockOffset,\n })\n }\n\n return spanSelectionPoint\n}\n","import type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {blockOffsetToSelectionPoint} from './util.block-offset-to-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetsToSelection({\n snapshot,\n offsets,\n backward,\n}: {\n snapshot: TraversalSnapshot\n offsets: {anchor: BlockOffset; focus: BlockOffset}\n backward?: boolean\n}): EditorSelection {\n const anchor = blockOffsetToSelectionPoint({\n snapshot,\n blockOffset: offsets.anchor,\n direction: backward ? 'backward' : 'forward',\n })\n const focus = blockOffsetToSelectionPoint({\n snapshot,\n blockOffset: offsets.focus,\n direction: backward ? 'forward' : 'backward',\n })\n\n if (!anchor || !focus) {\n return null\n }\n\n return {\n anchor,\n focus,\n backward,\n }\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport {getParent} from '../traversal/get-parent'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\n/**\n * @public\n */\nexport function childSelectionPointToBlockOffset({\n snapshot,\n selectionPoint,\n}: {\n snapshot: TraversalSnapshot\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const childSegment = selectionPoint.path.at(-1)\n\n if (!isKeyedSegment(childSegment)) {\n return undefined\n }\n\n const textBlock = getParent(snapshot, selectionPoint.path, {\n match: (node) => isTextBlock({schema: snapshot.context.schema}, node),\n })\n\n if (!textBlock) {\n return undefined\n }\n\n let offset = 0\n\n for (const child of textBlock.node.children) {\n if (child._key === childSegment._key) {\n return {\n path: textBlock.path,\n offset: offset + selectionPoint.offset,\n }\n }\n\n if (isSpan(snapshot.context, child)) {\n offset += child.text.length\n }\n }\n\n return undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {parseBlock} from './parse-blocks'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n keyGenerator: context.keyGenerator,\n block: incomingBlock,\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts"],"sourcesContent":["import {getNode} from '../traversal/get-node'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\n\nexport function blockOffsetToBlockSelectionPoint({\n snapshot,\n blockOffset,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n}): EditorSelectionPoint | undefined {\n const blockEntry = getNode(snapshot, blockOffset.path)\n\n if (!blockEntry) {\n return undefined\n }\n\n return {\n path: blockEntry.path,\n offset: blockOffset.offset,\n }\n}\n","import type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {blockOffsetToSpanSelectionPoint} from './util.block-offset'\nimport {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-selection-point'\n\nexport function blockOffsetToSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}): EditorSelectionPoint | undefined {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n })\n\n if (!spanSelectionPoint) {\n return blockOffsetToBlockSelectionPoint({\n snapshot,\n blockOffset,\n })\n }\n\n return spanSelectionPoint\n}\n","import type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {blockOffsetToSelectionPoint} from './util.block-offset-to-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetsToSelection({\n snapshot,\n offsets,\n backward,\n}: {\n snapshot: TraversalSnapshot\n offsets: {anchor: BlockOffset; focus: BlockOffset}\n backward?: boolean\n}): EditorSelection {\n const anchor = blockOffsetToSelectionPoint({\n snapshot,\n blockOffset: offsets.anchor,\n direction: backward ? 'backward' : 'forward',\n })\n const focus = blockOffsetToSelectionPoint({\n snapshot,\n blockOffset: offsets.focus,\n direction: backward ? 'forward' : 'backward',\n })\n\n if (!anchor || !focus) {\n return null\n }\n\n return {\n anchor,\n focus,\n backward,\n }\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport {getParent} from '../traversal/get-parent'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\n/**\n * @public\n */\nexport function childSelectionPointToBlockOffset({\n snapshot,\n selectionPoint,\n}: {\n snapshot: TraversalSnapshot\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const childSegment = selectionPoint.path.at(-1)\n\n if (!isKeyedSegment(childSegment)) {\n return undefined\n }\n\n const textBlock = getParent(snapshot, selectionPoint.path, {\n match: (node) => isTextBlock({schema: snapshot.context.schema}, node),\n })\n\n if (!textBlock) {\n return undefined\n }\n\n let offset = 0\n\n for (const child of textBlock.node.children) {\n if (child._key === childSegment._key) {\n return {\n path: textBlock.path,\n offset: offset + selectionPoint.offset,\n }\n }\n\n if (isSpan(snapshot.context, child)) {\n offset += child.text.length\n }\n }\n\n return undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {parseBlock} from './parse-blocks'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n keyGenerator: context.keyGenerator,\n block: incomingBlock,\n profile: 'lenient',\n schema: context.schema,\n })\n\n if (!parsedIncomingBlock || !isTextBlock(context, parsedIncomingBlock)) {\n return targetBlock\n }\n\n return {\n ...targetBlock,\n children: [...targetBlock.children, ...parsedIncomingBlock.children],\n markDefs: [\n ...(targetBlock.markDefs ?? []),\n ...(parsedIncomingBlock.markDefs ?? []),\n ],\n }\n}\n","import type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function reverseSelection<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n>(selection: TEditorSelection): TEditorSelection {\n if (!selection) {\n return selection\n }\n\n if (selection.backward) {\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: false,\n } as TEditorSelection\n }\n\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: true,\n } as TEditorSelection\n}\n"],"mappings":";;;;AAKA,SAAgB,iCAAiC,EAC/C,UACA,eAImC;CACnC,IAAM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;EACL,GAAG;EACH,UAAU,CAAC,GAAG,YAAY,UAAU,GAAG,oBAAoB,QAAQ;EACnE,UAAU,CACR,GAAI,YAAY,YAAY,CAAC,GAC7B,GAAI,oBAAoB,YAAY,CAAC,CACvC;CACF;AACF;;;;AC9BA,SAAgB,iBAEd,WAA+C;CAa/C,OAZK,cAID,UAAU,WACL;EACL,QAAQ,UAAU;EAClB,OAAO,UAAU;EACjB,UAAU;CACZ,IAGK;EACL,QAAQ,UAAU;EAClB,OAAO,UAAU;EACjB,UAAU;CACZ;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.3",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"collaborative",
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"@sanity/json-match": "^1.0.5",
|
|
57
57
|
"@sanity/pkg-utils": "^12.3.0",
|
|
58
58
|
"@sanity/tsconfig": "^2.1.0",
|
|
59
|
-
"@textspec/notation": "^1.0.2",
|
|
60
59
|
"@types/debug": "^4.1.13",
|
|
61
60
|
"@types/node": "^20",
|
|
62
61
|
"@types/react": "^19.2.17",
|
|
@@ -73,7 +72,7 @@
|
|
|
73
72
|
"vite": "^8.2.0",
|
|
74
73
|
"vitest": "^4.1.11",
|
|
75
74
|
"vitest-browser-react": "^2.2.0",
|
|
76
|
-
"@portabletext/test": "^2.
|
|
75
|
+
"@portabletext/test": "^2.1.0",
|
|
77
76
|
"racejar": "3.0.0"
|
|
78
77
|
},
|
|
79
78
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"behavior.types.action-C0XDEQnB.d.ts","names":[],"sources":["../src/internal-utils/mime-type.ts","../src/type-utils.ts","../src/converters/converter.types.ts","../src/types/paths.ts","../src/renderers/renderer.types.ts","../src/schema/container-types.ts","../src/editor/editor-schema.ts","../src/engine/interfaces/node.ts","../src/traversal/traversal-snapshot.ts","../src/editor/PortableTextEditor.tsx","../src/types/options.ts","../src/editor/Editable.tsx","../src/types/editor.ts","../src/engine/types/types.ts","../src/engine/interfaces/point.ts","../src/engine/interfaces/range.ts","../src/engine/interfaces/operation.ts","../src/engine/interfaces/range-ref.ts","../src/engine/dom/utils/diff-text.ts","../src/engine/dom/utils/dom.ts","../src/engine/dom/plugin/dom-editor.ts","../src/engine/interfaces/location.ts","../src/engine/interfaces/path-ref.ts","../src/engine/interfaces/point-ref.ts","../src/engine/interfaces/editor.ts","../src/engine/core/operation-channel.ts","../src/editor/range-decorations-machine.ts","../src/types/editor-engine.ts","../src/editor/editor-snapshot.ts","../src/behaviors/behavior.types.guard.ts","../src/behaviors/behavior.types.behavior.ts","../src/types/operation.ts","../src/editor/relay.ts","../src/editor.ts","../src/editor/editor-provider.tsx","../src/editor/editor-selector.ts","../src/editor/usePortableTextEditor.ts","../src/editor/usePortableTextEditorSelection.tsx","../src/utils/key-generator.ts","../src/editor/use-editor.ts","../src/types/block-offset.ts","../src/priority/priority.types.ts","../src/behaviors/behavior.config.ts","../src/editor/editor-machine.ts","../src/internal-utils/event-position.ts","../src/types/block-with-optional-key.ts","../src/behaviors/behavior.types.event.ts","../src/editor/editor-dom.ts","../src/behaviors/behavior.types.action.ts"],"mappings":";;;;KAAY;;;;KCGA,cACV,QACA,sBAAsB,QACtB,oBAAoB,OAAO,YACzB,eAAe,OAAO,SAAS,eAAe;KAWtC,eAAe,QAAQ,6BAA6B;EAC9D,YAAY;OAGP,WAAW,SAAS,sBACd,cAAc,wBACjB,OAAO;KAIL,cAAc,GAAG,UAAU,KAAK;KCvBhC,UAAU,kBAAkB,WAAW;EACjD,UAAU;EACV,WAAW,WAAW;EACtB,aAAa,aAAa;;KASvB,eAAe,kBAAkB,WAAW;EAE3C;EACA;;EAGA;EACA,UAAU;EACV;EACA;;EAGA;EACA;EACA,UAAU;EACV;;E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Ac;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCD,QACd,OAAO,yBAAyB,sBAC/B,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CD,OACd,QAAQ,cAAc,8CACrB,cAAc;;;;KAOL,kBAAkB,gBAAgB,mBAC5C;EACE,UAAU;EACV,OAAO;EACP,KAAK;GAEP,eAAe,mBACZ,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-parent-DgaKcy8-.js","names":[],"sources":["../src/utils/util.is-keyed-segment.ts","../src/paths/serialize-path.ts","../src/utils/asserters.ts","../src/traversal/get-container-children.ts","../src/traversal/get-children.ts","../src/traversal/get-node.ts","../src/engine/path/parent-path.ts","../src/traversal/get-parent.ts"],"sourcesContent":["import type {KeyedSegment} from '../types/paths'\n\n/**\n * @public\n */\nexport function isKeyedSegment(segment: unknown): segment is KeyedSegment {\n return typeof segment === 'object' && segment !== null && '_key' in segment\n}\n","import type {Path} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * Serialize a keyed path to a string using Sanity's bracket notation.\n *\n * - `[{_key: 'k0'}]` -> `[_key==\"k0\"]`\n * - `[{_key: 'k0'}, 'children', {_key: 's0'}]` -> `[_key==\"k0\"].children[_key==\"s0\"]`\n * - `[{_key: 't0'}, 'rows', {_key: 'r0'}, 'cells', {_key: 'c0'}, 'content', {_key: 'b0'}, 'children', {_key: 's0'}]` -> `[_key==\"t0\"].rows[_key==\"r0\"].cells[_key==\"c0\"].content[_key==\"b0\"].children[_key==\"s0\"]`\n */\nexport function serializePath(path: Path): string {\n return path.reduce<string>((result, segment, index) => {\n if (isKeyedSegment(segment)) {\n return `${result}[_key==\"${segment._key}\"]`\n }\n\n const separator = index === 0 ? '' : '.'\n return `${result}${separator}${segment}`\n }, '')\n}\n","import type {TypedObject} from '@portabletext/schema'\n\nexport function isTypedObject(object: unknown): object is TypedObject {\n return isRecord(object) && typeof object['_type'] === 'string'\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && (typeof value === 'object' || typeof value === 'function')\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {\n Containers,\n RegisteredContainer,\n} from '../schema/resolve-containers'\n\n/**\n * Resolve a container node's editable child array.\n *\n * Returns `{children, container}` for a node registered as a container:\n * `children` is the node's editable child array, and `container` is the\n * node's own container registration. Read `container.field.name` for the\n * path segment that reaches `children`, and thread `container` back in as\n * `parent` when descending into them.\n *\n * Returns `undefined` for anything that is not a container: text blocks,\n * spans, leaves, and unregistered objects. It is node-based and resolves\n * in one step with no path re-walk, so recursive descent over containers\n * is linear in nesting depth. The caller seeds the document root from\n * `context.value` itself.\n *\n * @beta\n */\nexport function getContainerChildren(\n containers: Containers,\n node: Node,\n parent?: RegisteredContainer,\n):\n | {\n children: Array<Node>\n container: RegisteredContainer\n }\n | undefined {\n const resolved = resolveNodeContainer(containers, parent, node)\n\n if (!resolved) {\n return undefined\n }\n\n const fieldValue = (node as Record<string, unknown>)[resolved.field.name]\n\n if (!Array.isArray(fieldValue)) {\n return undefined\n }\n\n return {\n children: fieldValue as Array<Node>,\n container: resolved,\n }\n}\n\n/**\n * Pick the positional override from `parent.of` if present; fall back\n * to the top-level entry. Returns only `RegisteredContainer` entries\n * since leaves do not have editable children.\n */\nfunction resolveNodeContainer(\n containers: Containers,\n parent: RegisteredContainer | undefined,\n node: Node,\n): RegisteredContainer | undefined {\n if (parent?.of) {\n for (const entry of parent.of) {\n if (entry.type === node._type) {\n // Only return container entries; leaves have no editable children.\n if ('field' in entry) {\n return entry\n }\n return undefined\n }\n }\n }\n return containers.get(node._type)\n}\n","import {isTextBlock} from '@portabletext/schema'\nimport type {EditorSchema} from '../editor/editor-schema'\nimport type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {serializePath} from '../paths/serialize-path'\nimport type {\n Containers,\n RegisteredContainer,\n} from '../schema/resolve-containers'\nimport {isTypedObject} from '../utils/asserters'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getContainerChildren} from './get-container-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the children of a node at a given path.\n *\n * @public\n */\nexport function getChildren(\n snapshot: TraversalSnapshot,\n path: Path,\n): Array<{node: Node; path: Path}> {\n let currentChildren: Array<Node> = snapshot.context.value\n let currentFieldName = 'value'\n let currentPath: Path = []\n let isRoot = true\n let currentParent: RegisteredContainer | undefined\n\n for (const segment of path) {\n if (typeof segment === 'string') {\n continue\n }\n\n let node: Node | undefined\n if (isKeyedSegment(segment)) {\n // Resolve via `blockIndexMap` (O(1)) and fall back to a linear scan on a\n // miss or when the snapshot's map disagrees with the value, mirroring\n // `getNode`. The candidate path is this segment's full keyed path.\n const candidatePath: Path = isRoot\n ? [{_key: segment._key}]\n : [...currentPath, currentFieldName, {_key: segment._key}]\n const index = snapshot.blockIndexMap.get(serializePath(candidatePath))\n node =\n index !== undefined && currentChildren[index]?._key === segment._key\n ? currentChildren[index]\n : currentChildren.find((child) => child._key === segment._key)\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n }\n\n if (!node) {\n return []\n }\n\n currentPath = isRoot\n ? [{_key: node._key}]\n : [...currentPath, currentFieldName, {_key: node._key}]\n isRoot = false\n\n const next = getNodeChildren(snapshot.context, node, currentParent)\n\n if (!next) {\n return []\n }\n\n currentChildren = next.children\n currentFieldName = next.fieldName\n currentParent = next.parent\n }\n\n return currentChildren.map((child) => ({\n node: child,\n path: isRoot\n ? [{_key: child._key}]\n : [...currentPath, currentFieldName, {_key: child._key}],\n }))\n}\n\n/**\n * Resolve a node's editable child array.\n *\n * When `parent` is provided and its `of` declares a positional entry\n * matching `node._type`, that positional entry's `field` is used.\n * Otherwise the top-level `containers.get(node._type)` provides the\n * fallback.\n *\n * The returned `parent` is the resolved container entry for `node`\n * itself (used by the caller to thread further descent).\n *\n * Internal descent kernel shared by the positional traversal utilities\n * (`getChildren`, `getNode`, `getNodes`, `getAncestors`); it folds the\n * text-block, container, and root-document cases. Public consumers that\n * only need to descend containers use {@link getContainerChildren}.\n */\nexport function getNodeChildren(\n context: {\n schema: EditorSchema\n containers: Containers\n },\n node: Node | {value: Array<Node>},\n parent?: RegisteredContainer,\n):\n | {\n children: Array<Node>\n fieldName: string\n parent: RegisteredContainer | undefined\n }\n | undefined {\n // Text blocks store children in .children\n if (isTextBlock(context, node)) {\n return {\n children: node.children,\n fieldName: 'children',\n parent: undefined,\n }\n }\n\n if (isTypedObject(node)) {\n const result = getContainerChildren(context.containers, node, parent)\n\n if (result) {\n return {\n children: result.children,\n fieldName: result.container.field.name,\n parent: result.container,\n }\n }\n }\n\n // Root context: has .value array but no _key or _type\n if (\n 'value' in node &&\n Array.isArray(node['value']) &&\n !('_key' in node) &&\n !('_type' in node)\n ) {\n return {\n children: node['value'] as Array<Node>,\n fieldName: 'value',\n parent: undefined,\n }\n }\n\n return undefined\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {serializePath} from '../paths/serialize-path'\nimport type {RegisteredContainer} from '../schema/resolve-containers'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getNodeChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the node at a given path.\n *\n * The path can be either keyed (KeyedSegment + field name strings) or\n * indexed (numbers). Keyed segments are resolved by matching `_key`,\n * field name strings name a structural descent into the previous\n * node's children, and numbers are resolved by index.\n *\n * The returned `path` always identifies the returned node: it's fully\n * keyed (numeric indices are converted to `KeyedSegment`s) and any\n * trailing segments in the input that point outside the value tree —\n * e.g. an object node's primitive field, or an annotation reached via\n * `'markDefs'` on a text block — are stripped so that\n * `getNode(snapshot, entry.path).node === entry.node`.\n *\n * The walk stops when a string segment names a field that isn't the\n * current node's structural child array. Annotations live in\n * `markDefs` on a text block, alongside `children` rather than inside\n * it, so `getNode` resolves an annotation path to the enclosing text\n * block. Use `getAnnotation` to resolve the annotation itself.\n *\n * @public\n */\nexport function getNode(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n const result = resolveNode(snapshot, path)\n return result.status === 'found' ? result.entry : undefined\n}\n\n/**\n * Result of walking a path against a snapshot.\n *\n * `unreachable` is the one outcome that means \"structurally impossible\n * by design\": the path digs past a sidecar field (e.g. `markDefs` on\n * a text block) into a keyed/indexed segment, which `getNode` can\n * never resolve (use `getAnnotation` for annotations). Every other\n * negative outcome is `missing`; on those branches a caller bug and a\n * benign race (the node removed by a concurrent edit) produce the\n * same state, so they cannot be told apart.\n */\nexport type ResolveNodeResult =\n | {status: 'found'; entry: {node: Node; path: Path}}\n | {status: 'missing'}\n | {status: 'unreachable'}\n\nexport function resolveNode(\n snapshot: TraversalSnapshot,\n path: Path,\n): ResolveNodeResult {\n if (path.length === 0) {\n return {status: 'missing'}\n }\n\n const {context, blockIndexMap} = snapshot\n let currentChildren: Array<Node> = context.value\n let currentFieldName: string | undefined\n let node: Node | undefined\n let currentParent: RegisteredContainer | undefined\n const resolvedPath: Path = []\n\n for (let i = 0; i < path.length; i++) {\n const segment = path[i]\n\n if (typeof segment === 'string') {\n // A string segment names a structural descent. If it matches the\n // field name produced by the previous node's `getNodeChildren`,\n // it's part of the value-tree descent — push it and continue.\n // Otherwise the string names a sidecar field (markDefs on a text\n // block, a primitive field on an object). If the input keeps\n // digging past it with more keyed/numeric segments, the caller\n // wanted a node inside the sidecar and `getNode` can't reach it\n // (use `getAnnotation` for annotations); report unreachable.\n // Otherwise the rest is just trailing field names — let the loop\n // exit and the post-loop strip remove them.\n if (currentFieldName !== undefined && segment === currentFieldName) {\n resolvedPath.push(segment)\n continue\n }\n for (let j = i + 1; j < path.length; j++) {\n const s = path[j]\n if (isKeyedSegment(s) || typeof s === 'number') {\n return {status: 'unreachable'}\n }\n }\n break\n }\n\n if (isKeyedSegment(segment)) {\n resolvedPath.push(segment)\n const index = blockIndexMap.get(serializePath(resolvedPath))\n if (\n index !== undefined &&\n currentChildren[index]?._key === segment._key\n ) {\n node = currentChildren[index]\n } else {\n // The map can miss (unkeyed transient nodes, e.g. `{_type:'table'}`\n // inserted by a remote patch before normalize mints a key) or\n // disagree with the traversed value (snapshots that pair the live\n // map with a pre-apply value, e.g. `textPatch`). Fall back to a\n // linear scan in both cases.\n node = currentChildren.find((child) => child._key === segment._key)\n if (node && node._key !== undefined) {\n resolvedPath[resolvedPath.length - 1] = {_key: node._key}\n }\n }\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push({_key: node._key})\n }\n } else {\n return {status: 'missing'}\n }\n\n if (!node) {\n return {status: 'missing'}\n }\n\n let hasMoreSegments = false\n for (let j = i + 1; j < path.length; j++) {\n const s = path[j]\n if (isKeyedSegment(s) || typeof s === 'number') {\n hasMoreSegments = true\n break\n }\n }\n\n if (hasMoreSegments) {\n const next = getNodeChildren(context, node, currentParent)\n\n if (!next) {\n return {status: 'missing'}\n }\n\n currentChildren = next.children\n currentFieldName = next.fieldName\n currentParent = next.parent\n } else {\n currentFieldName = undefined\n }\n }\n\n if (!node) {\n return {status: 'missing'}\n }\n\n // Strip trailing field-name segments. The walker may have pushed\n // matching field names during structural descent; if the deepest\n // reached keyed segment was the last keyed segment in the input,\n // any further field names that followed are part of the input but\n // don't identify the returned node.\n while (\n resolvedPath.length > 0 &&\n typeof resolvedPath[resolvedPath.length - 1] === 'string'\n ) {\n resolvedPath.pop()\n }\n\n return {status: 'found', entry: {node, path: resolvedPath}}\n}\n","import {isKeyedSegment} from '../../utils/util.is-keyed-segment'\nimport type {Path} from '../interfaces/path'\n\n/**\n * Get the parent path of a path.\n *\n * Drops the last node segment (keyed or numeric) and the preceding field\n * name string.\n *\n * [{_key:'b1'}, 'children', {_key:'s1'}] → [{_key:'b1'}]\n * [{_key:'b1'}, 'children', 0] → [{_key:'b1'}]\n * [{_key:'b1'}] → []\n */\nexport function parentPath(path: Path): Path {\n if (path.length === 0) {\n throw new Error(`Cannot get the parent path of the root path [${path}].`)\n }\n\n let lastNodeIndex = -1\n for (let i = path.length - 1; i >= 0; i--) {\n if (isKeyedSegment(path[i]) || typeof path[i] === 'number') {\n lastNodeIndex = i\n break\n }\n }\n\n if (lastNodeIndex === -1) {\n return []\n }\n\n const result = path.slice(0, lastNodeIndex)\n\n if (result.length > 0 && typeof result[result.length - 1] === 'string') {\n return result.slice(0, -1)\n }\n\n return result\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the parent of a node at a given path.\n *\n * A parent has children, so it is always a `PortableTextBlock` (text block\n * or object node).\n *\n * When `match` is provided and the parent does not satisfy it, returns\n * `undefined`.\n *\n * @public\n */\nexport function getParent<TMatch extends PortableTextBlock>(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => node is TMatch\n },\n): {node: TMatch; path: Path} | undefined\n/**\n * @public\n */\nexport function getParent(\n snapshot: TraversalSnapshot,\n path: Path,\n options?: {\n match?: (node: PortableTextBlock, path: Path) => boolean\n },\n): {node: PortableTextBlock; path: Path} | undefined\nexport function getParent(\n snapshot: TraversalSnapshot,\n path: Path,\n options?: {\n match?: (node: PortableTextBlock, path: Path) => boolean\n },\n): {node: PortableTextBlock; path: Path} | undefined {\n if (path.length === 0) {\n return undefined\n }\n\n const parent = parentPath(path)\n\n if (parent.length === 0) {\n return undefined\n }\n\n const entry = getNode(snapshot, parent)\n\n if (!entry) {\n return undefined\n }\n\n const result = {node: entry.node as PortableTextBlock, path: entry.path}\n\n if (options?.match && !options.match(result.node, result.path)) {\n return undefined\n }\n\n return result\n}\n"],"mappings":";;;;AAKA,SAAgB,eAAe,SAA2C;CACxE,OAAO,OAAO,WAAY,cAAY,WAAoB,UAAU;AACtE;;;;;;;;ACGA,SAAg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Q,MAAM,OAAO,MAAM,OAAO,IAAI,IAI7D,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-path-sub-schema-Dd0QYZ0m.js","names":[],"sources":["../src/traversal/get-ancestors.ts","../src/traversal/has-node.ts","../src/schema/resolve-container-at.ts","../src/schema/is-editable-container.ts","../src/traversal/is-object.ts","../src/engine/path/compare-paths.ts","../src/engine/point/compare-points.ts","../src/engine/point/is-after-point.ts","../src/engine/range/is-backward-range.ts","../src/engine/range/range-edges.ts","../src/engine/node/is-text-block-node.ts","../src/engine/path/is-ancestor-path.ts","../src/traversal/resolve-child-entry-index.ts","../src/traversal/get-nodes.ts","../src/traversal/get-sibling.ts","../src/engine/node/is-span-node.ts","../src/traversal/is-block.ts","../src/traversal/is-inline.ts","../src/traversal/get-enclosing-block.ts","../src/traversal/compare-points.ts","../src/schema/descend-to-parent.ts","../src/schema/get-enclosing-container.ts","../src/traversal/get-path-sub-schema.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {serializePath} from '../paths/serialize-path'\nimport type {RegisteredContainer} from '../schema/resolve-containers'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getNodeChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get all ancestors of the node at a given path, from nearest to furthest.\n *\n * For a path like [{_key:'t1'}, 'rows', {_key:'r1'}, 'cells', {_key:'c1'}],\n * the ancestors are (nearest first):\n * [{_key:'t1'}, 'rows', {_key:'r1'}]\n * [{_key:'t1'}]\n *\n * Walks from root to the target in a single pass collecting each ancestor\n * as it goes.\n *\n * Every ancestor is a `PortableTextBlock`: only text blocks and object\n * nodes can contain children.\n *\n * @public\n */\nexport function getAncestors(\n snapshot: TraversalSnapshot,\n path: Path,\n): Array<{node: PortableTextBlock; path: Path}> {\n // Collect keyed-segment indices to know where each ancestor's path ends.\n const keyedIndices: Array<number> = []\n for (let i = 0; i < path.length; i++) {\n if (isKeyedSegment(path[i])) {\n keyedIndices.push(i)\n }\n }\n\n // Need at least 2 keyed segments to have an ancestor (the last is self).\n if (keyedIndices.length <= 1) {\n return []\n }\n\n const {context, blockIndexMap} = snapshot\n let currentChildren: Array<Node> = context.value\n let currentParent: RegisteredContainer | undefined\n\n const ancestorsByDepth: Array<{node: PortableTextBlock; path: Path}> = []\n const resolvedPath: Path = []\n\n // Descend once. We walk only as far as the second-to-last keyed segment;\n // the last keyed segment is the target itself, which is not an ancestor.\n const targetKeyedIndex = keyedIndices[keyedIndices.length - 1]!\n\n let segmentIndex = 0\n while (segmentIndex < targetKeyedIndex) {\n const segment = path[segmentIndex]!\n\n if (typeof segment === 'string') {\n resolvedPath.push(segment)\n segmentIndex++\n continue\n }\n\n let node: Node | undefined\n if (isKeyedSegment(segment)) {\n resolvedPath.push(segment)\n const index = blockIndexMap.get(serializePath(resolvedPath))\n if (\n index !== undefined &&\n currentChildren[index]?._key === segment._key\n ) {\n node = currentChildren[index]\n } else {\n // The map can miss (unkeyed transient nodes, e.g. `{_type:'table'}`\n // inserted by a remote patch before normalize mints a key) or\n // disagree with the traversed value (snapshots that pair the live\n // map with a pre-apply value, e.g. `textPatch`). Fall back to a\n // linear scan in both cases.\n node = currentChildren.find((child) => child._key === segment._key)\n if (node && node._key !== undefined) {\n resolvedPath[resolvedPath.length - 1] = {_key: node._key}\n }\n }\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push({_key: node._key})\n }\n } else {\n return []\n }\n\n if (!node) {\n return []\n }\n\n // Descend with positional awareness. `getNodeChildren` checks the\n // current parent's `of` for a positional override before falling\n // back to the top-level `containers` map - so same-`_type`\n // registered under different parents with different `field`\n // resolves to the right entry at this position.\n const next = getNodeChildren(context, node, currentParent)\n if (!next) {\n return []\n }\n\n // An ancestor has children, so it is never a span. The narrowing\n // from `Node` to `PortableTextBlock` (text block | object) is safe.\n ancestorsByDepth.push({\n node: node as PortableTextBlock,\n path: resolvedPath.slice(),\n })\n\n currentChildren = next.children\n currentParent = next.parent\n segmentIndex++\n }\n\n // Return nearest-first (reverse of document order at the call site).\n return ancestorsByDepth.reverse()\n}\n","import type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Check if a node exists at a given path.\n *\n * @public\n */\nexport function hasNode(snapshot: TraversalSnapshot, path: Path): boolean {\n return getNode(snapshot, path) !== undefined\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport type {\n Containers,\n RegisteredContainer,\n RegisteredPositional,\n} from './container-types'\n\n/**\n * Walk the editor value following `path` and return the\n * {@link RegisteredContainer} or {@link RegisteredPositional} that applies\n * at `path`'s target position.\n *\n * Resolution rules at each step:\n *\n * 1. **Positional override.** If the current parent declares the\n * child's `_type` in its `of`, the positional entry wins.\n * Used to resolve same-`_type` registered under different\n * parents with different `field` values.\n *\n * 2. **Global fallback.** If the parent has no positional override,\n * fall back to the top-level entry for `_type` in\n * `containers`.\n *\n * 3. **Chain validity.** If any ancestor along the path has no\n * resolved container entry (unregistered or not reachable as a\n * container at its position), return `undefined`.\n *\n * Returns `undefined` when the target's `_type` is not registered\n * at this position. Returns a {@link RegisteredPositional} when the target\n * resolves to a leaf in a positional `of` (terminal node with no\n * editable children).\n *\n * @alpha\n */\nexport function resolveContainerAt(\n containers: Containers,\n value: ReadonlyArray<Node>,\n path: Path,\n): RegisteredContainer | RegisteredPositional | undefined {\n const keyedIndices: Array<number> = []\n for (let index = 0; index < path.length; index++) {\n if (isKeyedSegment(path[index])) {\n keyedIndices.push(index)\n }\n }\n if (keyedIndices.length === 0) {\n return undefined\n }\n\n let currentChildren: ReadonlyArray<Node> = value\n let parent: RegisteredContainer | undefined\n let resolved: RegisteredContainer | RegisteredPositional | undefined\n const targetKeyedIndex = keyedIndices[keyedIndices.length - 1]!\n\n let segmentIndex = 0\n while (segmentIndex <= targetKeyedIndex) {\n const segment = path[segmentIndex]!\n if (typeof segment === 'string') {\n segmentIndex++\n continue\n }\n\n let node: Node | undefined\n if (isKeyedSegment(segment)) {\n node = currentChildren.find((child) => child._key === segment._key)\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n } else {\n return undefined\n }\n if (!node) {\n return undefined\n }\n\n resolved = resolveNodeEntry(containers, parent, node)\n if (!resolved) {\n return undefined\n }\n\n if (segmentIndex < targetKeyedIndex) {\n // Walk one more level. The resolved entry must be a container\n // (have children) for descent to continue.\n if (!('field' in resolved)) {\n return undefined\n }\n const fieldValue = (node as Record<string, unknown>)[resolved.field.name]\n if (!Array.isArray(fieldValue)) {\n return undefined\n }\n parent = resolved\n currentChildren = fieldValue as Array<Node>\n }\n segmentIndex++\n }\n\n return resolved\n}\n\nfunction resolveNodeEntry(\n containers: Containers,\n parent: RegisteredContainer | undefined,\n node: Node,\n): RegisteredContainer | RegisteredPositional | undefined {\n if (parent?.of) {\n for (const entry of parent.of) {\n if (entry.type === node._type) {\n return entry\n }\n }\n }\n return containers.get(node._type)\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport {resolveContainerAt} from './resolve-container-at'\n\n/**\n * Check if a node at the given path is a registered editable container.\n *\n * Position-aware: {@link resolveContainerAt} descends from the editor\n * root threading the resolved parent at each step, so positionally-\n * registered containers (e.g. `cell` registered only inside\n * `table.of`) are recognized when reached through their declared\n * parent.\n */\nexport function isEditableContainer(\n snapshot: TraversalSnapshot,\n _node: Node,\n path: Path,\n): boolean {\n if (snapshot.context.containers.size === 0) {\n return false\n }\n\n // `resolveContainerAt` aborts on the first unregistered object-node\n // ancestor (chain validity falls out of the single descent), so the\n // single call below answers both \"is the node here a container?\" and\n // \"is the ancestor chain valid?\" in one walk.\n const resolved = resolveContainerAt(\n snapshot.context.containers,\n snapshot.context.value,\n path,\n )\n return !!(resolved && 'field' in resolved)\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport {isTypedObject} from '../utils/asserters'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Check if a node is an object node (not a text block or span).\n *\n * @public\n */\nexport function isObject(\n snapshot: TraversalSnapshot,\n node: unknown,\n): node is PortableTextObject {\n return (\n isTypedObject(node) &&\n node._type !== snapshot.context.schema.block.name &&\n node._type !== snapshot.context.schema.span.name\n )\n}\n","import {isKeyedSegment} from '../../utils/util.is-keyed-segment'\nimport type {Node} from '../interfaces/node'\nimport type {Path} from '../interfaces/path'\n\n/**\n * Compare two paths in document order.\n *\n * When paths contain keyed segments, the root node tree is needed to\n * resolve document order. Without a root, keyed segments are compared\n * by _key string (consistent but not necessarily document order).\n */\nexport function comparePaths(\n path: Path,\n another: Path,\n root: {value: Array<Node>},\n): -1 | 0 | 1 {\n const min = Math.min(path.length, another.length)\n let currentChildren: Array<Node> | undefined = root?.value\n let currentNode: Node | undefined\n\n for (let i = 0; i < min; i++) {\n const segment = path[i]!\n const otherSegment = another[i]!\n\n if (isKeyedSegment(segment) && isKeyedSegment(otherSegment)) {\n if (segment._key === otherSegment._key) {\n if (currentChildren) {\n currentNode = currentChildren.find((c) => c._key === segment._key)\n currentChildren = undefined\n }\n continue\n }\n\n if (currentChildren) {\n const segmentIndex = currentChildren.findIndex(\n (c) => c._key === segment._key,\n )\n const otherSegmentIndex = currentChildren.findIndex(\n (c) => c._key === otherSegment._key,\n )\n if (segmentIndex !== -1 && otherSegmentIndex !== -1) {\n return segmentIndex < otherSegmentIndex ? -1 : 1\n }\n }\n\n // Fallback: compare by _key string\n if (segment._key < otherSegment._key) {\n return -1\n }\n if (segment._key > otherSegment._key) {\n return 1\n }\n continue\n }\n\n if (typeof segment === 'string' && typeof otherSegment === 'string') {\n if (segment === otherSegment) {\n if (currentNode) {\n const fieldValue = (currentNode as Record<string, unknown>)[segment]\n currentChildren = Array.isArray(fieldValue)\n ? (fieldValue as Array<Node>)\n : undefined\n currentNode = undefined\n }\n continue\n }\n if (segment < otherSegment) {\n return -1\n }\n if (segment > otherSegment) {\n return 1\n }\n continue\n }\n\n if (typeof segment === 'number' && typeof otherSegment === 'number') {\n if (segment < otherSegment) {\n return -1\n }\n if (segment > otherSegment) {\n return 1\n }\n continue\n }\n\n break\n }\n\n return 0\n}\n","import type {Node} from '../interfaces/node'\nimport type {Point} from '../interfaces/point'\nimport {comparePaths} from '../path/compare-paths'\n\nexport function comparePoints(\n point: Point,\n another: Point,\n root: {value: Array<Node>},\n): -1 | 0 | 1 {\n const result = comparePaths(point.path, another.path, root)\n if (result === 0) {\n if (point.offset < another.offset) {\n return -1\n }\n if (point.offset > another.offset) {\n return 1\n }\n return 0\n }\n return result\n}\n","import type {Node} from '../interfaces/node'\nimport type {Point} from '../interfaces/point'\nimport {comparePoints} from './compare-points'\n\nexport function isAfterPoint(\n point: Point,\n another: Point,\n root: {value: Array<Node>},\n): boolean {\n return comparePoints(point, another, root) === 1\n}\n","import type {Node} from '../interfaces/node'\nimport type {Range} from '../interfaces/range'\nimport {isAfterPoint} from '../point/is-after-point'\n\nexport function isBackwardRange(\n range: Range,\n root: {value: Array<Node>},\n): boolean {\n const {anchor, focus} = range\n return isAfterPoint(anchor, focus, root)\n}\n","import type {Node} from '../interfaces/node'\nimport type {Point} from '../interfaces/point'\nimport type {Range} from '../interfaces/range'\nimport {isBackwardRange} from './is-backward-range'\n\nexport function rangeEdges(\n range: Range,\n root: {value: Array<Node>},\n): [Point, Point] {\n const {anchor, focus} = range\n return isBackwardRange(range, root) ? [focus, anchor] : [anchor, focus]\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSchema} from '../../editor/editor-schema'\nimport {isTypedObject} from '../../utils/asserters'\n\ntype TextBlockNode = {\n _type: string\n _key: string\n children?: Array<PortableTextSpan | PortableTextObject>\n markDefs?: Array<PortableTextObject>\n style?: string\n listItem?: string\n level?: number\n}\n\n/**\n * Checks if a node is a text block based on `_type` alone, without requiring\n * `children` to be present. This is needed to identify text blocks before\n * normalization has had a chance to add the missing `children` property.\n */\nexport function isTextBlockNode(\n context: {schema: EditorSchema},\n node: unknown,\n): node is TextBlockNode {\n return isTypedObject(node) && node._type === context.schema.block.name\n}\n","import {isKeyedSegment} from '../../utils/util.is-keyed-segment'\nimport type {Path} from '../interfaces/path'\n\nexport function isAncestorPath(path: Path, another: Path): boolean {\n if (path.length >= another.length) {\n return false\n }\n\n for (let i = 0; i < path.length; i++) {\n const segment = path[i]\n const otherSegment = another[i]\n\n if (isKeyedSegment(segment) && isKeyedSegment(otherSegment)) {\n if (segment._key !== otherSegment._key) {\n return false\n }\n } else if (segment !== otherSegment) {\n return false\n }\n }\n\n return true\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {serializePath} from '../paths/serialize-path'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * The index of the child addressed by `childPath`'s last segment within\n * `children` (entries as resolved by `getChildren`). Numeric last\n * segments are literal, bounds-checked indices. Keyed segments resolve\n * through `blockIndexMap` when the path is fully keyed (the map's id\n * space), verified against the entry at the mapped position, with a\n * linear scan fallback for misses, disagreements, and paths the map\n * cannot key, mirroring `getNode`/`getChildren`. Returns `-1` when the\n * child is not found.\n *\n * The map is taken explicitly rather than assumed current: some callers\n * deliberately resolve against pre-operation map state. The engine\n * keeps raw-array siblings of this helper (`resolveChildIndex` in\n * `apply-operation.ts`, `childIndexFromMap` in\n * `transform-block-index-map.ts`) for call sites that hold plain node\n * arrays mid-mutation, where no entries exist.\n */\nexport function resolveChildEntryIndex(\n blockIndexMap: ReadonlyMap<string, number>,\n children: ReadonlyArray<{node: Node; path: Path}>,\n childPath: Path,\n): number {\n const lastSegment = childPath[childPath.length - 1]\n\n if (typeof lastSegment === 'number') {\n return lastSegment >= 0 && lastSegment < children.length ? lastSegment : -1\n }\n\n if (!isKeyedSegment(lastSegment)) {\n return -1\n }\n\n let fullyKeyed = true\n for (\n let segmentIndex = 0;\n segmentIndex < childPath.length - 1;\n segmentIndex++\n ) {\n const segment = childPath[segmentIndex]\n if (typeof segment !== 'string' && !isKeyedSegment(segment)) {\n fullyKeyed = false\n break\n }\n }\n\n if (fullyKeyed) {\n const mappedIndex = blockIndexMap.get(serializePath(childPath))\n if (\n mappedIndex !== undefined &&\n children[mappedIndex]?.node._key === lastSegment._key\n ) {\n return mappedIndex\n }\n }\n\n return children.findIndex((child) => child.node._key === lastSegment._key)\n}\n","import type {EditorSchema} from '../editor/editor-schema'\nimport type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {isAncestorPath} from '../engine/path/is-ancestor-path'\nimport {serializePath} from '../paths/serialize-path'\nimport type {\n Containers,\n RegisteredContainer,\n} from '../schema/resolve-containers'\nimport {getChildren, getNodeChildren} from './get-children'\nimport {resolveChildEntryIndex} from './resolve-child-entry-index'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the descendant nodes of the node at a given path.\n *\n * When `from` and `to` are provided, performs a range-bounded DFS traversal,\n * yielding only nodes between `from` and `to` (inclusive). Both paths are\n * always in document order: `from` is the earlier path, `to` is the later\n * path. The `reverse` flag controls iteration direction within that range.\n *\n * When `match` is provided, only yields nodes where the predicate returns true.\n * The traversal still visits all nodes in range - `match` is a filter, not a\n * traversal control.\n *\n * When `at` is provided, traverses descendants of the node at that path\n * instead of the root.\n */\nexport function* getNodes(\n snapshot: TraversalSnapshot,\n options: {\n at?: Path\n from?: Path\n to?: Path\n match?: (node: Node, path: Path) => boolean\n reverse?: boolean\n } = {},\n): Generator<{node: Node; path: Path}, void, undefined> {\n const {at = [], from, to, match, reverse = false} = options\n\n if (from === undefined && to === undefined) {\n yield* getNodesSimple(snapshot, at, {match, reverse})\n return\n }\n\n yield* getNodesInRange(snapshot, at, {from, to, match, reverse})\n}\n\n/**\n * Get descendant nodes of a standalone node (not in the editor tree).\n * Used for cases like getDirtyPaths where the node hasn't been inserted yet.\n */\nexport function* getNodeDescendants(\n context: {\n schema: EditorSchema\n containers: Containers\n },\n node: Node | {value: Array<Node>},\n): Generator<{node: Node; path: Path}, void, undefined> {\n // The editor root wrapper ({value: [...]}) is not a real node, so its field\n // name is not part of paths. For standalone nodes (a real {_key, _type, ...}\n // passed in by callers like getDirtyPaths), the field name IS part of the\n // path.\n const isRoot = !('_key' in node) && !('_type' in node)\n yield* walkStandalone(context, node, [], isRoot)\n}\n\nfunction* walkStandalone(\n context: {\n schema: EditorSchema\n containers: Containers\n },\n node: Node | {value: Array<Node>},\n path: Path,\n isRoot: boolean,\n parent?: RegisteredContainer,\n): Generator<{node: Node; path: Path}, void, undefined> {\n const next = getNodeChildren(context, node, parent)\n if (!next) {\n return\n }\n\n for (const child of next.children) {\n const childPath: Path = isRoot\n ? [{_key: child._key}]\n : [...path, next.fieldName, {_key: child._key}]\n yield {node: child, path: childPath}\n yield* walkStandalone(context, child, childPath, false, next.parent)\n }\n}\n\n/**\n * Simple recursive DFS - the original behavior.\n * Yields all descendants of the node at `path`.\n */\nfunction* getNodesSimple(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match?: (node: Node, path: Path) => boolean\n reverse?: boolean\n },\n): Generator<{node: Node; path: Path}, void, undefined> {\n const {match, reverse = false} = options\n\n const children = getChildren(snapshot, path)\n\n const entries = reverse ? [...children].reverse() : children\n\n for (const entry of entries) {\n if (!match || match(entry.node, entry.path)) {\n yield entry\n }\n\n yield* getNodesSimple(snapshot, entry.path, options)\n }\n}\n\n/**\n * Compare two keyed paths in DFS pre-order. Returns -1, 0, or 1.\n *\n * Walks both paths in parallel; at the first divergence, consults\n * `blockIndexMap` for the sibling indices and compares them.\n *\n * Deliberately not `comparePaths` (`engine/path/compare-paths.ts`):\n * that compare treats an ancestor/descendant pair as equal (0), while\n * range traversal needs the ancestor ordered first (-1/1), it is what\n * excludes `to`'s descendants from a range. The two compares answer\n * different questions and must not be merged.\n */\nfunction comparePathsInTree(\n snapshot: TraversalSnapshot,\n pathA: Path,\n pathB: Path,\n): -1 | 0 | 1 {\n // Walk both full paths in parallel; at the first divergent keyed\n // segment, consult blockIndexMap for the sibling indices. The map is\n // keyed by serialized paths that include both keyed and field-name\n // segments, so we keep the full path prefix as we descend.\n const minLength = Math.min(pathA.length, pathB.length)\n const prefix: Path = []\n\n for (let i = 0; i < minLength; i++) {\n const segA = pathA[i]!\n const segB = pathB[i]!\n\n if (\n typeof segA === 'string' ||\n typeof segB === 'string' ||\n typeof segA === 'number' ||\n typeof segB === 'number' ||\n Array.isArray(segA) ||\n Array.isArray(segB)\n ) {\n prefix.push(segA as never)\n continue\n }\n\n if (segA._key === segB._key) {\n prefix.push(segA)\n continue\n }\n\n const indexA =\n snapshot.blockIndexMap.get(serializePath([...prefix, segA])) ?? -1\n const indexB =\n snapshot.blockIndexMap.get(serializePath([...prefix, segB])) ?? -1\n if (indexA < indexB) {\n return -1\n }\n if (indexA > indexB) {\n return 1\n }\n return 0\n }\n\n // One path is a prefix of the other (ancestor relationship).\n // In DFS order, shorter path (ancestor) comes first.\n if (pathA.length < pathB.length) {\n return -1\n }\n if (pathA.length > pathB.length) {\n return 1\n }\n\n return 0\n}\n\n/**\n * Range-bounded recursive DFS traversal.\n *\n * `from` and `to` are always in document order (from is earlier, to is\n * later), regardless of traversal direction.\n */\nfunction* getNodesInRange(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n from?: Path\n to?: Path\n match?: (node: Node, path: Path) => boolean\n reverse?: boolean\n },\n): Generator<{node: Node; path: Path}, void, undefined> {\n const {from, to, match, reverse = false} = options\n\n const children = getChildren(snapshot, path)\n\n // Seek instead of scan: only the children between the boundaries'\n // branches at this level can intersect [from, to], so resolve those\n // positions (O(1) through `blockIndexMap`) and iterate the window\n // between them. The per-entry checks below stay the semantic source\n // of truth; an unresolvable boundary just leaves its side of the\n // window open, degrading to the previous full scan.\n const startIndex =\n from === undefined ? 0 : (boundaryChildIndex(snapshot, children, from) ?? 0)\n const endIndex =\n to === undefined\n ? children.length - 1\n : (boundaryChildIndex(snapshot, children, to) ?? children.length - 1)\n const window = children.slice(startIndex, endIndex + 1)\n const entries = reverse ? window.reverse() : window\n\n for (const entry of entries) {\n if (canStopTraversal(snapshot, entry.path, from, to, reverse)) {\n return\n }\n\n if (!couldContainInRangeNodes(snapshot, entry.path, from, to)) {\n continue\n }\n\n if (isInRange(snapshot, entry.path, from, to)) {\n if (!match || match(entry.node, entry.path)) {\n yield entry\n }\n }\n\n yield* getNodesInRange(snapshot, entry.path, options)\n }\n}\n\n/**\n * The index of the child whose subtree `boundary` passes through, at\n * the level `children` was resolved for. `undefined` when the boundary\n * does not pass through this level or cannot be resolved, in which\n * case the caller must not narrow the window on that side.\n */\nfunction boundaryChildIndex(\n snapshot: TraversalSnapshot,\n children: Array<{node: Node; path: Path}>,\n boundary: Path,\n): number | undefined {\n const firstChild = children[0]\n if (!firstChild) {\n return undefined\n }\n const childPathLength = firstChild.path.length\n if (boundary.length < childPathLength) {\n return undefined\n }\n\n // The children share every path segment but the last; the boundary\n // passes through this level only when that shared prefix is an\n // ancestor of it.\n const sharedPrefix = firstChild.path.slice(0, -1)\n if (sharedPrefix.length > 0 && !isAncestorPath(sharedPrefix, boundary)) {\n return undefined\n }\n\n const resolvedIndex = resolveChildEntryIndex(\n snapshot.blockIndexMap,\n children,\n boundary.slice(0, childPathLength),\n )\n return resolvedIndex === -1 ? undefined : resolvedIndex\n}\n\n/**\n * Check if a node is within the [from, to] range in document order.\n * Both bounds are inclusive. Ancestor nodes of from or to are also\n * considered in range since they contain the range boundary.\n */\nfunction isInRange(\n snapshot: TraversalSnapshot,\n nodePath: Path,\n from: Path | undefined,\n to: Path | undefined,\n): boolean {\n if (\n from !== undefined &&\n comparePathsInTree(snapshot, nodePath, from) === -1\n ) {\n if (!isAncestorPath(nodePath, from)) {\n return false\n }\n }\n\n if (to !== undefined && comparePathsInTree(snapshot, nodePath, to) === 1) {\n if (!isAncestorPath(nodePath, to)) {\n return false\n }\n }\n\n return true\n}\n\n/**\n * Check if a subtree rooted at `nodePath` could contain any nodes in the\n * [from, to] range.\n */\nfunction couldContainInRangeNodes(\n snapshot: TraversalSnapshot,\n nodePath: Path,\n from: Path | undefined,\n to: Path | undefined,\n): boolean {\n if (isInRange(snapshot, nodePath, from, to)) {\n return true\n }\n\n if (from !== undefined && isAncestorPath(nodePath, from)) {\n return true\n }\n\n if (to !== undefined && isAncestorPath(nodePath, to)) {\n return true\n }\n\n return false\n}\n\n/**\n * Check if all remaining nodes in iteration order will be outside the range.\n */\nfunction canStopTraversal(\n snapshot: TraversalSnapshot,\n nodePath: Path,\n from: Path | undefined,\n to: Path | undefined,\n reverse: boolean,\n): boolean {\n if (reverse) {\n if (from === undefined) {\n return false\n }\n\n return (\n comparePathsInTree(snapshot, nodePath, from) === -1 &&\n !isAncestorPath(nodePath, from)\n )\n }\n\n if (to === undefined) {\n return false\n }\n\n return comparePathsInTree(snapshot, nodePath, to) === 1\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from './get-children'\nimport {resolveChildEntryIndex} from './resolve-child-entry-index'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get a sibling of the node at a given path.\n *\n * Without `match`, returns the immediate next or previous sibling.\n * With `match`, returns the first sibling in `direction` that satisfies\n * the predicate.\n *\n * When `match` is a type predicate, the returned `node` narrows to that type.\n *\n * @public\n */\nexport function getSibling<TMatch extends Node>(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n direction: 'next' | 'previous'\n match: (node: Node, path: Path) => node is TMatch\n },\n): {node: TMatch; path: Path} | undefined\n/**\n * @public\n */\nexport function getSibling(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n direction: 'next' | 'previous'\n match?: (node: Node, path: Path) => boolean\n },\n): {node: Node; path: Path} | undefined\nexport function getSibling(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n direction: 'next' | 'previous'\n match?: (node: Node, path: Path) => boolean\n },\n): {node: Node; path: Path} | undefined {\n const {direction, match} = options\n\n if (path.length === 0) {\n return undefined\n }\n\n const parent = parentPath(path)\n const children = getChildren(snapshot, parent)\n\n const currentIndex = resolveChildEntryIndex(\n snapshot.blockIndexMap,\n children,\n path,\n )\n\n if (currentIndex === -1) {\n return undefined\n }\n\n if (!match) {\n const siblingIndex =\n direction === 'next' ? currentIndex + 1 : currentIndex - 1\n\n if (siblingIndex < 0 || siblingIndex >= children.length) {\n return undefined\n }\n\n return children[siblingIndex]\n }\n\n const candidates =\n direction === 'next'\n ? children.slice(currentIndex + 1)\n : children.slice(0, currentIndex).reverse()\n\n return candidates.find((child) => match(child.node, child.path))\n}\n","import type {EditorSchema} from '../../editor/editor-schema'\nimport {isTypedObject} from '../../utils/asserters'\n\nexport type SpanNode = {\n _type: string\n _key: string\n text?: string\n marks?: Array<string>\n}\n\n/**\n * Checks if a node is a span based on `_type` alone, without requiring `text`\n * to be present. This is needed to identify spans before normalization has had\n * a chance to add the missing `text` property.\n */\nexport function isSpanNode(\n context: {schema: EditorSchema},\n node: unknown,\n): node is SpanNode {\n return isTypedObject(node) && node._type === context.schema.span.name\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {isSpanNode} from '../engine/node/is-span-node'\nimport {isTextBlockNode} from '../engine/node/is-text-block-node'\nimport {getNode} from './get-node'\nimport {getParent} from './get-parent'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Determine if a node at the given path is a block.\n *\n * A node is a block if its parent is not a text block. Top-level nodes\n * (direct children of the editor) are always blocks. Children of text blocks\n * (spans and inline objects) are not blocks. Children of containers are\n * blocks within that container.\n *\n * @public\n */\nexport function isBlock(snapshot: TraversalSnapshot, path: Path): boolean {\n const parent = getParent(snapshot, path)\n\n if (!parent) {\n return true\n }\n\n return !isTextBlockNode({schema: snapshot.context.schema}, parent.node)\n}\n\n/**\n * Get the node at the given path if it is a block.\n *\n * Returns the node narrowed to PortableTextBlock, or undefined if the node\n * doesn't exist or is not a block.\n *\n * @public\n */\nexport function getBlock(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: PortableTextBlock; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isBlock(snapshot, path)) {\n return undefined\n }\n\n if (isSpanNode({schema: snapshot.context.schema}, entry.node)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n","import type {Path} from '../engine/interfaces/path'\nimport {isBlock} from './is-block'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Determine if a node at the given path is inline.\n *\n * A node is inline if its parent is a text block. This is the inverse of\n * `isBlock`. Top-level nodes are never inline.\n *\n * @public\n */\nexport function isInline(snapshot: TraversalSnapshot, path: Path): boolean {\n return !isBlock(snapshot, path)\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getAncestors} from './get-ancestors'\nimport {getBlock} from './is-block'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Walk up from a path to find the nearest enclosing block.\n *\n * Returns the node at the path if it is a block, otherwise the first ancestor\n * that is a block. Works at any depth — inside a container this returns the\n * container-internal block, not the outer container.\n *\n * With `match`, returns the first enclosing block that also satisfies the\n * predicate. When `match` is a type predicate, the returned `node` narrows\n * to that type.\n *\n * `mode: 'lowest'` (default) returns the innermost enclosing block; the node\n * at the path itself counts. `mode: 'highest'` returns the outermost\n * ancestor that matches, falling back to the node at the path only if no\n * ancestor does.\n *\n * @public\n */\nexport function getEnclosingBlock<TMatch extends PortableTextBlock>(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => node is TMatch\n mode?: 'lowest' | 'highest'\n },\n): {node: TMatch; path: Path} | undefined\n/**\n * @public\n */\nexport function getEnclosingBlock(\n snapshot: TraversalSnapshot,\n path: Path,\n options?: {\n match?: (node: PortableTextBlock, path: Path) => boolean\n mode?: 'lowest' | 'highest'\n },\n): {node: PortableTextBlock; path: Path} | undefined\nexport function getEnclosingBlock(\n snapshot: TraversalSnapshot,\n path: Path,\n options?: {\n match?: (node: PortableTextBlock, path: Path) => boolean\n mode?: 'lowest' | 'highest'\n },\n): {node: PortableTextBlock; path: Path} | undefined {\n const match = options?.match\n const mode = options?.mode ?? 'lowest'\n\n if (mode === 'highest') {\n const ancestors = getAncestors(snapshot, path)\n\n for (const ancestor of [...ancestors].reverse()) {\n if (!match || match(ancestor.node, ancestor.path)) {\n return ancestor\n }\n }\n\n const direct = getBlock(snapshot, path)\n\n if (direct && (!match || match(direct.node, direct.path))) {\n return direct\n }\n\n return undefined\n }\n\n const direct = getBlock(snapshot, path)\n\n if (direct && (!match || match(direct.node, direct.path))) {\n return direct\n }\n\n for (const ancestor of getAncestors(snapshot, path)) {\n if (!match || match(ancestor.node, ancestor.path)) {\n return ancestor\n }\n }\n\n return undefined\n}\n","import {comparePaths} from '../engine/path/compare-paths'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Returns:\n *\n * - `-1` if `pointA` is before `pointB`\n * - `0` if `pointA` and `pointB` are equal\n * - `1` if `pointA` is after `pointB`.\n *\n * Compares the two points by document order, resolved at any depth. When\n * the paths are equal, compares offsets.\n *\n * @public\n */\nexport function comparePoints(\n snapshot: TraversalSnapshot,\n pointA: EditorSelectionPoint,\n pointB: EditorSelectionPoint,\n): -1 | 0 | 1 {\n const pathComparison = comparePaths(pointA.path, pointB.path, {\n value: snapshot.context.value,\n })\n\n if (pathComparison !== 0) {\n return pathComparison\n }\n\n if (pointA.offset < pointB.offset) {\n return -1\n }\n\n if (pointA.offset > pointB.offset) {\n return 1\n }\n\n return 0\n}\n","import type {Path} from '../engine/interfaces/path'\nimport {getAncestors} from '../traversal/get-ancestors'\nimport {isObject} from '../traversal/is-object'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {RegisteredContainer} from './container-types'\nimport {resolveContainerAt} from './resolve-container-at'\n\n/**\n * Descent primitive: return the immediate parent\n * {@link RegisteredContainer} of the node at `path` (and that parent's\n * path), or `undefined` when the target's immediate parent is the\n * editor root, when no object-node ancestor is a registered container,\n * or when descent hits an ancestor whose `_type` is not registered.\n *\n * Walks ancestors and resolves each object-node ancestor positionally\n * via {@link resolveContainerAt}. Text-block and span ancestors are\n * skipped - \"container\" here means the enclosing object container,\n * not the text-block holding spans.\n */\nexport function descendToParent(\n snapshot: TraversalSnapshot,\n path: Path,\n): {parent: RegisteredContainer; parentPath: Path} | undefined {\n const ancestors = getAncestors(snapshot, path)\n for (const ancestor of ancestors) {\n if (!isObject(snapshot, ancestor.node)) {\n continue\n }\n const resolved = resolveContainerAt(\n snapshot.context.containers,\n snapshot.context.value,\n ancestor.path,\n )\n if (!resolved || !('field' in resolved)) {\n return undefined\n }\n return {parent: resolved, parentPath: ancestor.path}\n }\n return undefined\n}\n","import type {OfDefinition} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport {descendToParent} from './descend-to-parent'\n\n/**\n * Return the immediate registered-container ancestor of `path` along\n * with its `of` array (the schema definitions accepted at this position).\n *\n * Position-aware: nested-only registrations (e.g. `cell` registered\n * only inside `table.row.of`) are recognized via the same descent\n * primitive used by all parent-aware traversal.\n *\n * Returns `undefined` when `path` has no registered-container ancestor\n * (i.e. is at the document root) or when descent hits a leaf-resolved\n * ancestor.\n */\nexport function getEnclosingContainer(\n snapshot: TraversalSnapshot,\n path: Path,\n):\n | {\n of: ReadonlyArray<OfDefinition>\n path: Path\n }\n | undefined {\n const descent = descendToParent(snapshot, path)\n if (!descent) {\n return undefined\n }\n return {\n of: descent.parent.field.of,\n path: descent.parentPath,\n }\n}\n","import {getSubSchema, type Schema} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getEnclosingContainer} from '../schema/get-enclosing-container'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Return the `Schema` view that applies at a given path.\n *\n * For paths at the root of the document, or for paths where no ancestor is\n * a registered container, returns the top-level schema. For paths inside a\n * container, walks ancestors to find the nearest container and returns the\n * sub-schema derived from its `of` declaration.\n *\n * @public\n */\nexport function getPathSubSchema(\n snapshot: TraversalSnapshot,\n path: Path,\n): Schema {\n const enclosing = getEnclosingContainer(snapshot, path)\n\n if (!enclosing) {\n return snapshot.context.schema\n }\n\n return getSubSchema(snapshot.context.schema, enclosing.of)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,SAAgB,aACd,UACA,MAC8C;CAE9C,IAAM,eAA8B,CAAC;CACrC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAC/B,AAAI,eAAe,KAAK,EAAE,KACxB,aAAa,KAAK,CAAC;CAKvB,IAAI,aAAa,UAAU,GACzB,OAAO,CAAC;CAGV,IAAM,EAAC,SAAS,kBAAiB,UAC7B,kBAA+B,QAAQ,OACvC,eAEE,mBAAiE,CAAC,GAClE,eAAqB,CAAC,GAItB,mBAAmB,aAAa,aAAa,SAAS,IAExD,eAAe;CACnB,OAAO,eAAe,mBAAkB;EACtC,IAAM,UAAU,KAAK;EAErB,IAAI,OAAO,WAAY,UAAU;GAE/B,AADA,aAAa,KAAK,OAAO,GACzB;GACA;EACF;EAEA,IAAI;EACJ,IAAI,eAAe,OAAO,GAAG;GAC3B,aAAa,KAAK,OAAO;GACzB,IAAM,QAAQ,cAAc,IAAI,cAAc,YAAY,CAAC;GAC3D,AACE,UAAU,KAAA,KACV,gBAAgB,MAAM,EAAE,SAAS,QAAQ,OAEzC,OAAO,gBAAgB,UAOvB,OAAO,gBAAgB,MAAM,UAAU,MAAM,SAAS,QAAQ,IAAI,GAC9D,QAAQ,KAAK,SAAS,KAAA,MACxB,aAAa,a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