@portabletext/block-tools 3.3.3 → 3.4.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.
@@ -1,79 +0,0 @@
1
- import type {Schema} from '@portabletext/schema'
2
- import {isArbitraryTypedObject} from './types'
3
-
4
- /**
5
- * @public
6
- */
7
- export type PortableTextBlock = PortableTextTextBlock | PortableTextObject
8
-
9
- /**
10
- * @public
11
- */
12
- export interface PortableTextTextBlock<
13
- TChild = PortableTextSpan | PortableTextObject,
14
- > {
15
- _type: string
16
- _key: string
17
- children: TChild[]
18
- markDefs?: PortableTextObject[]
19
- listItem?: string
20
- style?: string
21
- level?: number
22
- }
23
-
24
- export function isTextBlock(
25
- schema: Schema,
26
- block: unknown,
27
- ): block is PortableTextTextBlock {
28
- if (!isArbitraryTypedObject(block)) {
29
- return false
30
- }
31
-
32
- if (block._type !== schema.block.name) {
33
- return false
34
- }
35
-
36
- if (!Array.isArray(block.children)) {
37
- return false
38
- }
39
-
40
- return true
41
- }
42
-
43
- /**
44
- * @public
45
- */
46
- export interface PortableTextSpan {
47
- _key: string
48
- _type: 'span'
49
- text: string
50
- marks?: string[]
51
- }
52
-
53
- export function isSpan(
54
- schema: Schema,
55
- child: unknown,
56
- ): child is PortableTextSpan {
57
- if (!isArbitraryTypedObject(child)) {
58
- return false
59
- }
60
-
61
- if (child._type !== schema.span.name) {
62
- return false
63
- }
64
-
65
- if (typeof child.text !== 'string') {
66
- return false
67
- }
68
-
69
- return true
70
- }
71
-
72
- /**
73
- * @public
74
- */
75
- export interface PortableTextObject {
76
- _type: string
77
- _key: string
78
- [other: string]: unknown
79
- }