@portabletext/editor 8.1.6 → 8.1.7

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.
Files changed (26) hide show
  1. package/lib/{behavior.types.action-BDNqhLEt.d.ts → behavior.types.action-Dg36r1rf.d.ts} +2 -2
  2. package/lib/{behavior.types.action-BDNqhLEt.d.ts.map → behavior.types.action-Dg36r1rf.d.ts.map} +1 -1
  3. package/lib/behaviors/index.d.ts +1 -1
  4. package/lib/{get-container-CXdmRdiX.js → get-container-BNT2gY-T.js} +3 -3
  5. package/lib/{get-container-CXdmRdiX.js.map → get-container-BNT2gY-T.js.map} +1 -1
  6. package/lib/{get-parent-BLzi7eLr.js → get-parent-1LYvKkzm.js} +2 -2
  7. package/lib/{get-parent-BLzi7eLr.js.map → get-parent-1LYvKkzm.js.map} +1 -1
  8. package/lib/{get-path-sub-schema-DsN1qF_l.js → get-path-sub-schema-BQTgjrJ0.js} +2 -2
  9. package/lib/{get-path-sub-schema-DsN1qF_l.js.map → get-path-sub-schema-BQTgjrJ0.js.map} +1 -1
  10. package/lib/index.d.ts +1 -1
  11. package/lib/index.js +30 -647
  12. package/lib/index.js.map +1 -1
  13. package/lib/plugins/index.d.ts +1 -1
  14. package/lib/{selector.is-selecting-entire-blocks-BHVYIXbI.js → selector.is-selecting-entire-blocks-CAUZpsBb.js} +6 -6
  15. package/lib/{selector.is-selecting-entire-blocks-BHVYIXbI.js.map → selector.is-selecting-entire-blocks-CAUZpsBb.js.map} +1 -1
  16. package/lib/selectors/index.d.ts +1 -1
  17. package/lib/selectors/index.js +4 -4
  18. package/lib/traversal/index.d.ts +1 -1
  19. package/lib/traversal/index.js +3 -3
  20. package/lib/{util.is-equal-selections-sCQib0IC.js → util.is-equal-selections-Ae0HO_72.js} +2 -2
  21. package/lib/{util.is-equal-selections-sCQib0IC.js.map → util.is-equal-selections-Ae0HO_72.js.map} +1 -1
  22. package/lib/{util.slice-blocks-B-iKFEG7.js → util.slice-blocks-By7qN-i2.js} +3 -3
  23. package/lib/{util.slice-blocks-B-iKFEG7.js.map → util.slice-blocks-By7qN-i2.js.map} +1 -1
  24. package/lib/utils/index.d.ts +1 -1
  25. package/lib/utils/index.js +3 -3
  26. package/package.json +2 -5
