@portabletext/editor 8.0.3 → 8.1.1

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 (28) hide show
  1. package/lib/{behavior.types.action-C6D8CCF9.d.ts → behavior.types.action-C0XDEQnB.d.ts} +18 -1
  2. package/lib/behavior.types.action-C0XDEQnB.d.ts.map +1 -0
  3. package/lib/behaviors/index.d.ts +1 -1
  4. package/lib/{get-container-D1nM_ww9.js → get-container-D2pN5Npr.js} +3 -3
  5. package/lib/{get-container-D1nM_ww9.js.map → get-container-D2pN5Npr.js.map} +1 -1
  6. package/lib/{get-parent-Ci5241qs.js → get-parent-DgaKcy8-.js} +18 -12
  7. package/lib/get-parent-DgaKcy8-.js.map +1 -0
  8. package/lib/{get-path-sub-schema-CZd9VcVM.js → get-path-sub-schema-Dd0QYZ0m.js} +2 -2
  9. package/lib/{get-path-sub-schema-CZd9VcVM.js.map → get-path-sub-schema-Dd0QYZ0m.js.map} +1 -1
  10. package/lib/index.d.ts +1 -1
  11. package/lib/index.js +290 -205
  12. package/lib/index.js.map +1 -1
  13. package/lib/plugins/index.d.ts +1 -1
  14. package/lib/{selector.is-selecting-entire-blocks-DPnzucrd.js → selector.is-selecting-entire-blocks-BFhnnkHf.js} +4 -4
  15. package/lib/{selector.is-selecting-entire-blocks-DPnzucrd.js.map → selector.is-selecting-entire-blocks-BFhnnkHf.js.map} +1 -1
  16. package/lib/selectors/index.d.ts +1 -1
  17. package/lib/selectors/index.js +4 -4
  18. package/lib/traversal/index.d.ts +1 -1
  19. package/lib/traversal/index.js +3 -3
  20. package/lib/{util.is-equal-selections-N1hxVUbE.js → util.is-equal-selections-BdK98okY.js} +2 -2
  21. package/lib/{util.is-equal-selections-N1hxVUbE.js.map → util.is-equal-selections-BdK98okY.js.map} +1 -1
  22. package/lib/{util.slice-blocks-B2fZcNok.js → util.slice-blocks-_ElaB53f.js} +2 -2
  23. package/lib/{util.slice-blocks-B2fZcNok.js.map → util.slice-blocks-_ElaB53f.js.map} +1 -1
  24. package/lib/utils/index.d.ts +1 -1
  25. package/lib/utils/index.js +3 -3
  26. package/package.json +1 -1
  27. package/lib/behavior.types.action-C6D8CCF9.d.ts.map +0 -1
  28. package/lib/get-parent-Ci5241qs.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { G as Editor, Gt as RegistrableNode, J as EditorEmittedEvent, Z as Behavior } from "../behavior.types.action-C6D8CCF9.js";
1
+ import { G as Editor, Gt as RegistrableNode, J as EditorEmittedEvent, Z as Behavior } from "../behavior.types.action-C0XDEQnB.js";
2
2
  import React from "react";
