@portabletext/editor 7.0.2 → 7.0.4

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.
@@ -3,7 +3,7 @@ import { compareApplicableSchema, getActiveAnnotations, getActiveListItem, getAc
3
3
  import { getEnclosingBlock, parentPath } from "../_chunks-es/get-path-sub-schema.js";
4
4
  import { isSpan, isTextBlock } from "@portabletext/schema";
5
5
  import { spanSelectionPointToBlockOffset, getBlockEndPoint, getSelectionEndPoint as getSelectionEndPoint$1, getBlockStartPoint, getSelectionStartPoint as getSelectionStartPoint$1 } from "../_chunks-es/util.slice-blocks.js";
6
- import { getChildren, isKeyedSegment, isObjectNode } from "../_chunks-es/get-ancestor.js";
6
+ import { getChildren, isKeyedSegment, isObjectNode } from "../_chunks-es/get-node.js";
7
7
  const getAnchorBlock = (snapshot) => {
8
8
  const selection = snapshot.context.selection;
9
9
  if (selection)
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/selectors/selector.get-anchor-block.ts","../../src/selectors/selector.get-anchor-child.ts","../../src/selectors/selector.get-anchor-span.ts","../../src/selectors/selector.get-anchor-text-block.ts","../../src/selectors/selector.get-block-offsets.ts","../../src/selectors/selector.get-next-inline-objects.ts","../../src/selectors/selector.get-previous-inline-objects.ts","../../src/selectors/selector.get-selection.ts","../../src/selectors/selector.get-text-after.ts","../../src/selectors/selector.get-text-before.ts","../../src/selectors/selector.get-value.ts","../../src/utils/util.compare-points.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getEnclosingBlock} from '../node-traversal/get-enclosing-block'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * Returns the block containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorBlock: 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.anchor.path)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getInline} from '../node-traversal/get-inline'\nimport type {ChildPath} from '../types/paths'\n\n/**\n * Returns the child (span or inline object) containing the anchor selection,\n * resolved at any depth.\n *\n * @public\n */\nexport const getAnchorChild: 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.anchor.path)\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getAnchorChild} from './selector.get-anchor-child'\n\n/**\n * Returns the span containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const anchorChild = getAnchorChild(snapshot)\n\n return anchorChild && isSpan(snapshot.context, anchorChild.node)\n ? {node: anchorChild.node, path: anchorChild.path}\n : undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getAnchorBlock} from './selector.get-anchor-block'\n\n/**\n * Returns the text block containing the anchor selection, resolved at any\n * depth.\n *\n * @public\n */\nexport const getAnchorTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const anchorBlock = getAnchorBlock(snapshot)\n\n return anchorBlock && isTextBlock(snapshot.context, anchorBlock.node)\n ? {node: anchorBlock.node, path: anchorBlock.path}\n : undefined\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getBlockOffsets: EditorSelector<\n {start: BlockOffset; end: BlockOffset} | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (!selectionStartPoint || !selectionEndPoint) {\n return undefined\n }\n\n const start = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionStartPoint,\n })\n const end = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionEndPoint,\n })\n\n return start && end ? {start, end} : undefined\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getChildren} from '../node-traversal/get-children'\nimport {isObjectNode} from '../slate/node/is-object-node'\nimport {parentPath} from '../slate/path/parent-path'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * Returns all inline objects after the selection end within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getNextInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionEndPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const endSegment = point.path.at(-1)\n const endKey = isKeyedSegment(endSegment) ? endSegment._key : undefined\n\n if (!endKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n let endFound = false\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === endKey) {\n endFound = true\n continue\n }\n\n if (\n endFound &&\n isObjectNode({schema: snapshot.context.schema}, child.node)\n ) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getChildren} from '../node-traversal/get-children'\nimport {isObjectNode} from '../slate/node/is-object-node'\nimport {parentPath} from '../slate/path/parent-path'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * Returns all inline objects before the selection start within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getPreviousInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionStartPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const startSegment = point.path.at(-1)\n const startKey = isKeyedSegment(startSegment) ? startSegment._key : undefined\n\n if (!startKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === startKey) {\n break\n }\n\n if (isObjectNode({schema: snapshot.context.schema}, child.node)) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport const getSelection: EditorSelector<EditorSelection> = (snapshot) => {\n return snapshot.context.selection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextAfter: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const endOfBlock = getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endOfBlock,\n },\n },\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: startPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n return snapshot.context.value\n}\n","import type {EditorSnapshot} from '../editor/editor-snapshot'\nimport {comparePaths} from '../slate/path/compare-paths'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * Returns:\n *\n * - `-1` if `pointA` is before `pointB`\n * - `0` if `pointA` and `pointB` are equal\n * - `1` if `pointA` is after `pointB`.\n *\n * Compares the two points by document order, resolved at any depth. When\n * the paths are equal, compares offsets.\n */\nexport function comparePoints(\n snapshot: EditorSnapshot,\n pointA: EditorSelectionPoint,\n pointB: EditorSelectionPoint,\n): -1 | 0 | 1 {\n const pathComparison = comparePaths(pointA.path, pointB.path, {\n children: snapshot.context.value,\n })\n\n if (pathComparison !== 0) {\n return pathComparison\n }\n\n if (pointA.offset < pointB.offset) {\n return -1\n }\n\n if (pointA.offset > pointB.offset) {\n return 1\n }\n\n return 0\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {comparePoints} from '../utils/util.compare-points'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, endPoint) === 1\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {comparePoints} from '../utils/util.compare-points'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, startPoint) === -1\n }\n}\n"],"names":["getAnchorBlock","snapshot","selection","context","getEnclosingBlock","anchor","path","getAnchorChild","getInline","getAnchorSpan","anchorChild","isSpan","node","undefined","getAnchorTextBlock","anchorBlock","isTextBlock","getBlockOffsets","selectionStartPoint","getSelectionStartPoint","selectionEndPoint","getSelectionEndPoint","start","spanSelectionPointToBlockOffset","selectionPoint","end","getNextInlineObjects","point","endSegment","at","endKey","isKeyedSegment","_key","children","getChildren","parentPath","inlineObjects","endFound","child","segment","isObjectNode","schema","push","getPreviousInlineObjects","startSegment","startKey","getSelection","getBlockTextAfter","endPoint","block","getFocusTextBlock","focus","endOfBlock","getBlockEndPoint","getSelectionText","getBlockTextBefore","startPoint","startOfBlock","getBlockStartPoint","getValue","value","comparePoints","pointA","pointB","pathComparison","comparePaths","offset","isPointAfterSelection","isPointBeforeSelection"],"mappings":";;;;;;AAUO,MAAMA,iBAERC,CAAAA,aAAa;AAChB,QAAMC,YAAYD,SAASE,QAAQD;AAEnC,MAAKA;AAIL,WAAOE,kBAAkBH,UAAUC,UAAUG,OAAOC,IAAI;AAC1D,GCTaC,iBAMRN,CAAAA,aAAa;AAChB,QAAMC,YAAYD,SAASE,QAAQD;AAEnC,MAAKA;AAIL,WAAOM,UAAUP,UAAUC,UAAUG,OAAOC,IAAI;AAClD,GCfaG,gBAERR,CAAAA,aAAa;AAChB,QAAMS,cAAcH,eAAeN,QAAQ;AAE3C,SAAOS,eAAeC,OAAOV,SAASE,SAASO,YAAYE,IAAI,IAC3D;AAAA,IAACA,MAAMF,YAAYE;AAAAA,IAAMN,MAAMI,YAAYJ;AAAAA,EAAAA,IAC3CO;AACN,GCPaC,qBAERb,CAAAA,aAAa;AAChB,QAAMc,cAAcf,eAAeC,QAAQ;AAE3C,SAAOc,eAAeC,YAAYf,SAASE,SAASY,YAAYH,IAAI,IAChE;AAAA,IAACA,MAAMG,YAAYH;AAAAA,IAAMN,MAAMS,YAAYT;AAAAA,EAAAA,IAC3CO;AACN,GCVaI,kBAERhB,CAAAA,aAAa;AAChB,MAAI,CAACA,SAASE,QAAQD;AACpB;AAGF,QAAMgB,sBAAsBC,uBAAuBlB,QAAQ,GACrDmB,oBAAoBC,qBAAqBpB,QAAQ;AAEvD,MAAI,CAACiB,uBAAuB,CAACE;AAC3B;AAGF,QAAME,QAAQC,gCAAgC;AAAA,IAC5CtB;AAAAA,IACAuB,gBAAgBN;AAAAA,EAAAA,CACjB,GACKO,MAAMF,gCAAgC;AAAA,IAC1CtB;AAAAA,IACAuB,gBAAgBJ;AAAAA,EAAAA,CACjB;AAED,SAAOE,SAASG,MAAM;AAAA,IAAC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AAAA,EACF,CACD;AAED,MAAI,CAACP;AACH,WAAO;AAGT,QAAMQ,eAAeC,mBAAmB;AAAA,IACtCvD,SAASF,SAASE;AAAAA,IAClB8C;AAAAA,EAAAA,CACD;AAED,SAAOK,iBAAiB;AAAA,IAEtBnD,SAAS;AAAA,MACP,GAAGF,SAASE;AAAAA,MACZD,WAAW;AAAA,QACTG,QAAQoD;AAAAA,QACRN,OAAOK;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH,GCvCaG,WACX1D,CAAAA,aAEOA,SAASE,QAAQyD;ACKnB,SAASC,cACd5D,UACA6D,QACAC,QACY;AACZ,QAAMC,iBAAiBC,aAAaH,OAAOxD,MAAMyD,OAAOzD,MAAM;AAAA,IAC5D2B,UAAUhC,SAASE,QAAQyD;AAAAA,EAAAA,CAC5B;AAED,SAAII,mBAAmB,IACdA,iBAGLF,OAAOI,SAASH,OAAOG,SAClB,KAGLJ,OAAOI,SAASH,OAAOG,SAClB,IAGF;AACT;AC5BO,SAASC,sBACdxC,OACyB;AACzB,SAAQ1B,CAAAA,aAAa;AACnB,QAAI,CAACA,SAASE,QAAQD;AACpB,aAAO;AAGT,UAAM8C,WAAW3B,uBAAqBpB,SAASE,QAAQD,SAAS;AAEhE,WAAO2D,cAAc5D,UAAU0B,OAAOqB,QAAQ,MAAM;AAAA,EACtD;AACF;ACZO,SAASoB,uBACdzC,OACyB;AACzB,SAAQ1B,CAAAA,aAAa;AACnB,QAAI,CAACA,SAASE,QAAQD;AACpB,aAAO;AAGT,UAAMsD,aAAarC,yBAAuBlB,SAASE,QAAQD,SAAS;AAEpE,WAAO2D,cAAc5D,UAAU0B,OAAO6B,UAAU,MAAM;AAAA,EACxD;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/selectors/selector.get-anchor-block.ts","../../src/selectors/selector.get-anchor-child.ts","../../src/selectors/selector.get-anchor-span.ts","../../src/selectors/selector.get-anchor-text-block.ts","../../src/selectors/selector.get-block-offsets.ts","../../src/selectors/selector.get-next-inline-objects.ts","../../src/selectors/selector.get-previous-inline-objects.ts","../../src/selectors/selector.get-selection.ts","../../src/selectors/selector.get-text-after.ts","../../src/selectors/selector.get-text-before.ts","../../src/selectors/selector.get-value.ts","../../src/utils/util.compare-points.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getEnclosingBlock} from '../node-traversal/get-enclosing-block'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * Returns the block containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorBlock: 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.anchor.path)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getInline} from '../node-traversal/get-inline'\nimport type {ChildPath} from '../types/paths'\n\n/**\n * Returns the child (span or inline object) containing the anchor selection,\n * resolved at any depth.\n *\n * @public\n */\nexport const getAnchorChild: 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.anchor.path)\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getAnchorChild} from './selector.get-anchor-child'\n\n/**\n * Returns the span containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const anchorChild = getAnchorChild(snapshot)\n\n return anchorChild && isSpan(snapshot.context, anchorChild.node)\n ? {node: anchorChild.node, path: anchorChild.path}\n : undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getAnchorBlock} from './selector.get-anchor-block'\n\n/**\n * Returns the text block containing the anchor selection, resolved at any\n * depth.\n *\n * @public\n */\nexport const getAnchorTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const anchorBlock = getAnchorBlock(snapshot)\n\n return anchorBlock && isTextBlock(snapshot.context, anchorBlock.node)\n ? {node: anchorBlock.node, path: anchorBlock.path}\n : undefined\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getBlockOffsets: EditorSelector<\n {start: BlockOffset; end: BlockOffset} | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (!selectionStartPoint || !selectionEndPoint) {\n return undefined\n }\n\n const start = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionStartPoint,\n })\n const end = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionEndPoint,\n })\n\n return start && end ? {start, end} : undefined\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isObjectNode} from '../engine/node/is-object-node'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../node-traversal/get-children'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * Returns all inline objects after the selection end within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getNextInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionEndPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const endSegment = point.path.at(-1)\n const endKey = isKeyedSegment(endSegment) ? endSegment._key : undefined\n\n if (!endKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n let endFound = false\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === endKey) {\n endFound = true\n continue\n }\n\n if (\n endFound &&\n isObjectNode({schema: snapshot.context.schema}, child.node)\n ) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {isObjectNode} from '../engine/node/is-object-node'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../node-traversal/get-children'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * Returns all inline objects before the selection start within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getPreviousInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionStartPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const startSegment = point.path.at(-1)\n const startKey = isKeyedSegment(startSegment) ? startSegment._key : undefined\n\n if (!startKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === startKey) {\n break\n }\n\n if (isObjectNode({schema: snapshot.context.schema}, child.node)) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport const getSelection: EditorSelector<EditorSelection> = (snapshot) => {\n return snapshot.context.selection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextAfter: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const endOfBlock = getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endOfBlock,\n },\n },\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: startPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n return snapshot.context.value\n}\n","import type {EditorSnapshot} from '../editor/editor-snapshot'\nimport {comparePaths} from '../engine/path/compare-paths'\nimport type {EditorSelectionPoint} from '../types/editor'\n\n/**\n * Returns:\n *\n * - `-1` if `pointA` is before `pointB`\n * - `0` if `pointA` and `pointB` are equal\n * - `1` if `pointA` is after `pointB`.\n *\n * Compares the two points by document order, resolved at any depth. When\n * the paths are equal, compares offsets.\n */\nexport function comparePoints(\n snapshot: EditorSnapshot,\n pointA: EditorSelectionPoint,\n pointB: EditorSelectionPoint,\n): -1 | 0 | 1 {\n const pathComparison = comparePaths(pointA.path, pointB.path, {\n children: snapshot.context.value,\n })\n\n if (pathComparison !== 0) {\n return pathComparison\n }\n\n if (pointA.offset < pointB.offset) {\n return -1\n }\n\n if (pointA.offset > pointB.offset) {\n return 1\n }\n\n return 0\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {comparePoints} from '../utils/util.compare-points'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, endPoint) === 1\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {comparePoints} from '../utils/util.compare-points'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, startPoint) === -1\n }\n}\n"],"names":["getAnchorBlock","snapshot","selection","context","getEnclosingBlock","anchor","path","getAnchorChild","getInline","getAnchorSpan","anchorChild","isSpan","node","undefined","getAnchorTextBlock","anchorBlock","isTextBlock","getBlockOffsets","selectionStartPoint","getSelectionStartPoint","selectionEndPoint","getSelectionEndPoint","start","spanSelectionPointToBlockOffset","selectionPoint","end","getNextInlineObjects","point","endSegment","at","endKey","isKeyedSegment","_key","children","getChildren","parentPath","inlineObjects","endFound","child","segment","isObjectNode","schema","push","getPreviousInlineObjects","startSegment","startKey","getSelection","getBlockTextAfter","endPoint","block","getFocusTextBlock","focus","endOfBlock","getBlockEndPoint","getSelectionText","getBlockTextBefore","startPoint","startOfBlock","getBlockStartPoint","getValue","value","comparePoints","pointA","pointB","pathComparison","comparePaths","offset","isPointAfterSelection","isPointBeforeSelection"],"mappings":";;;;;;AAUO,MAAMA,iBAERC,CAAAA,aAAa;AAChB,QAAMC,YAAYD,SAASE,QAAQD;AAEnC,MAAKA;AAIL,WAAOE,kBAAkBH,UAAUC,UAAUG,OAAOC,IAAI;AAC1D,GCTaC,iBAMRN,CAAAA,aAAa;AAChB,QAAMC,YAAYD,SAASE,QAAQD;AAEnC,MAAKA;AAIL,WAAOM,UAAUP,UAAUC,UAAUG,OAAOC,IAAI;AAClD,GCfaG,gBAERR,CAAAA,aAAa;AAChB,QAAMS,cAAcH,eAAeN,QAAQ;AAE3C,SAAOS,eAAeC,OAAOV,SAASE,SAASO,YAAYE,IAAI,IAC3D;AAAA,IAACA,MAAMF,YAAYE;AAAAA,IAAMN,MAAMI,YAAYJ;AAAAA,EAAAA,IAC3CO;AACN,GCPaC,qBAERb,CAAAA,aAAa;AAChB,QAAMc,cAAcf,eAAeC,QAAQ;AAE3C,SAAOc,eAAeC,YAAYf,SAASE,SAASY,YAAYH,IAAI,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SAASE,QAAQD,SAAS;AAEhE,WAAO2D,cAAc5D,UAAU0B,OAAOqB,QAAQ,MAAM;AAAA,EACtD;AACF;ACZO,SAASoB,uBACdzC,OACyB;AACzB,SAAQ1B,CAAAA,aAAa;AACnB,QAAI,CAACA,SAASE,QAAQD;AACpB,aAAO;AAGT,UAAMsD,aAAarC,yBAAuBlB,SAASE,QAAQD,SAAS;AAEpE,WAAO2D,cAAc5D,UAAU0B,OAAO6B,UAAU,MAAM;AAAA,EACxD;AACF;"}
@@ -1,5 +1,5 @@
1
- import { getChildren } from "../_chunks-es/get-ancestor.js";
2
- import { getAncestor, getAncestors, getNode } from "../_chunks-es/get-ancestor.js";
1
+ import { getChildren } from "../_chunks-es/get-node.js";
2
+ import { getAncestor, getAncestors, getNode } from "../_chunks-es/get-node.js";
3
3
  import { getBlock, getEnclosingBlock, getParent, getPathSubSchema, getSibling, hasNode, isBlock, isInline } from "../_chunks-es/get-path-sub-schema.js";
