@portabletext/markdown 1.4.4 → 1.4.6
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/dist/index.d.ts +92 -113
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1205 -1398
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,150 +1,146 @@
|
|
|
1
1
|
import { PortableTextBlock, PortableTextObject, Schema } from "@portabletext/schema";
|
|
2
2
|
/**
|
|
3
|
-
* Any object with an `_type` property (which is required in portable text arrays),
|
|
4
|
-
* as well as a _potential_ `_key` (highly encouraged)
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
3
|
+
* Any object with an `_type` property (which is required in portable text arrays),
|
|
4
|
+
* as well as a _potential_ `_key` (highly encouraged)
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
7
|
interface TypedObject {
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
* Identifies the type of object/span this is, and is used to pick the correct React components
|
|
10
|
+
* to use when rendering a span or inline object with this type.
|
|
11
|
+
*/
|
|
12
12
|
_type: string;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* Uniquely identifies this object within its parent block.
|
|
15
|
+
* Not _required_, but highly encouraged.
|
|
16
|
+
*/
|
|
17
17
|
_key?: string;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Any object with an `_type` that is a string. Can hold any other properties.
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
20
|
+
* Any object with an `_type` that is a string. Can hold any other properties.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
23
|
type ArbitraryTypedObject = TypedObject & {
|
|
24
24
|
[key: string]: any;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* A Portable Text Block can be thought of as one paragraph, quote or list item.
|
|
28
|
-
* In other words, it is a container for text, that can have a visual style associated with it.
|
|
29
|
-
* The actual text value is stored in portable text spans inside of the `childen` array.
|
|
30
|
-
*
|
|
31
|
-
* @typeParam M - Mark types that be used for text spans
|
|
32
|
-
* @typeParam C - Types allowed as children of this block
|
|
33
|
-
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
|
|
34
|
-
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
|
|
35
|
-
* @public
|
|
36
|
-
*/
|
|
27
|
+
* A Portable Text Block can be thought of as one paragraph, quote or list item.
|
|
28
|
+
* In other words, it is a container for text, that can have a visual style associated with it.
|
|
29
|
+
* The actual text value is stored in portable text spans inside of the `childen` array.
|
|
30
|
+
*
|
|
31
|
+
* @typeParam M - Mark types that be used for text spans
|
|
32
|
+
* @typeParam C - Types allowed as children of this block
|
|
33
|
+
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
|
|
34
|
+
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
37
|
interface PortableTextBlock$1<M extends PortableTextMarkDefinition = PortableTextMarkDefinition, C extends TypedObject = ArbitraryTypedObject | PortableTextSpan, S extends string = PortableTextBlockStyle, L extends string = PortableTextListItemType> extends TypedObject {
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
* Type name identifying this as a portable text block.
|
|
40
|
+
* All items within a portable text array should have a `_type` property.
|
|
41
|
+
*
|
|
42
|
+
* Usually 'block', but can be customized to other values
|
|
43
|
+
*/
|
|
44
44
|
_type: "block" | (string & {});
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
* A key that identifies this block uniquely within the parent array. Used to more easily address
|
|
47
|
+
* the block when editing collaboratively, but is also very useful for keys inside of React and
|
|
48
|
+
* other rendering frameworks that can use keys to optimize operations.
|
|
49
|
+
*/
|
|
50
50
|
_key?: string;
|
|
51
51
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
* Array of inline items for this block. Usually contain text spans, but can be
|
|
53
|
+
* configured to include inline objects of other types as well.
|
|
54
|
+
*/
|
|
55
55
|
children: C[];
|
|
56
56
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
* Array of mark definitions used in child text spans. By having them be on the block level,
|
|
58
|
+
* the same mark definition can be reused for multiple text spans, which is often the case
|
|
59
|
+
* with nested marks.
|
|
60
|
+
*/
|
|
61
61
|
markDefs?: M[];
|
|
62
62
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
* Visual style of the block
|
|
64
|
+
* Common values: 'normal', 'blockquote', 'h1'...'h6'
|
|
65
|
+
*/
|
|
66
66
|
style?: S;
|
|
67
67
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
* If this block is a list item, identifies which style of list item this is
|
|
69
|
+
* Common values: 'bullet', 'number', but can be configured
|
|
70
|
+
*/
|
|
71
71
|
listItem?: L;
|
|
72
72
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
* If this block is a list item, identifies which level of nesting it belongs within
|
|
74
|
+
*/
|
|
75
75
|
level?: number;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Strictly speaking the same as a portable text block, but `listItem` is required
|
|
79
|
-
*
|
|
80
|
-
* @typeParam M - Mark types that be used for text spans
|
|
81
|
-
* @typeParam C - Types allowed as children of this block
|
|
82
|
-
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
|
|
83
|
-
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
|
|
84
|
-
* @public
|
|
85
|
-
*/
|
|
78
|
+
* Strictly speaking the same as a portable text block, but `listItem` is required
|
|
79
|
+
*
|
|
80
|
+
* @typeParam M - Mark types that be used for text spans
|
|
81
|
+
* @typeParam C - Types allowed as children of this block
|
|
82
|
+
* @typeParam S - Allowed block styles (eg `normal`, `blockquote`, `h3` etc)
|
|
83
|
+
* @typeParam L - Allowed list item types (eg `number`, `bullet` etc)
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
86
|
interface PortableTextListItemBlock<M extends PortableTextMarkDefinition = PortableTextMarkDefinition, C extends TypedObject = PortableTextSpan, S extends string = PortableTextBlockStyle, L extends string = PortableTextListItemType> extends Omit<PortableTextBlock$1<M, C, S, L>, "listItem"> {
|
|
87
87
|
listItem: L;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* A set of _common_ (but not required/standarized) block styles
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
90
|
+
* A set of _common_ (but not required/standarized) block styles
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
93
|
type PortableTextBlockStyle = "normal" | "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | (string & {});
|
|
94
94
|
/**
|
|
95
|
-
* A set of _common_ (but not required/standardized) list item types
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
95
|
+
* A set of _common_ (but not required/standardized) list item types
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
98
|
type PortableTextListItemType = "bullet" | "number" | (string & {});
|
|
99
99
|
/**
|
|
100
|
-
* A mark definition holds information for marked text. For instance, a text span could reference
|
|
101
|
-
* a mark definition for a hyperlink, a geoposition, a reference to a document or anything that is
|
|
102
|
-
* representable as a JSON object.
|
|
103
|
-
* @public
|
|
104
|
-
*/
|
|
100
|
+
* A mark definition holds information for marked text. For instance, a text span could reference
|
|
101
|
+
* a mark definition for a hyperlink, a geoposition, a reference to a document or anything that is
|
|
102
|
+
* representable as a JSON object.
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
105
|
interface PortableTextMarkDefinition {
|
|
106
106
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
* Unknown properties
|
|
108
|
+
*/
|
|
109
109
|
[key: string]: unknown;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
* Identifies the type of mark this is, and is used to pick the correct React components to use
|
|
112
|
+
* when rendering a text span marked with this mark type.
|
|
113
|
+
*/
|
|
114
114
|
_type: string;
|
|
115
115
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
* Uniquely identifies this mark definition within the block
|
|
117
|
+
*/
|
|
118
118
|
_key: string;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
|
-
* A Portable Text Span holds a chunk of the actual text value of a Portable Text Block
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
121
|
+
* A Portable Text Span holds a chunk of the actual text value of a Portable Text Block
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
124
|
interface PortableTextSpan {
|
|
125
125
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
* Type is always `span` for portable text spans, as these don't vary in shape
|
|
127
|
+
*/
|
|
128
128
|
_type: "span";
|
|
129
129
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
* Unique (within parent block) key for this portable text span
|
|
131
|
+
*/
|
|
132
132
|
_key?: string;
|
|
133
133
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
* The actual text value of this text span
|
|
135
|
+
*/
|
|
136
136
|
text: string;
|
|
137
137
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
* An array of marks this text span is annotated with, identified by its `_key`.
|
|
139
|
+
* If the key cannot be found in the parent blocks mark definition, the mark is assumed to be a
|
|
140
|
+
* decorator (a simpler mark without any properties - for instance `strong` or `em`)
|
|
141
|
+
*/
|
|
142
142
|
marks?: string[];
|
|
143
143
|
}
|
|
144
|
-
/**
|
|
145
|
-
* The simplest representation of a link
|
|
146
|
-
* @public
|
|
147
|
-
*/
|
|
148
144
|
/**
|
|
149
145
|
* @public
|
|
150
146
|
*/
|
|
@@ -156,7 +152,7 @@ type BlockSpacingRenderer = (options: {
|
|
|
156
152
|
* @public
|
|
157
153
|
*/
|
|
158
154
|
declare const DefaultBlockSpacingRenderer: BlockSpacingRenderer;
|
|
159
|
-
type LooseRecord<K extends string, V> = Record<string, V> & { [P in K]?: V };
|
|
155
|
+
type LooseRecord<K extends string, V> = Record<string, V> & { [P in K]?: V; };
|
|
160
156
|
/**
|
|
161
157
|
* Generic type for portable text renderers that takes blocks/inline blocks
|
|
162
158
|
*
|
|
@@ -525,9 +521,7 @@ declare const DefaultListRenderer: PortableTextTypeRenderer<{
|
|
|
525
521
|
*
|
|
526
522
|
* @public
|
|
527
523
|
*/
|
|
528
|
-
type StyleMatcher = ({
|
|
529
|
-
context
|
|
530
|
-
}: {
|
|
524
|
+
type StyleMatcher = ({ context }: {
|
|
531
525
|
context: {
|
|
532
526
|
schema: Schema;
|
|
533
527
|
};
|
|
@@ -537,9 +531,7 @@ type StyleMatcher = ({
|
|
|
537
531
|
*
|
|
538
532
|
* @public
|
|
539
533
|
*/
|
|
540
|
-
type ListItemMatcher = ({
|
|
541
|
-
context
|
|
542
|
-
}: {
|
|
534
|
+
type ListItemMatcher = ({ context }: {
|
|
543
535
|
context: {
|
|
544
536
|
schema: Schema;
|
|
545
537
|
};
|
|
@@ -549,9 +541,7 @@ type ListItemMatcher = ({
|
|
|
549
541
|
*
|
|
550
542
|
* @public
|
|
551
543
|
*/
|
|
552
|
-
type DecoratorMatcher = ({
|
|
553
|
-
context
|
|
554
|
-
}: {
|
|
544
|
+
type DecoratorMatcher = ({ context }: {
|
|
555
545
|
context: {
|
|
556
546
|
schema: Schema;
|
|
557
547
|
};
|
|
@@ -561,10 +551,7 @@ type DecoratorMatcher = ({
|
|
|
561
551
|
*
|
|
562
552
|
* @public
|
|
563
553
|
*/
|
|
564
|
-
type AnnotationMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({
|
|
565
|
-
context,
|
|
566
|
-
value
|
|
567
|
-
}: {
|
|
554
|
+
type AnnotationMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({ context, value }: {
|
|
568
555
|
context: {
|
|
569
556
|
schema: Schema;
|
|
570
557
|
keyGenerator: () => string;
|
|
@@ -576,11 +563,7 @@ type AnnotationMatcher<TValue extends Record<string, unknown> = Record<string, n
|
|
|
576
563
|
*
|
|
577
564
|
* @public
|
|
578
565
|
*/
|
|
579
|
-
type ObjectMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({
|
|
580
|
-
context,
|
|
581
|
-
value,
|
|
582
|
-
isInline
|
|
583
|
-
}: {
|
|
566
|
+
type ObjectMatcher<TValue extends Record<string, unknown> = Record<string, never>> = ({ context, value, isInline }: {
|
|
584
567
|
context: {
|
|
585
568
|
schema: Schema;
|
|
586
569
|
keyGenerator: () => string;
|
|
@@ -671,10 +654,6 @@ type Options = {
|
|
|
671
654
|
inline?: 'skip' | 'text';
|
|
672
655
|
};
|
|
673
656
|
};
|
|
674
|
-
/**
|
|
675
|
-
* Reads GFM column alignment from a markdown-it cell token's `style`
|
|
676
|
-
* attribute. Tolerates other CSS declarations sharing the value.
|
|
677
|
-
*/
|
|
678
657
|
/**
|
|
679
658
|
* Converts a markdown string to an array of Portable Text blocks.
|
|
680
659
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../node_modules/.pnpm/@portabletext+types@4.0.2/node_modules/@portabletext/types/dist/index.d.ts","../src/from-portable-text/renderers/block-spacing.ts","../src/from-portable-text/types.ts","../src/from-portable-text/portable-text-to-markdown.ts","../src/from-portable-text/renderers/hard-break.ts","../src/from-portable-text/renderers/list-item.ts","../src/from-portable-text/renderers/style.ts","../src/from-portable-text/renderers/marks.ts","../src/from-portable-text/renderers/type.ts","../src/to-portable-text/matchers.ts","../src/to-portable-text/markdown-to-portable-text.ts"],"x_google_ignoreList":[0],"mappings":";;;;;;UAKU;;;;;EAKR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