@portabletext/editor 8.1.1 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +3 -3
  2. package/lib/{behavior.types.action-C0XDEQnB.d.ts → behavior.types.action-DbwK30_J.d.ts} +52 -25
  3. package/lib/behavior.types.action-DbwK30_J.d.ts.map +1 -0
  4. package/lib/behaviors/index.d.ts +1 -1
  5. package/lib/{get-container-D2pN5Npr.js → get-container-CXdmRdiX.js} +3 -3
  6. package/lib/{get-container-D2pN5Npr.js.map → get-container-CXdmRdiX.js.map} +1 -1
  7. package/lib/{get-parent-DgaKcy8-.js → get-parent-BLzi7eLr.js} +39 -14
  8. package/lib/get-parent-BLzi7eLr.js.map +1 -0
  9. package/lib/{get-path-sub-schema-Dd0QYZ0m.js → get-path-sub-schema-DsN1qF_l.js} +9 -5
  10. package/lib/get-path-sub-schema-DsN1qF_l.js.map +1 -0
  11. package/lib/index.d.ts +1 -1
  12. package/lib/index.js +421 -396
  13. package/lib/index.js.map +1 -1
  14. package/lib/plugins/index.d.ts +1 -1
  15. package/lib/{selector.is-selecting-entire-blocks-BFhnnkHf.js → selector.is-selecting-entire-blocks-BHVYIXbI.js} +8 -5
  16. package/lib/selector.is-selecting-entire-blocks-BHVYIXbI.js.map +1 -0
  17. package/lib/selectors/index.d.ts +1 -1
  18. package/lib/selectors/index.js +4 -4
  19. package/lib/traversal/index.d.ts +9 -6
  20. package/lib/traversal/index.d.ts.map +1 -1
  21. package/lib/traversal/index.js +3 -3
  22. package/lib/{util.is-equal-selections-BdK98okY.js → util.is-equal-selections-sCQib0IC.js} +2 -2
  23. package/lib/{util.is-equal-selections-BdK98okY.js.map → util.is-equal-selections-sCQib0IC.js.map} +1 -1
  24. package/lib/{util.slice-blocks-_ElaB53f.js → util.slice-blocks-B-iKFEG7.js} +43 -56
  25. package/lib/util.slice-blocks-B-iKFEG7.js.map +1 -0
  26. package/lib/utils/index.d.ts +1 -1
  27. package/lib/utils/index.js +4 -8
  28. package/lib/utils/index.js.map +1 -1
  29. package/package.json +2 -3
  30. package/lib/behavior.types.action-C0XDEQnB.d.ts.map +0 -1
  31. package/lib/get-parent-DgaKcy8-.js.map +0 -1
  32. package/lib/get-path-sub-schema-Dd0QYZ0m.js.map +0 -1
  33. package/lib/selector.is-selecting-entire-blocks-BFhnnkHf.js.map +0 -1
  34. package/lib/util.slice-blocks-_ElaB53f.js.map +0 -1
package/README.md CHANGED
@@ -13,14 +13,14 @@
13
13
 