@@ -1 +1 @@
1
- {"version":3,"file":"get-path-sub-schema-DsN1qF_l.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 {nodeSegment} from '../paths/node-segment'\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 node-segment indices (keyed or numeric) to know where each\n // ancestor's path ends.\n const keyedIndices: Array<number> = []\n for (let i = 0; i < path.length; i++) {\n if (isKeyedSegment(path[i]) || typeof path[i] === 'number') {\n keyedIndices.push(i)\n }\n }\n\n // Need at least 2 node 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 const scanIndex = currentChildren.findIndex(\n (child) => child._key === segment._key,\n )\n node = scanIndex === -1 ? undefined : currentChildren[scanIndex]\n if (node) {\n resolvedPath[resolvedPath.length - 1] = nodeSegment(node, scanIndex)\n }\n }\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push(nodeSegment(node, segment))\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 {nodeSegment} from '../paths/node-segment'\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 (let childIndex = 0; childIndex < next.children.length; childIndex++) {\n const child = next.children[childIndex]!\n const childPath: Path = isRoot\n ? [nodeSegment(child, childIndex)]\n : [...path, next.fieldName, nodeSegment(child, childIndex)]\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":";;;;;;;;;;;;;;;;;;AA0BA,SAAgB,aACd,UACA,MAC8C;CAG9C,IAAM,eAA8B,CAAC;CACrC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAC/B,CAAI,eAAe,KAAK,EAAE,KAAK,OAAO,KAAK,MAAO,aAChD,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;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B,IAInB,OAAO,SAAS,OAAO,SAClB,KAGT,EAAI,OAAO,SAAS,OAAO,UAPlB;AAYX;;;;;;;;;;;;;ACnBA,SAAgB,gBACd,UACA,MAC6D;CAC7D,IAAM,YAAY,aAAa,UAAU,IAAI;CAC7C,KAAK,IAAM,YAAY,WAAW;EAChC,IAAI,CAAC,SAAS,UAAU,SAAS,IAAI,GACnC;EAEF,IAAM,WAAW,mBACf,SAAS,QAAQ,YACjB,SAAS,QAAQ,OACjB,SAAS,IACX;EAIA,OAHI,CAAC,YAAY,EAAE,WAAW,YAC5B,SAEK;GAAC,QAAQ;GAAU,YAAY,SAAS;EAAI;CACrD;AAEF;;;;;;;;;;;;;ACtBA,SAAgB,sBACd,UACA,MAMY;CACZ,IAAM,UAAU,gBAAgB,UAAU,IAAI;CACzC,aAGL,OAAO;EACL,IAAI,QAAQ,OAAO,MAAM;EACzB,MAAM,QAAQ;CAChB;AACF;;;;;;;;;;;ACnBA,SAAgB,iBACd,UACA,MACQ;CACR,IAAM,YAAY,sBAAsB,UAAU,IAAI;CAMtD,OAJK,YAIE,aAAa,SAAS,QAAQ,QAAQ,UAAU,EAAE,IAHhD,SAAS,QAAQ;AAI5B"}
1
+ {"version":3,"file":"get-path-sub-schema-BQTgjrJ0.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 {nodeSegment} from '../paths/node-segment'\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 node-segment indices (keyed or numeric) to know where each\n // ancestor's path ends.\n const keyedIndices: Array<number> = []\n for (let i = 0; i < path.length; i++) {\n if (isKeyedSegment(path[i]) || typeof path[i] === 'number') {\n keyedIndices.push(i)\n }\n }\n\n // Need at least 2 node 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 const scanIndex = currentChildren.findIndex(\n (child) => child._key === segment._key,\n )\n node = scanIndex === -1 ? undefined : currentChildren[scanIndex]\n if (node) {\n resolvedPath[resolvedPath.length - 1] = nodeSegment(node, scanIndex)\n }\n }\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push(nodeSegment(node, segment))\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 {nodeSegment} from '../paths/node-segment'\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 (let childIndex = 0; childIndex < next.children.length; childIndex++) {\n const child = next.children[childIndex]!\n const childPath: Path = isRoot\n ? [nodeSegment(child, childIndex)]\n : [...path, next.fieldName, nodeSegment(child, childIndex)]\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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JK,YAIE,aAAa,SAAS,QAAQ,QAAQ,UAAU,EAAE,IAHhD,SAAS,QAAQ;AAI5B"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $t as defineBlockObject, A as PortableTextSpan, At as Annotation, B as usePortableTextEditor, Bt as DecoratorRender, C as ListDefinition, Ct as EditorSchema, D as PortableTextBlock, Dt as RegisteredInlineObject, E as Patch, Et as RegisteredContainer, F as defineSchema, Ft as BlockObjectRenderProps, G as Editor, Gt as RegistrableNode, H as useEditorSelector, Ht as InlineObject, I as BlockOffset, It as Container, J as EditorEmittedEvent, Jt as SpanRenderProps, K as EditorConfig, Kt as Span, L as useEditor, Lt as ContainerRender, M as SchemaDefinition, Mt as AnnotationRenderProps, N as StyleDefinition, Nt as BlockObject, O as PortableTextChild, Ot as RegisteredPositional, P as StyleSchemaType, Pt as BlockObjectRender, Qt as defineAnnotation, R as defaultKeyGenerator, Rt as ContainerRenderProps, S as InlineObjectSchemaType, T as OfDefinition, Tt as RegisteredBlockObject, U as EditorProvider, Ut as InlineObjectRender, V as EditorSelector, Vt as DecoratorRenderProps, W as EditorProviderProps, Wt as InlineObjectRenderProps, X as Operation, Xt as TextBlockRender, Y as MutationEvent, Yt as TextBlock, Zt as TextBlockRenderProps, _ as BlockObjectSchemaType, _t as PortableTextEditable, an as AnnotationPath, at as EditorSelectionPoint, b as FieldDefinition, bt as PortableTextEditor, ct as OnPasteFn, dt as PasteData, en as defineContainer, et as EditorContext, f as PatchesEvent, ft as RangeDecoration, g as BlockObjectDefinition, gt as ScrollSelectionIntoViewFunction, h as BaseDefinition, ht as RenderPlaceholderFunction, in as defineTextBlock, it as EditorSelection, j as PortableTextTextBlock, jt as AnnotationRender, k as PortableTextObject, kt as RegisteredSpan, ln as Path, lt as OnPasteResult, m as AnnotationSchemaType, mt as RenderEditableFunction, nn as defineInlineObject, nt as AddedAnnotationPaths, on as BlockPath, ot as InvalidValueResolution, p as AnnotationDefinition, pt as RangeDecorationOnMovedDetails, q as EditorEvent, qt as SpanRender, rn as defineSpan, rt as EditableAPIDeleteOptions, sn as ChildPath, st as OnCopyFn, tn as defineDecorator, tt as EditorSnapshot, ut as OnPasteResultOrPromise, v as DecoratorDefinition, vt as PortableTextEditableProps, w as ListSchemaType, wt as Containers, x as InlineObjectDefinition, y as DecoratorSchemaType, yt as HotkeyOptions, z as usePortableTextEditorSelection, zt as Decorator } from "./behavior.types.action-BDNqhLEt.js";
1
+ import { $t as defineBlockObject, A as PortableTextSpan, At as Annotation, B as usePortableTextEditor, Bt as DecoratorRender, C as ListDefinition, Ct as EditorSchema, D as PortableTextBlock, Dt as RegisteredInlineObject, E as Patch, Et as RegisteredContainer, F as defineSchema, Ft as BlockObjectRenderProps, G as Editor, Gt as RegistrableNode, H as useEditorSelector, Ht as InlineObject, I as BlockOffset, It as Container, J as EditorEmittedEvent, Jt as SpanRenderProps, K as EditorConfig, Kt as Span, L as useEditor, Lt as ContainerRender, M as SchemaDefinition, Mt as AnnotationRenderProps, N as StyleDefinition, Nt as BlockObject, O as PortableTextChild, Ot as RegisteredPositional, P as StyleSchemaType, Pt as BlockObjectRender, Qt as defineAnnotation, R as defaultKeyGenerator, Rt as ContainerRenderProps, S as InlineObjectSchemaType, T as OfDefinition, Tt as RegisteredBlockObject, U as EditorProvider, Ut as InlineObjectRender, V as EditorSelector, Vt as DecoratorRenderProps, W as EditorProviderProps, Wt as InlineObjectRenderProps, X as Operation, Xt as TextBlockRender, Y as MutationEvent, Yt as TextBlock, Zt as TextBlockRenderProps, _ as BlockObjectSchemaType, _t as PortableTextEditable, an as AnnotationPath, at as EditorSelectionPoint, b as FieldDefinition, bt as PortableTextEditor, ct as OnPasteFn, dt as PasteData, en as defineContainer, et as EditorContext, f as PatchesEvent, ft as RangeDecoration, g as BlockObjectDefinition, gt as ScrollSelectionIntoViewFunction, h as BaseDefinition, ht as RenderPlaceholderFunction, in as defineTextBlock, it as EditorSelection, j as PortableTextTextBlock, jt as AnnotationRender, k as PortableTextObject, kt as RegisteredSpan, ln as Path, lt as OnPasteResult, m as AnnotationSchemaType, mt as RenderEditableFunction, nn as defineInlineObject, nt as AddedAnnotationPaths, on as BlockPath, ot as InvalidValueResolution, p as AnnotationDefinition, pt as RangeDecorationOnMovedDetails, q as EditorEvent, qt as SpanRender, rn as defineSpan, rt as EditableAPIDeleteOptions, sn as ChildPath, st as OnCopyFn, tn as defineDecorator, tt as EditorSnapshot, ut as OnPasteResultOrPromise, v as DecoratorDefinition, vt as PortableTextEditableProps, w as ListSchemaType, wt as Containers, x as InlineObjectDefinition, y as DecoratorSchemaType, yt as HotkeyOptions, z as usePortableTextEditorSelection, zt as Decorator } from "./behavior.types.action-Dg36r1rf.js";
2
2
  export { type AddedAnnotationPaths, type Annotation, type AnnotationDefinition, type AnnotationPath, type AnnotationRender, type AnnotationRenderProps, type AnnotationSchemaType, type BaseDefinition, type BlockObject, type BlockObjectDefinition, type BlockObjectRender, type BlockObjectRenderProps, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type ChildPath, type Container, type ContainerRender, type ContainerRenderProps, type Containers, type Decorator, type DecoratorDefinition, type DecoratorRender, type DecoratorRenderProps, type DecoratorSchemaType, type EditableAPIDeleteOptions, type Editor, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type FieldDefinition, type HotkeyOptions, type InlineObject, type InlineObjectDefinition, type InlineObjectRender, type InlineObjectRenderProps, type InlineObjectSchemaType, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type MutationEvent, type OfDefinition, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type Operation, type PasteData, type Patch, type PatchesEvent, type Path, type PortableTextBlock, type PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextObject, type PortableTextSpan, type PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type RegisteredBlockObject, type RegisteredContainer, type RegisteredInlineObject, type RegisteredPositional, type RegisteredSpan, type RegistrableNode, type RenderEditableFunction, type RenderPlaceholderFunction, type SchemaDefinition, type ScrollSelectionIntoViewFunction, type Span, type SpanRender, type SpanRenderProps, type StyleDefinition, type StyleSchemaType, type TextBlock, type TextBlockRender, type TextBlockRenderProps, defineAnnotation, defineBlockObject, defineContainer, defineDecorator, defineInlineObject, defineSchema, defineSpan, defineTextBlock, defaultKeyGenerator as keyGenerator, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };