@portabletext/editor 7.10.18 → 7.11.0

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 (40) hide show
  1. package/README.md +3 -0
  2. package/lib/{behavior.types.action-CYtiRDck.d.ts → behavior.types.action-DXkAaEGS.d.ts} +167 -95
  3. package/lib/behavior.types.action-DXkAaEGS.d.ts.map +1 -0
  4. package/lib/{behavior.types.behavior-B_77VtQR.js → behavior.types.behavior-BxSLb73I.js} +5 -5
  5. package/lib/behavior.types.behavior-BxSLb73I.js.map +1 -0
  6. package/lib/behaviors/index.d.ts +1 -1
  7. package/lib/behaviors/index.js +1 -1
  8. package/lib/{get-container-BeXYKpoi.js → get-container-D1nM_ww9.js} +14 -14
  9. package/lib/get-container-D1nM_ww9.js.map +1 -0
  10. package/lib/{get-parent-51Kzgaf9.js → get-parent-Ci5241qs.js} +3 -3
  11. package/lib/get-parent-Ci5241qs.js.map +1 -0
  12. package/lib/{get-path-sub-schema--2I4NJbG.js → get-path-sub-schema-CZd9VcVM.js} +10 -10
  13. package/lib/get-path-sub-schema-CZd9VcVM.js.map +1 -0
  14. package/lib/index.d.ts +2 -2
  15. package/lib/index.js +13 -12
  16. package/lib/index.js.map +1 -1
  17. package/lib/plugins/index.d.ts +4 -4
  18. package/lib/plugins/index.js +3 -3
  19. package/lib/plugins/index.js.map +1 -1
  20. package/lib/{selector.is-at-the-start-of-block-gJIMWRpU.js → selector.is-at-the-start-of-block-D0boZbDu.js} +4 -4
  21. package/lib/selector.is-at-the-start-of-block-D0boZbDu.js.map +1 -0
  22. package/lib/selectors/index.d.ts +6 -6
  23. package/lib/selectors/index.js +6 -6
  24. package/lib/selectors/index.js.map +1 -1
  25. package/lib/traversal/index.d.ts +31 -31
  26. package/lib/traversal/index.js +4 -4
  27. package/lib/traversal/index.js.map +1 -1
  28. package/lib/{util.is-equal-selections-BF4WJtz5.js → util.is-equal-selections-N1hxVUbE.js} +2 -2
  29. package/lib/{util.is-equal-selections-BF4WJtz5.js.map → util.is-equal-selections-N1hxVUbE.js.map} +1 -1
  30. package/lib/{util.slice-blocks-DQnr9X2s.js → util.slice-blocks-B2fZcNok.js} +2 -2
  31. package/lib/{util.slice-blocks-DQnr9X2s.js.map → util.slice-blocks-B2fZcNok.js.map} +1 -1
  32. package/lib/utils/index.d.ts +1 -1
  33. package/lib/utils/index.js +3 -3
  34. package/package.json +3 -3
  35. package/lib/behavior.types.action-CYtiRDck.d.ts.map +0 -1
  36. package/lib/behavior.types.behavior-B_77VtQR.js.map +0 -1
  37. package/lib/get-container-BeXYKpoi.js.map +0 -1
  38. package/lib/get-parent-51Kzgaf9.js.map +0 -1
  39. package/lib/get-path-sub-schema--2I4NJbG.js.map +0 -1
  40. package/lib/selector.is-at-the-start-of-block-gJIMWRpU.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-path-sub-schema--2I4NJbG.js","names":["PortableTextBlock","Node","Path","serializePath","RegisteredContainer","isKeyedSegment","getNodeChildren","TraversalSnapshot","getAncestors","snapshot","path","Array","node","keyedIndices","i","length","push","context","blockIndexMap","currentChildren","value","currentParent","ancestorsByDepth","resolvedPath","targetKeyedIndex","segmentIndex","segment","index","get","undefined","_key","find","child","at","next","slice","children","parent","reverse","Path","getNode","TraversalSnapshot","hasNode","snapshot","path","undefined","Node","Path","isKeyedSegment","Containers","RegisteredContainer","RegisteredPositional","resolveContainerAt","containers","value","ReadonlyArray","path","keyedIndices","Array","index","length","push","undefined","currentChildren","parent","resolved","targetKeyedIndex","segmentIndex","segment","node","find","child","_key","at","resolveNodeEntry","fieldValue","Record","field","name","isArray","of","entry","type","_type","get","Node","Path","TraversalSnapshot","resolveContainerAt","isEditableContainer","snapshot","_node","path","context","containers","size","resolved","value","PortableTextObject","isTypedObject","TraversalSnapshot","isObject","snapshot","node","_type","context","schema","block","name","span","isKeyedSegment","Node","Path","comparePaths","path","another","root","value","Array","min","Math","length","currentChildren","currentNode","i","segment","otherSegment","_key","find","c","undefined","segmentIndex","findIndex","otherSegmentIndex","fieldValue","Record","isArray","Node","Point","comparePaths","comparePoints","point","another","root","value","Array","result","path","offset","Node","Point","comparePoints","isAfterPoint","point","another","root","value","Array","Node","Range","isAfterPoint","isBackwardRange","range","root","value","Array","anchor","focus","Node","Point","Range","isBackwardRange","rangeEdges","range","root","value","Array","anchor","focus","PortableTextObject","PortableTextSpan","EditorSchema","isTypedObject","TextBlockNode","_type","_key","children","Array","markDefs","style","listItem","level","isTextBlockNode","context","schema","node","block","name","isKeyedSegment","Path","isAncestorPath","path","another","length","i","segment","otherSegment","_key","Node","Path","serializePath","isKeyedSegment","resolveChildEntryIndex","blockIndexMap","ReadonlyMap","children","ReadonlyArray","node","path","childPath","lastSegment","length","fullyKeyed","segmentIndex","segment","mappedIndex","get","undefined","_key","findIndex","child","EditorSchema","Node","Path","isAncestorPath","serializePath","Containers","RegisteredContainer","getChildren","getNodeChildren","resolveChildEntryIndex","TraversalSnapshot","getNodes","snapshot","options","at","from","to","match","node","path","reverse","Generator","undefined","getNodesSimple","getNodesInRange","getNodeDescendants","context","schema","containers","value","Array","isRoot","walkStandalone","parent","next","child","children","childPath","_key","fieldName","entries","entry","comparePathsInTree","pathA","pathB","minLength","Math","min","length","prefix","i","segA","segB","isArray","push","indexA","blockIndexMap","get","indexB","startIndex","boundaryChildIndex","endIndex","window","slice","canStopTraversal","couldContainInRangeNodes","isInRange","boundary","firstChild","childPathLength","sharedPrefix","resolvedIndex","nodePath","Node","Path","parentPath","getChildren","resolveChildEntryIndex","TraversalSnapshot","getSibling","snapshot","path","options","direction","match","node","TMatch","length","undefined","parent","children","currentIndex","blockIndexMap","siblingIndex","candidates","slice","reverse","find","child","EditorSchema","isTypedObject","SpanNode","_type","_key","text","marks","Array","isSpanNode","context","schema","node","span","name","PortableTextBlock","Path","isSpanNode","isTextBlockNode","getNode","getParent","TraversalSnapshot","isBlock","snapshot","path","parent","schema","context","node","getBlock","entry","undefined","Path","isBlock","TraversalSnapshot","isInline","snapshot","path","PortableTextBlock","Path","getAncestors","getBlock","TraversalSnapshot","getEnclosingBlock","snapshot","path","options","match","node","TMatch","mode","ancestors","ancestor","reverse","direct","undefined","comparePaths","EditorSelectionPoint","TraversalSnapshot","comparePoints","snapshot","pointA","pointB","pathComparison","path","value","context","offset","Path","getAncestors","isObject","TraversalSnapshot","RegisteredContainer","resolveContainerAt","descendToParent","snapshot","path","parent","parentPath","ancestors","ancestor","node","resolved","context","containers","value","undefined","OfDefinition","Path","TraversalSnapshot","descendToParent","getEnclosingContainer","snapshot","path","of","ReadonlyArray","descent","undefined","parent","field","parentPath","getSubSchema","Schema","Path","getEnclosingContainer","TraversalSnapshot","getPathSubSchema","snapshot","path","enclosing","context","schema","of"],"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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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,SAAgBQ,aACdC,UACAC,MAC8C;CAE9C,IAAMG,eAA8B,CAAA;CACpC,KAAK,IAAIC,IAAI,GAAGA,IAAIJ,KAAKK,QAAQD,KAC/B,AAAIT,eAAeK,KAAKI,EAAE,KACxBD,aAAaG,KAAKF,CAAC;CAKvB,IAAID,aAAaE,UAAU,GACzB,OAAO,CAAA;CAGT,IAAM,EAACE,SAASC,kBAAiBT,UAC7BU,kBAA+BF,QAAQG,OACvCC,eAEEC,mBAAiE,CAAA,GACjEC,eAAqB,CAAA,GAIrBC,mBAAmBX,aAAaA,aAAaE,SAAS,IAExDU,eAAe;CACnB,OAAOA,eAAeD,mBAAkB;EACtC,IAAME,UAAUhB,KAAKe;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L,OAAOK,SAClB,KAGT,EAAIN,OAAOM,SAASL,OAAOK,UAPlBJ;AAYX;;;;;;;;;;;;;ACnBA,SAAgBW,gBACdC,UACAC,MAC6D;CAC7D,IAAMG,YAAYV,aAAaM,UAAUC,IAAI;CAC7C,KAAK,IAAMI,YAAYD,WAAW;EAChC,IAAI,CAACT,SAASK,UAAUK,SAASC,IAAI,GACnC;EAEF,IAAMC,WAAWT,mBACfE,SAASQ,QAAQC,YACjBT,SAASQ,QAAQE,OACjBL,SAASJ,IACX;EAIA,OAHI,CAACM,YAAY,EAAE,WAAWA,YAC5B,SAEK;GAACL,QAAQK;GAAUJ,YAAYE,SAASJ;EAAI;CACrD;AAEF;;;;;;;;;;;;;ACtBA,SAAgBe,sBACdC,UACAC,MAMY;CACZ,IAAMG,UAAUN,gBAAgBE,UAAUC,IAAI;CACzCG,aAGL,OAAO;EACLF,IAAIE,QAAQE,OAAOC,MAAML;EACzBD,MAAMG,QAAQI;CAChB;AACF;;;;;;;;;;;ACnBA,SAAgBM,iBACdC,UACAC,MACQ;CACR,IAAMC,YAAYL,sBAAsBG,UAAUC,IAAI;CAMtD,OAJKC,YAIER,aAAaM,SAASG,QAAQC,QAAQF,UAAUG,EAAE,IAHhDL,SAASG,QAAQC;AAI5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"selector.is-at-the-start-of-block-gJIMWRpU.js","names":["Node","Range","comparePoints","rangeEdges","rangesOverlap","rangeA","rangeB","root","value","Array","startA","endA","startB","endB","PortableTextObject","PortableTextSpan","Path","isSpanNode","getNode","isInline","isObject","TraversalSnapshot","getInline","snapshot","path","node","entry","undefined","schema","context","PortableTextObject","PortableTextSpan","EditorSelector","getInline","ChildPath","getFocusChild","node","path","snapshot","selection","context","undefined","focus","PortableTextObject","EditorSelector","isSpanNode","ChildPath","getFocusChild","getFocusInlineObject","node","path","snapshot","focusChild","context","undefined","isSpan","PortableTextSpan","EditorSelector","ChildPath","getFocusChild","getFocusSpan","node","path","snapshot","focusChild","context","undefined","PortableTextBlock","EditorSelector","getEnclosingBlock","BlockPath","getFocusBlock","node","path","snapshot","selection","context","undefined","focus","isTextBlock","PortableTextTextBlock","EditorSelector","BlockPath","getFocusBlock","getFocusTextBlock","node","path","snapshot","focusBlock","context","undefined","EditorSchema","getRootAcceptedTypes","schema","Set","block","name","blockObjects","map","blockObject","isSpan","isTextBlock","PortableTextBlock","PortableTextChild","EditorSelector","EditorContext","Path","RegisteredContainer","getNodeChildren","EditorSelectionPoint","getSelectionEndPoint","getSelectionStartPoint","isKeyedSegment","sliceBlocks","Edge","SliceContext","Pick","keyGenerator","getSelectedValue","Array","snapshot","selection","context","startPoint","endPoint","sliceArray","blocks","value","pathPrefix","fieldNameInPrefix","undefined","startEdge","endEdge","parent","ReadonlyArray","length","startIdx","resolveIndex","endIdx","lo","hi","loEdge","hiEdge","result","i","block","blockPath","_key","startPointForBlock","endPointForBlock","startInside","edgeIsInside","endInside","push","schema","sliced","sliceBoundaryTextBlock","childInfo","innerSliced","children","fieldName","updatedBlock","Record","edge","findBlockIndexForPoint","point","nodeSegmentIndex","path","segment","findIndex","firstChild","lastChild","blockRelativeStart","stripPrefix","fallback","blockRelativeEnd","anchor","focus","opts","slice","offset","text","PortableTextBlock","EditorSelector","Path","getRootAcceptedTypes","resolveContainerAt","BlockPath","getSelectedValue","getFragment","Array","node","path","snapshot","envelope","length","selection","context","anchor","focus","map","block","_key","schema","containers","value","rootAcceptedTypes","textBlockName","name","lastRootValid","lastRootValidPrefix","current","pathPrefix","single","singlePath","container","children","Record","field","isArray","childBlocks","push","allRootAccepted","every","_type","has","PortableTextBlock","EditorSelector","BlockPath","getSelectionEndPoint","getFocusBlock","getSelectionEndBlock","node","path","snapshot","endPoint","context","selection","undefined","anchor","focus","PortableTextBlock","EditorSelector","BlockPath","getSelectionStartPoint","getFocusBlock","getSelectionStartBlock","node","path","snapshot","startPoint","context","selection","undefined","anchor","focus","rangesOverlap","hasNode","EditorSelection","EditorSelector","isOverlappingSelection","selection","snapshot","editorSelection","context","anchor","path","focus","value","EditorSelector","isSelectionCollapsed","isSelectionCollapsedUtil","snapshot","context","selection","EditorSelector","isSelectionCollapsed","isSelectionExpanded","snapshot","context","selection","PortableTextBlock","EditorSelector","getNodes","getBlock","BlockPath","getSelectionEndPoint","getSelectionStartPoint","isKeyedSegment","getSelectedBlocks","Array","node","path","snapshot","selection","context","startPoint","endPoint","startRootKey","find","_key","endRootKey","block","result","entry","from","to","match","_","length","push","EditorSelector","getBlockEndPoint","getBlockStartPoint","isEqualSelectionPoints","getSelectionEndBlock","getSelectionStartBlock","isSelectingEntireBlocks","snapshot","context","selection","startPoint","backward","focus","anchor","endPoint","startBlock","endBlock","startBlockStartPoint","block","endBlockEndPoint","EditorSelection","isSelectionCollapsed","isSelectionExpanded","selection","EditorSelector","EditorSelectionPoint","getSelectionEndPoint","snapshot","context","selection","undefined","backward","anchor","focus","isSpan","PortableTextSpan","EditorSelector","Path","getSibling","getSelectionEndPoint","getNextSpan","node","path","snapshot","point","undefined","direction","match","context","EditorSelector","EditorSelectionPoint","getSelectionStartPoint","snapshot","context","selection","undefined","backward","focus","anchor","isSpan","PortableTextSpan","EditorSelector","Path","getSibling","getSelectionStartPoint","getPreviousSpan","node","path","snapshot","point","undefined","direction","match","context","isSpan","PortableTextChild","EditorSelector","Path","getNode","getNodes","isInline","getSelectionEndPoint","getSelectionStartPoint","isKeyedSegment","SelectedChild","node","TChild","path","GetSelectedChildrenOptions","filter","child","getSelectedChildren","options","Array","snapshot","startPoint","context","selection","endPoint","startChildKey","findLast","_key","endChildKey","result","skip","offset","text","length","push","entry","from","to","match","_","isSpan","PortableTextSpan","EditorSelector","ChildPath","getSelectedChildren","getSelectedSpans","Array","node","path","snapshot","context","selection","filter","child","isTextBlock","EditorSelector","getParent","getPathSubSchema","getBlock","blockOffsetToSpanSelectionPoint","isSelectionExpanded","getFocusSpan","getNextSpan","getPreviousSpan","getSelectedSpans","MarkState","state","marks","Array","previousMarks","getMarkState","snapshot","context","selection","undefined","anchor","path","spanSelectionPoint","blockOffset","offset","direction","backward","focus","focusSpan","selectedSpans","spanInfo","map","span","block","match","node","schema","decoratorNames","decorators","decorator","name","markDefKeys","markDefs","markDef","_key","candidateMarks","Set","spanMarks","mark","add","candidate","isDecoratorSomewhere","some","includes","active","inScope","push","focusSubSchema","marksWithoutAnnotations","filter","spanHasAnnotations","length","spanIsEmpty","text","atTheBeginningOfSpan","atTheEndOfSpan","previousSpan","nextSpan","nextSpanAnnotations","spanAnnotations","previousSpanHasAnnotations","previousSpanHasSameAnnotations","every","previousSpanHasSameAnnotation","previousSpanHasSameMarks","nextSpanSharesSomeAnnotations","EditorSnapshot","getMarkState","getActiveAnnotationsMarks","snapshot","schema","context","markState","marks","filter","mark","decorators","map","decorator","name","includes","isTextBlock","PortableTextTextBlock","EditorSelector","Path","getEnclosingBlock","getNodes","getSelectionEndPoint","getSelectionStartPoint","getSelectedTextBlocks","Array","node","path","snapshot","selection","context","startPoint","endPoint","startBlock","endBlock","_key","result","entry","from","to","match","push","EditorSnapshot","getPathSubSchema","getMarkState","getSelectedTextBlocks","getActiveDecorators","snapshot","decoratorState","markState","selectedBlocks","decorators","Set","block","decorator","path","add","name","size","context","schema","markStateDecorators","marks","filter","mark","has","activeDecorators","Array","activeDecorator","includes","push","isSpan","isTextBlock","EditorSelector","getActiveAnnotationsMarks","getSelectedTextBlocks","getSelectedValue","isSelectionExpanded","isActiveAnnotation","annotation","options","mode","snapshot","selectedValue","some","block","context","annotationKeys","Set","markDefs","filter","markDef","_type","map","_key","size","children","child","text","length","marks","mark","has","selectedBlocks","selectionMarkDefs","flatMap","node","activeAnnotations","activeMarkDefs","includes","PortableTextObject","EditorSelector","getPathSubSchema","getMarkState","getSelectedTextBlocks","getActiveAnnotations","Array","snapshot","context","selection","selectedBlocks","markState","decoratorNames","Set","block","decorator","path","decorators","add","name","size","schema","activeAnnotations","marks","filter","mark","has","selectionMarkDefs","flatMap","node","markDefs","markDef","includes","_key","PortableTextListBlock","EditorSelector","getPathSubSchema","getSelectedTextBlocks","getActiveListItem","snapshot","context","selection","undefined","selectedTextBlocks","firstTextBlock","at","firstListItem","node","listItem","inScopeBlocks","filter","block","path","lists","some","l","name","every","PortableTextTextBlock","EditorSelector","getPathSubSchema","getSelectedTextBlocks","getActiveStyle","snapshot","context","selection","undefined","selectedTextBlocks","firstTextBlock","at","firstStyle","node","style","path","styles","name","inScopeBlocks","filter","block","some","s","every","PortableTextObject","EditorSelector","getSibling","isObject","ChildPath","getSelectionEndPoint","getNextInlineObject","node","path","snapshot","point","undefined","sibling","direction","match","PortableTextObject","EditorSelector","getSibling","isObject","ChildPath","getSelectionStartPoint","getPreviousInlineObject","node","path","snapshot","point","undefined","sibling","direction","match","isSpan","isTextBlock","PortableTextBlock","EditorSelector","EditorContext","Node","RegisteredContainer","getNodeChildren","getSelectedValue","getSelectionText","snapshot","selectedValue","collectText","context","Pick","blocks","ReadonlyArray","parent","text","block","child","children","childInfo","EditorSelector","BlockOffset","EditorSelection","blockOffsetToSpanSelectionPoint","spanSelectionPointToBlockOffset","getBlockEndPoint","getBlockStartPoint","getFocusTextBlock","getNextInlineObject","getPreviousInlineObject","getSelectionStartPoint","getSelectionText","isSelectionCollapsed","isSelectionExpanded","getCaretWordSelection","snapshot","context","selection","focusTextBlock","selectionStartPoint","selectionStartOffset","selectionPoint","undefined","previousInlineObject","blockStartPoint","block","textBefore","anchor","path","offset","focus","textDirectlyBefore","split","at","nextInlineObject","blockEndPoint","textAfter","textDirectlyAfter","caretWordStartOffset","length","caretWordEndOffset","caretWordStartSelectionPoint","blockOffset","direction","caretWordEndSelectionPoint","caretWordSelection","PortableTextObject","EditorSelector","isTextBlockNode","isEditableContainer","BlockPath","getFocusBlock","getFocusBlockObject","node","path","snapshot","focusBlock","undefined","context","PortableTextListBlock","EditorSelector","BlockPath","isListBlock","getFocusTextBlock","getFocusListBlock","node","path","snapshot","focusTextBlock","context","undefined","PortableTextBlock","EditorSelector","parentPath","getChildren","getBlock","BlockPath","getFocusBlock","getLastBlock","node","path","snapshot","focusBlock","siblings","last","at","context","value","_key","undefined","PortableTextBlock","EditorSelector","getSibling","getBlock","BlockPath","getSelectionEndBlock","getNextBlock","node","path","snapshot","selectionEndBlock","undefined","next","direction","PortableTextBlock","EditorSelector","getSibling","getBlock","BlockPath","getSelectionStartBlock","getPreviousBlock","node","path","snapshot","selectionStartBlock","undefined","previous","direction","PortableTextObject","PortableTextSpan","EditorSelector","ChildPath","getSelectionEndPoint","getFocusChild","getSelectionEndChild","node","path","snapshot","endPoint","context","selection","undefined","anchor","focus","PortableTextObject","PortableTextSpan","EditorSelector","ChildPath","getSelectionStartPoint","getFocusChild","getSelectionStartChild","node","path","snapshot","startPoint","context","selection","undefined","anchor","focus","EditorSelector","getPathSubSchema","getActiveDecorators","getSelectedSpans","isSelectionExpanded","isActiveDecorator","decorator","snapshot","selectedSpans","inScopeSpans","filter","span","path","decorators","some","d","name","length","every","node","marks","includes","activeDecorators","EditorSelector","getActiveListItem","isActiveListItem","listItem","snapshot","activeListItem","EditorSelector","getActiveStyle","isActiveStyle","style","snapshot","activeStyle","PortableTextBlock","EditorSelector","BlockPath","getBlockEndPoint","isEqualSelectionPoints","isSelectionCollapsed","isAtTheEndOfBlock","block","node","path","snapshot","context","selection","blockEndPoint","focus","PortableTextBlock","EditorSelector","BlockPath","getBlockStartPoint","isEqualSelectionPoints","isSelectionCollapsed","isAtTheStartOfBlock","block","node","path","snapshot","context","selection","blockStartPoint","focus"],"sources":["../src/engine/range/ranges-overlap.ts","../src/traversal/get-inline.ts","../src/selectors/selector.get-focus-child.ts","../src/selectors/selector.get-focus-inline-object.ts","../src/selectors/selector.get-focus-span.ts","../src/selectors/selector.get-focus-block.ts","../src/selectors/selector.get-focus-text-block.ts","../src/schema/get-root-accepted-types.ts","../src/selectors/selector.get-selected-value.ts","../src/selectors/selector.get-fragment.ts","../src/selectors/selector.get-selection-end-block.ts","../src/selectors/selector.get-selection-start-block.ts","../src/selectors/selector.is-overlapping-selection.ts","../src/selectors/selector.is-selection-collapsed.ts","../src/selectors/selector.is-selection-expanded.ts","../src/selectors/selector.get-selected-blocks.ts","../src/selectors/selector.is-selecting-entire-blocks.ts","../src/utils/util.is-selection-expanded.ts","../src/selectors/selector.get-selection-end-point.ts","../src/selectors/selector.get-next-span.ts","../src/selectors/selector.get-selection-start-point.ts","../src/selectors/selector.get-previous-span.ts","../src/selectors/selector.get-selected-children.ts","../src/selectors/selector.get-selected-spans.ts","../src/selectors/selector.get-mark-state.ts","../src/selectors/selector.get-active-annotation-marks.ts","../src/selectors/selector.get-selected-text-blocks.ts","../src/selectors/selector.get-active-decorators.ts","../src/selectors/selector.is-active-annotation.ts","../src/selectors/selector.get-active-annotations.ts","../src/selectors/selector.get-active-list-item.ts","../src/selectors/selector.get-active-style.ts","../src/selectors/selector.get-next-inline-object.ts","../src/selectors/selector.get-previous-inline-object.ts","../src/selectors/selector.get-selection-text.ts","../src/selectors/selector.get-caret-word-selection.ts","../src/selectors/selector.get-focus-block-object.ts","../src/selectors/selector.get-focus-list-block.ts","../src/selectors/selector.get-last-block.ts","../src/selectors/selector.get-next-block.ts","../src/selectors/selector.get-previous-block.ts","../src/selectors/selector.get-selection-end-child.ts","../src/selectors/selector.get-selection-start-child.ts","../src/selectors/selector.is-active-decorator.ts","../src/selectors/selector.is-active-list-item.ts","../src/selectors/selector.is-active-style.ts","../src/selectors/selector.is-at-the-end-of-block.ts","../src/selectors/selector.is-at-the-start-of-block.ts"],"sourcesContent":["import type {Node} from '../interfaces/node'\nimport type {Range} from '../interfaces/range'\nimport {comparePoints} from '../point/compare-points'\nimport {rangeEdges} from './range-edges'\n\n/**\n * Returns true if the two ranges share at least one point.\n *\n * Two ranges overlap iff each one's start is at or before the other's end.\n * Adjacent ranges that touch at a single point are considered overlapping.\n */\nexport function rangesOverlap(\n rangeA: Range,\n rangeB: Range,\n root: {value: Array<Node>},\n): boolean {\n const [startA, endA] = rangeEdges(rangeA, root)\n const [startB, endB] = rangeEdges(rangeB, root)\n return (\n comparePoints(startA, endB, root) <= 0 &&\n comparePoints(startB, endA, root) <= 0\n )\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {isSpanNode} from '../engine/node/is-span-node'\nimport {getNode} from './get-node'\nimport {isInline} from './is-inline'\nimport {isObject} from './is-object'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the node at the given path if it is inline (a span or inline object).\n *\n * A node is inline if its parent is a text block. Returns the node narrowed\n * to `PortableTextSpan | PortableTextObject`, or `undefined` if the node\n * doesn't exist or is not inline.\n */\nexport function getInline(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: PortableTextSpan | PortableTextObject; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry || !isInline(snapshot, entry.path)) {\n return undefined\n }\n\n if (\n !isSpanNode({schema: snapshot.context.schema}, entry.node) &&\n !isObject(snapshot, entry.node)\n ) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getInline} from '../traversal/get-inline'\nimport type {ChildPath} from '../types/paths'\n\n/**\n * Returns the child (span or inline object) containing the focus selection,\n * resolved at any depth.\n *\n * @public\n */\nexport const getFocusChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return undefined\n }\n\n return getInline(snapshot, selection.focus.path)\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isSpanNode} from '../engine/node/is-span-node'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * Returns the inline object containing the focus selection, resolved at any\n * depth.\n *\n * @public\n */\nexport const getFocusInlineObject: EditorSelector<\n {node: PortableTextObject; path: ChildPath} | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && !isSpanNode(snapshot.context, focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * Returns the span containing the focus selection, resolved at any depth.\n *\n * @public\n */\nexport const getFocusSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const focusChild = getFocusChild(snapshot)\n\n return focusChild && isSpan(snapshot.context, focusChild.node)\n ? {node: focusChild.node, path: focusChild.path}\n : undefined\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getEnclosingBlock} from '../traversal/get-enclosing-block'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * Returns the block containing the focus selection, resolved at any depth.\n *\n * When the focus is inside an editable container (e.g. a code block's line),\n * this returns the innermost block ancestor (the line), not the outer\n * container. When the focus is at root, behavior is unchanged.\n *\n * @public\n */\nexport const getFocusBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return undefined\n }\n\n return getEnclosingBlock(snapshot, selection.focus.path)\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * Returns the text block containing the focus selection, resolved at any depth.\n *\n * When the focus is inside an editable container (e.g. a code block's line),\n * this returns the innermost text block ancestor (the line), not the outer\n * container. When the focus is at root, behavior is unchanged.\n *\n * @public\n */\nexport const getFocusTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n return focusBlock && isTextBlock(snapshot.context, focusBlock.node)\n ? {node: focusBlock.node, path: focusBlock.path}\n : undefined\n}\n","import type {EditorSchema} from '../editor/editor-schema'\n\n/**\n * Set of types that are valid at the root of the editor's value: the\n * configured text-block type plus every registered block-object type.\n *\n * The editor accepts these at the top level of `value` and uses them\n * to validate input and as the implicit accept-list for any payload\n * that escapes registered containers.\n */\nexport function getRootAcceptedTypes(schema: EditorSchema): Set<string> {\n return new Set<string>([\n schema.block.name,\n ...schema.blockObjects.map((blockObject) => blockObject.name),\n ])\n}\n","import {\n isSpan,\n isTextBlock,\n type PortableTextBlock,\n type PortableTextChild,\n} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {Path} from '../engine/interfaces/path'\nimport type {RegisteredContainer} from '../schema/resolve-containers'\nimport {getNodeChildren} from '../traversal/get-children'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {sliceBlocks} from '../utils/util.slice-blocks'\n\ntype Edge = EditorSelectionPoint | 'array-start' | 'array-end'\n\ntype SliceContext = Pick<\n EditorContext,\n 'schema' | 'selection' | 'value' | 'containers'\n> & {keyGenerator?: () => string}\n\n/**\n * Returns the portion of the document's value covered by the selection,\n * resolved at any depth.\n *\n * Containers fully inside the selection are preserved verbatim. Containers\n * on the selection boundary are recursed into so only the selected portion\n * of their content is kept. Text blocks on the boundary are span-sliced.\n *\n * The result preserves the full ancestor envelope around the selection. For\n * the clipboard-shaped view that unwraps the envelope toward the selection's\n * lowest common ancestor, see {@link getFragment}.\n *\n * @public\n */\nexport const getSelectedValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return []\n }\n\n const startPoint = getSelectionStartPoint(selection)\n const endPoint = getSelectionEndPoint(selection)\n\n if (!startPoint || !endPoint) {\n return []\n }\n\n return sliceArray({\n context: snapshot.context,\n blocks: snapshot.context.value,\n pathPrefix: [],\n fieldNameInPrefix: undefined,\n startEdge: startPoint,\n endEdge: endPoint,\n })\n}\n\nfunction sliceArray({\n context,\n blocks,\n pathPrefix,\n fieldNameInPrefix,\n startEdge,\n endEdge,\n parent,\n}: {\n context: SliceContext\n blocks: ReadonlyArray<PortableTextBlock>\n pathPrefix: Path\n fieldNameInPrefix: string | undefined\n startEdge: Edge\n endEdge: Edge\n parent?: RegisteredContainer\n}): Array<PortableTextBlock> {\n if (blocks.length === 0) {\n return []\n }\n\n const startIdx = resolveIndex(blocks, pathPrefix, startEdge)\n const endIdx = resolveIndex(blocks, pathPrefix, endEdge)\n\n if (startIdx === -1 || endIdx === -1) {\n return []\n }\n\n const [lo, hi, loEdge, hiEdge] =\n startIdx <= endIdx\n ? [startIdx, endIdx, startEdge, endEdge]\n : [endIdx, startIdx, endEdge, startEdge]\n\n const result: Array<PortableTextBlock> = []\n\n for (let i = lo; i <= hi; i++) {\n const block = blocks[i]!\n const blockPath: Path = [\n ...pathPrefix,\n ...(fieldNameInPrefix ? [fieldNameInPrefix] : []),\n {_key: block._key},\n ]\n\n const startPointForBlock: Edge = i === lo ? loEdge : 'array-start'\n const endPointForBlock: Edge = i === hi ? hiEdge : 'array-end'\n\n const startInside = edgeIsInside(startPointForBlock, blockPath)\n const endInside = edgeIsInside(endPointForBlock, blockPath)\n\n if (!startInside && !endInside) {\n result.push(block)\n continue\n }\n\n if (isTextBlock({schema: context.schema}, block)) {\n const sliced = sliceBoundaryTextBlock({\n context,\n block,\n blockPath,\n startEdge: startPointForBlock,\n endEdge: endPointForBlock,\n })\n if (sliced) {\n result.push(sliced)\n }\n continue\n }\n\n const childInfo = getNodeChildren(context, block, parent)\n\n if (!childInfo) {\n result.push(block)\n continue\n }\n\n const innerSliced = sliceArray({\n context,\n blocks: childInfo.children as Array<PortableTextBlock>,\n pathPrefix: blockPath,\n fieldNameInPrefix: childInfo.fieldName,\n startEdge: startPointForBlock,\n endEdge: endPointForBlock,\n parent: childInfo.parent,\n })\n\n const updatedBlock: PortableTextBlock = {...block}\n ;(updatedBlock as Record<string, unknown>)[childInfo.fieldName] =\n innerSliced\n\n result.push(updatedBlock)\n }\n\n return result\n}\n\nfunction resolveIndex(\n blocks: ReadonlyArray<PortableTextBlock>,\n pathPrefix: Path,\n edge: Edge,\n): number {\n if (edge === 'array-start') {\n return 0\n }\n if (edge === 'array-end') {\n return blocks.length - 1\n }\n return findBlockIndexForPoint(blocks, pathPrefix, edge)\n}\n\nfunction findBlockIndexForPoint(\n blocks: ReadonlyArray<PortableTextBlock>,\n pathPrefix: Path,\n point: EditorSelectionPoint,\n): number {\n let nodeSegmentIndex = pathPrefix.length\n\n if (\n nodeSegmentIndex < point.path.length &&\n typeof point.path[nodeSegmentIndex] === 'string'\n ) {\n nodeSegmentIndex++\n }\n\n const segment = point.path[nodeSegmentIndex]\n\n if (segment === undefined) {\n return -1\n }\n\n if (isKeyedSegment(segment)) {\n return blocks.findIndex((block) => block._key === segment._key)\n }\n\n if (typeof segment === 'number') {\n return segment >= 0 && segment < blocks.length ? segment : -1\n }\n\n return -1\n}\n\nfunction edgeIsInside(edge: Edge, blockPath: Path): boolean {\n if (edge === 'array-start' || edge === 'array-end') {\n return false\n }\n return edge.path.length > blockPath.length\n}\n\nfunction sliceBoundaryTextBlock({\n context,\n block,\n blockPath,\n startEdge,\n endEdge,\n}: {\n context: SliceContext\n block: PortableTextBlock\n blockPath: Path\n startEdge: Edge\n endEdge: Edge\n}): PortableTextBlock | undefined {\n if (!isTextBlock({schema: context.schema}, block)) {\n return block\n }\n\n const firstChild = block.children[0]\n const lastChild = block.children[block.children.length - 1]\n\n // Build block-relative selection points. `sliceBlocks` assumes paths start\n // at the block level (e.g. `[{block}, 'children', {child}]`), so we strip\n // any ancestor container prefix from the path.\n const blockRelativeStart = stripPrefix(startEdge, blockPath, block, {\n fallback: 'block-start',\n firstChild,\n })\n const blockRelativeEnd = stripPrefix(endEdge, blockPath, block, {\n fallback: 'block-end',\n lastChild,\n context,\n })\n\n const sliced = sliceBlocks({\n context: {\n ...context,\n selection: {anchor: blockRelativeStart, focus: blockRelativeEnd},\n },\n blocks: [block],\n })\n\n return sliced[0]\n}\n\nfunction stripPrefix(\n edge: Edge,\n blockPath: Path,\n block: PortableTextBlock,\n opts: {\n fallback: 'block-start' | 'block-end'\n firstChild?: PortableTextChild\n lastChild?: PortableTextChild\n context?: SliceContext\n },\n): EditorSelectionPoint {\n if (edge !== 'array-start' && edge !== 'array-end') {\n // Is the point inside this block? If yes, strip the prefix.\n if (edge.path.length > blockPath.length) {\n return {\n path: edge.path.slice(blockPath.length - 1),\n offset: edge.offset,\n }\n }\n }\n // Fall back to block start or end.\n if (opts.fallback === 'block-start') {\n return {\n path: [\n {_key: block._key},\n 'children',\n {_key: opts.firstChild?._key ?? ''},\n ],\n offset: 0,\n }\n }\n return {\n path: [{_key: block._key}, 'children', {_key: opts.lastChild?._key ?? ''}],\n offset:\n opts.lastChild &&\n opts.context &&\n isSpan({schema: opts.context.schema}, opts.lastChild)\n ? opts.lastChild.text.length\n : 0,\n }\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {Path} from '../engine/interfaces/path'\nimport {getRootAcceptedTypes} from '../schema/get-root-accepted-types'\nimport {resolveContainerAt} from '../schema/resolve-container-at'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectedValue} from './selector.get-selected-value'\n\n/**\n * Returns the smallest top-level-valid fragment of the editor's value\n * that covers the current selection.\n *\n * Starts from {@link getSelectedValue}'s envelope and unwraps it toward\n * the selection's lowest common ancestor, stopping at the deepest level\n * whose siblings are all root-accepted types. Intermediate single-child\n * containers (a single row inside a table, a single cell inside a row)\n * are walked through to look for a deeper unwrap target; an intermediate\n * level with multiple siblings (the lowest common ancestor across two\n * cells in one row) ends the walk and the last root-valid wrapping is\n * returned.\n *\n * A selection whose endpoints terminate at the root level (collapsed at\n * a root-level node, or expanded across root siblings without descending\n * into them) is treated as the user pointing AT the named node(s) rather\n * than INTO them; the envelope is returned as-is and the unwrap walk is\n * skipped. This is how a chrome drag carries the container itself rather\n * than its unwrapped content.\n *\n * Backs every registered clipboard converter, `editor.getFragment()`\n * (which projects to blocks only), and the drag preview pipeline (which\n * uses the paths to find DOM nodes). Exposed for custom converters and\n * any consumer that needs the clipboard-shaped view of the current\n * selection without redundant ancestor envelopes.\n *\n * @public\n */\nexport const getFragment: EditorSelector<\n Array<{node: PortableTextBlock; path: BlockPath}>\n> = (snapshot) => {\n const envelope = getSelectedValue(snapshot)\n\n if (envelope.length === 0) {\n return []\n }\n\n const selection = snapshot.context.selection\n if (\n selection &&\n selection.anchor.path.length <= 1 &&\n selection.focus.path.length <= 1\n ) {\n return envelope.map((block) => ({\n node: block,\n path: [{_key: block._key}],\n }))\n }\n\n const {schema, containers, value} = snapshot.context\n const rootAcceptedTypes = getRootAcceptedTypes(schema)\n const textBlockName = schema.block.name\n\n // The outer envelope is rooted in `editor.value` so its top-level types\n // are root-accepted by construction.\n let lastRootValid: Array<PortableTextBlock> = envelope\n let lastRootValidPrefix: Path = []\n let current: Array<PortableTextBlock> = envelope\n const pathPrefix: Path = []\n\n while (current.length === 1) {\n const single = current[0]!\n const singlePath: Path = [...pathPrefix, {_key: single._key}]\n const container = resolveContainerAt(containers, value, singlePath)\n\n if (!container || !('field' in container)) {\n break\n }\n\n const children = (single as Record<string, unknown>)[container.field.name]\n if (!Array.isArray(children) || children.length === 0) {\n break\n }\n\n const childBlocks = children as Array<PortableTextBlock>\n pathPrefix.push({_key: single._key}, container.field.name)\n current = childBlocks\n\n const allRootAccepted = childBlocks.every(\n (block) =>\n block._type === textBlockName || rootAcceptedTypes.has(block._type),\n )\n\n if (allRootAccepted) {\n lastRootValid = childBlocks\n lastRootValidPrefix = [...pathPrefix]\n // Keep walking - a deeper level might also be root-valid (a single\n // block inside the cell that is itself a container, etc.).\n continue\n }\n\n // Children are intermediate types (e.g. `row`, `cell`). If there is\n // a single intermediate child, walk through it; otherwise the lowest\n // common ancestor is here and we stop with the last root-valid level.\n if (childBlocks.length !== 1) {\n break\n }\n }\n\n return lastRootValid.map((block) => ({\n node: block,\n path: [...lastRootValidPrefix, {_key: block._key}],\n }))\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * Returns the block containing the selection's end point, resolved at any\n * depth.\n *\n * @public\n */\nexport const getSelectionEndBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: BlockPath\n }\n | undefined\n> = (snapshot) => {\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n if (!endPoint) {\n return undefined\n }\n\n return getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * Returns the block containing the selection's start point, resolved at any\n * depth.\n *\n * @public\n */\nexport const getSelectionStartBlock: EditorSelector<\n | {\n node: PortableTextBlock\n path: BlockPath\n }\n | undefined\n> = (snapshot) => {\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n if (!startPoint) {\n return undefined\n }\n\n return getFocusBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n}\n","import {rangesOverlap} from '../engine/range/ranges-overlap'\nimport {hasNode} from '../traversal/has-node'\nimport type {EditorSelection} from '../types/editor'\nimport type {EditorSelector} from './../editor/editor-selector'\n\n/**\n * Returns true if the supplied selection shares at least one point with the\n * editor's current selection. Resolves at any container depth.\n *\n * Two selections that touch at a single endpoint share that point and are\n * considered overlapping.\n *\n * @public\n */\nexport function isOverlappingSelection(\n selection: EditorSelection,\n): EditorSelector<boolean> {\n return (snapshot) => {\n const editorSelection = snapshot.context.selection\n\n if (!selection || !editorSelection) {\n return false\n }\n\n if (\n !hasNode(snapshot, selection.anchor.path) ||\n !hasNode(snapshot, selection.focus.path) ||\n !hasNode(snapshot, editorSelection.anchor.path) ||\n !hasNode(snapshot, editorSelection.focus.path)\n ) {\n return false\n }\n\n return rangesOverlap(selection, editorSelection, {\n value: snapshot.context.value,\n })\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSelectionCollapsed as isSelectionCollapsedUtil} from '../utils/util.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const isSelectionCollapsed: EditorSelector<boolean> = (snapshot) =>\n isSelectionCollapsedUtil(snapshot.context.selection)\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport const isSelectionExpanded: EditorSelector<boolean> = (snapshot) => {\n return snapshot.context.selection !== null && !isSelectionCollapsed(snapshot)\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getNodes} from '../traversal/get-nodes'\nimport {getBlock} from '../traversal/is-block'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * Returns the root-level blocks the selection covers.\n *\n * Only looks at direct children of the editor. If the selection is inside\n * an editable container, the container itself is returned - not its inner\n * blocks. Containers are preserved whole.\n *\n * Use for block-level operations like `move.block up/down` and\n * drag-and-drop. For \"selection as portable text\" use `getSelectedValue`;\n * for \"text blocks at any depth\" use `getSelectedTextBlocks`.\n *\n * @public\n */\nexport const getSelectedBlocks: EditorSelector<\n Array<{node: PortableTextBlock; path: BlockPath}>\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return []\n }\n\n const startPoint = getSelectionStartPoint(selection)\n const endPoint = getSelectionEndPoint(selection)\n\n if (!startPoint || !endPoint) {\n return []\n }\n\n // Fast path: when both endpoints share the same root-level block, that\n // single block is the answer. The range walk only needs to run when\n // the selection crosses block boundaries.\n const startRootKey = startPoint.path.find(isKeyedSegment)?._key\n const endRootKey = endPoint.path.find(isKeyedSegment)?._key\n if (startRootKey && startRootKey === endRootKey) {\n const block = getBlock(snapshot, [{_key: startRootKey}])\n if (block) {\n return [{node: block.node, path: block.path}]\n }\n }\n\n const result: Array<{node: PortableTextBlock; path: BlockPath}> = []\n\n for (const entry of getNodes(snapshot, {\n from: startPoint.path,\n to: endPoint.path,\n match: (_, path) => path.length === 1,\n })) {\n const block = getBlock(snapshot, entry.path)\n if (block) {\n result.push({node: block.node, path: block.path})\n }\n }\n\n return result\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {isEqualSelectionPoints} from '../utils/util.is-equal-selection-points'\nimport {getSelectionEndBlock} from './selector.get-selection-end-block'\nimport {getSelectionStartBlock} from './selector.get-selection-start-block'\n\n/**\n * @public\n */\nexport const isSelectingEntireBlocks: EditorSelector<boolean> = (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n const endPoint = snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n\n const startBlock = getSelectionStartBlock(snapshot)\n const endBlock = getSelectionEndBlock(snapshot)\n\n if (!startBlock || !endBlock) {\n return false\n }\n\n const startBlockStartPoint = getBlockStartPoint({\n context: snapshot.context,\n block: startBlock,\n })\n const endBlockEndPoint = getBlockEndPoint({\n context: snapshot.context,\n block: endBlock,\n })\n\n return (\n isEqualSelectionPoints(startBlockStartPoint, startPoint) &&\n isEqualSelectionPoints(endBlockEndPoint, endPoint)\n )\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isSelectionCollapsed} from './util.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isSelectionExpanded(selection: EditorSelection) {\n if (!selection) {\n return false\n }\n\n return !isSelectionCollapsed(selection)\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport const getSelectionEndPoint: EditorSelector<\n EditorSelectionPoint | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n return snapshot.context.selection.backward\n ? snapshot.context.selection.anchor\n : snapshot.context.selection.focus\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {Path} from '../engine/interfaces/path'\nimport {getSibling} from '../traversal/get-sibling'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * Returns the span after the selection end within the same text block,\n * resolved at any depth.\n *\n * @public\n */\nexport const getNextSpan: EditorSelector<\n {node: PortableTextSpan; path: Path} | undefined\n> = (snapshot) => {\n const point = getSelectionEndPoint(snapshot)\n\n if (!point) {\n return undefined\n }\n\n return getSibling(snapshot, point.path, {\n direction: 'next',\n match: (node): node is PortableTextSpan => isSpan(snapshot.context, node),\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * @public\n */\nexport const getSelectionStartPoint: EditorSelector<\n EditorSelectionPoint | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n return snapshot.context.selection.backward\n ? snapshot.context.selection.focus\n : snapshot.context.selection.anchor\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {Path} from '../engine/interfaces/path'\nimport {getSibling} from '../traversal/get-sibling'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * Returns the span before the selection start within the same text block,\n * resolved at any depth.\n *\n * @public\n */\nexport const getPreviousSpan: EditorSelector<\n {node: PortableTextSpan; path: Path} | undefined\n> = (snapshot) => {\n const point = getSelectionStartPoint(snapshot)\n\n if (!point) {\n return undefined\n }\n\n return getSibling(snapshot, point.path, {\n direction: 'previous',\n match: (node): node is PortableTextSpan => isSpan(snapshot.context, node),\n })\n}\n","import {isSpan, type PortableTextChild} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from '../traversal/get-node'\nimport {getNodes} from '../traversal/get-nodes'\nimport {isInline} from '../traversal/is-inline'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\ntype SelectedChild<TChild extends PortableTextChild = PortableTextChild> = {\n node: TChild\n path: Path\n}\n\ntype GetSelectedChildrenOptions<\n TChild extends PortableTextChild = PortableTextChild,\n> = {\n filter?: (child: PortableTextChild) => child is TChild\n}\n\n/**\n * Returns the inline children (spans and inline objects) touched by the\n * selection, resolved at any depth.\n *\n * @public\n */\nexport function getSelectedChildren<\n TChild extends PortableTextChild = PortableTextChild,\n>(\n options?: GetSelectedChildrenOptions<TChild>,\n): EditorSelector<Array<SelectedChild<TChild>>> {\n const filter = options?.filter\n\n return (snapshot) => {\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n if (!startPoint || !endPoint) {\n return []\n }\n\n const startChildKey = startPoint.path.findLast(isKeyedSegment)?._key\n const endChildKey = endPoint.path.findLast(isKeyedSegment)?._key\n\n const result: Array<SelectedChild<TChild>> = []\n\n // Fast path: when both endpoints reference the same inline child -\n // the common case for collapsed selections and intra-span selections\n // - resolve that child directly instead of walking the range.\n if (\n startChildKey &&\n startChildKey === endChildKey &&\n isInline(snapshot, startPoint.path)\n ) {\n const node = getNode(snapshot, startPoint.path)\n if (node) {\n const child = node.node as PortableTextChild\n let skip = false\n if (child._key === startChildKey && isSpan(snapshot.context, child)) {\n if (startPoint.offset >= child.text.length) {\n skip = true\n }\n if (endPoint.offset <= 0) {\n skip = true\n }\n }\n if (!skip && (!filter || filter(child))) {\n result.push({node: child as TChild, path: node.path})\n }\n }\n return result\n }\n\n for (const entry of getNodes(snapshot, {\n from: startPoint.path,\n to: endPoint.path,\n match: (_, path) => isInline(snapshot, path),\n })) {\n const child = entry.node as PortableTextChild\n\n // Skip the start child when the selection begins exactly at its end\n // and skip the end child when the selection ends exactly at its start.\n if (child._key === startChildKey && isSpan(snapshot.context, child)) {\n if (startPoint.offset >= child.text.length) {\n continue\n }\n }\n\n if (child._key === endChildKey && isSpan(snapshot.context, child)) {\n if (endPoint.offset <= 0) {\n continue\n }\n }\n\n if (filter && !filter(child)) {\n continue\n }\n\n result.push({node: child as TChild, path: entry.path})\n }\n\n return result\n }\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectedChildren} from './selector.get-selected-children'\n\n/**\n * Returns the spans touched by the selection, resolved at any depth.\n *\n * @public\n */\nexport const getSelectedSpans: EditorSelector<\n Array<{\n node: PortableTextSpan\n path: ChildPath\n }>\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n return getSelectedChildren({\n filter: (child) => isSpan(snapshot.context, child),\n })(snapshot)\n}\n","import {isTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getParent} from '../traversal/get-parent'\nimport {getPathSubSchema} from '../traversal/get-path-sub-schema'\nimport {getBlock} from '../traversal/is-block'\nimport {blockOffsetToSpanSelectionPoint} from '../utils/util.block-offset'\nimport {isSelectionExpanded} from '../utils/util.is-selection-expanded'\nimport {getFocusSpan} from './selector.get-focus-span'\nimport {getNextSpan} from './selector.get-next-span'\nimport {getPreviousSpan} from './selector.get-previous-span'\nimport {getSelectedSpans} from './selector.get-selected-spans'\n\n/**\n * @beta\n */\nexport type MarkState =\n | {\n state: 'unchanged'\n marks: Array<string>\n }\n | {\n state: 'changed'\n marks: Array<string>\n previousMarks: Array<string>\n }\n\n/**\n * Given that text is inserted at the current position, what marks should\n * be applied?\n * @beta\n */\nexport const getMarkState: EditorSelector<MarkState | undefined> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n let selection = snapshot.context.selection\n\n if (getBlock(snapshot, selection.anchor.path)) {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset: {\n path: selection.anchor.path,\n offset: selection.anchor.offset,\n },\n direction: selection.backward ? 'backward' : 'forward',\n })\n\n selection = spanSelectionPoint\n ? {\n ...selection,\n anchor: spanSelectionPoint,\n }\n : selection\n }\n\n if (getBlock(snapshot, selection.focus.path)) {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset: {\n path: selection.focus.path,\n offset: selection.focus.offset,\n },\n direction: selection.backward ? 'backward' : 'forward',\n })\n\n selection = spanSelectionPoint\n ? {\n ...selection,\n focus: spanSelectionPoint,\n }\n : selection\n }\n\n const focusSpan = getFocusSpan({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n\n if (!focusSpan) {\n return undefined\n }\n\n if (isSelectionExpanded(selection)) {\n const selectedSpans = getSelectedSpans({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n\n // Per-span info: marks present, the decorator names declared by the\n // span's block sub-schema, and the annotation markDef keys declared on\n // the span's enclosing block. Used so that out-of-scope spans (where\n // the mark cannot apply) don't disqualify the mark across the\n // selection.\n const spanInfo = selectedSpans.map((span) => {\n const block = getParent(snapshot, span.path, {\n match: (node) => isTextBlock({schema: snapshot.context.schema}, node),\n })\n return {\n marks: span.node.marks ?? [],\n decoratorNames: getPathSubSchema(snapshot, span.path).decorators.map(\n (decorator) => decorator.name,\n ),\n markDefKeys: (block?.node.markDefs ?? []).map(\n (markDef) => markDef._key,\n ),\n }\n })\n\n // Candidate marks: union of all marks present on any selected span.\n const candidateMarks = new Set<string>()\n for (const {marks: spanMarks} of spanInfo) {\n for (const mark of spanMarks) {\n candidateMarks.add(mark)\n }\n }\n\n const marks: Array<string> = []\n for (const candidate of candidateMarks) {\n const isDecoratorSomewhere = spanInfo.some(({decoratorNames}) =>\n decoratorNames.includes(candidate),\n )\n let active = true\n for (const {marks: spanMarks, decoratorNames, markDefKeys} of spanInfo) {\n const inScope = isDecoratorSomewhere\n ? decoratorNames.includes(candidate)\n : markDefKeys.includes(candidate)\n if (!inScope) {\n continue\n }\n if (!spanMarks.includes(candidate)) {\n active = false\n break\n }\n }\n if (active) {\n marks.push(candidate)\n }\n }\n\n return {\n state: 'unchanged',\n marks,\n }\n }\n\n const focusSubSchema = getPathSubSchema(snapshot, focusSpan.path)\n const decorators = focusSubSchema.decorators.map(\n (decorator) => decorator.name,\n )\n const marks = focusSpan.node.marks ?? []\n const marksWithoutAnnotations = marks.filter((mark) =>\n decorators.includes(mark),\n )\n\n const spanHasAnnotations = marks.length > marksWithoutAnnotations.length\n\n const spanIsEmpty = focusSpan.node.text.length === 0\n\n const atTheBeginningOfSpan = snapshot.context.selection.anchor.offset === 0\n const atTheEndOfSpan =\n snapshot.context.selection.anchor.offset === focusSpan.node.text.length\n\n const previousSpan = getPreviousSpan({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n const nextSpan = getNextSpan({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection,\n },\n })\n const nextSpanAnnotations =\n nextSpan?.node?.marks?.filter((mark) => !decorators.includes(mark)) ?? []\n const spanAnnotations = marks.filter((mark) => !decorators.includes(mark))\n\n const previousSpanHasAnnotations = previousSpan\n ? previousSpan.node.marks?.some((mark) => !decorators.includes(mark))\n : false\n const previousSpanHasSameAnnotations = previousSpan\n ? previousSpan.node.marks\n ?.filter((mark) => !decorators.includes(mark))\n .every((mark) => marks.includes(mark))\n : false\n const previousSpanHasSameAnnotation = previousSpan\n ? previousSpan.node.marks?.some(\n (mark) => !decorators.includes(mark) && marks.includes(mark),\n )\n : false\n\n const previousSpanHasSameMarks = previousSpan\n ? previousSpan.node.marks?.every((mark) => marks.includes(mark))\n : false\n const nextSpanSharesSomeAnnotations = spanAnnotations.some((mark) =>\n nextSpanAnnotations?.includes(mark),\n )\n\n if (spanHasAnnotations && !spanIsEmpty) {\n if (atTheBeginningOfSpan) {\n if (previousSpanHasSameMarks) {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: previousSpan?.node.marks ?? [],\n }\n } else if (previousSpanHasSameAnnotations) {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: previousSpan?.node.marks ?? [],\n }\n } else if (previousSpanHasSameAnnotation) {\n return {\n state: 'unchanged',\n marks: focusSpan.node.marks ?? [],\n }\n } else if (!previousSpan) {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: [],\n }\n }\n }\n\n if (atTheEndOfSpan) {\n if (!nextSpan) {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: [],\n }\n }\n\n if (nextSpanAnnotations.length > 0 && !nextSpanSharesSomeAnnotations) {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: [],\n }\n }\n\n if (\n (nextSpanSharesSomeAnnotations &&\n nextSpanAnnotations.length < spanAnnotations.length) ||\n !nextSpanSharesSomeAnnotations\n ) {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: nextSpan?.node.marks ?? [],\n }\n }\n }\n }\n\n if (atTheBeginningOfSpan && !spanIsEmpty && previousSpan) {\n if (previousSpanHasAnnotations) {\n return {\n state: 'changed',\n marks,\n previousMarks: previousSpan?.node.marks ?? [],\n }\n } else {\n return {\n state: 'changed',\n previousMarks: marks,\n marks: (previousSpan?.node.marks ?? []).filter((mark) =>\n decorators.includes(mark),\n ),\n }\n }\n }\n\n return {\n state: 'unchanged',\n marks,\n }\n}\n","import type {EditorSnapshot} from '../editor/editor-snapshot'\nimport {getMarkState} from './selector.get-mark-state'\n\nexport function getActiveAnnotationsMarks(snapshot: EditorSnapshot) {\n const schema = snapshot.context.schema\n const markState = getMarkState(snapshot)\n\n return (markState?.marks ?? []).filter(\n (mark) =>\n !schema.decorators.map((decorator) => decorator.name).includes(mark),\n )\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {Path} from '../engine/interfaces/path'\nimport {getEnclosingBlock} from '../traversal/get-enclosing-block'\nimport {getNodes} from '../traversal/get-nodes'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * Returns the text blocks touched by the selection, resolved at any depth.\n *\n * Walks the tree between the selection endpoints and returns every text\n * block found, regardless of container nesting. For toolbar state and\n * anywhere that needs \"text blocks with text in the selection\".\n *\n * @public\n */\nexport const getSelectedTextBlocks: EditorSelector<\n Array<{node: PortableTextTextBlock; path: Path}>\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return []\n }\n\n const startPoint = getSelectionStartPoint(selection)\n const endPoint = getSelectionEndPoint(selection)\n\n if (!startPoint || !endPoint) {\n return []\n }\n\n // Fast path: when both endpoints sit inside the same text block - the\n // common case for toolbar state on a collapsed or single-block\n // selection - skip the range walk entirely. The range walk visits\n // every descendant in document order between the endpoints; that's\n // O(tree) work and gets very expensive in deeply nested containers.\n const startBlock = getEnclosingBlock(snapshot, startPoint.path)\n const endBlock = getEnclosingBlock(snapshot, endPoint.path)\n if (\n startBlock &&\n endBlock &&\n startBlock.node._key === endBlock.node._key &&\n isTextBlock(snapshot.context, startBlock.node)\n ) {\n return [{node: startBlock.node, path: startBlock.path}]\n }\n\n const result: Array<{node: PortableTextTextBlock; path: Path}> = []\n\n for (const entry of getNodes(snapshot, {\n from: startPoint.path,\n to: endPoint.path,\n match: (node) => isTextBlock(snapshot.context, node),\n })) {\n if (isTextBlock(snapshot.context, entry.node)) {\n result.push({node: entry.node, path: entry.path})\n }\n }\n\n return result\n}\n","import type {EditorSnapshot} from '../editor/editor-snapshot'\nimport {getPathSubSchema} from '../traversal/get-path-sub-schema'\nimport {getMarkState} from './selector.get-mark-state'\nimport {getSelectedTextBlocks} from './selector.get-selected-text-blocks'\n\nexport function getActiveDecorators(snapshot: EditorSnapshot) {\n const decoratorState = snapshot.decoratorState\n const markState = getMarkState(snapshot)\n\n // Union of decorator names across all selected blocks' sub-schemas. At\n // root this is the full schema; inside containers it's the union of\n // each block's sub-schema decorators (so cross-container selections\n // include decorators that any in-scope span allows).\n const selectedBlocks = getSelectedTextBlocks(snapshot)\n const decorators = new Set<string>()\n for (const block of selectedBlocks) {\n for (const decorator of getPathSubSchema(snapshot, block.path).decorators) {\n decorators.add(decorator.name)\n }\n }\n if (decorators.size === 0) {\n for (const decorator of snapshot.context.schema.decorators) {\n decorators.add(decorator.name)\n }\n }\n\n const markStateDecorators = (markState?.marks ?? []).filter((mark) =>\n decorators.has(mark),\n )\n\n let activeDecorators: Array<string> = markStateDecorators\n\n for (const decorator in decoratorState) {\n if (decoratorState[decorator] === false) {\n activeDecorators = activeDecorators.filter(\n (activeDecorator) => activeDecorator !== decorator,\n )\n } else if (decoratorState[decorator] === true) {\n if (!activeDecorators.includes(decorator)) {\n activeDecorators.push(decorator)\n }\n }\n }\n\n return activeDecorators\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveAnnotationsMarks} from './selector.get-active-annotation-marks'\nimport {getSelectedTextBlocks} from './selector.get-selected-text-blocks'\nimport {getSelectedValue} from './selector.get-selected-value'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * Check whether an annotation is active in the given `snapshot`.\n *\n * @public\n */\nexport function isActiveAnnotation(\n annotation: string,\n options?: {\n /**\n * Choose whether the annotation has to cover the entire selection\n * (`'full'`) or whether the selection covering at least one character\n * of the annotation suffices (`'partial'`). With a collapsed\n * selection the modes agree: the annotation is active when the caret\n * sits inside it, not at its edges.\n *\n * Defaults to `'full'`\n */\n mode?: 'partial' | 'full'\n },\n): EditorSelector<boolean> {\n return (snapshot) => {\n const mode = options?.mode ?? 'full'\n\n if (mode === 'partial' && isSelectionExpanded(snapshot)) {\n // An expanded selection \"partially selects\" the annotation when it\n // covers at least one character of annotated text.\n const selectedValue = getSelectedValue(snapshot)\n\n return selectedValue.some((block) => {\n if (!isTextBlock(snapshot.context, block)) {\n return false\n }\n\n const annotationKeys = new Set(\n (block.markDefs ?? [])\n .filter((markDef) => markDef._type === annotation)\n .map((markDef) => markDef._key),\n )\n\n if (annotationKeys.size === 0) {\n return false\n }\n\n return block.children.some(\n (child) =>\n isSpan(snapshot.context, child) &&\n // Spans the selection only touches at a zero-width boundary\n // survive the slice with empty text and intact `marks`,\n // keeping their definitions alive through the slice's\n // unused-definition pruning. A boundary touch selects nothing\n // of the annotation, so those spans don't count.\n child.text.length > 0 &&\n child.marks?.some((mark) => annotationKeys.has(mark)),\n )\n })\n }\n\n // `'partial'` with a collapsed selection falls through to here: a\n // caret covers no characters, so the `'partial'`/`'full'` distinction\n // is meaningless and both modes share the canonical caret answer this\n // computes (active inside an annotated span, not at its edges, where\n // typing doesn't extend the annotation either).\n const selectedBlocks = getSelectedTextBlocks(snapshot)\n const selectionMarkDefs = selectedBlocks.flatMap(\n (block) => block.node.markDefs ?? [],\n )\n const activeAnnotations = getActiveAnnotationsMarks(snapshot)\n const activeMarkDefs = selectionMarkDefs.filter(\n (markDef) =>\n markDef._type === annotation &&\n activeAnnotations.includes(markDef._key),\n )\n\n return activeMarkDefs.length > 0\n }\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getPathSubSchema} from '../traversal/get-path-sub-schema'\nimport {getMarkState} from './selector.get-mark-state'\nimport {getSelectedTextBlocks} from './selector.get-selected-text-blocks'\n\n/**\n * @public\n */\nexport const getActiveAnnotations: EditorSelector<Array<PortableTextObject>> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return []\n }\n\n const selectedBlocks = getSelectedTextBlocks(snapshot)\n const markState = getMarkState(snapshot)\n\n // Union of decorator names across selected blocks' sub-schemas. Marks\n // that aren't decorators in any in-scope sub-schema are annotations.\n const decoratorNames = new Set<string>()\n for (const block of selectedBlocks) {\n for (const decorator of getPathSubSchema(snapshot, block.path).decorators) {\n decoratorNames.add(decorator.name)\n }\n }\n if (decoratorNames.size === 0) {\n for (const decorator of snapshot.context.schema.decorators) {\n decoratorNames.add(decorator.name)\n }\n }\n\n const activeAnnotations = (markState?.marks ?? []).filter(\n (mark) => !decoratorNames.has(mark),\n )\n\n const selectionMarkDefs = selectedBlocks.flatMap(\n (block) => block.node.markDefs ?? [],\n )\n\n return selectionMarkDefs.filter((markDef) =>\n activeAnnotations.includes(markDef._key),\n )\n}\n","import type {PortableTextListBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getPathSubSchema} from '../traversal/get-path-sub-schema'\nimport {getSelectedTextBlocks} from './selector.get-selected-text-blocks'\n\n/**\n * @public\n */\nexport const getActiveListItem: EditorSelector<\n PortableTextListBlock['listItem'] | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedTextBlocks = getSelectedTextBlocks(snapshot)\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n const firstListItem = firstTextBlock.node.listItem\n\n if (!firstListItem) {\n return undefined\n }\n\n // Skip blocks whose sub-schema does not declare the list. A list item\n // is active when every in-scope block carries it.\n const inScopeBlocks = selectedTextBlocks.filter((block) =>\n getPathSubSchema(snapshot, block.path).lists.some(\n (l) => l.name === firstListItem,\n ),\n )\n\n if (inScopeBlocks.every((block) => block.node.listItem === firstListItem)) {\n return firstListItem\n }\n\n return undefined\n}\n","import type {PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getPathSubSchema} from '../traversal/get-path-sub-schema'\nimport {getSelectedTextBlocks} from './selector.get-selected-text-blocks'\n\n/**\n * @public\n */\nexport const getActiveStyle: EditorSelector<PortableTextTextBlock['style']> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectedTextBlocks = getSelectedTextBlocks(snapshot)\n const firstTextBlock = selectedTextBlocks.at(0)\n\n if (!firstTextBlock) {\n return undefined\n }\n\n // A block without a `style` reads as its sub-schema's default (the\n // first declared style), the same value normalization fills in when a\n // local edit touches the block.\n const firstStyle =\n firstTextBlock.node.style ??\n getPathSubSchema(snapshot, firstTextBlock.path).styles.at(0)?.name\n\n if (!firstStyle) {\n return undefined\n }\n\n // Skip blocks whose sub-schema does not declare the style. A style is\n // active when every in-scope block carries it.\n const inScopeBlocks = selectedTextBlocks.filter((block) =>\n getPathSubSchema(snapshot, block.path).styles.some(\n (s) => s.name === firstStyle,\n ),\n )\n\n if (\n inScopeBlocks.every(\n (block) =>\n (block.node.style ??\n getPathSubSchema(snapshot, block.path).styles.at(0)?.name) ===\n firstStyle,\n )\n ) {\n return firstStyle\n }\n\n return undefined\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSibling} from '../traversal/get-sibling'\nimport {isObject} from '../traversal/is-object'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * Returns the inline object after the selection end within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getNextInlineObject: EditorSelector<\n {node: PortableTextObject; path: ChildPath} | undefined\n> = (snapshot) => {\n const point = getSelectionEndPoint(snapshot)\n\n if (!point) {\n return undefined\n }\n\n const sibling = getSibling(snapshot, point.path, {\n direction: 'next',\n match: (node): node is PortableTextObject => isObject(snapshot, node),\n })\n\n return sibling\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSibling} from '../traversal/get-sibling'\nimport {isObject} from '../traversal/is-object'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * Returns the inline object before the selection start within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getPreviousInlineObject: EditorSelector<\n {node: PortableTextObject; path: ChildPath} | undefined\n> = (snapshot) => {\n const point = getSelectionStartPoint(snapshot)\n\n if (!point) {\n return undefined\n }\n\n const sibling = getSibling(snapshot, point.path, {\n direction: 'previous',\n match: (node): node is PortableTextObject => isObject(snapshot, node),\n })\n\n return sibling\n}\n","import {isSpan, isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport type {Node} from '../engine/interfaces/node'\nimport type {RegisteredContainer} from '../schema/resolve-containers'\nimport {getNodeChildren} from '../traversal/get-children'\nimport {getSelectedValue} from './selector.get-selected-value'\n\n/**\n * @public\n */\nexport const getSelectionText: EditorSelector<string> = (snapshot) => {\n const selectedValue = getSelectedValue(snapshot)\n\n return collectText(snapshot.context, selectedValue)\n}\n\nfunction collectText(\n context: Pick<EditorContext, 'schema' | 'containers'>,\n blocks: ReadonlyArray<Node | PortableTextBlock>,\n parent?: RegisteredContainer,\n): string {\n let text = ''\n\n for (const block of blocks) {\n if (isTextBlock(context, block)) {\n for (const child of block.children) {\n if (isSpan(context, child)) {\n text += child.text\n }\n }\n continue\n }\n\n const childInfo = getNodeChildren(context, block, parent)\n\n if (!childInfo) {\n continue\n }\n\n text += collectText(context, childInfo.children, childInfo.parent)\n }\n\n return text\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {\n blockOffsetToSpanSelectionPoint,\n spanSelectionPointToBlockOffset,\n} from '../utils/util.block-offset'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getNextInlineObject} from './selector.get-next-inline-object'\nimport {getPreviousInlineObject} from './selector.get-previous-inline-object'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\nimport {getSelectionText} from './selector.get-selection-text'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n * Returns the selection of the of the word the caret is placed in.\n * Note: Only returns a word selection if the current selection is collapsed\n */\nexport const getCaretWordSelection: EditorSelector<EditorSelection> = (\n snapshot,\n) => {\n if (!snapshot.context.selection) {\n return null\n }\n\n if (!isSelectionCollapsed(snapshot)) {\n return null\n }\n\n const focusTextBlock = getFocusTextBlock(snapshot)\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionStartOffset = selectionStartPoint\n ? spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionStartPoint,\n })\n : undefined\n\n if (!focusTextBlock || !selectionStartPoint || !selectionStartOffset) {\n return null\n }\n\n const previousInlineObject = getPreviousInlineObject(snapshot)\n const blockStartPoint = getBlockStartPoint({\n context: snapshot.context,\n block: focusTextBlock,\n })\n const textBefore = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: previousInlineObject\n ? {path: previousInlineObject.path, offset: 0}\n : blockStartPoint,\n focus: selectionStartPoint,\n },\n },\n })\n const textDirectlyBefore = textBefore.split(/\\s+/).at(-1)\n\n const nextInlineObject = getNextInlineObject(snapshot)\n const blockEndPoint = getBlockEndPoint({\n context: snapshot.context,\n block: focusTextBlock,\n })\n const textAfter = getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: selectionStartPoint,\n focus: nextInlineObject\n ? {path: nextInlineObject.path, offset: 0}\n : blockEndPoint,\n },\n },\n })\n const textDirectlyAfter = textAfter.split(/\\s+/).at(0)\n\n if (\n (textDirectlyBefore === undefined || textDirectlyBefore === '') &&\n (textDirectlyAfter === undefined || textDirectlyAfter === '')\n ) {\n return null\n }\n\n const caretWordStartOffset: BlockOffset = textDirectlyBefore\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset - textDirectlyBefore.length,\n }\n : selectionStartOffset\n const caretWordEndOffset: BlockOffset = textDirectlyAfter\n ? {\n ...selectionStartOffset,\n offset: selectionStartOffset.offset + textDirectlyAfter.length,\n }\n : selectionStartOffset\n\n const caretWordStartSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset: caretWordStartOffset,\n direction: 'backward',\n })\n const caretWordEndSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset: caretWordEndOffset,\n direction: 'forward',\n })\n\n if (!caretWordStartSelectionPoint || !caretWordEndSelectionPoint) {\n return null\n }\n\n const caretWordSelection = {\n anchor: caretWordStartSelectionPoint,\n focus: caretWordEndSelectionPoint,\n }\n\n return isSelectionExpanded({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: caretWordSelection,\n },\n })\n ? caretWordSelection\n : null\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isTextBlockNode} from '../engine/node/is-text-block-node'\nimport {isEditableContainer} from '../schema/is-editable-container'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * Returns the void block object containing the focus selection, resolved at\n * any depth.\n *\n * Excludes text blocks and editable containers (which have their own children\n * and are not \"void\"). When the focus is at root, behavior is unchanged.\n *\n * @public\n */\nexport const getFocusBlockObject: EditorSelector<\n {node: PortableTextObject; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n if (!focusBlock) {\n return undefined\n }\n\n if (isTextBlockNode(snapshot.context, focusBlock.node)) {\n return undefined\n }\n\n if (isEditableContainer(snapshot, focusBlock.node, focusBlock.path)) {\n return undefined\n }\n\n return {node: focusBlock.node, path: focusBlock.path}\n}\n","import type {PortableTextListBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {isListBlock} from '../utils/parse-blocks'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\n\n/**\n * Returns the list block containing the focus selection, resolved at any\n * depth.\n *\n * @public\n */\nexport const getFocusListBlock: EditorSelector<\n {node: PortableTextListBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusTextBlock = getFocusTextBlock(snapshot)\n\n return focusTextBlock && isListBlock(snapshot.context, focusTextBlock.node)\n ? {node: focusTextBlock.node, path: focusTextBlock.path}\n : undefined\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../traversal/get-children'\nimport {getBlock} from '../traversal/is-block'\nimport type {BlockPath} from '../types/paths'\nimport {getFocusBlock} from './selector.get-focus-block'\n\n/**\n * Returns the last block at the current container scope.\n *\n * When the focus is inside an editable container (e.g. a code block's line),\n * this returns the last block within that container (the last line). When\n * the focus is at root, or there is no selection, this returns the last\n * block in the document.\n *\n * @public\n */\nexport const getLastBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const focusBlock = getFocusBlock(snapshot)\n\n if (focusBlock) {\n const siblings = getChildren(snapshot, parentPath(focusBlock.path))\n const last = siblings.at(-1)\n\n if (last) {\n return getBlock(snapshot, last.path)\n }\n }\n\n const node = snapshot.context.value.at(-1)\n\n return node ? {node, path: [{_key: node._key}]} : undefined\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSibling} from '../traversal/get-sibling'\nimport {getBlock} from '../traversal/is-block'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionEndBlock} from './selector.get-selection-end-block'\n\n/**\n * Returns the block after the selection's end block within the same\n * container scope, if any.\n *\n * Siblings are resolved within the enclosing container (or the document root\n * if the selection is at root level). Never crosses container boundaries.\n *\n * @public\n */\nexport const getNextBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selectionEndBlock = getSelectionEndBlock(snapshot)\n\n if (!selectionEndBlock) {\n return undefined\n }\n\n const next = getSibling(snapshot, selectionEndBlock.path, {direction: 'next'})\n\n if (!next) {\n return undefined\n }\n\n return getBlock(snapshot, next.path)\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getSibling} from '../traversal/get-sibling'\nimport {getBlock} from '../traversal/is-block'\nimport type {BlockPath} from '../types/paths'\nimport {getSelectionStartBlock} from './selector.get-selection-start-block'\n\n/**\n * Returns the block before the selection's start block within the same\n * container scope, if any.\n *\n * Siblings are resolved within the enclosing container (or the document root\n * if the selection is at root level). Never crosses container boundaries.\n *\n * @public\n */\nexport const getPreviousBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selectionStartBlock = getSelectionStartBlock(snapshot)\n\n if (!selectionStartBlock) {\n return undefined\n }\n\n const previous = getSibling(snapshot, selectionStartBlock.path, {\n direction: 'previous',\n })\n\n if (!previous) {\n return undefined\n }\n\n return getBlock(snapshot, previous.path)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * Returns the child containing the selection's end point, resolved at any\n * depth.\n *\n * @public\n */\nexport const getSelectionEndChild: EditorSelector<\n | {\n node: PortableTextSpan | PortableTextObject\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n if (!endPoint) {\n return undefined\n }\n\n return getFocusChild({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusChild} from './selector.get-focus-child'\n\n/**\n * Returns the child containing the selection's start point, resolved at any\n * depth.\n *\n * @public\n */\nexport const getSelectionStartChild: EditorSelector<\n | {\n node: PortableTextSpan | PortableTextObject\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n if (!startPoint) {\n return undefined\n }\n\n return getFocusChild({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getPathSubSchema} from '../traversal/get-path-sub-schema'\nimport {getActiveDecorators} from './selector.get-active-decorators'\nimport {getSelectedSpans} from './selector.get-selected-spans'\nimport {isSelectionExpanded} from './selector.is-selection-expanded'\n\n/**\n * @public\n */\nexport function isActiveDecorator(decorator: string): EditorSelector<boolean> {\n return (snapshot) => {\n if (isSelectionExpanded(snapshot)) {\n const selectedSpans = getSelectedSpans(snapshot)\n\n // Skip spans whose enclosing block sub-schema does not declare the\n // decorator. A mark is active when every in-scope span carries it.\n const inScopeSpans = selectedSpans.filter((span) =>\n getPathSubSchema(snapshot, span.path).decorators.some(\n (d) => d.name === decorator,\n ),\n )\n\n return (\n inScopeSpans.length > 0 &&\n inScopeSpans.every((span) => span.node.marks?.includes(decorator))\n )\n }\n\n const activeDecorators = getActiveDecorators(snapshot)\n\n return activeDecorators.includes(decorator)\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveListItem} from './selector.get-active-list-item'\n\n/**\n * @public\n */\nexport function isActiveListItem(listItem: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeListItem = getActiveListItem(snapshot)\n\n return activeListItem === listItem\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getActiveStyle} from './selector.get-active-style'\n\n/**\n * @public\n */\nexport function isActiveStyle(style: string): EditorSelector<boolean> {\n return (snapshot) => {\n const activeStyle = getActiveStyle(snapshot)\n\n return activeStyle === style\n }\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {isEqualSelectionPoints} from '../utils/util.is-equal-selection-points'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheEndOfBlock(block: {\n node: PortableTextBlock\n path: BlockPath\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockEndPoint = getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return isEqualSelectionPoints(\n snapshot.context.selection.focus,\n blockEndPoint,\n )\n }\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {isEqualSelectionPoints} from '../utils/util.is-equal-selection-points'\nimport {isSelectionCollapsed} from './selector.is-selection-collapsed'\n\n/**\n * @public\n */\nexport function isAtTheStartOfBlock(block: {\n node: PortableTextBlock\n path: BlockPath\n}): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection || !isSelectionCollapsed(snapshot)) {\n return false\n }\n\n const blockStartPoint = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return isEqualSelectionPoints(\n snapshot.context.selection.focus,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