14
14
  This library provides you with the building blocks to create a completely custom editor experience built on top of Portable Text. We recommend [checking out the official documentation](https://www.portabletext.org/). The following guide includes the basics to get your started.
15
15
 
16
- In order to set up an editor you'll need to:
16
+ To set up an editor you need to:
17
17
 
18
18
  - Create a schema that defines the rich text and block content elements.
19
19
  - Create a toolbar to toggle and insert these elements.
20
20
  - Set up rendering for each element type in the editor, including text blocks and inline formatting.
21
21
  - Render the editor.
22
22
 
23
- Check out the [Portable Text Playground](../../apps/playground/) for a comprehensive example of the editor in action.
23
+ The [Portable Text Playground](../../apps/playground/) is a complete editor built with this library. Use it as a reference.
24
24
 
25
25
  ### Add the library to your project
26
26
 
@@ -361,7 +361,7 @@ Extend the editor with [official plugins](../../#editor-plugins).
361
361
 
362
362
  ## End-user experience
363
363
 
364
- In order to provide a robust and consistent end-user experience, the editor is backed by an elaborate E2E test suite generated from a [human-readable Gherkin spec](./gherkin-spec/).
364
+ A large E2E test suite, generated from a [human-readable Gherkin spec](./gherkin-spec/), guards the end-user experience: how selection, editing, and formatting behave under real keyboard and pointer input.
365
365
 
366
366
  ## Development
367
367
 
@@ -1417,6 +1417,10 @@ type InvalidValueResolution = {
1417
1417
  };
1418
1418
  /** @beta */
1419
1419
  type OnPasteResult = {
1420
+ /**
1421
+ * Delivered as-is to the `insert.blocks` Behavior event and validated
1422
+ * against the schema when inserted.
1423
+ */
1420
1424
  insert?: TypedObject[];
1421
1425
  path?: Path;
1422
1426
  } | undefined;
@@ -1639,6 +1643,10 @@ type SetSelectionOperation = {
1639
1643
  * @beta
1640
1644
  */
1641
1645
  type EngineOperation = InsertOperation | SetOperation | UnsetOperation | SetSelectionOperation | InsertTextOperation | RemoveTextOperation;
1646
+ type DecoratedRange = Range & {
1647
+ rangeDecoration: RangeDecoration;
1648
+ merge: (leaf: PortableTextSpan, decoration: object) => void;
1649
+ };
1642
1650
  /**
1643
1651
  * `RangeRef` objects keep a specific range in a document synced over time as new
1644
1652
  * operations are applied to the editor. You can access their `current` property
@@ -1892,22 +1900,36 @@ type OperationEvent = {
1892
1900
  * entry.
1893
1901
  */
1894
1902
  operationsInProgress: boolean;
1895
- isNormalizingNode: boolean;
1896
1903
  isPatching: boolean;
1897
- isProcessingRemoteChanges: boolean;
1898
- isUndoing: boolean;
1899
- isRedoing: boolean;
1900
1904
  withHistory: boolean;
1901
1905
  undoStepId: string | undefined;
1902
1906
  /**
1903
- * Derived from the engine flags above, for declarative filtering.
1907
+ * Derived from `applyContext`, for declarative filtering.
1904
1908
  */
1905
1909
  origin: OperationOrigin;
1910
+ /**
1911
+ * A frozen snapshot of `editor.applyContext` at apply entry: the frame
1912
+ * stack `origin` was derived from.
1913
+ */
1914
+ context: ReadonlyArray<ApplyContextFrame>;
1906
1915
  };
1907
1916
  type OperationListener = (event: OperationEvent) => void;
1908
- type DecoratedRange = Range & {
1909
- rangeDecoration: RangeDecoration;
1910
- merge: (leaf: PortableTextSpan, decoration: object) => void;
1917
+ /**
1918
+ * A frame pushed onto `editor.applyContext` for the duration of an
1919
+ * attribution bracket (remote changes, undo, redo, normalization). Brackets
1920
+ * nest, so a normalization that fires while replaying a remote patch pushes
1921
+ * a `normalization` frame on top of the still-active `remote` one; both
1922
+ * stay visible to `getOrigin` below instead of only the innermost.
1923
+ */
1924
+ type ApplyContextFrame = {
1925
+ kind: 'remote';
1926
+ source: 'patches' | 'update-value' | 'initial-sync';
1927
+ } | {
1928
+ kind: 'undo';
1929
+ } | {
1930
+ kind: 'redo';
1931
+ } | {
1932
+ kind: 'normalization';
1911
1933
  };
1912
1934
  type HistoryItem = {
1913
1935
  operations: EngineOperation[];
@@ -1926,6 +1948,13 @@ type RemotePatch = {
1926
1948
  interface PortableTextEditorEngine extends DOMEditor {
1927
1949
  _key: 'editor';
1928
1950
  _type: 'editor';
1951
+ /**
1952
+ * The attribution bracket stack: pushed on entry and popped in `finally`
1953
+ * by `withRemoteChanges`, `pluginUndoing`, `pluginRedoing`, and the
1954
+ * normalization brackets. `getOrigin` (`engine/core/apply-context.ts`)
1955
+ * reduces it to an `OperationOrigin`.
1956
+ */
1957
+ applyContext: Array<ApplyContextFrame>;
1929
1958
  containers: ResolvedContainers;
1930
1959
  annotations: Map<string, AnnotationConfig>;
1931
1960
  blockObjects: Map<string, BlockObjectConfig>;
@@ -1963,26 +1992,24 @@ interface PortableTextEditorEngine extends DOMEditor {
1963
1992
  undoStepId: string | undefined;
1964
1993
  isDeferringMutations: boolean;
1965
1994
  /**
1966
- * The last host value written in by value sync. A pristine block equal
1967
- * to it is persisted content, not the local placeholder.
1995
+ * The last host value recorded by a value sync that changed the engine. A
1996
+ * pristine block equal to it is persisted content, not the local
1997
+ * placeholder. Syncs that write nothing are not recorded: hosts mirror
1998
+ * `mutation.value` back as `update value`, and such an echo of the
1999
+ * editor's own state (its placeholder included) is not a claim that the
2000
+ * value is persisted.
1968
2001
  */
1969
2002
  lastSyncedValue: Array<PortableTextBlock> | undefined;
1970
- isNormalizingNode: boolean;
1971
- isPatching: boolean;
1972
- isPerformingBehaviorOperation: boolean;
1973
2003
  /**
1974
- * True while the editor applies content that arrived from outside:
1975
- * remote `patches` and value sync.
1976
- *
1977
- * Normalization reads this flag to leave adopted content alone. While
1978
- * it is set, only repairs of invalid structure run (missing `_key` or
1979
- * `text`, empty blocks). Optional fix-ups (merging same-mark spans,
1980
- * filling in `style`/`marks`/`markDefs` defaults) wait until a local
1981
- * edit touches the block and then emit as part of that edit.
2004
+ * True after patch generation emits a became-empty `unset([])`, until it
2005
+ * emits the field's rebuild (`setIfMissing` plus the block `insert`).
2006
+ * While true, the emitted stream has destroyed the field, so the next
2007
+ * content-producing local edit must re-materialize it even if a synced
2008
+ * value makes the placeholder look persisted.
1982
2009
  */
1983
- isProcessingRemoteChanges: boolean;
1984
- isRedoing: boolean;
1985
- isUndoing: boolean;
2010
+ valueUnsetEmitted: boolean;
2011
+ isPatching: boolean;
2012
+ isPerformingBehaviorOperation: boolean;
1986
2013
  withHistory: boolean;
1987
2014
  /**
1988
2015
  * The current {@link EditorSnapshot}. Reassigned (new object reference)
@@ -3412,4 +3439,4 @@ type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
3412
3439
  dom: EditorDom;
3413
3440
  }, guardResponse: TGuardResponse) => Array<BehaviorAction>;
3414
3441
  export { BehaviorGuard as $, defineBlockObject as $t, PortableTextSpan$1 as A, Annotation as At, usePortableTextEditor as B, DecoratorRender as Bt, ListDefinition as C, EditorSchema as Ct, PortableTextBlock$1 as D, RegisteredInlineObject as Dt, Patch$1 as E, RegisteredContainer as Et, defineSchema as F, BlockObjectRenderProps as Ft, Editor as G, RegistrableNode as Gt, useEditorSelector as H, InlineObject as Ht, BlockOffset as I, Container as It, EditorEmittedEvent as J, SpanRenderProps as Jt, EditorConfig as K, Span as Kt, useEditor as L, ContainerRender as Lt, SchemaDefinition$1 as M, AnnotationRenderProps as Mt, StyleDefinition as N, BlockObject as Nt, PortableTextChild$1 as O, RegisteredPositional as Ot, StyleSchemaType as P, BlockObjectRender as Pt, defineBehavior as Q, defineAnnotation as Qt, defaultKeyGenerator as R, ContainerRenderProps as Rt, InlineObjectSchemaType as S, Node$1 as St, OfDefinition$1 as T, RegisteredBlockObject as Tt, EditorProvider as U, InlineObjectRender as Ut, EditorSelector as V, DecoratorRenderProps as Vt, EditorProviderProps as W, InlineObjectRenderProps as Wt, Operation as X, TextBlockRender as Xt, MutationEvent as Y, TextBlock as Yt, Behavior as Z, TextBlockRenderProps as Zt, BlockObjectSchemaType as _, PortableTextEditable as _t, forward as a, AnnotationPath as an, EditorSelectionPoint as at, FieldDefinition$1 as b, PortableTextEditor as bt, CustomBehaviorEvent as c, KeyedSegment as cn, OnPasteFn as ct, SyntheticBehaviorEvent as d, PasteData as dt, defineContainer as en, EditorContext as et, PatchesEvent as f, RangeDecoration as ft, BlockObjectDefinition as g, ScrollSelectionIntoViewFunction as gt, BaseDefinition as h, RenderPlaceholderFunction as ht, execute as i, defineTextBlock as in, EditorSelection as it, PortableTextTextBlock$1 as j, AnnotationRender as jt, PortableTextObject$1 as k, RegisteredSpan as kt, InsertPlacement as l, Path as ln, OnPasteResult as lt, AnnotationSchemaType as m, RenderEditableFunction as mt, BehaviorActionSet as n, defineInlineObject as nn, AddedAnnotationPaths as nt, raise$1 as o, BlockPath as on, InvalidValueResolution as ot, AnnotationDefinition as p, RangeDecorationOnMovedDetails as pt, EditorEvent as q, SpanRender as qt, effect as r, defineSpan as rn, EditableAPIDeleteOptions as rt, BehaviorEvent as s, ChildPath as sn, OnCopyFn as st, BehaviorAction as t, defineDecorator as tn, EditorSnapshot as tt, NativeBehaviorEvent as u, PathSegment as un, OnPasteResultOrPromise as ut, DecoratorDefinition as v, PortableTextEditableProps as vt, ListSchemaType as w, Containers as wt, InlineObjectDefinition as x, TraversalSnapshot as xt, DecoratorSchemaType as y, HotkeyOptions as yt, usePortableTextEditorSelection as z, Decorator as zt };
3415
- //# sourceMappingURL=behavior.types.action-C0XDEQnB.d.ts.map
3442
+ //# sourceMappingURL=behavior.types.action-DbwK30_J.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behavior.types.action-DbwK30_J.d.ts","names":[],"sources":["../src/internal-utils/mime-type.ts","../src/type-utils.ts","../src/converters/converter.types.ts","../src/types/paths.ts","../src/renderers/renderer.types.ts","../src/schema/container-types.ts","../src/editor/editor-schema.ts","../src/engine/interfaces/node.ts","../src/traversal/traversal-snapshot.ts","../src/editor/PortableTextEditor.tsx","../src/types/options.ts","../src/editor/Editable.tsx","../src/types/editor.ts","../src/engine/types/types.ts","../src/engine/interfaces/point.ts","../src/engine/interfaces/range.ts","../src/engine/interfaces/operation.ts","../src/editor/range-decorations-machine.ts","../src/engine/interfaces/range-ref.ts","../src/engine/dom/utils/diff-text.ts","../src/engine/dom/utils/dom.ts","../src/engine/dom/plugin/dom-editor.ts","../src/engine/interfaces/location.ts","../src/engine/interfaces/path-ref.ts","../src/engine/interfaces/point-ref.ts","../src/engine/interfaces/editor.ts","../src/engine/core/operation-channel.ts","../src/engine/core/apply-context.ts","../src/types/editor-engine.ts","../src/editor/editor-snapshot.ts","../src/behaviors/behavior.types.guard.ts","../src/behaviors/behavior.types.behavior.ts","../src/types/operation.ts","../src/editor/relay.ts","../src/editor.ts","../src/editor/editor-provider.tsx","../src/editor/editor-selector.ts","../src/editor/usePortableTextEditor.ts","../src/editor/usePortableTextEditorSelection.tsx","../src/utils/key-generator.ts","../src/editor/use-editor.ts","../src/types/block-offset.ts","../src/priority/priority.types.ts","../src/behaviors/behavior.config.ts","../src/editor/editor-machine.ts","../src/internal-utils/event-position.ts","../src/types/block-with-optional-key.ts","../src/behaviors/behavior.types.event.ts","../src/editor/editor-dom.ts","../src/behaviors/behavior.types.action.ts"],"mappings":";;;;KAAY;;;;KCGA,cACV,QACA,sBAAsB,QACtB,oBAAoB,OAAO,YACzB,eAAe,OAAO,SAAS,eAAe;KAWtC,eAAe,QAAQ,6BAA6B;EAC9D,YAAY;OAGP,WAAW,SAAS,sBACd,cAAc,wBACjB,OAAO;KAIL,cAAc,GAAG,UAAU,KAAK;KCvBhC,UAAU,kBAAkB,WAAW;EACjD,UAAU;EACV,WAAW,WAAW;EACtB,aAAa,aAAa;;KASvB,eAAe,kBAAkB,WAAW;EAE3C;EACA;;EAGA;EACA,UAAU;EACV;EACA;;EAGA;EACA;EACA,UAAU;EACV;;EAGA;EACA;;EAGA;EACA,UAAU;EACV;;EAGA;EACA,MAAM,MAAM;EACZ,UAAU;;KAGJ,WAAW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;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCD,QACd,OAAO,yBAAyB,sBAC/B,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CD,OACd,QAAQ,cAAc,8CACrB,cAAc;;;;KAOL,kBAAkB,gBAAgB,mBAC5C;EACE,UAAU;EACV,OAAO;EACP,KAAK;GAEP,eAAe,mBACZ,MAAM"}
@@ -1,2 +1,2 @@
1
- import { $ as BehaviorGuard, Q as defineBehavior, Z as Behavior, a as forward, c as CustomBehaviorEvent, d as SyntheticBehaviorEvent, i as execute, l as InsertPlacement, n as BehaviorActionSet, o as raise, r as effect, s as BehaviorEvent, t as BehaviorAction, u as NativeBehaviorEvent } from "../behavior.types.action-C0XDEQnB.js";
1
+ import { $ as BehaviorGuard, Q as defineBehavior, Z as Behavior, a as forward, c as CustomBehaviorEvent, d as SyntheticBehaviorEvent, i as execute, l as InsertPlacement, n as BehaviorActionSet, o as raise, r as effect, s as BehaviorEvent, t as BehaviorAction, u as NativeBehaviorEvent } from "../behavior.types.action-DbwK30_J.js";
2
2
  export { type Behavior, type BehaviorAction, type BehaviorActionSet, type BehaviorEvent, type BehaviorGuard, type CustomBehaviorEvent, type InsertPlacement, type NativeBehaviorEvent, type SyntheticBehaviorEvent, defineBehavior, effect, execute, forward, raise };
@@ -1,5 +1,5 @@
1
- import { a as getChildren, d as isKeyedSegment, r as getNode } from "./get-parent-DgaKcy8-.js";
2
- import { C as getAncestors, _ as comparePoints, b as isEditableContainer, g as isAfterPoint, m as rangeEdges, r as comparePoints$1, u as getNodes, v as comparePaths, y as isObject$1 } from "./get-path-sub-schema-Dd0QYZ0m.js";
1
+ import { a as getChildren, p as isKeyedSegment, r as getNode } from "./get-parent-BLzi7eLr.js";
2
+ import { C as getAncestors, _ as comparePoints, b as isEditableContainer, g as isAfterPoint, m as rangeEdges, r as comparePoints$1, u as getNodes, v as comparePaths, y as isObject$1 } from "./get-path-sub-schema-DsN1qF_l.js";
3
3
  import { getSubSchema, isSpan, isTextBlock } from "@portabletext/schema";
4
4
  function getAncestor(snapshot, path, options) {
5
5
  let { match, mode = "lowest" } = options, ancestors = getAncestors(snapshot, path);
@@ -219,4 +219,4 @@ function getContainer(snapshot, path) {
219
219
  }
220
220
  export { getAncestor as _, getTextBlock as a, pathContains as c, isRange as d, isPoint as f, isLeafObject as g, getLeaf as h, getFirstChild as i, getSpan as l, isPath as m, getUnionSchema as n, rangeIntersects as o, isObject as p, getLastChild as r, isBeforePoint as s, getContainer as t, getText as u };
221
221
 
222
- //# sourceMappingURL=get-container-D2pN5Npr.js.map
222
+ //# sourceMappingURL=get-container-CXdmRdiX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-container-D2pN5Npr.js","names":[],"sources":["../src/traversal/get-ancestor.ts","../src/traversal/is-leaf-object.ts","../src/traversal/get-leaf.ts","../src/engine/path/is-path.ts","../src/engine/utils/is-object.ts","../src/engine/point/is-point.ts","../src/engine/range/is-range.ts","../src/traversal/get-text.ts","../src/traversal/get-span.ts","../src/traversal/path-contains.ts","../src/engine/point/is-before-point.ts","../src/traversal/range-intersects.ts","../src/traversal/get-text-block.ts","../src/traversal/get-first-child.ts","../src/traversal/get-last-child.ts","../src/traversal/get-union-schema.ts","../src/traversal/get-container.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getAncestors} from './get-ancestors'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Find an 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 * `mode: 'lowest'` (default) returns the nearest matching ancestor.\n * `mode: 'highest'` returns the outermost matching ancestor.\n *\n * When `match` is a type predicate, the returned `node` narrows to that type.\n *\n * @public\n */\nexport function getAncestor<TMatch extends PortableTextBlock>(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => node is TMatch\n mode?: 'lowest' | 'highest'\n },\n): {node: TMatch; path: Path} | undefined\n/**\n * @public\n */\nexport function getAncestor(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => boolean\n mode?: 'lowest' | 'highest'\n },\n): {node: PortableTextBlock; path: Path} | undefined\nexport function getAncestor(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => boolean\n mode?: 'lowest' | 'highest'\n },\n): {node: PortableTextBlock; path: Path} | undefined {\n const {match, mode = 'lowest'} = options\n const ancestors = getAncestors(snapshot, path)\n\n if (mode === 'highest') {\n for (const ancestor of [...ancestors].reverse()) {\n if (match(ancestor.node, ancestor.path)) {\n return ancestor\n }\n }\n return undefined\n }\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","import type {PortableTextObject} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {isEditableContainer} from '../schema/is-editable-container'\nimport {isObject} from './is-object'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Check if a node is a leaf object: an object node that has no editable\n * children (not a container).\n * Returns true for block objects and inline objects that don't have\n * registered editable content (containers).\n *\n * @public\n */\nexport function isLeafObject(\n snapshot: TraversalSnapshot,\n node: unknown,\n path: Path,\n): node is PortableTextObject {\n return isObject(snapshot, node) && !isEditableContainer(snapshot, node, path)\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {getChildren} from './get-children'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the deepest leaf node starting from a path, walking toward either the\n * start or end edge. A leaf is any node that has no children according to the\n * traversal context.\n *\n * @public\n */\nexport function getLeaf(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {edge: 'start' | 'end'},\n): {node: Node; path: Path} | undefined {\n const {edge} = options\n\n let currentPath = path\n\n // If starting from root (empty path), descend into first/last child\n if (currentPath.length === 0) {\n const children = getChildren(snapshot, [])\n if (children.length === 0) {\n return undefined\n }\n const firstOrLast = edge === 'end' ? children.at(-1)! : children.at(0)!\n const nodeChildren = getChildren(snapshot, firstOrLast.path)\n if (nodeChildren.length === 0) {\n return firstOrLast\n }\n currentPath = firstOrLast.path\n } else {\n // Check if the node at path is already a leaf\n const entry = getNode(snapshot, currentPath)\n if (!entry) {\n return undefined\n }\n const children = getChildren(snapshot, currentPath)\n if (children.length === 0) {\n return entry\n }\n }\n\n // Descend to deepest leaf\n while (true) {\n const children = getChildren(snapshot, currentPath)\n if (children.length === 0) {\n const entry = getNode(snapshot, currentPath)\n return entry ?? undefined\n }\n const child = edge === 'end' ? children.at(-1)! : children.at(0)!\n currentPath = child.path\n }\n}\n","import {isKeyedSegment} from '../../utils/util.is-keyed-segment'\nimport type {Path} from '../interfaces/path'\n\nexport function isPath(value: any): value is Path {\n return (\n Array.isArray(value) &&\n (value.length === 0 ||\n typeof value[0] === 'number' ||\n typeof value[0] === 'string' ||\n isKeyedSegment(value[0]))\n )\n}\n","export const isObject = (value: any) =>\n typeof value === 'object' && value !== null\n","import type {Point} from '../interfaces/point'\nimport {isPath} from '../path/is-path'\nimport {isObject} from '../utils/is-object'\n\nexport function isPoint(value: any): value is Point {\n return (\n isObject(value) && typeof value.offset === 'number' && isPath(value.path)\n )\n}\n","import type {Range} from '../interfaces/range'\nimport {isPoint} from '../point/is-point'\nimport {isObject} from '../utils/is-object'\n\nexport function isRange(value: any): value is Range {\n return isObject(value) && isPoint(value.anchor) && isPoint(value.focus)\n}\n","import {isSpan} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport {getNodes} from './get-nodes'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the concatenated text content of the node at a given path.\n *\n * @public\n */\nexport function getText(\n snapshot: TraversalSnapshot,\n path: Path,\n): string | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (isSpan({schema: snapshot.context.schema}, entry.node)) {\n return entry.node.text\n }\n\n let text = ''\n\n for (const descendant of getNodes(snapshot, {at: path})) {\n if (isSpan({schema: snapshot.context.schema}, descendant.node)) {\n text += descendant.node.text\n }\n }\n\n return text\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the span node at a given path.\n *\n * @public\n */\nexport function getSpan(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: PortableTextSpan; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isSpan({schema: snapshot.context.schema}, entry.node)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n","import type {Path} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * Returns true if `ancestor` is equal to `descendant`, or if `descendant`\n * lives anywhere inside `ancestor`'s subtree.\n *\n * @public\n */\nexport function pathContains(ancestor: Path, descendant: Path): boolean {\n if (ancestor.length > descendant.length) {\n return false\n }\n\n for (let i = 0; i < ancestor.length; i++) {\n const segment = ancestor[i]\n const otherSegment = descendant[i]\n\n if (isKeyedSegment(segment) && isKeyedSegment(otherSegment)) {\n if (segment._key !== otherSegment._key) {\n return false\n }\n } else if (segment !== otherSegment) {\n return false\n }\n }\n\n return true\n}\n","import type {Node} from '../interfaces/node'\nimport type {Point} from '../interfaces/point'\nimport {comparePoints} from './compare-points'\n\nexport function isBeforePoint(\n point: Point,\n another: Point,\n root: {value: Array<Node>},\n): boolean {\n return comparePoints(point, another, root) === -1\n}\n","import {comparePaths} from '../engine/path/compare-paths'\nimport {isAfterPoint} from '../engine/point/is-after-point'\nimport {isBeforePoint} from '../engine/point/is-before-point'\nimport {isPoint} from '../engine/point/is-point'\nimport {isRange} from '../engine/range/is-range'\nimport {rangeEdges} from '../engine/range/range-edges'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport type {Path} from '../types/paths'\nimport {comparePoints} from './compare-points'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Returns true if `range` and the supplied `target` intersect. The target\n * may be a `Path`, an `EditorSelectionPoint`, or another\n * `EditorSelection`.\n *\n * For a `Path` or `EditorSelectionPoint` target, \"intersect\" means the\n * target lies at or between `range`'s start and end edges (inclusive).\n *\n * For an `EditorSelection` target, \"intersect\" means either endpoint of\n * `target` lies inside `range`, or `range` strictly encloses `target`.\n *\n * Pass `snapshot.context.selection` as `range` to ask the question against\n * the editor's current selection.\n *\n * Returns `false` when either `range` or `target` is `null`.\n *\n * @public\n */\nexport function rangeIntersects(\n snapshot: TraversalSnapshot,\n range: EditorSelection,\n target: Path | EditorSelectionPoint | EditorSelection,\n): boolean {\n if (!range || target === null) {\n return false\n }\n\n const root = {value: snapshot.context.value}\n\n if (isRange(target)) {\n if (\n rangeIntersects(snapshot, range, target.anchor) ||\n rangeIntersects(snapshot, range, target.focus)\n ) {\n return true\n }\n const [rs, re] = rangeEdges(range, root)\n const [ts, te] = rangeEdges(target, root)\n return isBeforePoint(rs, ts, root) && isAfterPoint(re, te, root)\n }\n\n const [start, end] = rangeEdges(range, root)\n let isAfterStart = false\n let isBeforeEnd = false\n\n if (isPoint(target)) {\n isAfterStart = comparePoints(snapshot, target, start) >= 0\n isBeforeEnd = comparePoints(snapshot, target, end) <= 0\n } else {\n isAfterStart = comparePaths(target, start.path, root) >= 0\n isBeforeEnd = comparePaths(target, end.path, root) <= 0\n }\n\n return isAfterStart && isBeforeEnd\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the text block node at a given path.\n *\n * @public\n */\nexport function getTextBlock(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: PortableTextTextBlock; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isTextBlock({schema: snapshot.context.schema}, entry.node)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n","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 first child of a node at a given path.\n *\n * @public\n */\nexport function getFirstChild(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n return getChildren(snapshot, path).at(0)\n}\n","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 * @public\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","import {getSubSchema, type Schema} from '@portabletext/schema'\nimport type {Containers} from '../schema/resolve-containers'\n\n/**\n * Return a `Schema` that contains every named member declared anywhere\n * in the editor's schema graph that is reachable from a position where text\n * is edited - the root schema merged with the sub-schema of every registered\n * container whose field accepts text blocks, deduped by name. Useful for\n * rendering a static toolbar whose buttons stay stable across selection\n * moves while still reflecting everything that could plausibly be edited or\n * inserted somewhere.\n *\n * Containers whose field does NOT accept text blocks (e.g. a `table`\n * container whose `rows` field only accepts `row` objects, or a `row`\n * container whose `cells` field only accepts `cell` objects) are\n * **structural**: their immediate `of` types are organizational, not\n * insertable user content. Those structural types are excluded from the\n * union. Their nested text-block-accepting descendants (e.g. a `cell`\n * that contains a `content` field of `{type: 'block'}`) are reached via\n * those descendants' own container registration.\n *\n * Pair with `getPathSubSchema` (or a path-based intersection across a\n * range) to determine which of the union's members are applicable at the\n * current selection.\n *\n * @public\n */\nexport function getUnionSchema(schema: Schema, containers: Containers): Schema {\n const decorators = mergeByName(schema.decorators, [])\n const annotations = mergeByName(schema.annotations, [])\n const lists = mergeByName(schema.lists, [])\n const styles = mergeByName(schema.styles, [])\n const inlineObjects = mergeByName(schema.inlineObjects, [])\n const blockObjects = mergeByName(schema.blockObjects, [])\n\n for (const container of containers.values()) {\n if (!acceptsTextBlock(container.field.of, schema.block.name)) {\n continue\n }\n const sub = getSubSchema(schema, container.field.of)\n mergeByName(sub.decorators, decorators)\n mergeByName(sub.annotations, annotations)\n mergeByName(sub.lists, lists)\n mergeByName(sub.styles, styles)\n mergeByName(sub.inlineObjects, inlineObjects)\n mergeByName(sub.blockObjects, blockObjects)\n }\n\n return {\n ...schema,\n decorators,\n annotations,\n lists,\n styles,\n inlineObjects,\n blockObjects,\n }\n}\n\nfunction acceptsTextBlock(\n of: ReadonlyArray<{type: string}>,\n blockName: string,\n): boolean {\n return of.some(\n (member) => member.type === 'block' || member.type === blockName,\n )\n}\n\nfunction mergeByName<T extends {name: string}>(\n source: ReadonlyArray<T>,\n target: Array<T>,\n): Array<T> {\n for (const entry of source) {\n if (target.some((existing) => existing.name === entry.name)) {\n continue\n }\n target.push(entry)\n }\n return target\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {isEditableContainer} from '../schema/is-editable-container'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the registered editable container at a given path.\n *\n * @public\n */\nexport function getContainer(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isEditableContainer(snapshot, entry.node, entry.path)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n"],"mappings":";;;AAmCA,SAAgB,YACd,UACA,MACA,SAImD;CACnD,IAAM,EAAC,OAAO,OAAO,aAAY,SAC3B,YAAY,aAAa,UAAU,IAAI;CAE7C,IAAI,SAAS,WAAW;EACtB,KAAK,IAAM,YAAY,CAAC,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C,CAAC,GAChD,QAAQ,YAAY,OAAO,OAAO,CAAC,CAAC,GACpC,SAAS,YAAY,OAAO,QAAQ,CAAC,CAAC,GACtC,gBAAgB,YAAY,OAAO,eAAe,CAAC,CAAC,GACpD,eAAe,YAAY,OAAO,cAAc,CAAC,CAAC;CAExD,KAAK,IAAM,aAAa,WAAW,OAAO,GAAG;EAC3C,IAAI,CAAC,iBAAiB,UAAU,MAAM,IAAI,OAAO,MAAM,IAAI,GACzD;EAEF,IAAM,MAAM,aAAa,QAAQ,UAAU,MAAM,EAAE;EAMnD,AALA,YAAY,IAAI,YAAY,UAAU,GACtC,YAAY,IAAI,aAAa,WAAW,GACxC,YAAY,IAAI,OAAO,KAAK,GAC5B,YAAY,IAAI,QAAQ,MAAM,GAC9B,YAAY,IAAI,eAAe,aAAa,GAC5C,YAAY,IAAI,cAAc,YAAY;CAC5C;CAEA,OAAO;EACL,GAAG;EACH;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,SAAS,iBACP,IACA,WACS;CACT,OAAO,GAAG,MACP,WAAW,OAAO,SAAS,WAAW,OAAO,SAAS,SACzD;AACF;AAEA,SAAS,YACP,QACA,QACU;CACV,KAAK,IAAM,SAAS,QACd,OAAO,MAAM,aAAa,SAAS,SAAS,MAAM,IAAI,KAG1D,OAAO,KAAK,KAAK;CAEnB,OAAO;AACT;;;;;;ACpEA,SAAgB,aACd,UACA,MACsC;CACtC,IAAM,QAAQ,QAAQ,UAAU,IAAI;CAE/B,aAIA,oBAAoB,UAAU,MAAM,MAAM,MAAM,IAAI,GAIzD,OAAO;EAAC,MAAM,MAAM;EAAM,MAAM,MAAM;CAAI;AAC5C"}
1
+ {"version":3,"file":"get-container-CXdmRdiX.js","names":[],"sources":["../src/traversal/get-ancestor.ts","../src/traversal/is-leaf-object.ts","../src/traversal/get-leaf.ts","../src/engine/path/is-path.ts","../src/engine/utils/is-object.ts","../src/engine/point/is-point.ts","../src/engine/range/is-range.ts","../src/traversal/get-text.ts","../src/traversal/get-span.ts","../src/traversal/path-contains.ts","../src/engine/point/is-before-point.ts","../src/traversal/range-intersects.ts","../src/traversal/get-text-block.ts","../src/traversal/get-first-child.ts","../src/traversal/get-last-child.ts","../src/traversal/get-union-schema.ts","../src/traversal/get-container.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getAncestors} from './get-ancestors'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Find an 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 * `mode: 'lowest'` (default) returns the nearest matching ancestor.\n * `mode: 'highest'` returns the outermost matching ancestor.\n *\n * When `match` is a type predicate, the returned `node` narrows to that type.\n *\n * @public\n */\nexport function getAncestor<TMatch extends PortableTextBlock>(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => node is TMatch\n mode?: 'lowest' | 'highest'\n },\n): {node: TMatch; path: Path} | undefined\n/**\n * @public\n */\nexport function getAncestor(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => boolean\n mode?: 'lowest' | 'highest'\n },\n): {node: PortableTextBlock; path: Path} | undefined\nexport function getAncestor(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => boolean\n mode?: 'lowest' | 'highest'\n },\n): {node: PortableTextBlock; path: Path} | undefined {\n const {match, mode = 'lowest'} = options\n const ancestors = getAncestors(snapshot, path)\n\n if (mode === 'highest') {\n for (const ancestor of [...ancestors].reverse()) {\n if (match(ancestor.node, ancestor.path)) {\n return ancestor\n }\n }\n return undefined\n }\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","import type {PortableTextObject} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {isEditableContainer} from '../schema/is-editable-container'\nimport {isObject} from './is-object'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Check if a node is a leaf object: an object node that has no editable\n * children (not a container).\n * Returns true for block objects and inline objects that don't have\n * registered editable content (containers).\n *\n * @public\n */\nexport function isLeafObject(\n snapshot: TraversalSnapshot,\n node: unknown,\n path: Path,\n): node is PortableTextObject {\n return isObject(snapshot, node) && !isEditableContainer(snapshot, node, path)\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {getChildren} from './get-children'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the deepest leaf node starting from a path, walking toward either the\n * start or end edge. A leaf is any node that has no children according to the\n * traversal context.\n *\n * @public\n */\nexport function getLeaf(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {edge: 'start' | 'end'},\n): {node: Node; path: Path} | undefined {\n const {edge} = options\n\n let currentPath = path\n\n // If starting from root (empty path), descend into first/last child\n if (currentPath.length === 0) {\n const children = getChildren(snapshot, [])\n if (children.length === 0) {\n return undefined\n }\n const firstOrLast = edge === 'end' ? children.at(-1)! : children.at(0)!\n const nodeChildren = getChildren(snapshot, firstOrLast.path)\n if (nodeChildren.length === 0) {\n return firstOrLast\n }\n currentPath = firstOrLast.path\n } else {\n // Check if the node at path is already a leaf\n const entry = getNode(snapshot, currentPath)\n if (!entry) {\n return undefined\n }\n const children = getChildren(snapshot, currentPath)\n if (children.length === 0) {\n return entry\n }\n }\n\n // Descend to deepest leaf\n while (true) {\n const children = getChildren(snapshot, currentPath)\n if (children.length === 0) {\n const entry = getNode(snapshot, currentPath)\n return entry ?? undefined\n }\n const child = edge === 'end' ? children.at(-1)! : children.at(0)!\n currentPath = child.path\n }\n}\n","import {isKeyedSegment} from '../../utils/util.is-keyed-segment'\nimport type {Path} from '../interfaces/path'\n\nexport function isPath(value: any): value is Path {\n return (\n Array.isArray(value) &&\n (value.length === 0 ||\n typeof value[0] === 'number' ||\n typeof value[0] === 'string' ||\n isKeyedSegment(value[0]))\n )\n}\n","export const isObject = (value: any) =>\n typeof value === 'object' && value !== null\n","import type {Point} from '../interfaces/point'\nimport {isPath} from '../path/is-path'\nimport {isObject} from '../utils/is-object'\n\nexport function isPoint(value: any): value is Point {\n return (\n isObject(value) && typeof value.offset === 'number' && isPath(value.path)\n )\n}\n","import type {Range} from '../interfaces/range'\nimport {isPoint} from '../point/is-point'\nimport {isObject} from '../utils/is-object'\n\nexport function isRange(value: any): value is Range {\n return isObject(value) && isPoint(value.anchor) && isPoint(value.focus)\n}\n","import {isSpan} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport {getNodes} from './get-nodes'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the concatenated text content of the node at a given path.\n *\n * @public\n */\nexport function getText(\n snapshot: TraversalSnapshot,\n path: Path,\n): string | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (isSpan({schema: snapshot.context.schema}, entry.node)) {\n return entry.node.text\n }\n\n let text = ''\n\n for (const descendant of getNodes(snapshot, {at: path})) {\n if (isSpan({schema: snapshot.context.schema}, descendant.node)) {\n text += descendant.node.text\n }\n }\n\n return text\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the span node at a given path.\n *\n * @public\n */\nexport function getSpan(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: PortableTextSpan; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isSpan({schema: snapshot.context.schema}, entry.node)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n","import type {Path} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * Returns true if `ancestor` is equal to `descendant`, or if `descendant`\n * lives anywhere inside `ancestor`'s subtree.\n *\n * @public\n */\nexport function pathContains(ancestor: Path, descendant: Path): boolean {\n if (ancestor.length > descendant.length) {\n return false\n }\n\n for (let i = 0; i < ancestor.length; i++) {\n const segment = ancestor[i]\n const otherSegment = descendant[i]\n\n if (isKeyedSegment(segment) && isKeyedSegment(otherSegment)) {\n if (segment._key !== otherSegment._key) {\n return false\n }\n } else if (segment !== otherSegment) {\n return false\n }\n }\n\n return true\n}\n","import type {Node} from '../interfaces/node'\nimport type {Point} from '../interfaces/point'\nimport {comparePoints} from './compare-points'\n\nexport function isBeforePoint(\n point: Point,\n another: Point,\n root: {value: Array<Node>},\n): boolean {\n return comparePoints(point, another, root) === -1\n}\n","import {comparePaths} from '../engine/path/compare-paths'\nimport {isAfterPoint} from '../engine/point/is-after-point'\nimport {isBeforePoint} from '../engine/point/is-before-point'\nimport {isPoint} from '../engine/point/is-point'\nimport {isRange} from '../engine/range/is-range'\nimport {rangeEdges} from '../engine/range/range-edges'\nimport type {EditorSelection, EditorSelectionPoint} from '../types/editor'\nimport type {Path} from '../types/paths'\nimport {comparePoints} from './compare-points'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Returns true if `range` and the supplied `target` intersect. The target\n * may be a `Path`, an `EditorSelectionPoint`, or another\n * `EditorSelection`.\n *\n * For a `Path` or `EditorSelectionPoint` target, \"intersect\" means the\n * target lies at or between `range`'s start and end edges (inclusive).\n *\n * For an `EditorSelection` target, \"intersect\" means either endpoint of\n * `target` lies inside `range`, or `range` strictly encloses `target`.\n *\n * Pass `snapshot.context.selection` as `range` to ask the question against\n * the editor's current selection.\n *\n * Returns `false` when either `range` or `target` is `null`.\n *\n * @public\n */\nexport function rangeIntersects(\n snapshot: TraversalSnapshot,\n range: EditorSelection,\n target: Path | EditorSelectionPoint | EditorSelection,\n): boolean {\n if (!range || target === null) {\n return false\n }\n\n const root = {value: snapshot.context.value}\n\n if (isRange(target)) {\n if (\n rangeIntersects(snapshot, range, target.anchor) ||\n rangeIntersects(snapshot, range, target.focus)\n ) {\n return true\n }\n const [rs, re] = rangeEdges(range, root)\n const [ts, te] = rangeEdges(target, root)\n return isBeforePoint(rs, ts, root) && isAfterPoint(re, te, root)\n }\n\n const [start, end] = rangeEdges(range, root)\n let isAfterStart = false\n let isBeforeEnd = false\n\n if (isPoint(target)) {\n isAfterStart = comparePoints(snapshot, target, start) >= 0\n isBeforeEnd = comparePoints(snapshot, target, end) <= 0\n } else {\n isAfterStart = comparePaths(target, start.path, root) >= 0\n isBeforeEnd = comparePaths(target, end.path, root) <= 0\n }\n\n return isAfterStart && isBeforeEnd\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the text block node at a given path.\n *\n * @public\n */\nexport function getTextBlock(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: PortableTextTextBlock; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isTextBlock({schema: snapshot.context.schema}, entry.node)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n","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 first child of a node at a given path.\n *\n * @public\n */\nexport function getFirstChild(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n return getChildren(snapshot, path).at(0)\n}\n","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 * @public\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","import {getSubSchema, type Schema} from '@portabletext/schema'\nimport type {Containers} from '../schema/resolve-containers'\n\n/**\n * Return a `Schema` that contains every named member declared anywhere\n * in the editor's schema graph that is reachable from a position where text\n * is edited - the root schema merged with the sub-schema of every registered\n * container whose field accepts text blocks, deduped by name. Useful for\n * rendering a static toolbar whose buttons stay stable across selection\n * moves while still reflecting everything that could plausibly be edited or\n * inserted somewhere.\n *\n * Containers whose field does NOT accept text blocks (e.g. a `table`\n * container whose `rows` field only accepts `row` objects, or a `row`\n * container whose `cells` field only accepts `cell` objects) are\n * **structural**: their immediate `of` types are organizational, not\n * insertable user content. Those structural types are excluded from the\n * union. Their nested text-block-accepting descendants (e.g. a `cell`\n * that contains a `content` field of `{type: 'block'}`) are reached via\n * those descendants' own container registration.\n *\n * Pair with `getPathSubSchema` (or a path-based intersection across a\n * range) to determine which of the union's members are applicable at the\n * current selection.\n *\n * @public\n */\nexport function getUnionSchema(schema: Schema, containers: Containers): Schema {\n const decorators = mergeByName(schema.decorators, [])\n const annotations = mergeByName(schema.annotations, [])\n const lists = mergeByName(schema.lists, [])\n const styles = mergeByName(schema.styles, [])\n const inlineObjects = mergeByName(schema.inlineObjects, [])\n const blockObjects = mergeByName(schema.blockObjects, [])\n\n for (const container of containers.values()) {\n if (!acceptsTextBlock(container.field.of, schema.block.name)) {\n continue\n }\n const sub = getSubSchema(schema, container.field.of)\n mergeByName(sub.decorators, decorators)\n mergeByName(sub.annotations, annotations)\n mergeByName(sub.lists, lists)\n mergeByName(sub.styles, styles)\n mergeByName(sub.inlineObjects, inlineObjects)\n mergeByName(sub.blockObjects, blockObjects)\n }\n\n return {\n ...schema,\n decorators,\n annotations,\n lists,\n styles,\n inlineObjects,\n blockObjects,\n }\n}\n\nfunction acceptsTextBlock(\n of: ReadonlyArray<{type: string}>,\n blockName: string,\n): boolean {\n return of.some(\n (member) => member.type === 'block' || member.type === blockName,\n )\n}\n\nfunction mergeByName<T extends {name: string}>(\n source: ReadonlyArray<T>,\n target: Array<T>,\n): Array<T> {\n for (const entry of source) {\n if (target.some((existing) => existing.name === entry.name)) {\n continue\n }\n target.push(entry)\n }\n return target\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {isEditableContainer} from '../schema/is-editable-container'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the registered editable container at a given path.\n *\n * @public\n */\nexport function getContainer(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n const entry = getNode(snapshot, path)\n\n if (!entry) {\n return undefined\n }\n\n if (!isEditableContainer(snapshot, entry.node, entry.path)) {\n return undefined\n }\n\n return {node: entry.node, path: entry.path}\n}\n"],"mappings":";;;AAmCA,SAAgB,YACd,UACA,MACA,SAImD;CACnD,IAAM,EAAC,OAAO,OAAO,aAAY,SAC3B,YAAY,aAAa,UAAU,IAAI;CAE7C,IAAI,SAAS,WAAW;EACtB,KAAK,IAAM,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC,QAAQ,GAC5C,IAAI,MAAM,SAAS,MAAM,SAAS,IAAI,GACpC,OAAO;EAGX;CACF;CAEA,KAAK,IAAM,YAAY,WACrB,IAAI,MAAM,SAAS,MAAM,SAAS,IAAI,GACpC,OAAO;AAKb;;;;;;;;;AChDA,SAAgB,aACd,UACA,MACA,MAC4B;CAC5B,OAAO,WAAS,UAAU,IAAI,KAAK,CAAC,oBAAoB,UAAU,MAAM,IAAI;AAC9E;;;;;;;;ACPA,SAAgB,QACd,UACA,MACA,SACsC;CACtC,IAAM,EAAC,SAAQ,SAEX,cAAc;CAGlB,IAAI,YAAY,WAAW,GAAG;EAC5B,IAAM,WAAW,YAAY,UAAU,CAAC,CAAC;EACzC,IAAI,SAAS,WAAW,GACtB;EAEF,IAAM,cAAc,SAAS,QAAQ,SAAS,GAAG,EAAE,IAAK,SAAS,GAAG,CAAC;EAErE,IADqB,YAAY,UAAU,YAAY,IACnD,CAAA,CAAa,WAAW,GAC1B,OAAO;EA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CACT,OAAO,GAAG,MACP,WAAW,OAAO,SAAS,WAAW,OAAO,SAAS,SACzD;AACF;AAEA,SAAS,YACP,QACA,QACU;CACV,KAAK,IAAM,SAAS,QACd,OAAO,MAAM,aAAa,SAAS,SAAS,MAAM,IAAI,KAG1D,OAAO,KAAK,KAAK;CAEnB,OAAO;AACT;;;;;;ACpEA,SAAgB,aACd,UACA,MACsC;CACtC,IAAM,QAAQ,QAAQ,UAAU,IAAI;CAE/B,aAIA,oBAAoB,UAAU,MAAM,MAAM,MAAM,IAAI,GAIzD,OAAO;EAAC,MAAM,MAAM;EAAM,MAAM,MAAM;CAAI;AAC5C"}
@@ -15,6 +15,23 @@ function isKeyedSegment(segment) {
15
15
  function serializePath(path) {
16
16
  return path.reduce((result, segment, index) => isKeyedSegment(segment) ? `${result}[_key=="${segment._key}"]` : `${result}${index === 0 ? "" : "."}${segment}`, "");
17
17
  }
18
+ /**
19
+ * A key only addresses a node when it's a non-empty string; sync payloads
20
+ * and hand-authored content can carry `undefined`, `null`, or `''`.
21
+ */
22
+ function hasUsableKey(key) {
23
+ return typeof key == "string" && key !== "";
24
+ }
25
+ /**
26
+ * The path segment that identifies `node` among its siblings: keyed when
27
+ * the node has a usable `_key`, otherwise the sibling index. A fabricated
28
+ * `{_key: undefined}` segment identifies nothing (several keyless siblings
29
+ * would all canonicalize to the same segment), so producers of resolved
30
+ * paths must fall back to the index until normalization mints a key.
31
+ */
32
+ function nodeSegment(node, index) {
33
+ return hasUsableKey(node._key) ? { _key: node._key } : index;
34
+ }
18
35
  function isTypedObject(object) {
19
36
  return isRecord(object) && typeof object._type == "string";
20
37
  }
@@ -77,21 +94,22 @@ function getChildren(snapshot, path) {
77
94
  node = index !== void 0 && currentChildren[index]?._key === segment._key ? currentChildren[index] : currentChildren.find((child) => child._key === segment._key);
78
95
  } else typeof segment == "number" && (node = currentChildren.at(segment));
79
96
  if (!node) return [];
80
- currentPath = isRoot ? [{ _key: node._key }] : [
97
+ let nodeIndex = currentChildren.indexOf(node);
98
+ currentPath = isRoot ? [nodeSegment(node, nodeIndex)] : [
81
99
  ...currentPath,
82
100
  currentFieldName,
83
- { _key: node._key }
101
+ nodeSegment(node, nodeIndex)
84
102
  ], isRoot = !1;
85
103
  let next = getNodeChildren(snapshot.context, node, currentParent);
86
104
  if (!next) return [];
87
105
  currentChildren = next.children, currentFieldName = next.fieldName, currentParent = next.parent;
88
106
  }
89
- return currentChildren.map((child) => ({
107
+ return currentChildren.map((child, childIndex) => ({
90
108
  node: child,
91
- path: isRoot ? [{ _key: child._key }] : [
109
+ path: isRoot ? [nodeSegment(child, childIndex)] : [
92
110
  ...currentPath,
93
111
  currentFieldName,
94
- { _key: child._key }
112
+ nodeSegment(child, childIndex)
95
113
  ]
96
114
  }));
97
115
  }
@@ -139,11 +157,14 @@ function getNodeChildren(context, node, parent) {
139
157
  * field name strings name a structural descent into the previous
140
158
  * node's children, and numbers are resolved by index.
141
159
  *
142
- * The returned `path` always identifies the returned node: it's fully
143
- * keyed (numeric indices are converted to `KeyedSegment`s) and any
144
- * trailing segments in the input that point outside the value tree —
145
- * e.g. an object node's primitive field, or an annotation reached via
146
- * `'markDefs'` on a text block are stripped so that
160
+ * The returned `path` always identifies the returned node: segments
161
+ * are keyed wherever the node has a usable `_key` (numeric indices are
162
+ * converted to `KeyedSegment`s), and stay numeric for nodes
163
+ * normalization has not keyed yet (a `{_key: undefined}` segment would
164
+ * not distinguish keyless siblings). Any trailing segments in the
165
+ * input that point outside the value tree — e.g. an object node's
166
+ * primitive field, or an annotation reached via `'markDefs'` on a text
167
+ * block — are stripped so that
147
168
  * `getNode(snapshot, entry.path).node === entry.node`.
148
169
  *
149
170
  * The walk stops when a string segment names a field that isn't the
@@ -177,8 +198,12 @@ function resolveNode(snapshot, path) {
177
198
  if (isKeyedSegment(segment)) {
178
199
  resolvedPath.push(segment);
179
200
  let index = blockIndexMap.get(serializePath(resolvedPath));
180
- index !== void 0 && currentChildren[index]?._key === segment._key ? node = currentChildren[index] : (node = currentChildren.find((child) => child._key === segment._key), node && node._key !== void 0 && (resolvedPath[resolvedPath.length - 1] = { _key: node._key }));
181
- } else if (typeof segment == "number") node = currentChildren.at(segment), node && resolvedPath.push({ _key: node._key });
201
+ if (index !== void 0 && currentChildren[index]?._key === segment._key) node = currentChildren[index];
202
+ else {
203
+ let scanIndex = currentChildren.findIndex((child) => child._key === segment._key);
204
+ node = scanIndex === -1 ? void 0 : currentChildren[scanIndex], node && (resolvedPath[resolvedPath.length - 1] = nodeSegment(node, scanIndex));
205
+ }
206
+ } else if (typeof segment == "number") node = currentChildren.at(segment), node && resolvedPath.push(nodeSegment(node, segment));
182
207
  else return { status: "missing" };
183
208
  if (!node) return { status: "missing" };
184
209
  let hasMoreSegments = !1;
@@ -238,6 +263,6 @@ function getParent(snapshot, path, options) {
238
263
  };
239
264
  if (!(options?.match && !options.match(result.node, result.path))) return result;
240
265
  }
241
- export { getChildren as a, isRecord as c, isKeyedSegment as d, resolveNode as i, isTypedObject as l, parentPath as n, getNodeChildren as o, getNode as r, getContainerChildren as s, getParent as t, serializePath as u };
266
+ export { getChildren as a, isRecord as c, nodeSegment as d, serializePath as f, resolveNode as i, isTypedObject as l, parentPath as n, getNodeChildren as o, isKeyedSegment as p, getNode as r, getContainerChildren as s, getParent as t, hasUsableKey as u };
242
267
 
243
- //# sourceMappingURL=get-parent-DgaKcy8-.js.map
268
+ //# sourceMappingURL=get-parent-BLzi7eLr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parent-BLzi7eLr.js","names":[],"sources":["../src/utils/util.is-keyed-segment.ts","../src/paths/serialize-path.ts","../src/paths/node-segment.ts","../src/utils/asserters.ts","../src/traversal/get-container-children.ts","../src/traversal/get-children.ts","../src/traversal/get-node.ts","../src/engine/path/parent-path.ts","../src/traversal/get-parent.ts"],"sourcesContent":["import type {KeyedSegment} from '../types/paths'\n\n/**\n * @public\n */\nexport function isKeyedSegment(segment: unknown): segment is KeyedSegment {\n return typeof segment === 'object' && segment !== null && '_key' in segment\n}\n","import type {Path} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\n\n/**\n * Serialize a keyed path to a string using Sanity's bracket notation.\n *\n * - `[{_key: 'k0'}]` -> `[_key==\"k0\"]`\n * - `[{_key: 'k0'}, 'children', {_key: 's0'}]` -> `[_key==\"k0\"].children[_key==\"s0\"]`\n * - `[{_key: 't0'}, 'rows', {_key: 'r0'}, 'cells', {_key: 'c0'}, 'content', {_key: 'b0'}, 'children', {_key: 's0'}]` -> `[_key==\"t0\"].rows[_key==\"r0\"].cells[_key==\"c0\"].content[_key==\"b0\"].children[_key==\"s0\"]`\n */\nexport function serializePath(path: Path): string {\n return path.reduce<string>((result, segment, index) => {\n if (isKeyedSegment(segment)) {\n return `${result}[_key==\"${segment._key}\"]`\n }\n\n const separator = index === 0 ? '' : '.'\n return `${result}${separator}${segment}`\n }, '')\n}\n","import type {KeyedSegment} from '../types/paths'\n\n/**\n * A key only addresses a node when it's a non-empty string; sync payloads\n * and hand-authored content can carry `undefined`, `null`, or `''`.\n */\nexport function hasUsableKey(key: unknown): key is string {\n return typeof key === 'string' && key !== ''\n}\n\n/**\n * The path segment that identifies `node` among its siblings: keyed when\n * the node has a usable `_key`, otherwise the sibling index. A fabricated\n * `{_key: undefined}` segment identifies nothing (several keyless siblings\n * would all canonicalize to the same segment), so producers of resolved\n * paths must fall back to the index until normalization mints a key.\n */\nexport function nodeSegment(\n node: {_key?: unknown},\n index: number,\n): KeyedSegment | number {\n return hasUsableKey(node._key) ? {_key: node._key} : index\n}\n","import type {TypedObject} from '@portabletext/schema'\n\nexport function isTypedObject(object: unknown): object is TypedObject {\n return isRecord(object) && typeof object['_type'] === 'string'\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && (typeof value === 'object' || typeof value === 'function')\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {\n Containers,\n RegisteredContainer,\n} from '../schema/resolve-containers'\n\n/**\n * Resolve a container node's editable child array.\n *\n * Returns `{children, container}` for a node registered as a container:\n * `children` is the node's editable child array, and `container` is the\n * node's own container registration. Read `container.field.name` for the\n * path segment that reaches `children`, and thread `container` back in as\n * `parent` when descending into them.\n *\n * Returns `undefined` for anything that is not a container: text blocks,\n * spans, leaves, and unregistered objects. It is node-based and resolves\n * in one step with no path re-walk, so recursive descent over containers\n * is linear in nesting depth. The caller seeds the document root from\n * `context.value` itself.\n *\n * @beta\n */\nexport function getContainerChildren(\n containers: Containers,\n node: Node,\n parent?: RegisteredContainer,\n):\n | {\n children: Array<Node>\n container: RegisteredContainer\n }\n | undefined {\n const resolved = resolveNodeContainer(containers, parent, node)\n\n if (!resolved) {\n return undefined\n }\n\n const fieldValue = (node as Record<string, unknown>)[resolved.field.name]\n\n if (!Array.isArray(fieldValue)) {\n return undefined\n }\n\n return {\n children: fieldValue as Array<Node>,\n container: resolved,\n }\n}\n\n/**\n * Pick the positional override from `parent.of` if present; fall back\n * to the top-level entry. Returns only `RegisteredContainer` entries\n * since leaves do not have editable children.\n */\nfunction resolveNodeContainer(\n containers: Containers,\n parent: RegisteredContainer | undefined,\n node: Node,\n): RegisteredContainer | undefined {\n if (parent?.of) {\n for (const entry of parent.of) {\n if (entry.type === node._type) {\n // Only return container entries; leaves have no editable children.\n if ('field' in entry) {\n return entry\n }\n return undefined\n }\n }\n }\n return containers.get(node._type)\n}\n","import {isTextBlock} from '@portabletext/schema'\nimport type {EditorSchema} from '../editor/editor-schema'\nimport type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {nodeSegment} from '../paths/node-segment'\nimport {serializePath} from '../paths/serialize-path'\nimport type {\n Containers,\n RegisteredContainer,\n} from '../schema/resolve-containers'\nimport {isTypedObject} from '../utils/asserters'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getContainerChildren} from './get-container-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the children of a node at a given path.\n *\n * @public\n */\nexport function getChildren(\n snapshot: TraversalSnapshot,\n path: Path,\n): Array<{node: Node; path: Path}> {\n let currentChildren: Array<Node> = snapshot.context.value\n let currentFieldName = 'value'\n let currentPath: Path = []\n let isRoot = true\n let currentParent: RegisteredContainer | undefined\n\n for (const segment of path) {\n if (typeof segment === 'string') {\n continue\n }\n\n let node: Node | undefined\n if (isKeyedSegment(segment)) {\n // Resolve via `blockIndexMap` (O(1)) and fall back to a linear scan on a\n // miss or when the snapshot's map disagrees with the value, mirroring\n // `getNode`. The candidate path is this segment's full keyed path.\n const candidatePath: Path = isRoot\n ? [{_key: segment._key}]\n : [...currentPath, currentFieldName, {_key: segment._key}]\n const index = snapshot.blockIndexMap.get(serializePath(candidatePath))\n node =\n index !== undefined && currentChildren[index]?._key === segment._key\n ? currentChildren[index]\n : currentChildren.find((child) => child._key === segment._key)\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n }\n\n if (!node) {\n return []\n }\n\n const nodeIndex = currentChildren.indexOf(node)\n currentPath = isRoot\n ? [nodeSegment(node, nodeIndex)]\n : [...currentPath, currentFieldName, nodeSegment(node, nodeIndex)]\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, childIndex) => ({\n node: child,\n path: isRoot\n ? [nodeSegment(child, childIndex)]\n : [...currentPath, currentFieldName, nodeSegment(child, childIndex)],\n }))\n}\n\n/**\n * Resolve a node's editable child array.\n *\n * When `parent` is provided and its `of` declares a positional entry\n * matching `node._type`, that positional entry's `field` is used.\n * Otherwise the top-level `containers.get(node._type)` provides the\n * fallback.\n *\n * The returned `parent` is the resolved container entry for `node`\n * itself (used by the caller to thread further descent).\n *\n * Internal descent kernel shared by the positional traversal utilities\n * (`getChildren`, `getNode`, `getNodes`, `getAncestors`); it folds the\n * text-block, container, and root-document cases. Public consumers that\n * only need to descend containers use {@link getContainerChildren}.\n */\nexport function getNodeChildren(\n context: {\n schema: EditorSchema\n containers: Containers\n },\n node: Node | {value: Array<Node>},\n parent?: RegisteredContainer,\n):\n | {\n children: Array<Node>\n fieldName: string\n parent: RegisteredContainer | undefined\n }\n | undefined {\n // Text blocks store children in .children\n if (isTextBlock(context, node)) {\n return {\n children: node.children,\n fieldName: 'children',\n parent: undefined,\n }\n }\n\n if (isTypedObject(node)) {\n const result = getContainerChildren(context.containers, node, parent)\n\n if (result) {\n return {\n children: result.children,\n fieldName: result.container.field.name,\n parent: result.container,\n }\n }\n }\n\n // Root context: has .value array but no _key or _type\n if (\n 'value' in node &&\n Array.isArray(node['value']) &&\n !('_key' in node) &&\n !('_type' in node)\n ) {\n return {\n children: node['value'] as Array<Node>,\n fieldName: 'value',\n parent: undefined,\n }\n }\n\n return undefined\n}\n","import type {Node} from '../engine/interfaces/node'\nimport type {Path} from '../engine/interfaces/path'\nimport {nodeSegment} from '../paths/node-segment'\nimport {serializePath} from '../paths/serialize-path'\nimport type {RegisteredContainer} from '../schema/resolve-containers'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getNodeChildren} from './get-children'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the node at a given path.\n *\n * The path can be either keyed (KeyedSegment + field name strings) or\n * indexed (numbers). Keyed segments are resolved by matching `_key`,\n * field name strings name a structural descent into the previous\n * node's children, and numbers are resolved by index.\n *\n * The returned `path` always identifies the returned node: segments\n * are keyed wherever the node has a usable `_key` (numeric indices are\n * converted to `KeyedSegment`s), and stay numeric for nodes\n * normalization has not keyed yet (a `{_key: undefined}` segment would\n * not distinguish keyless siblings). Any trailing segments in the\n * input that point outside the value tree — e.g. an object node's\n * primitive field, or an annotation reached via `'markDefs'` on a text\n * block — are stripped so that\n * `getNode(snapshot, entry.path).node === entry.node`.\n *\n * The walk stops when a string segment names a field that isn't the\n * current node's structural child array. Annotations live in\n * `markDefs` on a text block, alongside `children` rather than inside\n * it, so `getNode` resolves an annotation path to the enclosing text\n * block. Use `getAnnotation` to resolve the annotation itself.\n *\n * @public\n */\nexport function getNode(\n snapshot: TraversalSnapshot,\n path: Path,\n): {node: Node; path: Path} | undefined {\n const result = resolveNode(snapshot, path)\n return result.status === 'found' ? result.entry : undefined\n}\n\n/**\n * Result of walking a path against a snapshot.\n *\n * `unreachable` is the one outcome that means \"structurally impossible\n * by design\": the path digs past a sidecar field (e.g. `markDefs` on\n * a text block) into a keyed/indexed segment, which `getNode` can\n * never resolve (use `getAnnotation` for annotations). Every other\n * negative outcome is `missing`; on those branches a caller bug and a\n * benign race (the node removed by a concurrent edit) produce the\n * same state, so they cannot be told apart.\n */\nexport type ResolveNodeResult =\n | {status: 'found'; entry: {node: Node; path: Path}}\n | {status: 'missing'}\n | {status: 'unreachable'}\n\nexport function resolveNode(\n snapshot: TraversalSnapshot,\n path: Path,\n): ResolveNodeResult {\n if (path.length === 0) {\n return {status: 'missing'}\n }\n\n const {context, blockIndexMap} = snapshot\n let currentChildren: Array<Node> = context.value\n let currentFieldName: string | undefined\n let node: Node | undefined\n let currentParent: RegisteredContainer | undefined\n const resolvedPath: Path = []\n\n for (let i = 0; i < path.length; i++) {\n const segment = path[i]\n\n if (typeof segment === 'string') {\n // A string segment names a structural descent. If it matches the\n // field name produced by the previous node's `getNodeChildren`,\n // it's part of the value-tree descent — push it and continue.\n // Otherwise the string names a sidecar field (markDefs on a text\n // block, a primitive field on an object). If the input keeps\n // digging past it with more keyed/numeric segments, the caller\n // wanted a node inside the sidecar and `getNode` can't reach it\n // (use `getAnnotation` for annotations); report unreachable.\n // Otherwise the rest is just trailing field names — let the loop\n // exit and the post-loop strip remove them.\n if (currentFieldName !== undefined && segment === currentFieldName) {\n resolvedPath.push(segment)\n continue\n }\n for (let j = i + 1; j < path.length; j++) {\n const s = path[j]\n if (isKeyedSegment(s) || typeof s === 'number') {\n return {status: 'unreachable'}\n }\n }\n break\n }\n\n if (isKeyedSegment(segment)) {\n resolvedPath.push(segment)\n const index = blockIndexMap.get(serializePath(resolvedPath))\n if (\n index !== undefined &&\n currentChildren[index]?._key === segment._key\n ) {\n node = currentChildren[index]\n } else {\n // The map can miss (unkeyed transient nodes, e.g. `{_type:'table'}`\n // inserted by a remote patch before normalize mints a key) or\n // disagree with the traversed value (snapshots that pair the live\n // map with a pre-apply value, e.g. `textPatch`). Fall back to a\n // linear scan in both cases.\n const scanIndex = currentChildren.findIndex(\n (child) => child._key === segment._key,\n )\n node = scanIndex === -1 ? undefined : currentChildren[scanIndex]\n if (node) {\n resolvedPath[resolvedPath.length - 1] = nodeSegment(node, scanIndex)\n }\n }\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push(nodeSegment(node, segment))\n }\n } else {\n return {status: 'missing'}\n }\n\n if (!node) {\n return {status: 'missing'}\n }\n\n let hasMoreSegments = false\n for (let j = i + 1; j < path.length; j++) {\n const s = path[j]\n if (isKeyedSegment(s) || typeof s === 'number') {\n hasMoreSegments = true\n break\n }\n }\n\n if (hasMoreSegments) {\n const next = getNodeChildren(context, node, currentParent)\n\n if (!next) {\n return {status: 'missing'}\n }\n\n currentChildren = next.children\n currentFieldName = next.fieldName\n currentParent = next.parent\n } else {\n currentFieldName = undefined\n }\n }\n\n if (!node) {\n return {status: 'missing'}\n }\n\n // Strip trailing field-name segments. The walker may have pushed\n // matching field names during structural descent; if the deepest\n // reached keyed segment was the last keyed segment in the input,\n // any further field names that followed are part of the input but\n // don't identify the returned node.\n while (\n resolvedPath.length > 0 &&\n typeof resolvedPath[resolvedPath.length - 1] === 'string'\n ) {\n resolvedPath.pop()\n }\n\n return {status: 'found', entry: {node, path: resolvedPath}}\n}\n","import {isKeyedSegment} from '../../utils/util.is-keyed-segment'\nimport type {Path} from '../interfaces/path'\n\n/**\n * Get the parent path of a path.\n *\n * Drops the last node segment (keyed or numeric) and the preceding field\n * name string.\n *\n * [{_key:'b1'}, 'children', {_key:'s1'}] → [{_key:'b1'}]\n * [{_key:'b1'}, 'children', 0] → [{_key:'b1'}]\n * [{_key:'b1'}] → []\n */\nexport function parentPath(path: Path): Path {\n if (path.length === 0) {\n throw new Error(`Cannot get the parent path of the root path [${path}].`)\n }\n\n let lastNodeIndex = -1\n for (let i = path.length - 1; i >= 0; i--) {\n if (isKeyedSegment(path[i]) || typeof path[i] === 'number') {\n lastNodeIndex = i\n break\n }\n }\n\n if (lastNodeIndex === -1) {\n return []\n }\n\n const result = path.slice(0, lastNodeIndex)\n\n if (result.length > 0 && typeof result[result.length - 1] === 'string') {\n return result.slice(0, -1)\n }\n\n return result\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {Path} from '../engine/interfaces/path'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getNode} from './get-node'\nimport type {TraversalSnapshot} from './traversal-snapshot'\n\n/**\n * Get the parent of a node at a given path.\n *\n * A parent has children, so it is always a `PortableTextBlock` (text block\n * or object node).\n *\n * When `match` is provided and the parent does not satisfy it, returns\n * `undefined`.\n *\n * @public\n */\nexport function getParent<TMatch extends PortableTextBlock>(\n snapshot: TraversalSnapshot,\n path: Path,\n options: {\n match: (node: PortableTextBlock, path: Path) => node is TMatch\n },\n): {node: TMatch; path: Path} | undefined\n/**\n * @public\n */\nexport function getParent(\n snapshot: TraversalSnapshot,\n path: Path,\n options?: {\n match?: (node: PortableTextBlock, path: Path) => boolean\n },\n): {node: PortableTextBlock; path: Path} | undefined\nexport function getParent(\n snapshot: TraversalSnapshot,\n path: Path,\n options?: {\n match?: (node: PortableTextBlock, path: Path) => boolean\n },\n): {node: PortableTextBlock; path: Path} | undefined {\n if (path.length === 0) {\n return undefined\n }\n\n const parent = parentPath(path)\n\n if (parent.length === 0) {\n return undefined\n }\n\n const entry = getNode(snapshot, parent)\n\n if (!entry) {\n return undefined\n }\n\n const result = {node: entry.node as PortableTextBlock, path: entry.path}\n\n if (options?.match && !options.match(result.node, result.path)) {\n return undefined\n }\n\n return result\n}\n"],"mappings":";;;;AAKA,SAAgB,eAAe,SAA2C;CACxE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,GAAG,EAAE,IAGpB;AACT;ACHA,SAAgB,UACd,UACA,MACA,SAGmD;CACnD,IAAI,KAAK,WAAW,GAClB;CAGF,IAAM,SAAS,WAAW,IAAI;CAE9B,IAAI,OAAO,WAAW,GACpB;CAGF,IAAM,QAAQ,QAAQ,UAAU,MAAM;CAEtC,IAAI,CAAC,OACH;CAGF,IAAM,SAAS;EAAC,MAAM,MAAM;EAA2B,MAAM,MAAM;CAAI;CAEnE,eAAS,SAAS,CAAC,QAAQ,MAAM,OAAO,MAAM,OAAO,IAAI,IAI7D,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { a as getChildren, d as isKeyedSegment, l as isTypedObject, n as parentPath, o as getNodeChildren, r as getNode, t as getParent, u as serializePath } from "./get-parent-DgaKcy8-.js";
1
+ import { a as getChildren, d as nodeSegment, f as serializePath, l as isTypedObject, n as parentPath, o as getNodeChildren, p as isKeyedSegment, r as getNode, t as getParent } from "./get-parent-BLzi7eLr.js";
2
2
  import { getSubSchema } from "@portabletext/schema";
3
3
  /**
4
4
  * Get all ancestors of the node at a given path, from nearest to furthest.
@@ -18,7 +18,7 @@ import { getSubSchema } from "@portabletext/schema";
18
18
  */
19
19
  function getAncestors(snapshot, path) {
20
20
  let keyedIndices = [];
21
- for (let i = 0; i < path.length; i++) isKeyedSegment(path[i]) && keyedIndices.push(i);
21
+ for (let i = 0; i < path.length; i++) (isKeyedSegment(path[i]) || typeof path[i] == "number") && keyedIndices.push(i);
22
22
  if (keyedIndices.length <= 1) return [];
23
23
  let { context, blockIndexMap } = snapshot, currentChildren = context.value, currentParent, ancestorsByDepth = [], resolvedPath = [], targetKeyedIndex = keyedIndices[keyedIndices.length - 1], segmentIndex = 0;
24
24
  for (; segmentIndex < targetKeyedIndex;) {
@@ -31,8 +31,12 @@ function getAncestors(snapshot, path) {
31
31
  if (isKeyedSegment(segment)) {
32
32
  resolvedPath.push(segment);
33
33
  let index = blockIndexMap.get(serializePath(resolvedPath));
34
- index !== void 0 && currentChildren[index]?._key === segment._key ? node = currentChildren[index] : (node = currentChildren.find((child) => child._key === segment._key), node && node._key !== void 0 && (resolvedPath[resolvedPath.length - 1] = { _key: node._key }));
35
- } else if (typeof segment == "number") node = currentChildren.at(segment), node && resolvedPath.push({ _key: node._key });
34
+ if (index !== void 0 && currentChildren[index]?._key === segment._key) node = currentChildren[index];
35
+ else {
36
+ let scanIndex = currentChildren.findIndex((child) => child._key === segment._key);
37
+ node = scanIndex === -1 ? void 0 : currentChildren[scanIndex], node && (resolvedPath[resolvedPath.length - 1] = nodeSegment(node, scanIndex));
38
+ }
39
+ } else if (typeof segment == "number") node = currentChildren.at(segment), node && resolvedPath.push(nodeSegment(node, segment));
36
40
  else return [];
37
41
  if (!node) return [];
38
42
  let next = getNodeChildren(context, node, currentParent);
@@ -510,4 +514,4 @@ function getPathSubSchema(snapshot, path) {
510
514
  }
511
515
  export { getAncestors as C, hasNode as S, comparePoints$1 as _, isInline as a, isEditableContainer as b, isSpanNode as c, resolveChildEntryIndex as d, isAncestorPath as f, isAfterPoint as g, isBackwardRange as h, getEnclosingBlock as i, getSibling as l, rangeEdges as m, getEnclosingContainer as n, getBlock as o, isTextBlockNode as p, comparePoints as r, isBlock as s, getPathSubSchema as t, getNodes as u, comparePaths as v, resolveContainerAt as x, isObject as y };
512
516
 
513
- //# sourceMappingURL=get-path-sub-schema-Dd0QYZ0m.js.map
517
+ //# sourceMappingURL=get-path-sub-schema-DsN1qF_l.js.map