@portabletext/editor 7.10.19 → 7.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -64
- package/lib/{behavior.types.action-CYtiRDck.d.ts → behavior.types.action-DH6ujvaH.d.ts} +409 -109
- package/lib/behavior.types.action-DH6ujvaH.d.ts.map +1 -0
- package/lib/{behavior.types.behavior-B_77VtQR.js → behavior.types.behavior-BxSLb73I.js} +5 -5
- package/lib/behavior.types.behavior-BxSLb73I.js.map +1 -0
- package/lib/behaviors/index.d.ts +1 -1
- package/lib/behaviors/index.js +1 -1
- package/lib/{get-container-BeXYKpoi.js → get-container-D1nM_ww9.js} +14 -14
- package/lib/get-container-D1nM_ww9.js.map +1 -0
- package/lib/{get-parent-51Kzgaf9.js → get-parent-Ci5241qs.js} +3 -3
- package/lib/get-parent-Ci5241qs.js.map +1 -0
- package/lib/{get-path-sub-schema--2I4NJbG.js → get-path-sub-schema-CZd9VcVM.js} +10 -10
- package/lib/get-path-sub-schema-CZd9VcVM.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +294 -101
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +6 -6
- package/lib/plugins/index.js +5 -5
- package/lib/plugins/index.js.map +1 -1
- package/lib/{selector.is-at-the-start-of-block-gJIMWRpU.js → selector.is-at-the-start-of-block-D0boZbDu.js} +4 -4
- package/lib/selector.is-at-the-start-of-block-D0boZbDu.js.map +1 -0
- package/lib/selectors/index.d.ts +6 -6
- package/lib/selectors/index.js +6 -6
- package/lib/selectors/index.js.map +1 -1
- package/lib/traversal/index.d.ts +31 -31
- package/lib/traversal/index.js +4 -4
- package/lib/traversal/index.js.map +1 -1
- package/lib/{util.is-equal-selections-BF4WJtz5.js → util.is-equal-selections-N1hxVUbE.js} +2 -2
- package/lib/{util.is-equal-selections-BF4WJtz5.js.map → util.is-equal-selections-N1hxVUbE.js.map} +1 -1
- package/lib/{util.slice-blocks-DQnr9X2s.js → util.slice-blocks-B2fZcNok.js} +2 -2
- package/lib/{util.slice-blocks-DQnr9X2s.js.map → util.slice-blocks-B2fZcNok.js.map} +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +3 -3
- package/package.json +3 -3
- package/lib/behavior.types.action-CYtiRDck.d.ts.map +0 -1
- package/lib/behavior.types.behavior-B_77VtQR.js.map +0 -1
- package/lib/get-container-BeXYKpoi.js.map +0 -1
- package/lib/get-parent-51Kzgaf9.js.map +0 -1
- package/lib/get-path-sub-schema--2I4NJbG.js.map +0 -1
- package/lib/selector.is-at-the-start-of-block-gJIMWRpU.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior.types.action-DH6ujvaH.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/schema/resolve-container-at.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/core/operation-channel.ts","../src/engine/interfaces/location.ts","../src/engine/interfaces/path-ref.ts","../src/engine/interfaces/point-ref.ts","../src/engine/interfaces/range-ref.ts","../src/engine/interfaces/editor.ts","../src/engine/dom/utils/diff-text.ts","../src/engine/dom/utils/dom.ts","../src/engine/dom/plugin/dom-editor.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,kBAAkB,eACvC,UACA;EAEA,UAAU;EACV,OAAO,cAAc,eAAe;MAChC,cACJ,eAAe;KAKL,aAAa,kBAAkB,eACzC,UACA;EAEA,UAAU;EACV,OAAO,cAAc,eAAe;MAChC,cACJ,eAAe;;;;;UChEA;EACf;;;;;;KAOU;;;;;;;;;KAUA,gCAAgC,eAAe;;;;;KAM/C,OAAO;;;;;;KAOP,YAAY;;;;;;KAOZ,iBAAiB;;;;;;KAOjB,YAAY;;;;;;;;;;;;KC7BZ;EACV,YAAY;EACZ,UAAU;EACV;EACA,MAAM;EACN,MAAM;EACN;EACA;;;;;;;;;;;;;;EAcA,gBAAgB,OAAO,yBAAyB;;;;;KAKtC,mBAAmB,OAAO,yBAAyB;;;;;;;;;;;KAYnD;EACV,YAAY;EACZ,UAAU;EACV;EACA,MAAM;EACN,MAAM;EACN;EACA;;;;;EAKA,gBA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MAAM;EACnD,wBAAwB;;;;;EAKxB,mBAAmB,UAAU,mBAAmB;;;;;;;;EAQhD,wBAAwB;IACtB;IACA;QACI;EACN,uBAAuB,UAAU,mBAAmB;EACpD,qBAAqB,UAAU,mBAAmB;;;;;EAKlD,iBACE,OACA;IAEA,OAAO,cAAc;IACrB;MACE,SAAS;MACT;MACA;;;;;;;KCrCM;EAEN;EACA,OAAO;;EAGP;EACA,OAAO,sBAAsB,yBAAyB;;EAGtD;EACA,OAAO,yBAAyB;;EAGhC;EACA,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAuBP,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;iBAqBN,QACd,OAAO,yBACN,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCD,QACd,OAAO,sBAAsB,yBAAyB,sBACrD,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* })
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* @
|
|
16
|
+
* @public
|
|
17
17
|
*/
|
|
18
18
|
function execute(event) {
|
|
19
19
|
return {
|
|
@@ -56,7 +56,7 @@ function execute(event) {
|
|
|
56
56
|
* })
|
|
57
57
|
* ```
|
|
58
58
|
*
|
|
59
|
-
* @
|
|
59
|
+
* @public
|
|
60
60
|
*/
|
|
61
61
|
function forward(event) {
|
|
62
62
|
return {
|
|
@@ -95,7 +95,7 @@ function forward(event) {
|
|
|
95
95
|
* })
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
98
|
-
* @
|
|
98
|
+
* @public
|
|
99
99
|
*/
|
|
100
100
|
function raise(event) {
|
|
101
101
|
return {
|
|
@@ -143,7 +143,7 @@ function raise(event) {
|
|
|
143
143
|
* })
|
|
144
144
|
* ```
|
|
145
145
|
*
|
|
146
|
-
* @
|
|
146
|
+
* @public
|
|
147
147
|
*/
|
|
148
148
|
function effect(effect) {
|
|
149
149
|
return {
|
|
@@ -156,4 +156,4 @@ function defineBehavior(behavior) {
|
|
|
156
156
|
}
|
|
157
157
|
export { raise as a, forward as i, effect as n, execute as r, defineBehavior as t };
|
|
158
158
|
|
|
159
|
-
//# sourceMappingURL=behavior.types.behavior-
|
|
159
|
+
//# sourceMappingURL=behavior.types.behavior-BxSLb73I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"behavior.types.behavior-BxSLb73I.js","names":["EditorDom","EditorSnapshot","PickFromUnion","CustomBehaviorEvent","ExternalBehaviorEvent","NativeBehaviorEvent","SyntheticBehaviorEvent","BehaviorAction","type","event","effect","payload","send","execute","forward","raise","BehaviorActionSet","snapshot","TBehaviorEvent","dom","guardResponse","TGuardResponse","Array","BehaviorActionSet","BehaviorEvent","BehaviorEventTypeNamespace","CustomBehaviorEvent","ResolveBehaviorEvent","BehaviorGuard","Behavior","TBehaviorEventType","on","guard","TBehaviorEvent","TGuardResponse","actions","Array","defineBehavior","Record","behavior","TPayload"],"sources":["../src/behaviors/behavior.types.action.ts","../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorDom} from '../editor/editor-dom'\nimport type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n ExternalBehaviorEvent,\n NativeBehaviorEvent,\n SyntheticBehaviorEvent,\n} from './behavior.types.event'\n\n/**\n * @public\n */\nexport type BehaviorAction =\n | {\n type: 'execute'\n event: SyntheticBehaviorEvent\n }\n | {\n type: 'forward'\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'raise'\n event: SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'effect'\n effect: (payload: {\n /**\n * Send a Behavior Event back into the Editor.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: '...',\n * actions: [\n * () => [\n * effect(({send}) => {\n * doSomethingAsync()\n * .then(() => {\n * send({\n * type: '...',\n * })\n * })\n * })\n * ],\n * ],\n * })\n * ```\n */\n send: (event: ExternalBehaviorEvent) => void\n }) => void\n }\n\n/**\n * Directly executes an event, bypassing all Behavior matching.\n *\n * Use `execute` when you want to perform an action without triggering any\n * Behaviors. The event is executed immediately as a direct operation.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: 'insert.text',\n * guard: ({event}) => event.text === 'a',\n * actions: [() => [execute({type: 'insert.text', text: 'b'})]],\n * })\n * ```\n *\n * @public\n */\nexport function execute(\n event: SyntheticBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'execute'> {\n return {type: 'execute', event}\n}\n\n/**\n * Forwards an event to the next Behavior(s) in the current chain.\n *\n * Use `forward` to pass an event to succeeding Behaviors without starting a\n * fresh lookup. This is useful for intercepting events, performing side\n * effects, and then letting the default handling continue.\n *\n * **Key rule:** When forwarding to a different event type, only Behaviors that\n * were already in the remaining chain AND match the new type will run. This\n * means cross-type `forward` is mostly useful for falling through to default\n * Behaviors, not for triggering user-defined Behaviors of a different type.\n *\n * To trigger all Behaviors for a different event type, use {@link raise}\n * instead.\n *\n * @example\n * ```ts\n * // Intercept and forward same event type\n * defineBehavior({\n * on: 'insert.text',\n * actions: [({event}) => [effect(logEvent), forward(event)]],\n * })\n *\n * // Forward to default handling of different event type\n * defineBehavior({\n * on: 'clipboard.paste',\n * actions: [\n * ({event}) => {\n * const text = event.originEvent.dataTransfer?.getData('text/plain')\n * return text ? [forward({type: 'insert.text', text})] : []\n * },\n * ],\n * })\n * ```\n *\n * @public\n */\nexport function forward(\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'forward'> {\n return {type: 'forward', event}\n}\n\n/**\n * Raises an event, triggering a fresh lookup of all Behaviors.\n *\n * Use `raise` when you want to trigger an event \"from scratch\", including all\n * Behaviors that match the event type. This is the appropriate action when you\n * want to trigger Behaviors for a different event type.\n *\n * If no Behavior matches the raised event, synthetic events will fall through\n * to their default operation.\n *\n * @example\n * ```ts\n * // Raise a custom event that triggers other Behaviors\n * defineBehavior({\n * on: 'insert.text',\n * guard: ({event}) => event.text === 'a',\n * actions: [() => [raise({type: 'custom.specialInsert'})]],\n * })\n *\n * // Raise a different event type (fresh lookup includes all Behaviors)\n * defineBehavior({\n * on: 'clipboard.paste',\n * actions: [\n * ({event}) => {\n * const text = event.originEvent.dataTransfer?.getData('text/plain')\n * return text ? [raise({type: 'insert.text', text})] : []\n * },\n * ],\n * })\n * ```\n *\n * @public\n */\nexport function raise(\n event: SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'raise'> {\n return {type: 'raise', event}\n}\n\n/**\n * Performs a side effect.\n *\n * Use `effect` for logging, analytics, async operations, or other side effects.\n *\n * **Note:** Using `effect` alone (without `forward`) will stop event\n * propagation. To perform a side effect while allowing the default Behavior\n * to continue, combine `effect` with `forward`.\n *\n * The effect callback receives a `send` function that can be used to send\n * events back to the editor asynchronously.\n *\n * @example\n * ```ts\n * // Log events while preserving default Behavior\n * defineBehavior({\n * on: 'insert.text',\n * actions: [({event}) => [effect(() => console.log(event)), forward(event)]],\n * })\n *\n * // Effect alone stops propagation (native event is cancelled)\n * defineBehavior({\n * on: 'keyboard.keydown',\n * actions: [() => [effect(() => console.log('key pressed'))]],\n * })\n *\n * // Async effect that sends an event later\n * defineBehavior({\n * on: 'custom.save',\n * actions: [\n * () => [\n * effect(async ({send}) => {\n * await saveDocument()\n * send({type: 'custom.saved'})\n * }),\n * ],\n * ],\n * })\n * ```\n *\n * @public\n */\nexport function effect(\n effect: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect'],\n): PickFromUnion<BehaviorAction, 'type', 'effect'> {\n return {type: 'effect', effect}\n}\n\n/**\n * @public\n */\nexport type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (\n payload: {\n snapshot: EditorSnapshot\n event: TBehaviorEvent\n dom: EditorDom\n },\n guardResponse: TGuardResponse,\n) => Array<BehaviorAction>\n","import type {BehaviorActionSet} from './behavior.types.action'\nimport type {\n BehaviorEvent,\n BehaviorEventTypeNamespace,\n CustomBehaviorEvent,\n ResolveBehaviorEvent,\n} from './behavior.types.event'\nimport type {BehaviorGuard} from './behavior.types.guard'\n\n/**\n * @public\n */\nexport type Behavior<\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] =\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<TBehaviorEventType> =\n ResolveBehaviorEvent<TBehaviorEventType>,\n> = {\n /**\n * Editor Event that triggers this Behavior.\n */\n on: TBehaviorEventType\n /**\n * Predicate function that determines if the Behavior should be executed.\n * Returning a non-nullable value from the guard will pass the value to the\n * actions and execute them.\n */\n guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>\n /**\n * Array of Behavior Action sets.\n * Each set represents a step in the history stack.\n */\n actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>\n}\n\n/**\n * @public\n *\n * @example\n *\n * ```tsx\n * const noLowerCaseA = defineBehavior({\n * on: 'insert.text',\n * guard: ({event, snapshot}) => event.text === 'a',\n * actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],\n * })\n * ```\n *\n */\nexport function defineBehavior<\n TPayload extends Record<string, unknown>,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = CustomBehaviorEvent['type'],\n TGuardResponse = true,\n>(\n behavior: Behavior<\n TBehaviorEventType,\n TGuardResponse,\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>\n >,\n): Behavior\nexport function defineBehavior<\n TPayload extends never = never,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<TBehaviorEventType, TPayload> =\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>,\n>(\n behavior: Behavior<TBehaviorEventType, TGuardResponse, TBehaviorEvent>,\n): Behavior {\n return behavior as unknown as Behavior\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwEA,SAAgBa,QACdJ,OACkD;CAClD,OAAO;EAACD,MAAM;EAAWC;CAAK;AAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgBK,QACdL,OACkD;CAClD,OAAO;EAACD,MAAM;EAAWC;CAAK;AAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgBM,MACdN,OACgD;CAChD,OAAO;EAACD,MAAM;EAASC;CAAK;AAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgBC,OACdA,QACiD;CACjD,OAAO;EAACF,MAAM;EAAUE;CAAM;AAChC;ACzIA,SAAgB2B,eAUdE,UACU;CACV,OAAOA;AACT"}
|
package/lib/behaviors/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
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-DH6ujvaH.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 };
|
package/lib/behaviors/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as raise, i as forward, n as effect, r as execute, t as defineBehavior } from "../behavior.types.behavior-
|
|
1
|
+
import { a as raise, i as forward, n as effect, r as execute, t as defineBehavior } from "../behavior.types.behavior-BxSLb73I.js";
|
|
2
2
|
export { defineBehavior, effect, execute, forward, raise };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as getChildren, r as getNode, u as isKeyedSegment } from "./get-parent-
|
|
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
|
|
1
|
+
import { i as getChildren, r as getNode, u as isKeyedSegment } from "./get-parent-Ci5241qs.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-CZd9VcVM.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);
|
|
@@ -15,7 +15,7 @@ function getAncestor(snapshot, path, options) {
|
|
|
15
15
|
* Returns true for block objects and inline objects that don't have
|
|
16
16
|
* registered editable content (containers).
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
20
|
function isLeafObject(snapshot, node, path) {
|
|
21
21
|
return isObject$1(snapshot, node) && !isEditableContainer(snapshot, node, path);
|
|
@@ -25,7 +25,7 @@ function isLeafObject(snapshot, node, path) {
|
|
|
25
25
|
* start or end edge. A leaf is any node that has no children according to the
|
|
26
26
|
* traversal context.
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @public
|
|
29
29
|
*/
|
|
30
30
|
function getLeaf(snapshot, path, options) {
|
|
31
31
|
let { edge } = options, currentPath = path;
|
|
@@ -59,7 +59,7 @@ function isRange(value) {
|
|
|
59
59
|
/**
|
|
60
60
|
* Get the concatenated text content of the node at a given path.
|
|
61
61
|
*
|
|
62
|
-
* @
|
|
62
|
+
* @public
|
|
63
63
|
*/
|
|
64
64
|
function getText(snapshot, path) {
|
|
65
65
|
let entry = getNode(snapshot, path);
|
|
@@ -72,7 +72,7 @@ function getText(snapshot, path) {
|
|
|
72
72
|
/**
|
|
73
73
|
* Get the span node at a given path.
|
|
74
74
|
*
|
|
75
|
-
* @
|
|
75
|
+
* @public
|
|
76
76
|
*/
|
|
77
77
|
function getSpan(snapshot, path) {
|
|
78
78
|
let entry = getNode(snapshot, path);
|
|
@@ -85,7 +85,7 @@ function getSpan(snapshot, path) {
|
|
|
85
85
|
* Returns true if `ancestor` is equal to `descendant`, or if `descendant`
|
|
86
86
|
* lives anywhere inside `ancestor`'s subtree.
|
|
87
87
|
*
|
|
88
|
-
* @
|
|
88
|
+
* @public
|
|
89
89
|
*/
|
|
90
90
|
function pathContains(ancestor, descendant) {
|
|
91
91
|
if (ancestor.length > descendant.length) return !1;
|
|
@@ -116,7 +116,7 @@ function isBeforePoint(point, another, root) {
|
|
|
116
116
|
*
|
|
117
117
|
* Returns `false` when either `range` or `target` is `null`.
|
|
118
118
|
*
|
|
119
|
-
* @
|
|
119
|
+
* @public
|
|
120
120
|
*/
|
|
121
121
|
function rangeIntersects(snapshot, range, target) {
|
|
122
122
|
if (!range || target === null) return !1;
|
|
@@ -132,7 +132,7 @@ function rangeIntersects(snapshot, range, target) {
|
|
|
132
132
|
/**
|
|
133
133
|
* Get the text block node at a given path.
|
|
134
134
|
*
|
|
135
|
-
* @
|
|
135
|
+
* @public
|
|
136
136
|
*/
|
|
137
137
|
function getTextBlock(snapshot, path) {
|
|
138
138
|
let entry = getNode(snapshot, path);
|
|
@@ -144,7 +144,7 @@ function getTextBlock(snapshot, path) {
|
|
|
144
144
|
/**
|
|
145
145
|
* Get the first child of a node at a given path.
|
|
146
146
|
*
|
|
147
|
-
* @
|
|
147
|
+
* @public
|
|
148
148
|
*/
|
|
149
149
|
function getFirstChild(snapshot, path) {
|
|
150
150
|
return getChildren(snapshot, path).at(0);
|
|
@@ -152,7 +152,7 @@ function getFirstChild(snapshot, path) {
|
|
|
152
152
|
/**
|
|
153
153
|
* Get the last child of a node at a given path.
|
|
154
154
|
*
|
|
155
|
-
* @
|
|
155
|
+
* @public
|
|
156
156
|
*/
|
|
157
157
|
function getLastChild(snapshot, path) {
|
|
158
158
|
return getChildren(snapshot, path).at(-1);
|
|
@@ -179,7 +179,7 @@ function getLastChild(snapshot, path) {
|
|
|
179
179
|
* range) to determine which of the union's members are applicable at the
|
|
180
180
|
* current selection.
|
|
181
181
|
*
|
|
182
|
-
* @
|
|
182
|
+
* @public
|
|
183
183
|
*/
|
|
184
184
|
function getUnionSchema(schema, containers) {
|
|
185
185
|
let decorators = mergeByName(schema.decorators, []), annotations = mergeByName(schema.annotations, []), lists = mergeByName(schema.lists, []), styles = mergeByName(schema.styles, []), inlineObjects = mergeByName(schema.inlineObjects, []), blockObjects = mergeByName(schema.blockObjects, []);
|
|
@@ -208,7 +208,7 @@ function mergeByName(source, target) {
|
|
|
208
208
|
/**
|
|
209
209
|
* Get the registered editable container at a given path.
|
|
210
210
|
*
|
|
211
|
-
* @
|
|
211
|
+
* @public
|
|
212
212
|
*/
|
|
213
213
|
function getContainer(snapshot, path) {
|
|
214
214
|
let entry = getNode(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-
|
|
222
|
+
//# sourceMappingURL=get-container-D1nM_ww9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-container-D1nM_ww9.js","names":["PortableTextBlock","Path","getAncestors","TraversalSnapshot","getAncestor","snapshot","path","options","match","node","TMatch","mode","ancestors","ancestor","reverse","undefined","PortableTextObject","Path","isEditableContainer","isObject","TraversalSnapshot","isLeafObject","snapshot","node","path","Node","Path","getChildren","getNode","TraversalSnapshot","getLeaf","snapshot","path","options","edge","node","currentPath","length","children","undefined","firstOrLast","at","nodeChildren","entry","child","isKeyedSegment","Path","isPath","value","Array","isArray","length","Point","isPath","isObject","isPoint","value","offset","path","Range","isPoint","isObject","isRange","value","anchor","focus","isSpan","Path","getNode","getNodes","TraversalSnapshot","getText","snapshot","path","entry","undefined","schema","context","node","text","descendant","at","isSpan","PortableTextSpan","Path","getNode","TraversalSnapshot","getSpan","snapshot","path","node","entry","undefined","schema","context","Path","isKeyedSegment","pathContains","ancestor","descendant","length","i","segment","otherSegment","_key","Node","Point","comparePoints","isBeforePoint","point","another","root","value","Array","comparePaths","isAfterPoint","isBeforePoint","isPoint","isRange","rangeEdges","EditorSelection","EditorSelectionPoint","Path","comparePoints","TraversalSnapshot","rangeIntersects","snapshot","range","target","root","value","context","anchor","focus","rs","re","ts","te","start","end","isAfterStart","isBeforeEnd","path","isTextBlock","PortableTextTextBlock","Path","getNode","TraversalSnapshot","getTextBlock","snapshot","path","node","entry","undefined","schema","context","Node","Path","getChildren","TraversalSnapshot","getFirstChild","snapshot","path","node","at","Node","Path","getChildren","TraversalSnapshot","getLastChild","snapshot","path","node","children","at","getSubSchema","Schema","Containers","getUnionSchema","schema","containers","decorators","mergeByName","annotations","lists","styles","inlineObjects","blockObjects","container","values","acceptsTextBlock","field","of","block","name","sub","ReadonlyArray","type","blockName","some","member","source","T","target","Array","entry","existing","push","Node","Path","isEditableContainer","getNode","TraversalSnapshot","getContainer","snapshot","path","node","entry","undefined"],"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,SAAgBI,YACdC,UACAC,MACAC,SAImD;CACnD,IAAM,EAACC,OAAOG,OAAO,aAAYJ,SAC3BK,YAAYV,aAAaG,UAAUC,IAAI;CAE7C,IAAIK,SAAS,WAAW;EACtB,KAAK,IAAME,YAAY,CAAC,GAAGD,SAAS,CAAC,CAACE,QAAQ,GAC5C,IAAIN,MAAMK,SAASJ,MAAMI,SAASP,IAAI,GACpC,OAAOO;EAGX;CACF;CAEA,KAAK,IAAMA,YAAYD,WACrB,IAAIJ,MAAMK,SAASJ,MAAMI,SAASP,IAAI,GACpC,OAAOO;AAKb;;;;;;;;;AChDA,SAAgBQ,aACdC,UACAC,MACAC,MAC4B;CAC5B,OAAOL,WAASG,UAAUC,IAAI,KAAK,CAACL,oBAAoBI,UAAUC,MAAMC,IAAI;AAC9E;;;;;;;;ACPA,SAAgBM,QACdC,UACAC,MACAC,SACsC;CACtC,IAAM,EAACC,SAAQD,SAEXG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AAQ,CAAA,CAAE,GACtCC,gBAAgBJ,YAAYH,OAAOO,eAAe,CAAA,CAAE,GACpDC,eAAeL,YAAYH,OAAOQ,cAAc,CAAA,CAAE;CAExD,KAAK,IAAMC,aAAaR,WAAWS,OAAO,GAAG;EAC3C,IAAI,CAACC,iBAAiBF,UAAUG,MAAMC,IAAIb,OAAOc,MAAMC,IAAI,GACzD;EAEF,IAAMC,MAAMpB,aAAaI,QAAQS,UAAUG,MAAMC,EAAE;EAMnDV,AALAA,YAAYa,IAAId,YAAYA,UAAU,GACtCC,YAAYa,IAAIZ,aAAaA,WAAW,GACxCD,YAAYa,IAAIX,OAAOA,KAAK,GAC5BF,YAAYa,IAAIV,QAAQA,MAAM,GAC9BH,YAAYa,IAAIT,eAAeA,aAAa,GAC5CJ,YAAYa,IAAIR,cAAcA,YAAY;CAC5C;CAEA,OAAO;EACL,GAAGR;EACHE;EACAE;EACAC;EACAC;EACAC;EACAC;CACF;AACF;AAEA,SAASG,iBACPE,IACAM,WACS;CACT,OAAON,GAAGO,MACPC,WAAWA,OAAOH,SAAS,WAAWG,OAAOH,SAASC,SACzD;AACF;AAEA,SAAShB,YACPmB,QACAE,QACU;CACV,KAAK,IAAME,SAASJ,QACdE,OAAOJ,MAAMO,aAAaA,SAASZ,SAASW,MAAMX,IAAI,KAG1DS,OAAOI,KAAKF,KAAK;CAEnB,OAAOF;AACT;;;;;;ACpEA,SAAgBU,aACdC,UACAC,MACsC;CACtC,IAAME,QAAQN,QAAQG,UAAUC,IAAI;CAE/BE,aAIAP,oBAAoBI,UAAUG,MAAMD,MAAMC,MAAMF,IAAI,GAIzD,OAAO;EAACC,MAAMC,MAAMD;EAAMD,MAAME,MAAMF;CAAI;AAC5C"}
|
|
@@ -61,7 +61,7 @@ function resolveNodeContainer(containers, parent, node) {
|
|
|
61
61
|
/**
|
|
62
62
|
* Get the children of a node at a given path.
|
|
63
63
|
*
|
|
64
|
-
* @
|
|
64
|
+
* @public
|
|
65
65
|
*/
|
|
66
66
|
function getChildren(snapshot, path) {
|
|
67
67
|
let currentChildren = snapshot.context.value, currentFieldName = "value", currentPath = [], isRoot = !0, currentParent;
|
|
@@ -152,7 +152,7 @@ function getNodeChildren(context, node, parent) {
|
|
|
152
152
|
* it, so `getNode` resolves an annotation path to the enclosing text
|
|
153
153
|
* block. Use `getAnnotation` to resolve the annotation itself.
|
|
154
154
|
*
|
|
155
|
-
* @
|
|
155
|
+
* @public
|
|
156
156
|
*/
|
|
157
157
|
function getNode(snapshot, path) {
|
|
158
158
|
if (path.length === 0) return;
|
|
@@ -234,4 +234,4 @@ function getParent(snapshot, path, options) {
|
|
|
234
234
|
}
|
|
235
235
|
export { getNodeChildren as a, isTypedObject as c, getChildren as i, serializePath as l, parentPath as n, getContainerChildren as o, getNode as r, isRecord as s, getParent as t, isKeyedSegment as u };
|
|
236
236
|
|
|
237
|
-
//# sourceMappingURL=get-parent-
|
|
237
|
+
//# sourceMappingURL=get-parent-Ci5241qs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-parent-Ci5241qs.js","names":["KeyedSegment","isKeyedSegment","segment","Path","isKeyedSegment","serializePath","path","reduce","result","segment","index","_key","separator","TypedObject","isTypedObject","object","isRecord","value","Record","Node","Containers","RegisteredContainer","getContainerChildren","containers","node","parent","children","Array","container","resolved","resolveNodeContainer","undefined","fieldValue","Record","field","name","isArray","of","entry","type","_type","get","isTextBlock","EditorSchema","Node","Path","serializePath","Containers","RegisteredContainer","isTypedObject","isKeyedSegment","getContainerChildren","TraversalSnapshot","getChildren","snapshot","path","Array","node","currentChildren","context","value","currentFieldName","currentPath","isRoot","currentParent","segment","candidatePath","_key","index","blockIndexMap","get","undefined","find","child","at","next","getNodeChildren","children","fieldName","parent","map","schema","containers","result","container","field","name","isArray","Node","Path","serializePath","RegisteredContainer","isKeyedSegment","getNodeChildren","TraversalSnapshot","getNode","snapshot","path","node","length","undefined","context","blockIndexMap","currentChildren","Array","value","currentFieldName","currentParent","resolvedPath","i","segment","push","j","s","index","get","_key","find","child","at","hasMoreSegments","next","children","fieldName","parent","pop","isKeyedSegment","Path","parentPath","path","length","Error","lastNodeIndex","i","result","slice","PortableTextBlock","Path","parentPath","getNode","TraversalSnapshot","getParent","snapshot","path","options","match","node","TMatch","length","undefined","parent","entry","result"],"sources":["../src/utils/util.is-keyed-segment.ts","../src/paths/serialize-path.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 {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 {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 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 * 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 {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: it's fully\n * keyed (numeric indices are converted to `KeyedSegment`s) and any\n * trailing segments in the input that point outside the value tree —\n * e.g. an object node's primitive field, or an annotation reached via\n * `'markDefs'` on a text 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 if (path.length === 0) {\n return undefined\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); return undefined.\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 undefined\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 node = currentChildren.find((child) => child._key === segment._key)\n if (node && node._key !== undefined) {\n resolvedPath[resolvedPath.length - 1] = {_key: node._key}\n }\n }\n } else if (typeof segment === 'number') {\n node = currentChildren.at(segment)\n if (node) {\n resolvedPath.push({_key: node._key})\n }\n } else {\n return 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 currentFieldName = next.fieldName\n currentParent = next.parent\n } else {\n currentFieldName = undefined\n }\n }\n\n if (!node) {\n return undefined\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 {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,SAAgBC,eAAeC,SAA2C;CACxE,OAAO,OAAOA,WAAY,cAAYA,WAAoB,UAAUA;AACtE;;;;;;;;ACGA,SAAgBG,cAAcC,MAAoB;CAChD,OAAOA,KAAKC,QAAgBC,QAAQC,SAASC,UACvCN,eAAeK,OAAO,IACjB,GAAGD,OAAM,UAAWC,QAAQE,KAAI,MAIlC,GAAGH,SADQE,UAAU,IAAI,KAAK,MACND,WAC9B,EAAE;AACP;ACjBA,SAAgBK,cAAcC,QAAwC;CACpE,OAAOC,SAASD,MAAM,KAAK,OAAOA,OAAO,SAAa;AACxD;AAEA,SAAgBC,SAASC,OAAkD;CACzE,OAAO,CAAC,CAACA,UAAU,OAAOA,SAAU,YAAY,OAAOA,SAAU;AACnE;;;;;;;;;;;;;;;;;;ACeA,SAAgBK,qBACdC,YACAC,MACAC,QAMY;CACZ,IAAMI,WAAWC,qBAAqBP,YAAYE,QAAQD,IAAI;CAE9D,IAAI,CAACK,UACH;CAGF,IAAMG,aAAcR,KAAiCK,SAASK,MAAMC;CAE/DR,UAAMS,QAAQJ,UAAU,GAI7B,OAAO;EACLN,UAAUM;EACVJ,WAAWC;CACb;AACF;;;;;;AAOA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,SAAgBoB,WAAWC,MAAkB;CAC3C,IAAIA,KAAKC,WAAW,GAClB,MAAUC,MAAM,gDAAgDF,KAAI,GAAI;CAG1E,IAAIG,gBAAgB;CACpB,KAAK,IAAIC,IAAIJ,KAAKC,SAAS,GAAGG,KAAK,GAAGA,KACpC,IAAIP,eAAeG,KAAKI,EAAE,KAAK,OAAOJ,KAAKI,MAAO,UAAU;EAC1DD,gBAAgBC;EAChB;CACF;CAGF,IAAID,kBAAkB,IACpB,OAAO,CAAA;CAGT,IAAME,SAASL,KAAKM,MAAM,GAAGH,aAAa;CAM1C,OAJIE,OAAOJ,SAAS,KAAK,OAAOI,OAAOA,OAAOJ,SAAS,MAAO,WACrDI,OAAOC,MAAM,GAAG,EAAE,IAGpBD;AACT;ACHA,SAAgBO,UACdC,UACAC,MACAC,SAGmD;CACnD,IAAID,KAAKK,WAAW,GAClB;CAGF,IAAME,SAASZ,WAAWK,IAAI;CAE9B,IAAIO,OAAOF,WAAW,GACpB;CAGF,IAAMG,QAAQZ,QAAQG,UAAUQ,MAAM;CAEtC,IAAI,CAACC,OACH;CAGF,IAAMC,SAAS;EAACN,MAAMK,MAAML;EAA2BH,MAAMQ,MAAMR;CAAI;CAEnEC,eAASC,SAAS,CAACD,QAAQC,MAAMO,OAAON,MAAMM,OAAOT,IAAI,IAI7D,OAAOS;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getNodeChildren, c as isTypedObject, i as getChildren, l as serializePath, n as parentPath, r as getNode, t as getParent, u as isKeyedSegment } from "./get-parent-
|
|
1
|
+
import { a as getNodeChildren, c as isTypedObject, i as getChildren, l as serializePath, n as parentPath, r as getNode, t as getParent, u as isKeyedSegment } from "./get-parent-Ci5241qs.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.
|
|
@@ -14,7 +14,7 @@ import { getSubSchema } from "@portabletext/schema";
|
|
|
14
14
|
* Every ancestor is a `PortableTextBlock`: only text blocks and object
|
|
15
15
|
* nodes can contain children.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
17
|
+
* @public
|
|
18
18
|
*/
|
|
19
19
|
function getAncestors(snapshot, path) {
|
|
20
20
|
let keyedIndices = [];
|
|
@@ -47,7 +47,7 @@ function getAncestors(snapshot, path) {
|
|
|
47
47
|
/**
|
|
48
48
|
* Check if a node exists at a given path.
|
|
49
49
|
*
|
|
50
|
-
* @
|
|
50
|
+
* @public
|
|
51
51
|
*/
|
|
52
52
|
function hasNode(snapshot, path) {
|
|
53
53
|
return getNode(snapshot, path) !== void 0;
|
|
@@ -128,7 +128,7 @@ function isEditableContainer(snapshot, _node, path) {
|
|
|
128
128
|
/**
|
|
129
129
|
* Check if a node is an object node (not a text block or span).
|
|
130
130
|
*
|
|
131
|
-
* @
|
|
131
|
+
* @public
|
|
132
132
|
*/
|
|
133
133
|
function isObject(snapshot, node) {
|
|
134
134
|
return isTypedObject(node) && node._type !== snapshot.context.schema.block.name && node._type !== snapshot.context.schema.span.name;
|
|
@@ -392,7 +392,7 @@ function isSpanNode(context, node) {
|
|
|
392
392
|
* (spans and inline objects) are not blocks. Children of containers are
|
|
393
393
|
* blocks within that container.
|
|
394
394
|
*
|
|
395
|
-
* @
|
|
395
|
+
* @public
|
|
396
396
|
*/
|
|
397
397
|
function isBlock(snapshot, path) {
|
|
398
398
|
let parent = getParent(snapshot, path);
|
|
@@ -404,7 +404,7 @@ function isBlock(snapshot, path) {
|
|
|
404
404
|
* Returns the node narrowed to PortableTextBlock, or undefined if the node
|
|
405
405
|
* doesn't exist or is not a block.
|
|
406
406
|
*
|
|
407
|
-
* @
|
|
407
|
+
* @public
|
|
408
408
|
*/
|
|
409
409
|
function getBlock(snapshot, path) {
|
|
410
410
|
let entry = getNode(snapshot, path);
|
|
@@ -419,7 +419,7 @@ function getBlock(snapshot, path) {
|
|
|
419
419
|
* A node is inline if its parent is a text block. This is the inverse of
|
|
420
420
|
* `isBlock`. Top-level nodes are never inline.
|
|
421
421
|
*
|
|
422
|
-
* @
|
|
422
|
+
* @public
|
|
423
423
|
*/
|
|
424
424
|
function isInline(snapshot, path) {
|
|
425
425
|
return !isBlock(snapshot, path);
|
|
@@ -446,7 +446,7 @@ function getEnclosingBlock(snapshot, path, options) {
|
|
|
446
446
|
* Compares the two points by document order, resolved at any depth. When
|
|
447
447
|
* the paths are equal, compares offsets.
|
|
448
448
|
*
|
|
449
|
-
* @
|
|
449
|
+
* @public
|
|
450
450
|
*/
|
|
451
451
|
function comparePoints(snapshot, pointA, pointB) {
|
|
452
452
|
let pathComparison = comparePaths(pointA.path, pointB.path, { value: snapshot.context.value });
|
|
@@ -502,7 +502,7 @@ function getEnclosingContainer(snapshot, path) {
|
|
|
502
502
|
* container, walks ancestors to find the nearest container and returns the
|
|
503
503
|
* sub-schema derived from its `of` declaration.
|
|
504
504
|
*
|
|
505
|
-
* @
|
|
505
|
+
* @public
|
|
506
506
|
*/
|
|
507
507
|
function getPathSubSchema(snapshot, path) {
|
|
508
508
|
let enclosing = getEnclosingContainer(snapshot, path);
|
|
@@ -510,4 +510,4 @@ function getPathSubSchema(snapshot, path) {
|
|
|
510
510
|
}
|
|
511
511
|
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
512
|
|
|
513
|
-
//# sourceMappingURL=get-path-sub-schema
|
|
513
|
+
//# sourceMappingURL=get-path-sub-schema-CZd9VcVM.js.map
|