4
4
  import { getFirstChild, getLeaf, getSpanNode, getText, getTextBlockNode, getUnionSchema, isLeaf } from "../_chunks-es/get-first-child.js";
5
5
  function getLastChild(snapshot, path) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/node-traversal/get-last-child.ts"],"sourcesContent":["import type {Node} from '../slate/interfaces/node'\nimport type {Path} from '../slate/interfaces/path'\nimport {getChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the last child of a node at a given path.\n *\n * @beta\n */\nexport function getLastChild(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n const children = getChildren(snapshot, path)\n\n return children.at(-1)\n}\n"],"names":["getLastChild","snapshot","path","getChildren","at"],"mappings":";;;;AAUO,SAASA,aACdC,UACAC,MACsC;AAGtC,SAFiBC,YAAYF,UAAUC,IAAI,EAE3BE,GAAG,EAAE;AACvB;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/node-traversal/get-last-child.ts"],"sourcesContent":["import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {getChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the last child of a node at a given path.\n *\n * @beta\n */\nexport function getLastChild(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n const children = getChildren(snapshot, path)\n\n return children.at(-1)\n}\n"],"names":["getLastChild","snapshot","path","getChildren","at"],"mappings":";;;;AAUO,SAASA,aACdC,UACAC,MACsC;AAGtC,SAFiBC,YAAYF,UAAUC,IAAI,EAE3BE,GAAG,EAAE;AACvB;"}
@@ -1,6 +1,6 @@
1
1
  import { blockOffsetToSpanSelectionPoint, getAncestorTextBlock, isEqualSelectionPoints, parseBlock } from "../_chunks-es/util.slice-blocks.js";
2
2
  import { getBlockEndPoint, getBlockStartPoint, getSelectionEndPoint, getSelectionStartPoint, isEqualPaths, isSelectionCollapsed, sliceBlocks, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
3
- import { getNode, isKeyedSegment } from "../_chunks-es/get-ancestor.js";
3
+ import { getNode, isKeyedSegment } from "../_chunks-es/get-node.js";
4
4
  import { isSpan, isTextBlock } from "@portabletext/schema";
5
5
  import { isSpan as isSpan2, isTextBlock as isTextBlock2 } from "@portabletext/schema";
6
6
  import { getTextBlockText, isEmptyTextBlock } from "../_chunks-es/util.is-empty-text-block.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "7.0.2",
3
+ "version": "7.0.4",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -50,7 +50,7 @@
50
50
  "xstate": "^5.31.1",
51
51
  "@portabletext/html": "^1.0.2",
52
52
  "@portabletext/keyboard-shortcuts": "^2.1.2",
53
- "@portabletext/markdown": "^1.3.1",
53
+ "@portabletext/markdown": "^1.3.2",
54
54
  "@portabletext/patches": "^2.0.4",
55
55
  "@portabletext/schema": "^2.2.0"
56
56
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-ancestor.js","sources":["../../src/utils/asserters.ts","../../src/slate/node/is-object-node.ts","../../src/utils/util.is-keyed-segment.ts","../../src/node-traversal/get-children.ts","../../src/node-traversal/get-node.ts","../../src/node-traversal/get-ancestors.ts","../../src/node-traversal/get-ancestor.ts"],"sourcesContent":["import type {TypedObject} from '@portabletext/schema'\n\nexport function isTypedObject(object: unknown): object is TypedObject {\n return isRecord(object) && typeof object['_type'] === 'string'\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && (typeof value === 'object' || typeof value === 'function')\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSchema} from '../../editor/editor-schema'\nimport {isTypedObject} from '../../utils/asserters'\n\nexport function isObjectNode(\n context: {schema: EditorSchema},\n node: unknown,\n): node is PortableTextObject {\n return (\n isTypedObject(node) &&\n node._type !== context.schema.block.name &&\n node._type !== context.schema.span.name\n )\n}\n","import type {KeyedSegment} from '../types/paths'\n\n/**\n * @public\n */\nexport function isKeyedSegment(segment: unknown): segment is KeyedSegment {\n return typeof segment === 'object' && segment !== null && '_key' in segment\n}\n","import {isTextBlock} from '@portabletext/schema'\nimport type {EditorSchema} from '../editor/editor-schema'\nimport type {\n Containers,\n RegisteredContainer,\n} from '../schema/resolve-containers'\nimport type {Node} from '../slate/interfaces/node'\nimport type {Path} from '../slate/interfaces/path'\nimport {isObjectNode} from '../slate/node/is-object-node'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the children of a node at a given path.\n *\n * @beta\n */\nexport function getChildren(\n snapshot: TraversalSnapshot,\n path: Path,\n): Array<{node: Node; path: Path}> {\n let currentChildren: Array<Node> = snapshot.context.value\n let currentFieldName = 'value'\n let currentPath: Path = []\n let isRoot = true\n let currentParent: RegisteredContainer | undefined\n\n for (const segment of path) {\n if (typeof segment === 'string') {\n continue\n }\n\n let node: Node | undefined\n if (isKeyedSegment(segment)) {\n node = currentChildren.find((child) => child._key === segment._key)\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n }\n\n if (!node) {\n return []\n }\n\n currentPath = isRoot\n ? [{_key: node._key}]\n : [...currentPath, currentFieldName, {_key: node._key}]\n isRoot = false\n\n const next = getNodeChildren(snapshot.context, node, currentParent)\n\n if (!next) {\n return []\n }\n\n currentChildren = next.children\n currentFieldName = next.fieldName\n currentParent = next.parent\n }\n\n return currentChildren.map((child) => ({\n node: child,\n path: isRoot\n ? [{_key: child._key}]\n : [...currentPath, currentFieldName, {_key: child._key}],\n }))\n}\n\n/**\n * Resolve a node's editable child array.\n *\n * When `parent` is provided and its `of` declares a positional entry\n * matching `node._type`, that positional entry's `field` is used.\n * Otherwise the top-level `containers.get(node._type)` provides the\n * fallback.\n *\n * The returned `parent` is the resolved container entry for `node`\n * itself (used by the caller to thread further descent).\n *\n * @beta\n */\nexport function getNodeChildren(\n context: {\n schema: EditorSchema\n containers: Containers\n },\n node: Node | {value: Array<Node>},\n parent?: RegisteredContainer,\n):\n | {\n children: Array<Node>\n fieldName: string\n parent: RegisteredContainer | undefined\n }\n | undefined {\n // Text blocks store children in .children\n if (isTextBlock(context, node)) {\n return {\n children: node.children,\n fieldName: 'children',\n parent: undefined,\n }\n }\n\n if (isObjectNode(context, node)) {\n const resolved = resolveNodeContainer(context.containers, parent, node)\n\n if (!resolved) {\n return undefined\n }\n\n const fieldValue = (node as Record<string, unknown>)[resolved.field.name]\n\n if (!Array.isArray(fieldValue)) {\n return undefined\n }\n\n return {\n children: fieldValue as Array<Node>,\n fieldName: resolved.field.name,\n parent: resolved,\n }\n }\n\n // Root context: has .value array but no _key or _type\n if (\n 'value' in node &&\n Array.isArray(node['value']) &&\n !('_key' in node) &&\n !('_type' in node)\n ) {\n return {\n children: node['value'] as Array<Node>,\n fieldName: 'value',\n parent: undefined,\n }\n }\n\n return undefined\n}\n\n/**\n * Pick the positional override from `parent.of` if present; fall back\n * to the top-level entry. Returns only `RegisteredContainer` entries\n * since leaves do not have editable children.\n */\nfunction resolveNodeContainer(\n containers: Containers,\n parent: RegisteredContainer | undefined,\n node: Node,\n): RegisteredContainer | undefined {\n if (parent?.of) {\n for (const entry of parent.of) {\n if (entry.type === node._type) {\n // Only return container entries; leaves have no editable children.\n if ('field' in entry) {\n return entry\n }\n return undefined\n }\n }\n }\n return containers.get(node._type)\n}\n","import type {Node} from '../slate/interfaces/node'\nimport type {Path} from '../slate/interfaces/path'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getNodeChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the node at a given path.\n *\n * The path can be either keyed (KeyedSegment + field name strings) or\n * indexed (numbers). Keyed segments are resolved by matching `_key`,\n * field name strings are skipped (they're structural), and numbers\n * are resolved by index.\n *\n * The returned path is always fully keyed, even if the input path\n * contained numeric indices.\n *\n * @beta\n */\nexport function getNode(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n if (path.length === 0) {\n return undefined\n }\n\n const {context, blockIndexMap} = snapshot\n let currentChildren: Array<Node> = context.value\n let node: Node | undefined\n let currentParent:\n | import('../schema/resolve-containers').RegisteredContainer\n | undefined\n const resolvedPath: Path = []\n let isRootLevel = true\n\n for (let i = 0; i < path.length; i++) {\n const segment = path[i]\n\n if (typeof segment === 'string') {\n resolvedPath.push(segment)\n continue\n }\n\n if (isKeyedSegment(segment)) {\n if (isRootLevel && blockIndexMap.size === currentChildren.length) {\n const index = blockIndexMap.get(segment._key)\n if (index !== undefined) {\n const candidate = currentChildren[index]\n if (candidate && candidate._key === segment._key) {\n node = candidate\n } else {\n node = currentChildren.find((child) => child._key === segment._key)\n }\n } else {\n node = currentChildren.find((child) => child._key === segment._key)\n }\n } else {\n node = currentChildren.find((child) => child._key === segment._key)\n }\n resolvedPath.push(segment)\n isRootLevel = false\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push({_key: node._key})\n }\n } else {\n return undefined\n }\n\n if (!node) {\n return undefined\n }\n\n let hasMoreSegments = false\n for (let j = i + 1; j < path.length; j++) {\n const s = path[j]\n if (isKeyedSegment(s) || typeof s === 'number') {\n hasMoreSegments = true\n break\n }\n }\n\n if (hasMoreSegments) {\n const next = getNodeChildren(context, node, currentParent)\n\n if (!next) {\n return undefined\n }\n\n currentChildren = next.children\n currentParent = next.parent\n }\n }\n\n if (!node) {\n return undefined\n }\n\n return {node, path: resolvedPath}\n}\n","import type {Node} from '../slate/interfaces/node'\nimport type {Path} from '../slate/interfaces/path'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getNodeChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get all ancestors of the node at a given path, from nearest to furthest.\n *\n * For a path like [{_key:'t1'}, 'rows', {_key:'r1'}, 'cells', {_key:'c1'}],\n * the ancestors are (nearest first):\n * [{_key:'t1'}, 'rows', {_key:'r1'}]\n * [{_key:'t1'}]\n *\n * Walks from root to the target in a single pass collecting each ancestor\n * as it goes.\n *\n * @beta\n */\nexport function getAncestors(\n snapshot: TraversalSnapshot,\n path: Path,\n): Array<{node: Node; path: Path}> {\n // Collect keyed-segment indices to know where each ancestor's path ends.\n const keyedIndices: Array<number> = []\n for (let i = 0; i < path.length; i++) {\n if (isKeyedSegment(path[i])) {\n keyedIndices.push(i)\n }\n }\n\n // Need at least 2 keyed segments to have an ancestor (the last is self).\n if (keyedIndices.length <= 1) {\n return []\n }\n\n const {context, blockIndexMap} = snapshot\n let currentChildren: Array<Node> = context.value\n let isRootLevel = true\n let currentParent:\n | import('../schema/resolve-containers').RegisteredContainer\n | undefined\n\n const ancestorsByDepth: Array<{node: Node; path: Path}> = []\n const resolvedPath: Path = []\n\n // Descend once. We walk only as far as the second-to-last keyed segment;\n // the last keyed segment is the target itself, which is not an ancestor.\n const targetKeyedIndex = keyedIndices[keyedIndices.length - 1]!\n\n let segmentIndex = 0\n while (segmentIndex < targetKeyedIndex) {\n const segment = path[segmentIndex]!\n\n if (typeof segment === 'string') {\n resolvedPath.push(segment)\n segmentIndex++\n continue\n }\n\n let node: Node | undefined\n if (isKeyedSegment(segment)) {\n // Production snapshots maintain `blockIndexMap` in lockstep with\n // `context.value` so this fast path always fires. Some test\n // fixtures still pass empty or stale maps, which is the debt this\n // size check is working around - see /specs/snapshot-invariants.md.\n // When the fixtures are aligned, drop the guard and use the map\n // directly.\n if (isRootLevel && blockIndexMap.size === currentChildren.length) {\n const index = blockIndexMap.get(segment._key)\n node =\n index !== undefined\n ? currentChildren[index]\n : currentChildren.find((child) => child._key === segment._key)\n } else {\n node = currentChildren.find((child) => child._key === segment._key)\n }\n resolvedPath.push(segment)\n isRootLevel = false\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push({_key: node._key})\n }\n } else {\n return []\n }\n\n if (!node) {\n return []\n }\n\n // Descend with positional awareness. `getNodeChildren` checks the\n // current parent's `of` for a positional override before falling\n // back to the top-level `containers` map - so same-`_type`\n // registered under different parents with different `field`\n // resolves to the right entry at this position.\n const next = getNodeChildren(context, node, currentParent)\n if (!next) {\n return []\n }\n\n ancestorsByDepth.push({\n node,\n path: resolvedPath.slice(),\n })\n\n currentChildren = next.children\n currentParent = next.parent\n segmentIndex++\n }\n\n // Return nearest-first (reverse of document order at the call site).\n return ancestorsByDepth.reverse()\n}\n","import type {Node} from '../slate/interfaces/node'\nimport type {Path} from '../slate/interfaces/path'\nimport {getAncestors} from './get-ancestors'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Find the first ancestor of the node at a given path that matches a predicate.\n * Does not check the node at the path itself, only its ancestors.\n *\n * When `match` is a type predicate, the returned `node` narrows to that type.\n *\n * @beta\n */\nexport function getAncestor<TMatch extends Node>(\n snapshot: TraversalSnapshot,\n path: Path,\n match: (node: Node, path: Path) => node is TMatch,\n): {node: TMatch; path: Path} | undefined\n/**\n * @beta\n */\nexport function getAncestor(\n snapshot: TraversalSnapshot,\n path: Path,\n match: (node: Node, path: Path) => boolean,\n): {node: Node; path: Path} | undefined\nexport function getAncestor(\n snapshot: TraversalSnapshot,\n path: Path,\n match: (node: Node, path: Path) => boolean,\n): {node: Node; path: Path} | undefined {\n const ancestors = getAncestors(snapshot, path)\n\n for (const ancestor of ancestors) {\n if (match(ancestor.node, ancestor.path)) {\n return ancestor\n }\n }\n\n return undefined\n}\n"],"names":["isTypedObject","object","isRecord","value","isObjectNode","context","node","_type","schema","block","name","span","isKeyedSegment","segment","getChildren","snapshot","path","currentChildren","currentFieldName","currentPath","isRoot","currentParent","find","child","_key","at","next","getNodeChildren","children","fieldName","parent","map","isTextBlock","undefined","resolved","resolveNodeContainer","containers","fieldValue","field","Array","isArray","of","entry","type","get","getNode","length","blockIndexMap","resolvedPath","isRootLevel","i","push","size","index","candidate","hasMoreSegments","j","s","getAncestors","keyedIndices","ancestorsByDepth","targetKeyedIndex","segmentIndex","slice","reverse","getAncestor","match","ancestors","ancestor"],"mappings":";AAEO,SAASA,cAAcC,QAAwC;AACpE,SAAOC,SAASD,MAAM,KAAK,OAAOA,OAAO,SAAa;AACxD;AAEO,SAASC,SAASC,OAAkD;AACzE,SAAO,CAAC,CAACA,UAAU,OAAOA,SAAU,YAAY,OAAOA,SAAU;AACnE;ACJO,SAASC,aACdC,SACAC,MAC4B;AAC5B,SACEN,cAAcM,IAAI,KAClBA,KAAKC,UAAUF,QAAQG,OAAOC,MAAMC,QACpCJ,KAAKC,UAAUF,QAAQG,OAAOG,KAAKD;AAEvC;ACRO,SAASE,eAAeC,SAA2C;AACxE,SAAO,OAAOA,WAAY,YAAYA,YAAY,QAAQ,UAAUA;AACtE;ACUO,SAASC,YACdC,UACAC,MACiC;AACjC,MAAIC,kBAA+BF,SAASV,QAAQF,OAChDe,mBAAmB,SACnBC,cAAoB,CAAA,GACpBC,SAAS,IACTC;AAEJ,aAAWR,WAAWG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