@portabletext/editor 7.9.0 → 7.10.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/lib/_chunks-dts/behavior.types.action.d.ts +110 -274
- package/lib/_chunks-dts/behavior.types.action.d.ts.map +1 -1
- package/lib/_chunks-dts/block-offset.d.ts +10 -0
- package/lib/_chunks-dts/block-offset.d.ts.map +1 -0
- package/lib/_chunks-dts/editor-selector.d.ts +33 -0
- package/lib/_chunks-dts/editor-selector.d.ts.map +1 -0
- package/lib/_chunks-dts/editor.d.ts +99 -0
- package/lib/_chunks-dts/editor.d.ts.map +1 -0
- package/lib/_chunks-es/{get-first-child.js → get-container.js} +10 -1
- package/lib/_chunks-es/get-container.js.map +1 -0
- package/lib/_chunks-es/get-path-sub-schema.js +38 -6
- package/lib/_chunks-es/get-path-sub-schema.js.map +1 -1
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js +3 -0
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/_chunks-es/{util.is-empty-text-block.js → util.is-equal-selections.js} +7 -2
- package/lib/_chunks-es/util.is-equal-selections.js.map +1 -0
- package/lib/_chunks-es/util.slice-blocks.js +1 -8
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/behaviors/index.d.ts +1 -1
- package/lib/index.d.ts +67 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +282 -106
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +2 -1
- package/lib/plugins/index.d.ts.map +1 -1
- package/lib/selectors/index.d.ts +3 -1
- package/lib/selectors/index.d.ts.map +1 -1
- package/lib/selectors/index.js +4 -2
- package/lib/selectors/index.js.map +1 -1
- package/lib/traversal/index.d.ts +11 -2
- package/lib/traversal/index.d.ts.map +1 -1
- package/lib/traversal/index.js +3 -2
- package/lib/utils/index.d.ts +3 -3
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +3 -6
- package/lib/utils/index.js.map +1 -1
- package/package.json +20 -20
- package/lib/_chunks-es/get-first-child.js.map +0 -1
- package/lib/_chunks-es/util.is-empty-text-block.js.map +0 -1
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bt as RegistrableNode, g as EditorEmittedEvent, y as Behavior } from "../_chunks-dts/behavior.types.action.js";
|
|
2
|
+
import { t as Editor } from "../_chunks-dts/editor.js";
|
|
2
3
|
import React from "react";
|
|
3
4
|
/**
|
|
4
5
|
* @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/plugin.behavior.tsx","../../src/plugins/plugin.node.tsx","../../src/plugins/plugin.editor-ref.tsx","../../src/plugins/plugin.event-listener.tsx"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/plugins/plugin.behavior.tsx","../../src/plugins/plugin.node.tsx","../../src/plugins/plugin.editor-ref.tsx","../../src/plugins/plugin.event-listener.tsx"],"mappings":";;;;;;AAcA;;;;;;;iBAAgB,cAAA,CAAe,KAAA;EAAQ,SAAA,EAAW,KAAK,CAAC,QAAA;AAAA;;;;AAAxD;;;;;;;;;iBCEgB,UAAA,CAAW,KAAA;EAAQ,KAAA,EAAO,KAAK,CAAC,eAAA;AAAA;;;ADFhD;cEPa,eAAA,EAAe,KAAA,CAAA,yBAAA,CAAA,KAAA,CAAA,aAAA,CAAA,MAAA;;;;AFO5B;;;;;;;;;AAAkE;;ACElE;;;;;;;;;AAAiE;;ACTjE;;;;;;;;;;;;;;AAA4B;;AC8C5B;;;;;;;;iBAAgB,mBAAA,CAAoB,KAAA;EAClC,EAAA,GAAK,KAAA,EAAO,kBAAkB;AAAA"}
|
package/lib/selectors/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { It as Path, M as EditorSelection, N as EditorSelectionPoint, Nt as BlockPath, Pt as ChildPath } from "../_chunks-dts/behavior.types.action.js";
|
|
2
|
+
import { t as EditorSelector } from "../_chunks-dts/editor-selector.js";
|
|
3
|
+
import { t as BlockOffset } from "../_chunks-dts/block-offset.js";
|
|
2
4
|
import { PortableTextBlock, PortableTextListBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock } from "@portabletext/schema";
|
|
3
5
|
/**
|
|
4
6
|
* The set of schema member names applicable at the current selection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/selectors/selector.get-applicable-schema.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-anchor-block.ts","../../src/selectors/selector.get-anchor-child.ts","../../src/selectors/selector.get-anchor-span.ts","../../src/selectors/selector.get-anchor-text-block.ts","../../src/selectors/selector.get-block-offsets.ts","../../src/selectors/selector.get-caret-word-selection.ts","../../src/selectors/selector.get-first-block.ts","../../src/selectors/selector.get-focus-block.ts","../../src/selectors/selector.get-focus-block-object.ts","../../src/selectors/selector.get-focus-child.ts","../../src/selectors/selector.get-focus-inline-object.ts","../../src/selectors/selector.get-focus-list-block.ts","../../src/selectors/selector.get-focus-span.ts","../../src/selectors/selector.get-focus-text-block.ts","../../src/selectors/selector.get-fragment.ts","../../src/selectors/selector.get-last-block.ts","../../src/selectors/selector.get-mark-state.ts","../../src/selectors/selector.get-next-block.ts","../../src/selectors/selector.get-next-inline-object.ts","../../src/selectors/selector.get-next-inline-objects.ts","../../src/selectors/selector.get-next-span.ts","../../src/selectors/selector.get-previous-block.ts","../../src/selectors/selector.get-previous-inline-object.ts","../../src/selectors/selector.get-previous-inline-objects.ts","../../src/selectors/selector.get-previous-span.ts","../../src/selectors/selector.get-selected-blocks.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-selected-text-blocks.ts","../../src/selectors/selector.get-selected-value.ts","../../src/selectors/selector.get-selection.ts","../../src/selectors/selector.get-selection-end-block.ts","../../src/selectors/selector.get-selection-end-child.ts","../../src/selectors/selector.get-selection-end-point.ts","../../src/selectors/selector.get-selection-start-block.ts","../../src/selectors/selector.get-selection-start-child.ts","../../src/selectors/selector.get-selection-start-point.ts","../../src/selectors/selector.get-selection-text.ts","../../src/selectors/selector.get-text-after.ts","../../src/selectors/selector.get-text-before.ts","../../src/selectors/selector.get-value.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts","../../src/selectors/selector.is-at-the-end-of-block.ts","../../src/selectors/selector.is-at-the-start-of-block.ts","../../src/selectors/selector.is-overlapping-selection.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts","../../src/selectors/selector.is-selecting-entire-blocks.ts","../../src/selectors/selector.is-selection-collapsed.ts","../../src/selectors/selector.is-selection-expanded.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/selectors/selector.get-applicable-schema.ts","../../src/selectors/selector.get-active-annotations.ts","../../src/selectors/selector.get-active-list-item.ts","../../src/selectors/selector.get-active-style.ts","../../src/selectors/selector.get-anchor-block.ts","../../src/selectors/selector.get-anchor-child.ts","../../src/selectors/selector.get-anchor-span.ts","../../src/selectors/selector.get-anchor-text-block.ts","../../src/selectors/selector.get-block-offsets.ts","../../src/selectors/selector.get-caret-word-selection.ts","../../src/selectors/selector.get-first-block.ts","../../src/selectors/selector.get-focus-block.ts","../../src/selectors/selector.get-focus-block-object.ts","../../src/selectors/selector.get-focus-child.ts","../../src/selectors/selector.get-focus-inline-object.ts","../../src/selectors/selector.get-focus-list-block.ts","../../src/selectors/selector.get-focus-span.ts","../../src/selectors/selector.get-focus-text-block.ts","../../src/selectors/selector.get-fragment.ts","../../src/selectors/selector.get-last-block.ts","../../src/selectors/selector.get-mark-state.ts","../../src/selectors/selector.get-next-block.ts","../../src/selectors/selector.get-next-inline-object.ts","../../src/selectors/selector.get-next-inline-objects.ts","../../src/selectors/selector.get-next-span.ts","../../src/selectors/selector.get-previous-block.ts","../../src/selectors/selector.get-previous-inline-object.ts","../../src/selectors/selector.get-previous-inline-objects.ts","../../src/selectors/selector.get-previous-span.ts","../../src/selectors/selector.get-selected-blocks.ts","../../src/selectors/selector.get-selected-spans.ts","../../src/selectors/selector.get-selected-text-blocks.ts","../../src/selectors/selector.get-selected-value.ts","../../src/selectors/selector.get-selection.ts","../../src/selectors/selector.get-selection-end-block.ts","../../src/selectors/selector.get-selection-end-child.ts","../../src/selectors/selector.get-selection-end-point.ts","../../src/selectors/selector.get-selection-start-block.ts","../../src/selectors/selector.get-selection-start-child.ts","../../src/selectors/selector.get-selection-start-point.ts","../../src/selectors/selector.get-selection-text.ts","../../src/selectors/selector.get-text-after.ts","../../src/selectors/selector.get-text-before.ts","../../src/selectors/selector.get-value.ts","../../src/selectors/selector.is-active-annotation.ts","../../src/selectors/selector.is-active-decorator.ts","../../src/selectors/selector.is-active-list-item.ts","../../src/selectors/selector.is-active-style.ts","../../src/selectors/selector.is-at-the-end-of-block.ts","../../src/selectors/selector.is-at-the-start-of-block.ts","../../src/selectors/selector.is-overlapping-selection.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts","../../src/selectors/selector.is-selecting-entire-blocks.ts","../../src/selectors/selector.is-selection-collapsed.ts","../../src/selectors/selector.is-selection-expanded.ts"],"mappings":";;;;;;;;AAWA;;KAAY,gBAAA;EACV,UAAA,EAAY,WAAA;EACZ,WAAA,EAAa,WAAA;EACb,KAAA,EAAO,WAAA;EACP,MAAA,EAAQ,WAAA;EACR,YAAA,EAAc,WAAA;EACd,aAAA,EAAe,WAAA;AAAA;;;;;;;;;;;;;;;AAAW;AAsC5B;;;;AAAiE;AAuDjE;;;;;;;;;AAEqB;;ACvGrB;;;;cD8Ca,mBAAA,EAAqB,cAAc,CAAC,gBAAA;;;;;;;;AC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AAAA;;;;cCTC,sBAAA,EAAwB,cAAc,CACjD,oBAAA;;;;cCIW,gBAAA,EAAkB,cAAc;;;;cCFhC,iBAAA,EAAmB,cAAc;;;;cCAjC,kBAAA,EAAoB,cAAc;;;;cCHlC,QAAA,EAAU,cAAA,CAAe,KAAA,CAAM,iBAAA;;;;;A3CK5C;iB4CAgB,kBAAA,CACd,UAAA,UACA,OAAA;;;;;;;EAOE,IAAA;AAAA,IAED,cAAc;;;;iBCbD,iBAAA,CAAkB,SAAA,WAAoB,cAAc;;;;iBCHpD,gBAAA,CAAiB,QAAA,WAAmB,cAAc;;;;iBCAlD,aAAA,CAAc,KAAA,WAAgB,cAAc;;;A/CK5D;iBgDDgB,iBAAA,CAAkB,KAAA;EAChC,IAAA,EAAM,iBAAA;EACN,IAAA,EAAM,SAAA;AAAA,IACJ,cAAA;;;AhDFJ;iBiDDgB,mBAAA,CAAoB,KAAA;EAClC,IAAA,EAAM,iBAAA;EACN,IAAA,EAAM,SAAA;AAAA,IACJ,cAAA;;;;AjDFJ;;;;;;iBkDGgB,sBAAA,CACd,SAAA,EAAW,eAAA,GACV,cAAc;;;;iBCRD,qBAAA,CACd,KAAA,EAAO,oBAAA,GACN,cAAc;;;;iBCFD,sBAAA,CACd,KAAA,EAAO,oBAAA,GACN,cAAc;;;;cCAJ,uBAAA,EAAyB,cAAc;;;;cCJvC,oBAAA,EAAsB,cAAc;;;;cCApC,mBAAA,EAAqB,cAAc"}
|
package/lib/selectors/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { getInline, getSelectionStartPoint, getSelectionEndPoint, getFocusTextBl
|
|
|
2
2
|
import { compareApplicableSchema, getActiveAnnotations, getActiveListItem, getActiveStyle, getApplicableSchema, getCaretWordSelection, getFirstBlock, getFocusBlock, getFocusBlockObject, getFocusChild, getFocusInlineObject, getFocusListBlock, getFocusSpan, getFragment, getLastBlock, getMarkState, getNextBlock, getNextInlineObject, getNextSpan, getPreviousBlock, getPreviousInlineObject, getPreviousSpan, getSelectedBlocks, getSelectedSpans, getSelectedTextBlocks, getSelectedValue, getSelectionEndBlock, getSelectionEndChild, getSelectionStartBlock, getSelectionStartChild, isActiveAnnotation, isActiveDecorator, isActiveListItem, isActiveStyle, isAtTheEndOfBlock, isAtTheStartOfBlock, isOverlappingSelection, isSelectingEntireBlocks, isSelectionCollapsed, isSelectionExpanded } from "../_chunks-es/selector.is-at-the-start-of-block.js";
|
|
3
3
|
import { getEnclosingBlock, isObject, comparePoints } from "../_chunks-es/get-path-sub-schema.js";
|
|
4
4
|
import { isSpan, isTextBlock } from "@portabletext/schema";
|
|
5
|
-
import { spanSelectionPointToBlockOffset,
|
|
6
|
-
import { getChildren, parentPath
|
|
5
|
+
import { spanSelectionPointToBlockOffset, getSelectionEndPoint as getSelectionEndPoint$1, getBlockEndPoint, getSelectionStartPoint as getSelectionStartPoint$1, getBlockStartPoint } from "../_chunks-es/util.slice-blocks.js";
|
|
6
|
+
import { isKeyedSegment, getChildren, parentPath } from "../_chunks-es/get-parent.js";
|
|
7
7
|
const getAnchorBlock = (snapshot) => {
|
|
8
8
|
const selection = snapshot.context.selection;
|
|
9
9
|
if (selection)
|
|
@@ -100,6 +100,7 @@ const getAnchorBlock = (snapshot) => {
|
|
|
100
100
|
block
|
|
101
101
|
});
|
|
102
102
|
return getSelectionText({
|
|
103
|
+
...snapshot,
|
|
103
104
|
context: {
|
|
104
105
|
...snapshot.context,
|
|
105
106
|
selection: {
|
|
@@ -128,6 +129,7 @@ const getAnchorBlock = (snapshot) => {
|
|
|
128
129
|
block
|
|
129
130
|
});
|
|
130
131
|
return getSelectionText({
|
|
132
|
+
...snapshot,
|
|
131
133
|
context: {
|
|
132
134
|
...snapshot.context,
|
|
133
135
|
selection: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/selectors/selector.get-anchor-block.ts","../../src/selectors/selector.get-anchor-child.ts","../../src/selectors/selector.get-anchor-span.ts","../../src/selectors/selector.get-anchor-text-block.ts","../../src/selectors/selector.get-block-offsets.ts","../../src/selectors/selector.get-next-inline-objects.ts","../../src/selectors/selector.get-previous-inline-objects.ts","../../src/selectors/selector.get-selection.ts","../../src/selectors/selector.get-text-after.ts","../../src/selectors/selector.get-text-before.ts","../../src/selectors/selector.get-value.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getEnclosingBlock} from '../traversal/get-enclosing-block'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * Returns the block containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return undefined\n }\n\n return getEnclosingBlock(snapshot, selection.anchor.path)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getInline} from '../traversal/get-inline'\nimport type {ChildPath} from '../types/paths'\n\n/**\n * Returns the child (span or inline object) containing the anchor selection,\n * resolved at any depth.\n *\n * @public\n */\nexport const getAnchorChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return undefined\n }\n\n return getInline(snapshot, selection.anchor.path)\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getAnchorChild} from './selector.get-anchor-child'\n\n/**\n * Returns the span containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const anchorChild = getAnchorChild(snapshot)\n\n return anchorChild && isSpan(snapshot.context, anchorChild.node)\n ? {node: anchorChild.node, path: anchorChild.path}\n : undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getAnchorBlock} from './selector.get-anchor-block'\n\n/**\n * Returns the text block containing the anchor selection, resolved at any\n * depth.\n *\n * @public\n */\nexport const getAnchorTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const anchorBlock = getAnchorBlock(snapshot)\n\n return anchorBlock && isTextBlock(snapshot.context, anchorBlock.node)\n ? {node: anchorBlock.node, path: anchorBlock.path}\n : undefined\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getBlockOffsets: EditorSelector<\n {start: BlockOffset; end: BlockOffset} | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (!selectionStartPoint || !selectionEndPoint) {\n return undefined\n }\n\n const start = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionStartPoint,\n })\n const end = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionEndPoint,\n })\n\n return start && end ? {start, end} : undefined\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../traversal/get-children'\nimport {isObject} from '../traversal/is-object'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * Returns all inline objects after the selection end within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getNextInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionEndPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const endSegment = point.path.at(-1)\n const endKey = isKeyedSegment(endSegment) ? endSegment._key : undefined\n\n if (!endKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n let endFound = false\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === endKey) {\n endFound = true\n continue\n }\n\n if (endFound && isObject(snapshot, child.node)) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../traversal/get-children'\nimport {isObject} from '../traversal/is-object'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * Returns all inline objects before the selection start within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getPreviousInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionStartPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const startSegment = point.path.at(-1)\n const startKey = isKeyedSegment(startSegment) ? startSegment._key : undefined\n\n if (!startKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === startKey) {\n break\n }\n\n if (isObject(snapshot, child.node)) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport const getSelection: EditorSelector<EditorSelection> = (snapshot) => {\n return snapshot.context.selection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextAfter: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const endOfBlock = getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endOfBlock,\n },\n },\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: startPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n return snapshot.context.value\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {comparePoints} from '../traversal/compare-points'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, endPoint) === 1\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {comparePoints} from '../traversal/compare-points'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, startPoint) === -1\n }\n}\n"],"names":["getAnchorBlock","snapshot","selection","context","getEnclosingBlock","anchor","path","getAnchorChild","getInline","getAnchorSpan","anchorChild","isSpan","node","undefined","getAnchorTextBlock","anchorBlock","isTextBlock","getBlockOffsets","selectionStartPoint","getSelectionStartPoint","selectionEndPoint","getSelectionEndPoint","start","spanSelectionPointToBlockOffset","selectionPoint","end","getNextInlineObjects","point","endSegment","at","endKey","isKeyedSegment","_key","children","getChildren","parentPath","inlineObjects","endFound","child","segment","isObject","push","getPreviousInlineObjects","startSegment","startKey","getSelection","getBlockTextAfter","endPoint","block","getFocusTextBlock","focus","endOfBlock","getBlockEndPoint","getSelectionText","getBlockTextBefore","startPoint","startOfBlock","getBlockStartPoint","getValue","value","is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AAAAA,MACZD,WAAW;AAAA,QACTG,QAAQmD;AAAAA,QACRN,OAAOK;AAAAA,MAAAA;AAAAA,IACT;AAAA,EACF,CACD;AACH,GCvCaG,WACXzD,CAAAA,aAEOA,SAASE,QAAQwD;ACDnB,SAASC,sBACdjC,OACyB;AACzB,SAAQ1B,CAAAA,aAAa;AACnB,QAAI,CAACA,SAASE,QAAQD;AACpB,aAAO;AAGT,UAAM6C,WAAW1B,uBAAqBpB,SAASE,QAAQD,SAAS;AAEhE,WAAO2D,cAAc5D,UAAU0B,OAAOoB,QAAQ,MAAM;AAAA,EACtD;AACF;ACZO,SAASe,uBACdnC,OACyB;AACzB,SAAQ1B,CAAAA,aAAa;AACnB,QAAI,CAACA,SAASE,QAAQD;AACpB,aAAO;AAGT,UAAMqD,aAAapC,yBAAuBlB,SAASE,QAAQD,SAAS;AAEpE,WAAO2D,cAAc5D,UAAU0B,OAAO4B,UAAU,MAAM;AAAA,EACxD;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/selectors/selector.get-anchor-block.ts","../../src/selectors/selector.get-anchor-child.ts","../../src/selectors/selector.get-anchor-span.ts","../../src/selectors/selector.get-anchor-text-block.ts","../../src/selectors/selector.get-block-offsets.ts","../../src/selectors/selector.get-next-inline-objects.ts","../../src/selectors/selector.get-previous-inline-objects.ts","../../src/selectors/selector.get-selection.ts","../../src/selectors/selector.get-text-after.ts","../../src/selectors/selector.get-text-before.ts","../../src/selectors/selector.get-value.ts","../../src/selectors/selector.is-point-after-selection.ts","../../src/selectors/selector.is-point-before-selection.ts"],"sourcesContent":["import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getEnclosingBlock} from '../traversal/get-enclosing-block'\nimport type {BlockPath} from '../types/paths'\n\n/**\n * Returns the block containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorBlock: EditorSelector<\n {node: PortableTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return undefined\n }\n\n return getEnclosingBlock(snapshot, selection.anchor.path)\n}\n","import type {PortableTextObject, PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {getInline} from '../traversal/get-inline'\nimport type {ChildPath} from '../types/paths'\n\n/**\n * Returns the child (span or inline object) containing the anchor selection,\n * resolved at any depth.\n *\n * @public\n */\nexport const getAnchorChild: EditorSelector<\n | {\n node: PortableTextObject | PortableTextSpan\n path: ChildPath\n }\n | undefined\n> = (snapshot) => {\n const selection = snapshot.context.selection\n\n if (!selection) {\n return undefined\n }\n\n return getInline(snapshot, selection.anchor.path)\n}\n","import {isSpan, type PortableTextSpan} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {ChildPath} from '../types/paths'\nimport {getAnchorChild} from './selector.get-anchor-child'\n\n/**\n * Returns the span containing the anchor selection, resolved at any depth.\n *\n * @public\n */\nexport const getAnchorSpan: EditorSelector<\n {node: PortableTextSpan; path: ChildPath} | undefined\n> = (snapshot) => {\n const anchorChild = getAnchorChild(snapshot)\n\n return anchorChild && isSpan(snapshot.context, anchorChild.node)\n ? {node: anchorChild.node, path: anchorChild.path}\n : undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockPath} from '../types/paths'\nimport {getAnchorBlock} from './selector.get-anchor-block'\n\n/**\n * Returns the text block containing the anchor selection, resolved at any\n * depth.\n *\n * @public\n */\nexport const getAnchorTextBlock: EditorSelector<\n {node: PortableTextTextBlock; path: BlockPath} | undefined\n> = (snapshot) => {\n const anchorBlock = getAnchorBlock(snapshot)\n\n return anchorBlock && isTextBlock(snapshot.context, anchorBlock.node)\n ? {node: anchorBlock.node, path: anchorBlock.path}\n : undefined\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {BlockOffset} from '../types/block-offset'\nimport {spanSelectionPointToBlockOffset} from '../utils/util.block-offset'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * @public\n */\nexport const getBlockOffsets: EditorSelector<\n {start: BlockOffset; end: BlockOffset} | undefined\n> = (snapshot) => {\n if (!snapshot.context.selection) {\n return undefined\n }\n\n const selectionStartPoint = getSelectionStartPoint(snapshot)\n const selectionEndPoint = getSelectionEndPoint(snapshot)\n\n if (!selectionStartPoint || !selectionEndPoint) {\n return undefined\n }\n\n const start = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionStartPoint,\n })\n const end = spanSelectionPointToBlockOffset({\n snapshot,\n selectionPoint: selectionEndPoint,\n })\n\n return start && end ? {start, end} : undefined\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../traversal/get-children'\nimport {isObject} from '../traversal/is-object'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionEndPoint} from './selector.get-selection-end-point'\n\n/**\n * Returns all inline objects after the selection end within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getNextInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionEndPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const endSegment = point.path.at(-1)\n const endKey = isKeyedSegment(endSegment) ? endSegment._key : undefined\n\n if (!endKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n let endFound = false\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === endKey) {\n endFound = true\n continue\n }\n\n if (endFound && isObject(snapshot, child.node)) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {PortableTextObject} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\nimport {parentPath} from '../engine/path/parent-path'\nimport {getChildren} from '../traversal/get-children'\nimport {isObject} from '../traversal/is-object'\nimport type {ChildPath} from '../types/paths'\nimport {isKeyedSegment} from '../utils/util.is-keyed-segment'\nimport {getSelectionStartPoint} from './selector.get-selection-start-point'\n\n/**\n * Returns all inline objects before the selection start within the same text\n * block, resolved at any depth.\n *\n * @public\n */\nexport const getPreviousInlineObjects: EditorSelector<\n Array<{node: PortableTextObject; path: ChildPath}>\n> = (snapshot) => {\n const point = getSelectionStartPoint(snapshot)\n\n if (!point) {\n return []\n }\n\n const startSegment = point.path.at(-1)\n const startKey = isKeyedSegment(startSegment) ? startSegment._key : undefined\n\n if (!startKey) {\n return []\n }\n\n const children = getChildren(snapshot, parentPath(point.path))\n const inlineObjects: Array<{node: PortableTextObject; path: ChildPath}> = []\n\n for (const child of children) {\n const segment = child.path.at(-1)\n const childKey = isKeyedSegment(segment) ? segment._key : undefined\n\n if (childKey === startKey) {\n break\n }\n\n if (isObject(snapshot, child.node)) {\n inlineObjects.push({\n node: child.node,\n path: child.path,\n })\n }\n }\n\n return inlineObjects\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport const getSelection: EditorSelector<EditorSelection> = (snapshot) => {\n return snapshot.context.selection\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockEndPoint} from '../utils/util.get-block-end-point'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextAfter: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const endOfBlock = getBlockEndPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: endPoint,\n focus: endOfBlock,\n },\n },\n })\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {getBlockStartPoint} from '../utils/util.get-block-start-point'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\nimport {getFocusTextBlock} from './selector.get-focus-text-block'\nimport {getSelectionText} from './selector.get-selection-text'\n\n/**\n * @public\n */\nexport const getBlockTextBefore: EditorSelector<string> = (snapshot) => {\n if (!snapshot.context.selection) {\n return ''\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n const block = getFocusTextBlock({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startPoint,\n focus: startPoint,\n },\n },\n })\n\n if (!block) {\n return ''\n }\n\n const startOfBlock = getBlockStartPoint({\n context: snapshot.context,\n block,\n })\n\n return getSelectionText({\n ...snapshot,\n context: {\n ...snapshot.context,\n selection: {\n anchor: startOfBlock,\n focus: startPoint,\n },\n },\n })\n}\n","import type {PortableTextBlock} from '@portabletext/schema'\nimport type {EditorSelector} from '../editor/editor-selector'\n\n/**\n * @public\n */\nexport const getValue: EditorSelector<Array<PortableTextBlock>> = (\n snapshot,\n) => {\n return snapshot.context.value\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {comparePoints} from '../traversal/compare-points'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionEndPoint} from '../utils/util.get-selection-end-point'\n\n/**\n * @public\n */\nexport function isPointAfterSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const endPoint = getSelectionEndPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, endPoint) === 1\n }\n}\n","import type {EditorSelector} from '../editor/editor-selector'\nimport {comparePoints} from '../traversal/compare-points'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {getSelectionStartPoint} from '../utils/util.get-selection-start-point'\n\n/**\n * @public\n */\nexport function isPointBeforeSelection(\n point: EditorSelectionPoint,\n): EditorSelector<boolean> {\n return (snapshot) => {\n if (!snapshot.context.selection) {\n return false\n }\n\n const startPoint = getSelectionStartPoint(snapshot.context.selection)\n\n return comparePoints(snapshot, point, startPoint) === -1\n }\n}\n"],"names":["getAnchorBlock","snapshot","selection","context","getEnclosingBlock","anchor","path","getAnchorChild","getInline","getAnchorSpan","anchorChild","isSpan","node","undefined","getAnchorTextBlock","anchorBlock","isTextBlock","getBlockOffsets","selectionStartPoint","getSelectionStartPoint","selectionEndPoint","getSelectionEndPoint","start","spanSelectionPointToBlockOffset","selectionPoint","end","getNextInlineObjects","point","endSegment","at","endKey","isKeyedSegment","_key","children","getChildren","parentPath","inlineObjects","endFound","child","segment","isObject","push","getPreviousInlineObjects","startSegment","startKey","getSelection","getBlockTextAfter","endPoint","block","getFocusTextBlock","focus","endOfBlock","getBlockEndPoint","getSelectionText","getBlockTextBefore","startPoint","startOfBlock","getBlockStartPoint","getValue","value","isPointAfterSelection","comparePoints","isPointBeforeSelection"],"mappings":";;;;;;AAUO,MAAMA,iBAERC,CAAAA,aAAa;AAChB,QAAMC,YAAYD,SAASE,QAAQD;AAEnC,MAAKA;AAIL,WAAOE,kBAAkBH,UAAUC,UAAUG,OAAOC,IAAI;AAC1D,GCTaC,iBAMRN,CAAAA,aAAa;AAChB,QAAMC,YAAYD,SAASE,QAAQD;AAEnC,MAAKA;AAIL,WAAOM,UAAUP,UAAUC,UAAUG,OAAOC,IAAI;AAClD,GCfaG,gBAERR,CAAAA,aAAa;AAChB,QAAMS,cAAcH,eAAeN,QAAQ;AAE3C,SAAOS,eAAeC,OAAOV,SAASE,SAASO,YAAYE,IAAI,IAC3D;AAAA,IAACA,MAAMF,YAAYE;AAAAA,IAAMN,MAAMI,YAAYJ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QD;AACpB,aAAO;AAGT,UAAMqD,aAAapC,yBAAuBlB,SAASE,QAAQD,SAAS;AAEpE,WAAO2D,cAAc5D,UAAU0B,OAAO4B,UAAU,MAAM;AAAA,EACxD;AACF;"}
|
package/lib/traversal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { It as
|
|
1
|
+
import { It as Path, M as EditorSelection, N as EditorSelectionPoint, at as Containers, nt as TraversalSnapshot, rt as Node, st as RegisteredContainer } from "../_chunks-dts/behavior.types.action.js";
|
|
2
2
|
import { PortableTextBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock, Schema } from "@portabletext/schema";
|
|
3
3
|
/**
|
|
4
4
|
* Find an ancestor of the node at a given path that matches a predicate.
|
|
@@ -95,6 +95,15 @@ declare function getChildren(snapshot: TraversalSnapshot, path: Path): Array<{
|
|
|
95
95
|
node: Node;
|
|
96
96
|
path: Path;
|
|
97
97
|
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Get the registered editable container at a given path.
|
|
100
|
+
*
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
declare function getContainer(snapshot: TraversalSnapshot, path: Path): {
|
|
104
|
+
node: Node;
|
|
105
|
+
path: Path;
|
|
106
|
+
} | undefined;
|
|
98
107
|
/**
|
|
99
108
|
* Resolve a container node's editable child array.
|
|
100
109
|
*
|
|
@@ -392,5 +401,5 @@ declare function isLeafObject(snapshot: TraversalSnapshot, node: unknown, path:
|
|
|
392
401
|
* @beta
|
|
393
402
|
*/
|
|
394
403
|
declare function isObject(snapshot: TraversalSnapshot, node: unknown): node is PortableTextObject;
|
|
395
|
-
export { comparePoints, getAncestor, getAncestors, getAnnotation, getBlock, getChildren, getContainerChildren, getEnclosingBlock, getFirstChild, getLastChild, getLeaf, getNode, getParent, getPathSubSchema, getSibling, getSpan, getText, getTextBlock, getUnionSchema, hasNode, isBlock, isInline, isLeafObject, isObject, pathContains, rangeIntersects };
|
|
404
|
+
export { comparePoints, getAncestor, getAncestors, getAnnotation, getBlock, getChildren, getContainer, getContainerChildren, getEnclosingBlock, getFirstChild, getLastChild, getLeaf, getNode, getParent, getPathSubSchema, getSibling, getSpan, getText, getTextBlock, getUnionSchema, hasNode, isBlock, isInline, isLeafObject, isObject, pathContains, rangeIntersects };
|
|
396
405
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/traversal/get-ancestor.ts","../../src/traversal/get-ancestors.ts","../../src/traversal/get-annotation.ts","../../src/traversal/is-block.ts","../../src/traversal/get-children.ts","../../src/traversal/get-container-children.ts","../../src/traversal/get-enclosing-block.ts","../../src/traversal/get-first-child.ts","../../src/traversal/get-last-child.ts","../../src/traversal/get-leaf.ts","../../src/traversal/get-node.ts","../../src/traversal/get-parent.ts","../../src/traversal/get-path-sub-schema.ts","../../src/traversal/get-sibling.ts","../../src/traversal/compare-points.ts","../../src/traversal/path-contains.ts","../../src/traversal/range-intersects.ts","../../src/traversal/get-span.ts","../../src/traversal/get-text.ts","../../src/traversal/get-text-block.ts","../../src/traversal/get-union-schema.ts","../../src/traversal/has-node.ts","../../src/traversal/is-inline.ts","../../src/traversal/is-leaf-object.ts","../../src/traversal/is-object.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/traversal/get-ancestor.ts","../../src/traversal/get-ancestors.ts","../../src/traversal/get-annotation.ts","../../src/traversal/is-block.ts","../../src/traversal/get-children.ts","../../src/traversal/get-container.ts","../../src/traversal/get-container-children.ts","../../src/traversal/get-enclosing-block.ts","../../src/traversal/get-first-child.ts","../../src/traversal/get-last-child.ts","../../src/traversal/get-leaf.ts","../../src/traversal/get-node.ts","../../src/traversal/get-parent.ts","../../src/traversal/get-path-sub-schema.ts","../../src/traversal/get-sibling.ts","../../src/traversal/compare-points.ts","../../src/traversal/path-contains.ts","../../src/traversal/range-intersects.ts","../../src/traversal/get-span.ts","../../src/traversal/get-text.ts","../../src/traversal/get-text-block.ts","../../src/traversal/get-union-schema.ts","../../src/traversal/has-node.ts","../../src/traversal/is-inline.ts","../../src/traversal/is-leaf-object.ts","../../src/traversal/is-object.ts"],"mappings":";;AAgBA;;;;;;;;;;;AAAA,iBAAgB,WAAA,gBAA2B,iBAAA,EACzC,QAAA,EAAU,iBAAA,EACV,IAAA,EAAM,IAAA,EACN,OAAA;EACE,KAAA,GAAQ,IAAA,EAAM,iBAAA,EAAmB,IAAA,EAAM,IAAA,KAAS,IAAA,IAAQ,MAAA;EACxD,IAAA;AAAA;EAEA,IAAA,EAAM,MAAA;EAAQ,IAAA,EAAM,IAAA;AAAA;;;;iBAIR,WAAA,CACd,QAAA,EAAU,iBAAA,EACV,IAAA,EAAM,IAAA,EACN,OAAA;EACE,KAAA,GAAQ,IAAA,EAAM,iBAAA,EAAmB,IAAA,EAAM,IAAA;EACvC,IAAA;AAAA;EAEA,IAAA,EAAM,iBAAA;EAAmB,IAAA,EAAM,IAAA;AAAA;AAlBnC;;;;;;;;;;;;;;;;AAAA,iBCSgB,YAAA,CACd,QAAA,EAAU,iBAAA,EACV,IAAA,EAAM,IAAA,GACL,KAAA;EAAO,IAAA,EAAM,iBAAA;EAAmB,IAAA,EAAM,IAAA;AAAA;ADZzC;;;;;;;;;;;AAAA,iBECgB,aAAA,CACd,QAAA,EAAU,iBAAA,EACV,IAAA,EAAM,IAAA;EACJ,IAAA,EAAM,kBAAA;EAAoB,IAAA,EAAM,IAAA;AAAA;AFJpC;;;;;;;;;;AAAA,iBGEgB,OAAA,CAAQ,QAAA,EAAU,iBAAA,EAAmB,IAAA,EAAM,IAAI;;;;;;;;;iBAkB/C,QAAA,CACd,QAAA,EAAU,iBAAA,EACV,IAAA,EAAM,IAAA;EACJ,IAAA,EAAM,iBAAA;EAAmB,IAAA,EAAM,IAAA;AAAA;;;;;;iBCpBnB,WAAA,CACd,QAAA,EAAU,iBAAA,EACV,IAAA,EAAM,IAAA,GACL,KAAA;EAAO,I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 +1,5 @@
|
|
|
1
|
-
import { getTextBlock } from "../_chunks-es/get-
|
|
2
|
-
import { getAncestor, getFirstChild, getLeaf, getSpan, getText, getUnionSchema, isLeafObject, pathContains, rangeIntersects } from "../_chunks-es/get-
|
|
1
|
+
import { getTextBlock } from "../_chunks-es/get-container.js";
|
|
2
|
+
import { getAncestor, getContainer, getFirstChild, getLeaf, getSpan, getText, getUnionSchema, isLeafObject, pathContains, rangeIntersects } from "../_chunks-es/get-container.js";
|
|
3
3
|
import { comparePoints, getAncestors, getBlock, getEnclosingBlock, getPathSubSchema, getSibling, hasNode, isBlock, isInline, isObject } from "../_chunks-es/get-path-sub-schema.js";
|
|
4
4
|
import { isKeyedSegment, getChildren } from "../_chunks-es/get-parent.js";
|
|
5
5
|
import { getContainerChildren, getNode, getParent } from "../_chunks-es/get-parent.js";
|
|
@@ -32,6 +32,7 @@ export {
|
|
|
32
32
|
getAnnotation,
|
|
33
33
|
getBlock,
|
|
34
34
|
getChildren,
|
|
35
|
+
getContainer,
|
|
35
36
|
getContainerChildren,
|
|
36
37
|
getEnclosingBlock,
|
|
37
38
|
getFirstChild,
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Ft as KeyedSegment, It as Path, M as EditorSelection, N as EditorSelectionPoint, Nt as BlockPath, Pt as ChildPath, S as EditorContext, nt as TraversalSnapshot } from "../_chunks-dts/behavior.types.action.js";
|
|
2
|
+
import { t as BlockOffset } from "../_chunks-dts/block-offset.js";
|
|
3
3
|
import { PortableTextBlock, PortableTextTextBlock, isSpan, isTextBlock } from "@portabletext/schema";
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
@@ -124,7 +124,7 @@ declare function mergeTextBlocks({
|
|
|
124
124
|
context: Pick<EditorContext, 'keyGenerator' | 'schema'>;
|
|
125
125
|
targetBlock: PortableTextTextBlock;
|
|
126
126
|
incomingBlock: PortableTextTextBlock;
|
|
127
|
-
}): PortableTextTextBlock<
|
|
127
|
+
}): PortableTextTextBlock<import("@portabletext/schema").PortableTextObject | import("@portabletext/schema").PortableTextSpan>;
|
|
128
128
|
/**
|
|
129
129
|
* @public
|
|
130
130
|
*/
|
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/util.block-offset.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.get-block-end-point.ts","../../src/utils/util.get-block-start-point.ts","../../src/utils/util.get-selection-end-point.ts","../../src/utils/util.get-selection-start-point.ts","../../src/utils/util.get-text-block-text.ts","../../src/utils/util.is-empty-text-block.ts","../../src/utils/util.is-equal-paths.ts","../../src/utils/util.is-equal-selection-points.ts","../../src/utils/util.is-equal-selections.ts","../../src/utils/util.is-keyed-segment.ts","../../src/utils/util.is-selection-collapsed.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts","../../src/utils/util.slice-blocks.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/utils/util.block-offset.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.get-block-end-point.ts","../../src/utils/util.get-block-start-point.ts","../../src/utils/util.get-selection-end-point.ts","../../src/utils/util.get-selection-start-point.ts","../../src/utils/util.get-text-block-text.ts","../../src/utils/util.is-empty-text-block.ts","../../src/utils/util.is-equal-paths.ts","../../src/utils/util.is-equal-selection-points.ts","../../src/utils/util.is-equal-selections.ts","../../src/utils/util.is-keyed-segment.ts","../../src/utils/util.is-selection-collapsed.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts","../../src/utils/util.slice-blocks.ts"],"mappings":";;;AAYA;;;AAAA,iBAAgB,+BAAA;EACd,QAAA;EACA,WAAA;EACA;AAAA;EAEA,QAAA,EAAU,iBA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;;;iBCHO,YAAA,CAAa,CAAA,EAAG,IAAA,EAAM,CAAA,EAAG,IAAI;;;;iBCA7B,sBAAA,CACd,CAAA,EAAG,oBAAA,EACH,CAAA,EAAG,oBAAoB;;;;iBCFT,iBAAA,CAAkB,CAAA,EAAG,eAAA,EAAiB,CAAA,EAAG,eAAe;;;;iBCDxD,cAAA,CAAe,OAAA,YAAmB,OAAA,IAAW,YAAY;;;;iBCCzD,oBAAA,CAAqB,SAA0B,EAAf,eAAe;;;AbM/D;iBcLgB,eAAA;EACd,OAAA;EACA,WAAA;EACA;AAAA;EAEA,OAAA,EAAS,IAAA,CAAK,aAAA;EACd,WAAA,EAAa,qBAAA;EACb,aAAA,EAAe,qBAAA;AAAA,IAChB,qBAAA,gCAAA,kBAAA,kCAAA,gBAAA;;;;iBCVe,gBAAA,0BACW,WAAA,CAAY,eAAA,UACrC,SAAA,EAAW,gBAAA,GAAmB,gBAAA;;;AfKhC;iBgBEgB,WAAA;EACd,OAAA;EACA;AAAA;EAEA,OAAA,EAAS,IAAA,CAAK,aAAA;IACZ,YAAA;EAAA;EAEF,MAAA,EAAQ,KAAA,CAAM,iBAAA;AAAA,IACZ,KAAA,CAAM,iBAAA"}
|
package/lib/utils/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { blockOffsetToSpanSelectionPoint,
|
|
2
|
-
import { getBlockEndPoint, getBlockStartPoint, getSelectionEndPoint, getSelectionStartPoint, isEqualPaths, isSelectionCollapsed, sliceBlocks, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
|
|
1
|
+
import { blockOffsetToSpanSelectionPoint, parseBlock } from "../_chunks-es/util.slice-blocks.js";
|
|
2
|
+
import { getBlockEndPoint, getBlockStartPoint, getSelectionEndPoint, getSelectionStartPoint, isEqualPaths, isEqualSelectionPoints, isSelectionCollapsed, sliceBlocks, spanSelectionPointToBlockOffset } from "../_chunks-es/util.slice-blocks.js";
|
|
3
3
|
import { getNode, isKeyedSegment, getParent } from "../_chunks-es/get-parent.js";
|
|
4
4
|
import { isSpan, isTextBlock } from "@portabletext/schema";
|
|
5
5
|
import { isSpan as isSpan2, isTextBlock as isTextBlock2 } from "@portabletext/schema";
|
|
6
|
-
import { getTextBlockText, isEmptyTextBlock } from "../_chunks-es/util.is-
|
|
6
|
+
import { getTextBlockText, isEmptyTextBlock, isEqualSelections } from "../_chunks-es/util.is-equal-selections.js";
|
|
7
7
|
function blockOffsetToBlockSelectionPoint({
|
|
8
8
|
snapshot,
|
|
9
9
|
blockOffset
|
|
@@ -73,9 +73,6 @@ function childSelectionPointToBlockOffset({
|
|
|
73
73
|
isSpan(snapshot.context, child) && (offset += child.text.length);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
function isEqualSelections(a, b) {
|
|
77
|
-
return !a && !b ? !0 : !a || !b ? !1 : isEqualSelectionPoints(a.anchor, b.anchor) && isEqualSelectionPoints(a.focus, b.focus);
|
|
78
|
-
}
|
|
79
76
|
function mergeTextBlocks({
|
|
80
77
|
context,
|
|
81
78
|
targetBlock,
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/utils/util.block-offset-to-block-selection-point.ts","../../src/utils/util.block-offset-to-selection-point.ts","../../src/utils/util.block-offsets-to-selection.ts","../../src/utils/util.child-selection-point-to-block-offset.ts","../../src/utils/util.merge-text-blocks.ts","../../src/utils/util.reverse-selection.ts"],"sourcesContent":["import {getNode} from '../traversal/get-node'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\n\nexport function blockOffsetToBlockSelectionPoint({\n snapshot,\n blockOffset,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n}): EditorSelectionPoint | undefined {\n const blockEntry = getNode(snapshot, blockOffset.path)\n\n if (!blockEntry) {\n return undefined\n }\n\n return {\n path: blockEntry.path,\n offset: blockOffset.offset,\n }\n}\n","import type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {blockOffsetToSpanSelectionPoint} from './util.block-offset'\nimport {blockOffsetToBlockSelectionPoint} from './util.block-offset-to-block-selection-point'\n\nexport function blockOffsetToSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n}: {\n snapshot: TraversalSnapshot\n blockOffset: BlockOffset\n direction: 'forward' | 'backward'\n}): EditorSelectionPoint | undefined {\n const spanSelectionPoint = blockOffsetToSpanSelectionPoint({\n snapshot,\n blockOffset,\n direction,\n })\n\n if (!spanSelectionPoint) {\n return blockOffsetToBlockSelectionPoint({\n snapshot,\n blockOffset,\n })\n }\n\n return spanSelectionPoint\n}\n","import type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelection} from '../types/editor'\nimport {blockOffsetToSelectionPoint} from './util.block-offset-to-selection-point'\n\n/**\n * @public\n */\nexport function blockOffsetsToSelection({\n snapshot,\n offsets,\n backward,\n}: {\n snapshot: TraversalSnapshot\n offsets: {anchor: BlockOffset; focus: BlockOffset}\n backward?: boolean\n}): EditorSelection {\n const anchor = blockOffsetToSelectionPoint({\n snapshot,\n blockOffset: offsets.anchor,\n direction: backward ? 'backward' : 'forward',\n })\n const focus = blockOffsetToSelectionPoint({\n snapshot,\n blockOffset: offsets.focus,\n direction: backward ? 'forward' : 'backward',\n })\n\n if (!anchor || !focus) {\n return null\n }\n\n return {\n anchor,\n focus,\n backward,\n }\n}\n","import {isSpan, isTextBlock} from '@portabletext/schema'\nimport {getParent} from '../traversal/get-parent'\nimport type {TraversalSnapshot} from '../traversal/traversal-snapshot'\nimport type {BlockOffset} from '../types/block-offset'\nimport type {EditorSelectionPoint} from '../types/editor'\nimport {isKeyedSegment} from './util.is-keyed-segment'\n\n/**\n * @public\n */\nexport function childSelectionPointToBlockOffset({\n snapshot,\n selectionPoint,\n}: {\n snapshot: TraversalSnapshot\n selectionPoint: EditorSelectionPoint\n}): BlockOffset | undefined {\n const childSegment = selectionPoint.path.at(-1)\n\n if (!isKeyedSegment(childSegment)) {\n return undefined\n }\n\n const textBlock = getParent(snapshot, selectionPoint.path, {\n match: (node) => isTextBlock({schema: snapshot.context.schema}, node),\n })\n\n if (!textBlock) {\n return undefined\n }\n\n let offset = 0\n\n for (const child of textBlock.node.children) {\n if (child._key === childSegment._key) {\n return {\n path: textBlock.path,\n offset: offset + selectionPoint.offset,\n }\n }\n\n if (isSpan(snapshot.context, child)) {\n offset += child.text.length\n }\n }\n\n return undefined\n}\n","import {isTextBlock, type PortableTextTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {parseBlock} from './parse-blocks'\n\n/**\n * @beta\n */\nexport function mergeTextBlocks({\n context,\n targetBlock,\n incomingBlock,\n}: {\n context: Pick<EditorContext, 'keyGenerator' | 'schema'>\n targetBlock: PortableTextTextBlock\n incomingBlock: PortableTextTextBlock\n}) {\n const parsedIncomingBlock = parseBlock({\n keyGenerator: context.keyGenerator,\n block: incomingBlock,\n options: {\n normalize: false,\n removeUnusedMarkDefs: true,\n validateFields: false,\n },\n schema: context.schema,\n })\n\n if (!parsedIncomingBlock || !isTextBlock(context, parsedIncomingBlock)) {\n return targetBlock\n }\n\n return {\n ...targetBlock,\n children: [...targetBlock.children, ...parsedIncomingBlock.children],\n markDefs: [\n ...(targetBlock.markDefs ?? []),\n ...(parsedIncomingBlock.markDefs ?? []),\n ],\n }\n}\n","import type {EditorSelection} from '../types/editor'\n\n/**\n * @public\n */\nexport function reverseSelection<\n TEditorSelection extends NonNullable<EditorSelection> | null,\n>(selection: TEditorSelection): TEditorSelection {\n if (!selection) {\n return selection\n }\n\n if (selection.backward) {\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: false,\n } as TEditorSelection\n }\n\n return {\n anchor: selection.focus,\n focus: selection.anchor,\n backward: true,\n } as TEditorSelection\n}\n"],"names":["blockOffsetToBlockSelectionPoint","snapshot","blockOffset","blockEntry","getNode","path","offset","blockOffsetToSelectionPoint","direction","blockOffsetToSpanSelectionPoint","blockOffsetsToSelection","offsets","backward","anchor","focus","childSelectionPointToBlockOffset","selectionPoint","childSegment","at","isKeyedSegment","textBlock","getParent","match","node","isTextBlock","schema","context","child","children","_key","isSpan","text","length","mergeTextBlocks","targetBlock","incomingBlock","parsedIncomingBlock","parseBlock","keyGenerator","block","options","normalize","removeUnusedMarkDefs","validateFields","markDefs","reverseSelection","selection"],"mappings":";;;;;;AAKO,SAASA,iCAAiC;AAAA,EAC/CC;AAAAA,EACAC;AAIF,GAAqC;AACnC,QAAMC,aAAaC,QAAQH,UAAUC,YAAYG,IAAI;AAErD,MAAKF;AAIL,WAAO;AAAA,MACLE,MAAMF,WAAWE;AAAAA,MACjBC,QAAQJ,YAAYI;AAAAA,IAAAA;AAExB;AChBO,SAASC,4BAA4B;AAAA,EAC1CN;AAAAA,EACAC;AAAAA,EACAM;AAKF,GAAqC;AAOnC,SAN2BC,gCAAgC;AAAA,IACzDR;AAAAA,IACAC;AAAAA,IACAM;AAAAA,EAAAA,CACD,KAGQR,iCAAiC;AAAA,IACtCC;AAAAA,IACAC;AAAAA,EAAAA,CACD;AAIL;ACrBO,SAASQ,wBAAwB;AAAA,EACtCT;AAAAA,EACAU;AAAAA,EACAC;AAKF,GAAoB;AAClB,QAAMC,SAASN,4BAA4B;AAAA,IACzCN;AAAAA,IACAC,aAAaS,QAAQE;AAAAA,IACrBL,WAAWI,WAAW,aAAa;AAAA,EAAA,CACpC,GACKE,QAAQP,4BAA4B;AAAA,IACxCN;AAAAA,IACAC,aAAaS,QAAQG;AA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ACR,GAAIV,YAAYU,YAAY,CAAA,GAC5B,GAAIR,oBAAoBQ,YAAY,CAAA,CAAG;AAAA,EAAA;AAG7C;AClCO,SAASC,iBAEdC,WAA+C;AAC/C,SAAKA,cAIDA,UAAUlC,WACL;AAAA,IACLC,QAAQiC,UAAUhC;AAAAA,IAClBA,OAAOgC,UAAUjC;AAAAA,IACjBD,UAAU;AAAA,EAAA,IAIP;AAAA,IACLC,QAAQiC,UAAUhC;AAAAA,IAClBA,OAAOgC,UAAUjC;AAAAA,IACjBD,UAAU;AAAA,EAAA;AAEd;"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.0",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"realtime",
|
|
6
|
+
"collaborative",
|
|
8
7
|
"content",
|
|
8
|
+
"editor",
|
|
9
|
+
"portable-text",
|
|
9
10
|
"portable-text-editor",
|
|
11
|
+
"realtime",
|
|
12
|
+
"sanity",
|
|
10
13
|
"structure",
|
|
11
|
-
"
|
|
12
|
-
"editor",
|
|
13
|
-
"text",
|
|
14
|
-
"portable-text"
|
|
14
|
+
"text"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://www.sanity.io/",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/portabletext/editor/issues"
|
|
19
19
|
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Sanity.io <hello@sanity.io>",
|
|
20
22
|
"repository": {
|
|
21
23
|
"type": "git",
|
|
22
24
|
"url": "git+https://github.com/portabletext/editor.git",
|
|
23
25
|
"directory": "packages/editor"
|
|
24
26
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
"files": [
|
|
28
|
+
"lib"
|
|
29
|
+
],
|
|
28
30
|
"type": "module",
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"main": "./lib/index.js",
|
|
33
|
+
"types": "./lib/index.d.ts",
|
|
29
34
|
"exports": {
|
|
30
35
|
".": "./lib/index.js",
|
|
31
36
|
"./behaviors": "./lib/behaviors/index.js",
|
|
@@ -37,11 +42,6 @@
|
|
|
37
42
|
"./utils": "./lib/utils/index.js",
|
|
38
43
|
"./package.json": "./package.json"
|
|
39
44
|
},
|
|
40
|
-
"main": "./lib/index.js",
|
|
41
|
-
"types": "./lib/index.d.ts",
|
|
42
|
-
"files": [
|
|
43
|
-
"lib"
|
|
44
|
-
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@portabletext/to-html": "^5.0.2",
|
|
47
47
|
"@xstate/react": "^6.1.0",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"xstate": "^5.32.2",
|
|
51
51
|
"@portabletext/html": "^1.1.0",
|
|
52
52
|
"@portabletext/keyboard-shortcuts": "^2.1.3",
|
|
53
|
-
"@portabletext/markdown": "^1.4.
|
|
53
|
+
"@portabletext/markdown": "^1.4.3",
|
|
54
54
|
"@portabletext/patches": "^2.0.5",
|
|
55
55
|
"@portabletext/schema": "^2.2.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@sanity/diff-match-patch": "^3.2.0",
|
|
59
|
-
"@sanity/pkg-utils": "^10.2
|
|
59
|
+
"@sanity/pkg-utils": "^10.8.2",
|
|
60
60
|
"@sanity/tsconfig": "^2.1.0",
|
|
61
61
|
"@textspec/notation": "^1.0.2",
|
|
62
62
|
"@types/debug": "^4.1.12",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
"@vitest/browser-playwright": "^4.1.9",
|
|
69
69
|
"@vitest/coverage-istanbul": "^4.1.9",
|
|
70
70
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
71
|
-
"eslint": "^9.39.
|
|
71
|
+
"eslint": "^9.39.4",
|
|
72
72
|
"eslint-formatter-gha": "^1.6.0",
|
|
73
73
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
74
74
|
"jsdom": "^27.2.0",
|
|
75
75
|
"react": "^19.2.7",
|
|
76
76
|
"react-dom": "^19.2.7",
|
|
77
|
-
"typescript": "
|
|
78
|
-
"typescript-eslint": "^8.
|
|
77
|
+
"typescript": "6.0.3",
|
|
78
|
+
"typescript-eslint": "^8.62.0",
|
|
79
79
|
"vite": "^7.3.5",
|
|
80
80
|
"vitest": "^4.1.9",
|
|
81
81
|
"vitest-browser-react": "^2.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-first-child.js","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-union-schema.ts","../../src/traversal/get-first-child.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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 * @beta\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 {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 * @beta\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 {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 * @beta\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"],"names":["getAncestor","snapshot","path","options","match","mode","ancestors","getAncestors","ancestor","reverse","node","isLeafObject","isObject","isEditableContainer","getLeaf","edge","currentPath","length","children","getChildren","firstOrLast","at","entry","getNode","undefined","isPath","value","Array","isArray","isKeyedSegment","isPoint","offset","isRange","anchor","focus","getText","isSpan","schema","context","text","descendant","getNodes","getSpan","pathContains","i","segment","otherSegment","_key","isBeforePoint","point","another","root","comparePoints","rangeIntersects","range","target","rs","re","rangeEdges","ts","te","isAfterPoint","start","end","isAfterStart","isBeforeEnd","comparePaths","getTextBlock","isTextBlock","getUnionSchema","containers","decorators","mergeByName","annotations","lists","styles","inlineObjects","blockObjects","container","values","acceptsTextBlock","field","of","block","name","sub","getSubSchema","blockName","some","member","type","source","existing","push","getFirstChild"],"mappings":";;;AAmCO,SAASA,YACdC,UACAC,MACAC,SAImD;AACnD,QAAM;AAAA,IAACC;AAAAA,IAAOC,OAAO;AAAA,EAAA,IAAYF,SAC3BG,YAAYC,aAAaN,UAAUC,IAAI;AAE7C,MAAIG,SAAS,WAAW;AACtB,eAAWG,YAAY,CAAC,GAAGF,SAAS,EAAEG,QAAAA;AACpC,UAAIL,MAAMI,SAASE,MAAMF,SAASN,IAAI;AACpC,eAAOM;AAGX;AAAA,EACF;AAEA,aAAWA,YAAYF;AACrB,QAAIF,MAAMI,SAASE,MAAMF,SAASN,IAAI;AACpC,aAAOM;AAKb;A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