3
3
  /**
4
4
  * @public
@@ -1,6 +1,6 @@
1
- import { a as getNodeChildren, i as getChildren, n as parentPath, r as getNode, t as getParent, u as isKeyedSegment } from "./get-parent-Ci5241qs.js";
2
- import { S as hasNode, _ as comparePoints, a as isInline, b as isEditableContainer, c as isSpanNode, i as getEnclosingBlock, l as getSibling, m as rangeEdges, o as getBlock, p as isTextBlockNode, t as getPathSubSchema, u as getNodes, x as resolveContainerAt, y as isObject } from "./get-path-sub-schema-CZd9VcVM.js";
3
- import { d as getSelectionEndPoint$1, f as isSelectionCollapsed$1, g as isEqualSelectionPoints, m as getBlockEndPoint, n as isListBlock, p as getBlockStartPoint, t as sliceBlocks, u as getSelectionStartPoint$1, v as blockOffsetToSpanSelectionPoint, y as spanSelectionPointToBlockOffset } from "./util.slice-blocks-B2fZcNok.js";
1
+ import { a as getChildren, d as isKeyedSegment, n as parentPath, o as getNodeChildren, r as getNode, t as getParent } from "./get-parent-DgaKcy8-.js";
2
+ import { S as hasNode, _ as comparePoints, a as isInline, b as isEditableContainer, c as isSpanNode, i as getEnclosingBlock, l as getSibling, m as rangeEdges, o as getBlock, p as isTextBlockNode, t as getPathSubSchema, u as getNodes, x as resolveContainerAt, y as isObject } from "./get-path-sub-schema-Dd0QYZ0m.js";
3
+ import { d as getSelectionEndPoint$1, f as isSelectionCollapsed$1, g as isEqualSelectionPoints, m as getBlockEndPoint, n as isListBlock, p as getBlockStartPoint, t as sliceBlocks, u as getSelectionStartPoint$1, v as blockOffsetToSpanSelectionPoint, y as spanSelectionPointToBlockOffset } from "./util.slice-blocks-_ElaB53f.js";
4
4
  import { isSpan, isTextBlock } from "@portabletext/schema";
5
5
  /**
6
6
  * Returns true if the two ranges share at least one point.
@@ -797,4 +797,4 @@ const isSelectingEntireBlocks = (snapshot) => {
797
797
  };
798
798
  export { getSelectionEndPoint as A, getFocusBlock as B, getSelectedTextBlocks as C, getPreviousSpan as D, getSelectedSpans as E, getSelectionEndBlock as F, rangesOverlap as G, getFocusInlineObject as H, getFragment as I, getSelectedValue as L, isSelectionCollapsed as M, isOverlappingSelection as N, getSelectionStartPoint as O, getSelectionStartBlock as P, getRootAcceptedTypes as R, getActiveDecorators as S, getMarkState as T, getFocusChild as U, getFocusSpan as V, getInline as W, getNextInlineObject as _, isActiveListItem as a, getActiveAnnotations as b, getSelectionEndChild as c, getLastBlock as d, getFocusListBlock as f, getPreviousInlineObject as g, getSelectionText as h, isActiveStyle as i, isSelectionExpanded$1 as j, getNextSpan as k, getPreviousBlock as l, getCaretWordSelection as m, isAtTheStartOfBlock as n, isActiveDecorator as o, getFocusBlockObject as p, isAtTheEndOfBlock as r, getSelectionStartChild as s, isSelectingEntireBlocks as t, getNextBlock as u, getActiveStyle as v, getActiveAnnotationsMarks as w, isActiveAnnotation as x, getActiveListItem as y, getFocusTextBlock as z };
799
799
 
800
- //# sourceMappingURL=selector.is-selecting-entire-blocks-DPnzucrd.js.map
800
+ //# sourceMappingURL=selector.is-selecting-entire-blocks-BFhnnkHf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"selector.is-selecting-entire-blocks-DPnzucrd.js","names":[],"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/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","../src/selectors/selector.is-selecting-entire-blocks.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 {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 * @public\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 * @public\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,\n blockStartPoint,\n )\n }\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"],"mappings":";;;;;;;;;;AAWA,SAAgB,cACd,QACA,QACA,MACS;CACT,IAAM,CAAC,QAAQ,QAAQ,WAAW,QAAQ,IAAI,GACxC,CAAC,QAAQ,QAAQ,WAAW,QAAQ,IAAI;CAC9C,OACE,cAAc,QAAQ,MAAM,IAAI,KAAK,KACrC,cAAc,QAAQ,MAAM,IAAI,KAAK;AAEzC;;;;;;;;ACPA,SAAgB,UACd,UACA,MACuE;CACvE,IAAM,QAAQ,QAAQ,UAAU,IAAI;CAEhC,OAAC,SAAS,CAAC,SAAS,UAAU,MAAM,IAAI,MAK1C,GAAC,WAAW,EAAC,QAAQ,SAAS,QAAQ,OAAM,GAAG,MAAM,IAAI,KACzD,CAAC,SAAS,UAAU,MAAM,IAAI,IAKhC,OAAO;EAAC,MAAM,MAAM;EAAM,MAAM,MAAM;CAAI;AAC5C;;;;;;;ACtBA,MAAa,iBAMR,aAAa;CAChB,IAAM,YAAY,SAAS,QAAQ;CAE9B,eAIL,OAAO,UAAU,UAAU,UAAU,MAAM,IAAI;AACjD,GCba,wBAER,aAAa;CAChB,IAAM,aAAa,cAAc,QAAQ;CAEzC,OAAO,cAAc,CAAC,WAAW,SAAS,SAAS,WAAW,IAAI,IAC9D;EAAC,MAAM,WAAW;EAAM,MAAM,WAAW;CAAI,IAC7C,KAAA;AACN,GCVa,gBAER,aAAa;CAChB,IAAM,aAAa,cAAc,QAAQ;CAEzC,OAAO,cAAc,OAAO,SAAS,SAAS,WAAW,IAAI,IACzD;EAAC,MAAM,WAAW;EAAM,MAAM,WAAW;CAAI,IAC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,CAAC,qBAAqB,QAAQ,GAC/D,OAAO;EAGT,IAAM,gBAAgB,iBAAiB;GACrC,SAAS,SAAS;GAClB;EACF,CAAC;EAED,OAAO,uBACL,SAAS,QAAQ,UAAU,OAC3B,aACF;CACF;AACF;;;;ACnBA,SAAgB,oBAAoB,OAGR;CAC1B,QAAQ,aAAa;EACnB,IAAI,CAAC,SAAS,QAAQ,aAAa,CAAC,qBAAqB,QAAQ,GAC/D,OAAO;EAGT,IAAM,kBAAkB,mBAAmB;GACzC,SAAS,SAAS;GAClB;EACF,CAAC;EAED,OAAO,uBACL,SAAS,QAAQ,UAAU,OAC3B,eACF;CACF;AACF;;;;ACnBA,MAAa,2BAAoD,aAAa;CAC5E,IAAI,CAAC,SAAS,QAAQ,WACpB,OAAO;CAGT,IAAM,aAAa,SAAS,QAAQ,UAAU,WAC1C,SAAS,QAAQ,UAAU,QAC3B,SAAS,QAAQ,UAAU,QACzB,WAAW,SAAS,QAAQ,UAAU,WACxC,SAAS,QAAQ,UAAU,SAC3B,SAAS,QAAQ,UAAU,OAEzB,aAAa,uBAAuB,QAAQ,GAC5C,WAAW,qBAAqB,QAAQ;CAE9C,IAAI,CAAC,cAAc,CAAC,UAClB,OAAO;CAGT,IAAM,uBAAuB,mBAAmB;EAC9C,SAAS,SAAS;EAClB,OAAO;CACT,CAAC,GACK,mBAAmB,iBAAiB;EACxC,SAAS,SAAS;EAClB,OAAO;CACT,CAAC;CAED,OACE,uBAAuB,sBAAsB,UAAU,KACvD,uBAAuB,kBAAkB,QAAQ;AAErD"}
1
+ {"version":3,"file":"selector.is-selecting-entire-blocks-BFhnnkHf.js","names":[],"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/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","../src/selectors/selector.is-selecting-entire-blocks.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 {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 * @public\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 * @public\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,\n blockStartPoint,\n )\n }\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"],"mappings":";;;;;;;;;;AAWA,SAAgB,cACd,QACA,QACA,MACS;CACT,IAAM,CAAC,QAAQ,QAAQ,WAAW,QAAQ,IAAI,GACxC,CAAC,QAAQ,QAAQ,WAAW,QAAQ,IAAI;CAC9C,OACE,cAAc,QAAQ,MAAM,IAAI,KAAK,KACrC,cAAc,QAAQ,MAAM,IAAI,KAAK;AAEzC;;;;;;;;ACPA,SAAgB,UACd,UACA,MACuE;CACvE,IAAM,QAAQ,QAAQ,UAAU,IAAI;CAEhC,OAAC,SAAS,CAAC,SAAS,UAAU,MAAM,IAAI,MAK1C,GAAC,WAAW,EAAC,QAAQ,SAAS,QAAQ,OAAM,GAAG,MAAM,IAAI,KACzD,CAAC,SAAS,UAAU,MAAM,IAAI,IAKhC,OAAO;EAAC,MAAM,MAAM;EAAM,MAAM,MAAM;CAAI;AAC5C;;;;;;;ACtBA,MAAa,iBAMR,aAAa;CAChB,IAAM,YAAY,SAAS,QAAQ;CAE9B,eAIL,OAAO,UAAU,UAAU,UAAU,MAAM,IAAI;AACjD,GCba,wBAER,aAAa;CAChB,IAAM,aAAa,cAAc,QAAQ;CAEzC,OAAO,cAAc,CAAC,WAAW,SAAS,SAAS,WAAW,IAAI,IAC9D;EAAC,MAAM,WAAW;EAAM,MAAM,WAAW;CAAI,IAC7C,KAAA;AACN,GCVa,gBAER,aAAa;CAChB,IAAM,aAAa,cAAc,QAAQ;CAEzC,OAAO,cAAc,OAAO,SAAS,SAAS,WAAW,IAAI,IACzD;EAAC,MAAM,WAAW;EAAM,MAAM,WAAW;CAAI,IAC7C,KAAA;AACN,GCJa,iBAER,aAAa;CAChB,IAAM,YAAY,S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AgB,iBAAiB;GACrC,SAAS,SAAS;GAClB;EACF,CAAC;EAED,OAAO,uBACL,SAAS,QAAQ,UAAU,OAC3B,aACF;CACF;AACF;;;;ACnBA,SAAgB,oBAAoB,OAGR;CAC1B,QAAQ,aAAa;EACnB,IAAI,CAAC,SAAS,QAAQ,aAAa,CAAC,qBAAqB,QAAQ,GAC/D,OAAO;EAGT,IAAM,kBAAkB,mBAAmB;GACzC,SAAS,SAAS;GAClB;EACF,CAAC;EAED,OAAO,uBACL,SAAS,QAAQ,UAAU,OAC3B,eACF;CACF;AACF;;;;ACnBA,MAAa,2BAAoD,aAAa;CAC5E,IAAI,CAAC,SAAS,QAAQ,WACpB,OAAO;CAGT,IAAM,aAAa,SAAS,QAAQ,UAAU,WAC1C,SAAS,QAAQ,UAAU,QAC3B,SAAS,QAAQ,UAAU,QACzB,WAAW,SAAS,QAAQ,UAAU,WACxC,SAAS,QAAQ,UAAU,SAC3B,SAAS,QAAQ,UAAU,OAEzB,aAAa,uBAAuB,QAAQ,GAC5C,WAAW,qBAAqB,QAAQ;CAE9C,IAAI,CAAC,cAAc,CAAC,UAClB,OAAO;CAGT,IAAM,uBAAuB,mBAAmB;EAC9C,SAAS,SAAS;EAClB,OAAO;CACT,CAAC,GACK,mBAAmB,iBAAiB;EACxC,SAAS,SAAS;EAClB,OAAO;CACT,CAAC;CAED,OACE,uBAAuB,sBAAsB,UAAU,KACvD,uBAAuB,kBAAkB,QAAQ;AAErD"}
@@ -1,4 +1,4 @@
1
- import { I as BlockOffset, V as EditorSelector, at as EditorSelectionPoint, it as EditorSelection, ln as Path, on as BlockPath, sn as ChildPath } from "../behavior.types.action-C6D8CCF9.js";
1
+ import { I as BlockOffset, V as EditorSelector, at as EditorSelectionPoint, it as EditorSelection, ln as Path, on as BlockPath, sn as ChildPath } from "../behavior.types.action-C0XDEQnB.js";
2
2
  import { PortableTextBlock, PortableTextListBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock } from "@portabletext/schema";
3
3
  /**
4
4
  * The set of schema member names applicable at the current selection,
@@ -1,7 +1,7 @@
1
- import { i as getChildren, n as parentPath, u as isKeyedSegment } from "../get-parent-Ci5241qs.js";
2
- import { i as getEnclosingBlock, o as getBlock, r as comparePoints, t as getPathSubSchema, u as getNodes, y as isObject } from "../get-path-sub-schema-CZd9VcVM.js";
3
- import { d as getSelectionEndPoint$1, m as getBlockEndPoint, p as getBlockStartPoint, u as getSelectionStartPoint$1, y as spanSelectionPointToBlockOffset } from "../util.slice-blocks-B2fZcNok.js";
4
- import { A as getSelectionEndPoint, B as getFocusBlock, C as getSelectedTextBlocks, D as getPreviousSpan, E as getSelectedSpans, F as getSelectionEndBlock, H as getFocusInlineObject, I as getFragment, L as getSelectedValue, M as isSelectionCollapsed, N as isOverlappingSelection, O as getSelectionStartPoint, P as getSelectionStartBlock, T as getMarkState, U as getFocusChild, V as getFocusSpan, W as getInline, _ as getNextInlineObject, a as isActiveListItem, b as getActiveAnnotations, c as getSelectionEndChild, d as getLastBlock, f as getFocusListBlock, g as getPreviousInlineObject, h as getSelectionText, i as isActiveStyle, j as isSelectionExpanded, k as getNextSpan, l as getPreviousBlock, m as getCaretWordSelection, n as isAtTheStartOfBlock, o as isActiveDecorator, p as getFocusBlockObject, r as isAtTheEndOfBlock, s as getSelectionStartChild, t as isSelectingEntireBlocks, u as getNextBlock, v as getActiveStyle, x as isActiveAnnotation, y as getActiveListItem, z as getFocusTextBlock } from "../selector.is-selecting-entire-blocks-DPnzucrd.js";
1
+ import { a as getChildren, d as isKeyedSegment, n as parentPath } from "../get-parent-DgaKcy8-.js";
2
+ import { i as getEnclosingBlock, o as getBlock, r as comparePoints, t as getPathSubSchema, u as getNodes, y as isObject } from "../get-path-sub-schema-Dd0QYZ0m.js";
3
+ import { d as getSelectionEndPoint$1, m as getBlockEndPoint, p as getBlockStartPoint, u as getSelectionStartPoint$1, y as spanSelectionPointToBlockOffset } from "../util.slice-blocks-_ElaB53f.js";
4
+ import { A as getSelectionEndPoint, B as getFocusBlock, C as getSelectedTextBlocks, D as getPreviousSpan, E as getSelectedSpans, F as getSelectionEndBlock, H as getFocusInlineObject, I as getFragment, L as getSelectedValue, M as isSelectionCollapsed, N as isOverlappingSelection, O as getSelectionStartPoint, P as getSelectionStartBlock, T as getMarkState, U as getFocusChild, V as getFocusSpan, W as getInline, _ as getNextInlineObject, a as isActiveListItem, b as getActiveAnnotations, c as getSelectionEndChild, d as getLastBlock, f as getFocusListBlock, g as getPreviousInlineObject, h as getSelectionText, i as isActiveStyle, j as isSelectionExpanded, k as getNextSpan, l as getPreviousBlock, m as getCaretWordSelection, n as isAtTheStartOfBlock, o as isActiveDecorator, p as getFocusBlockObject, r as isAtTheEndOfBlock, s as getSelectionStartChild, t as isSelectingEntireBlocks, u as getNextBlock, v as getActiveStyle, x as isActiveAnnotation, y as getActiveListItem, z as getFocusTextBlock } from "../selector.is-selecting-entire-blocks-BFhnnkHf.js";
5
5
  import { isSpan, isTextBlock } from "@portabletext/schema";
6
6
  /**
7
7
  * Resolve which schema members are applicable at the current selection. For
@@ -1,4 +1,4 @@
1
- import { Et as RegisteredContainer, St as Node, at as EditorSelectionPoint, it as EditorSelection, ln as Path, wt as Containers, xt as TraversalSnapshot } from "../behavior.types.action-C6D8CCF9.js";
1
+ import { Et as RegisteredContainer, St as Node, at as EditorSelectionPoint, it as EditorSelection, ln as Path, wt as Containers, xt as TraversalSnapshot } from "../behavior.types.action-C0XDEQnB.js";
2
2
  import { PortableTextBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock, Schema } from "@portabletext/schema";
3
3
  /**
4
4
  * Find an ancestor of the node at a given path that matches a predicate.
@@ -1,6 +1,6 @@
1
- import { i as getChildren, o as getContainerChildren, r as getNode, t as getParent, u as isKeyedSegment } from "../get-parent-Ci5241qs.js";
2
- import { C as getAncestors, S as hasNode, a as isInline, i as getEnclosingBlock, l as getSibling, o as getBlock, r as comparePoints, s as isBlock, t as getPathSubSchema, y as isObject } from "../get-path-sub-schema-CZd9VcVM.js";
3
- import { _ as getAncestor, a as getTextBlock, c as pathContains, g as isLeafObject, h as getLeaf, i as getFirstChild, l as getSpan, n as getUnionSchema, o as rangeIntersects, r as getLastChild, t as getContainer, u as getText } from "../get-container-D1nM_ww9.js";
1
+ import { a as getChildren, d as isKeyedSegment, r as getNode, s as getContainerChildren, t as getParent } from "../get-parent-DgaKcy8-.js";
2
+ import { C as getAncestors, S as hasNode, a as isInline, i as getEnclosingBlock, l as getSibling, o as getBlock, r as comparePoints, s as isBlock, t as getPathSubSchema, y as isObject } from "../get-path-sub-schema-Dd0QYZ0m.js";
3
+ import { _ as getAncestor, a as getTextBlock, c as pathContains, g as isLeafObject, h as getLeaf, i as getFirstChild, l as getSpan, n as getUnionSchema, o as rangeIntersects, r as getLastChild, t as getContainer, u as getText } from "../get-container-D2pN5Npr.js";
4
4
  /**
5
5
  * Get the annotation at a given path.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { g as isEqualSelectionPoints } from "./util.slice-blocks-B2fZcNok.js";
1
+ import { g as isEqualSelectionPoints } from "./util.slice-blocks-_ElaB53f.js";
2
2
  import { isSpan, isTextBlock } from "@portabletext/schema";
3
3
  /**
4
4
  * @public
@@ -22,4 +22,4 @@ function isEqualSelections(a, b) {
22
22
  }
23
23
  export { isEmptyTextBlock as n, getTextBlockText as r, isEqualSelections as t };
24
24
 
25
- //# sourceMappingURL=util.is-equal-selections-N1hxVUbE.js.map
25
+ //# sourceMappingURL=util.is-equal-selections-BdK98okY.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.is-equal-selections-N1hxVUbE.js","names":[],"sources":["../src/utils/util.get-text-block-text.ts","../src/utils/util.is-empty-text-block.ts","../src/utils/util.is-equal-selections.ts"],"sourcesContent":["import type {PortableTextTextBlock} from '@portabletext/schema'\n\n/**\n * @public\n */\nexport function getTextBlockText(block: PortableTextTextBlock) {\n return block.children.map((child) => child.text ?? '').join('')\n}\n","import {isSpan, isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {getTextBlockText} from './util.get-text-block-text'\n\n/**\n * @public\n */\nexport function isEmptyTextBlock(\n context: Pick<EditorContext, 'schema'>,\n block: PortableTextBlock | unknown,\n) {\n if (!isTextBlock(context, block)) {\n return false\n }\n\n const onlyText = block.children.every((child) => isSpan(context, child))\n const blockText = getTextBlockText(block)\n\n return onlyText && blockText === ''\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n"],"mappings":";;;;;AAKA,SAAgB,iBAAiB,OAA8B;CAC7D,OAAO,MAAM,SAAS,KAAK,UAAU,MAAM,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE;AAChE;;;;ACAA,SAAgB,iBACd,SACA,OACA;CACA,IAAI,CAAC,YAAY,SAAS,KAAK,GAC7B,OAAO;CAGT,IAAM,WAAW,MAAM,SAAS,OAAO,UAAU,OAAO,SAAS,KAAK,CAAC,GACjE,YAAY,iBAAiB,KAAK;CAExC,OAAO,YAAY,cAAc;AACnC;;;;ACbA,SAAgB,kBAAkB,GAAoB,GAAoB;CASxE,OARI,CAAC,KAAK,CAAC,IACF,KAGL,CAAC,KAAK,CAAC,IACF,KAIP,uBAAuB,EAAE,QAAQ,EAAE,MAAM,KACzC,uBAAuB,EAAE,OAAO,EAAE,KAAK;AAE3C"}
1
+ {"version":3,"file":"util.is-equal-selections-BdK98okY.js","names":[],"sources":["../src/utils/util.get-text-block-text.ts","../src/utils/util.is-empty-text-block.ts","../src/utils/util.is-equal-selections.ts"],"sourcesContent":["import type {PortableTextTextBlock} from '@portabletext/schema'\n\n/**\n * @public\n */\nexport function getTextBlockText(block: PortableTextTextBlock) {\n return block.children.map((child) => child.text ?? '').join('')\n}\n","import {isSpan, isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {getTextBlockText} from './util.get-text-block-text'\n\n/**\n * @public\n */\nexport function isEmptyTextBlock(\n context: Pick<EditorContext, 'schema'>,\n block: PortableTextBlock | unknown,\n) {\n if (!isTextBlock(context, block)) {\n return false\n }\n\n const onlyText = block.children.every((child) => isSpan(context, child))\n const blockText = getTextBlockText(block)\n\n return onlyText && blockText === ''\n}\n","import type {EditorSelection} from '../types/editor'\nimport {isEqualSelectionPoints} from './util.is-equal-selection-points'\n\n/**\n * @public\n */\nexport function isEqualSelections(a: EditorSelection, b: EditorSelection) {\n if (!a && !b) {\n return true\n }\n\n if (!a || !b) {\n return false\n }\n\n return (\n isEqualSelectionPoints(a.anchor, b.anchor) &&\n isEqualSelectionPoints(a.focus, b.focus)\n )\n}\n"],"mappings":";;;;;AAKA,SAAgB,iBAAiB,OAA8B;CAC7D,OAAO,MAAM,SAAS,KAAK,UAAU,MAAM,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE;AAChE;;;;ACAA,SAAgB,iBACd,SACA,OACA;CACA,IAAI,CAAC,YAAY,SAAS,KAAK,GAC7B,OAAO;CAGT,IAAM,WAAW,MAAM,SAAS,OAAO,UAAU,OAAO,SAAS,KAAK,CAAC,GACjE,YAAY,iBAAiB,KAAK;CAExC,OAAO,YAAY,cAAc;AACnC;;;;ACbA,SAAgB,kBAAkB,GAAoB,GAAoB;CASxE,OARI,CAAC,KAAK,CAAC,IACF,KAGL,CAAC,KAAK,CAAC,IACF,KAIP,uBAAuB,EAAE,QAAQ,EAAE,MAAM,KACzC,uBAAuB,EAAE,OAAO,EAAE,KAAK;AAE3C"}
@@ -1,4 +1,4 @@
1
- import { c as isTypedObject, r as getNode, s as isRecord, t as getParent, u as isKeyedSegment } from "./get-parent-Ci5241qs.js";
1
+ import { c as isRecord, d as isKeyedSegment, l as isTypedObject, r as getNode, t as getParent } from "./get-parent-DgaKcy8-.js";
2
2
  import { getSubSchema, isSpan, isTextBlock } from "@portabletext/schema";
3
3
  /**
4
4
  * Pure text-offset arithmetic over a node's children array, shared by
@@ -630,4 +630,4 @@ function sliceBlocks({ context, blocks }) {
630
630
  }
631
631
  export { isEqualPaths as _, parseBlocks as a, childAtTextOffset as b, parseSpan as c, getSelectionEndPoint as d, isSelectionCollapsed as f, isEqualSelectionPoints as g, getBlockKeyFromSelectionPoint as h, parseBlock as i, defaultKeyGenerator as l, getBlockEndPoint as m, isListBlock as n, parseInlineObject as o, getBlockStartPoint as p, parseAnnotation as r, parseMarkDefs as s, sliceBlocks as t, getSelectionStartPoint as u, blockOffsetToSpanSelectionPoint as v, textOffsetOfChild as x, spanSelectionPointToBlockOffset as y };
632
632
 
633
- //# sourceMappingURL=util.slice-blocks-B2fZcNok.js.map
633
+ //# sourceMappingURL=util.slice-blocks-_ElaB53f.js.map