@portabletext/editor 7.8.2 → 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.
Files changed (42) hide show
  1. package/lib/_chunks-dts/behavior.types.action.d.ts +110 -274
  2. package/lib/_chunks-dts/behavior.types.action.d.ts.map +1 -1
  3. package/lib/_chunks-dts/block-offset.d.ts +10 -0
  4. package/lib/_chunks-dts/block-offset.d.ts.map +1 -0
  5. package/lib/_chunks-dts/editor-selector.d.ts +33 -0
  6. package/lib/_chunks-dts/editor-selector.d.ts.map +1 -0
  7. package/lib/_chunks-dts/editor.d.ts +99 -0
  8. package/lib/_chunks-dts/editor.d.ts.map +1 -0
  9. package/lib/_chunks-es/{get-first-child.js → get-container.js} +10 -1
  10. package/lib/_chunks-es/get-container.js.map +1 -0
  11. package/lib/_chunks-es/get-parent.js +18 -6
  12. package/lib/_chunks-es/get-parent.js.map +1 -1
  13. package/lib/_chunks-es/get-path-sub-schema.js +38 -6
  14. package/lib/_chunks-es/get-path-sub-schema.js.map +1 -1
  15. package/lib/_chunks-es/selector.is-at-the-start-of-block.js +3 -0
  16. package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
  17. package/lib/_chunks-es/{util.is-empty-text-block.js → util.is-equal-selections.js} +7 -2
  18. package/lib/_chunks-es/util.is-equal-selections.js.map +1 -0
  19. package/lib/_chunks-es/util.slice-blocks.js +1 -8
  20. package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
  21. package/lib/behaviors/index.d.ts +1 -1
  22. package/lib/index.d.ts +67 -2
  23. package/lib/index.d.ts.map +1 -0
  24. package/lib/index.js +282 -106
  25. package/lib/index.js.map +1 -1
  26. package/lib/plugins/index.d.ts +2 -1
  27. package/lib/plugins/index.d.ts.map +1 -1
  28. package/lib/selectors/index.d.ts +3 -1
  29. package/lib/selectors/index.d.ts.map +1 -1
  30. package/lib/selectors/index.js +4 -2
  31. package/lib/selectors/index.js.map +1 -1
  32. package/lib/traversal/index.d.ts +41 -7
  33. package/lib/traversal/index.d.ts.map +1 -1
  34. package/lib/traversal/index.js +24 -2
  35. package/lib/traversal/index.js.map +1 -1
  36. package/lib/utils/index.d.ts +3 -3
  37. package/lib/utils/index.d.ts.map +1 -1
  38. package/lib/utils/index.js +3 -6
  39. package/lib/utils/index.js.map +1 -1
  40. package/package.json +20 -20
  41. package/lib/_chunks-es/get-first-child.js.map +0 -1
  42. package/lib/_chunks-es/util.is-empty-text-block.js.map +0 -1
package/package.json CHANGED
@@ -1,31 +1,36 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "7.8.2",
3
+ "version": "7.10.0",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
- "sanity",
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
- "collaborative",
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
- "license": "MIT",
26
- "author": "Sanity.io <hello@sanity.io>",
27
- "sideEffects": false,
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.2",
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.1",
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.1",
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": "5.9.3",
78
- "typescript-eslint": "^8.48.0",
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;AChDO,SAASG,aACdV,UACAS,MACAR,MAC4B;AAC5B,SAAOU,WAASX,UAAUS,IAAI,KAAK,CAACG,oBAAoBZ,UAAUS,MAAMR,IAAI;AAC9E;ACPO,SAASY,QACdb,UACAC,MACAC,SACsC;AACtC,QAAM;AAAA,IAACY;AAAAA,EAAAA,IAAQZ;AAEf,MAAIa,cAAcd;AAGlB,MAAIc,YAAYC,WAAW,GAAG;AAC5B,UAAMC,WAAWC,YAAYlB,UAAU,EAAE;AACzC,QAAIiB,SAASD,WAAW;AACtB;AAEF,UAAMG,cAAcL,SAAS,QAAQG,SAASG,GAAG,EAAE,IAAKH,SAASG,GAAG,CAAC;AAErE,QADqBF,YAAYlB,UAAUmB,YAAYlB,IAAI,EAC1Ce,WAAW;AAC1B,aAAOG;AAETJ,kBAAcI,YAAYlB;AAAAA,EAC5B,OAAO;AAEL,UAAMoB,QAAQC,QAAQtB,UAAUe,WAAW;AAC3C,QAAI,CAACM;AACH;AAGF,QADiBH,YAAY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BF,YAAYa,IAAIV,QAAQA,MAAM,GAC9BH,YAAYa,IAAIT,eAAeA,aAAa,GAC5CJ,YAAYa,IAAIR,cAAcA,YAAY;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL,GAAGxC;AAAAA,IACHkC;AAAAA,IACAE;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,EAAAA;AAEJ;AAEA,SAASG,iBACPE,IACAK,WACS;AACT,SAAOL,GAAGM,KACPC,CAAAA,WAAWA,OAAOC,SAAS,WAAWD,OAAOC,SAASH,SACzD;AACF;AAEA,SAASf,YACPmB,QACApC,QACU;AACV,aAAWjC,SAASqE;AACdpC,WAAOiC,KAAMI,CAAAA,aAAaA,SAASR,SAAS9D,MAAM8D,IAAI,KAG1D7B,OAAOsC,KAAKvE,KAAK;AAEnB,SAAOiC;AACT;ACrEO,SAASuC,cACd7F,UACAC,MACsC;AACtC,SAAOiB,YAAYlB,UAAUC,IAAI,EAAEmB,GAAG,CAAC;AACzC;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.is-empty-text-block.js","sources":["../../src/utils/util.get-text-block-text.ts","../../src/utils/util.is-empty-text-block.ts"],"sourcesContent":["import type {PortableTextTextBlock} from '@portabletext/schema'\n\n/**\n * @public\n */\nexport function getTextBlockText(block: PortableTextTextBlock) {\n return block.children.map((child) => child.text ?? '').join('')\n}\n","import {isSpan, isTextBlock, type PortableTextBlock} from '@portabletext/schema'\nimport type {EditorContext} from '../editor/editor-snapshot'\nimport {getTextBlockText} from './util.get-text-block-text'\n\n/**\n * @public\n */\nexport function isEmptyTextBlock(\n context: Pick<EditorContext, 'schema'>,\n block: PortableTextBlock | unknown,\n) {\n if (!isTextBlock(context, block)) {\n return false\n }\n\n const onlyText = block.children.every((child) => isSpan(context, child))\n const blockText = getTextBlockText(block)\n\n return onlyText && blockText === ''\n}\n"],"names":["getTextBlockText","block","children","map","child","text","join","isEmptyTextBlock","context","isTextBlock","onlyText","every","isSpan","blockText"],"mappings":";AAKO,SAASA,iBAAiBC,OAA8B;AAC7D,SAAOA,MAAMC,SAASC,IAAKC,CAAAA,UAAUA,MAAMC,QAAQ,EAAE,EAAEC,KAAK,EAAE;AAChE;ACAO,SAASC,iBACdC,SACAP,OACA;AACA,MAAI,CAACQ,YAAYD,SAASP,KAAK;AAC7B,WAAO;AAGT,QAAMS,WAAWT,MAAMC,SAASS,MAAOP,CAAAA,UAAUQ,OAAOJ,SAASJ,KAAK,CAAC,GACjES,YAAYb,iBAAiBC,KAAK;AAExC,SAAOS,YAAYG,cAAc;AACnC;"}