@valbuild/core 0.20.0 → 0.20.1
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.
@@ -11,7 +11,7 @@ export type RichTextOptions = {
|
|
11
11
|
};
|
12
12
|
export type ParagraphNode<O extends RichTextOptions> = {
|
13
13
|
tag: "p";
|
14
|
-
children: (string | SpanNode<O>
|
14
|
+
children: (string | SpanNode<O>)[];
|
15
15
|
};
|
16
16
|
export type LineThrough<O extends RichTextOptions> = O["lineThrough"] extends true ? "line-through" : never;
|
17
17
|
export type Italic<O extends RichTextOptions> = O["italic"] extends true ? "italic" : never;
|
@@ -30,7 +30,7 @@ export type ImageNode<O extends RichTextOptions> = O["img"] extends true ? {
|
|
30
30
|
} : never;
|
31
31
|
export type ListItemNode<O extends RichTextOptions> = {
|
32
32
|
tag: "li";
|
33
|
-
children: (string | SpanNode<O> |
|
33
|
+
children: (string | SpanNode<O> | UnorderedListNode<O> | OrderedListNode<O>)[];
|
34
34
|
};
|
35
35
|
export type UnorderedListNode<O extends RichTextOptions> = O["ul"] extends true ? {
|
36
36
|
tag: "ul";
|
@@ -63,7 +63,7 @@ export type AnyRichTextOptions = {
|
|
63
63
|
};
|
64
64
|
export type RichTextSourceNode<O extends RichTextOptions> = Exclude<RichTextNode<O>, {
|
65
65
|
tag: "img";
|
66
|
-
}> |
|
66
|
+
}> | SourceNode<O>;
|
67
67
|
export type RichTextSource<O extends RichTextOptions> = {
|
68
68
|
[VAL_EXTENSION]: "richtext";
|
69
69
|
children: (HeadingNode<O> | ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O> | SourceNode<O>)[];
|
package/package.json
CHANGED
package/src/source/richtext.ts
CHANGED
@@ -19,7 +19,7 @@ export type RichTextOptions = {
|
|
19
19
|
|
20
20
|
export type ParagraphNode<O extends RichTextOptions> = {
|
21
21
|
tag: "p";
|
22
|
-
children: (string | SpanNode<O>
|
22
|
+
children: (string | SpanNode<O>)[];
|
23
23
|
// AnchorNode<O>
|
24
24
|
};
|
25
25
|
|
@@ -79,7 +79,6 @@ export type ListItemNode<O extends RichTextOptions> = {
|
|
79
79
|
| string
|
80
80
|
| SpanNode<O>
|
81
81
|
// | AnchorNode<O>
|
82
|
-
| ImageNode<O>
|
83
82
|
| UnorderedListNode<O>
|
84
83
|
| OrderedListNode<O>
|
85
84
|
)[];
|
@@ -140,9 +139,6 @@ export type AnyRichTextOptions = {
|
|
140
139
|
|
141
140
|
export type RichTextSourceNode<O extends RichTextOptions> =
|
142
141
|
| Exclude<RichTextNode<O>, { tag: "img" }>
|
143
|
-
| ParagraphNode<O>
|
144
|
-
| ListItemNode<O>
|
145
|
-
| ImageNode<O>
|
146
142
|
| SourceNode<O>;
|
147
143
|
|
148
144
|
export type RichTextSource<O extends RichTextOptions> = {
|
@@ -230,6 +226,9 @@ function parseTokens<O extends RichTextOptions>(
|
|
230
226
|
];
|
231
227
|
}
|
232
228
|
if (token.type === "text") {
|
229
|
+
if ("tokens" in token && Array.isArray(token.tokens)) {
|
230
|
+
return parseTokens(token.tokens);
|
231
|
+
}
|
233
232
|
return [token.text];
|
234
233
|
}
|
235
234
|
if (token.type === "list") {
|