@valbuild/core 0.62.5 → 0.63.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/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/initSchema.d.ts +30 -2
- package/dist/declarations/src/module.d.ts +1 -1
- package/dist/declarations/src/patch/operation.d.ts +4 -0
- package/dist/declarations/src/schema/keyOf.d.ts +3 -2
- package/dist/declarations/src/schema/object.d.ts +15 -0
- package/dist/declarations/src/schema/richtext.d.ts +21 -1
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/declarations/src/selector/future/index.d.ts +4 -3
- package/dist/declarations/src/selector/index.d.ts +4 -3
- package/dist/declarations/src/selector/richtext.d.ts +3 -0
- package/dist/declarations/src/source/future/remote.d.ts +2 -2
- package/dist/declarations/src/source/index.d.ts +8 -1
- package/dist/declarations/src/source/richtext.d.ts +69 -63
- package/dist/{index-596f28bb.cjs.prod.js → index-00decfd4.cjs.prod.js} +256 -19
- package/dist/{index-316f5dd8.esm.js → index-370592bb.esm.js} +236 -19
- package/dist/{index-3193efd5.cjs.dev.js → index-796c5d0d.cjs.dev.js} +256 -19
- package/dist/valbuild-core.cjs.dev.js +3 -1
- package/dist/valbuild-core.cjs.prod.js +3 -1
- package/dist/valbuild-core.esm.js +3 -1
- package/expr/dist/valbuild-core-expr.cjs.dev.js +3 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +3 -1
- package/expr/dist/valbuild-core-expr.esm.js +3 -1
- package/package.json +2 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +3 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +3 -1
- package/patch/dist/valbuild-core-patch.esm.js +4 -2
@@ -11,7 +11,7 @@ export type { FileSource } from "./source/file.js";
|
|
11
11
|
export type { RawString } from "./schema/string.js";
|
12
12
|
export type { ImageSource } from "./source/image.js";
|
13
13
|
export { RT_IMAGE_TAG } from "./source/richtext.js";
|
14
|
-
export type {
|
14
|
+
export type { AllRichTextOptions, Bold, Styles, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichTextNode, RichTextOptions, RichTextSource, BlockNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
|
15
15
|
export { type Val, type SerializedVal, type ModuleFilePath, type PatchId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
|
16
16
|
export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
|
17
17
|
export type { ValidationError, ValidationErrors, } from "./schema/validation/ValidationError.js";
|
@@ -30,6 +30,14 @@ export declare function initSchema(): {
|
|
30
30
|
array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<import("./schema/index.js").SelectorOfSchema<S>[]>;
|
31
31
|
object: <Props extends {
|
32
32
|
[key: string]: import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>;
|
33
|
+
} & {
|
34
|
+
valPath?: undefined;
|
35
|
+
val?: undefined;
|
36
|
+
_type?: undefined;
|
37
|
+
_ref?: undefined;
|
38
|
+
andThen?: undefined;
|
39
|
+
assert?: undefined;
|
40
|
+
fold?: undefined;
|
33
41
|
}>(schema: Props) => import("./schema/index.js").Schema<{ [key in keyof Props]: import("./schema/index.js").SelectorOfSchema<Props[key]>; }>;
|
34
42
|
number: (options?: {
|
35
43
|
max?: number | undefined;
|
@@ -46,10 +54,30 @@ export declare function initSchema(): {
|
|
46
54
|
val?: undefined;
|
47
55
|
valPath?: undefined;
|
48
56
|
} & { [k in Key]: string; } : Key extends import("./schema/index.js").Schema<string> ? string : unknown>[]>(key: Key, ...objects: T_1) => import("./schema/index.js").Schema<T_1 extends import("./schema/index.js").Schema<infer S_1 extends import("./selector/index.js").SelectorSource>[] ? S_1 extends import("./selector/index.js").SelectorSource ? S_1 | (Key extends import("./schema/index.js").Schema<infer K extends import("./selector/index.js").SelectorSource> ? K : never) : never : never>;
|
49
|
-
richtext: <O extends
|
57
|
+
richtext: <O extends Partial<{
|
58
|
+
style: Partial<{
|
59
|
+
bold: boolean;
|
60
|
+
italic: boolean;
|
61
|
+
lineThrough: boolean;
|
62
|
+
}>;
|
63
|
+
block: Partial<{
|
64
|
+
h1: boolean;
|
65
|
+
h2: boolean;
|
66
|
+
h3: boolean;
|
67
|
+
h4: boolean;
|
68
|
+
h5: boolean;
|
69
|
+
h6: boolean;
|
70
|
+
ul: boolean;
|
71
|
+
ol: boolean;
|
72
|
+
}>;
|
73
|
+
inline: Partial<{
|
74
|
+
a: boolean;
|
75
|
+
img: boolean;
|
76
|
+
}>;
|
77
|
+
}>>(options?: O | undefined) => import("./schema/index.js").Schema<import("./index.js").RichTextSource<O>>;
|
50
78
|
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").ImageSource>;
|
51
79
|
literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
|
52
|
-
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly
|
80
|
+
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly import("./source/index.js").Source[] ? number : S_2 extends import("./source/index.js").SourceObject ? string extends keyof S_2 ? import("./schema/string.js").RawString : keyof S_2 : S_2 extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
|
53
81
|
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
|
54
82
|
file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
|
55
83
|
};
|
@@ -12,7 +12,7 @@ export type ValModuleBrand = {
|
|
12
12
|
[brand]: "ValModule";
|
13
13
|
};
|
14
14
|
export type InferValModuleType<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
|
15
|
-
type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends ImageSelector ? ImageSource : T extends {
|
15
|
+
export type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends ImageSelector ? ImageSource : T extends {
|
16
16
|
[key in string]: SelectorSource;
|
17
17
|
} ? {
|
18
18
|
[key in keyof T]: ReplaceRawStringWithString<T[key]>;
|
@@ -63,7 +63,11 @@ export type Operation = {
|
|
63
63
|
value: JSONValue;
|
64
64
|
} | {
|
65
65
|
op: "file";
|
66
|
+
/** path of the top-most element where the schema of the element points to */
|
66
67
|
path: string[];
|
68
|
+
/** file path relative to project (starts with /public, e.g. /public/example.png) */
|
67
69
|
filePath: string;
|
70
|
+
/** files can be nested within an object (for richtext), in order to find the actual file element this path can be used (we use this to add the patch_id on files) */
|
71
|
+
nestedFilePath?: string[];
|
68
72
|
value: JSONValue;
|
69
73
|
};
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { Schema, SerializedSchema } from "./index.js";
|
2
2
|
import { ValModuleBrand } from "../module.js";
|
3
3
|
import { GenericSelector } from "../selector/index.js";
|
4
|
-
import { SourceArray, SourceObject } from "../source/index.js";
|
4
|
+
import { Source, SourceArray, SourceObject } from "../source/index.js";
|
5
5
|
import { SourcePath } from "../val/index.js";
|
6
6
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
7
|
+
import { RawString } from "./string.js";
|
7
8
|
export type SerializedKeyOfSchema = {
|
8
9
|
type: "keyOf";
|
9
10
|
path: SourcePath;
|
@@ -11,7 +12,7 @@ export type SerializedKeyOfSchema = {
|
|
11
12
|
opt: boolean;
|
12
13
|
values: "string" | "number" | string[];
|
13
14
|
};
|
14
|
-
type KeyOfSelector<Sel extends GenericSelector<SourceArray | SourceObject>> = Sel extends GenericSelector<infer S> ? S extends readonly
|
15
|
+
type KeyOfSelector<Sel extends GenericSelector<SourceArray | SourceObject>> = Sel extends GenericSelector<infer S> ? S extends readonly Source[] ? number : S extends SourceObject ? string extends keyof S ? RawString : keyof S : S extends Record<string, Source> ? RawString : never : never;
|
15
16
|
export declare class KeyOfSchema<Sel extends GenericSelector<SourceArray | SourceObject>> extends Schema<KeyOfSelector<Sel>> {
|
16
17
|
readonly schema?: SerializedSchema | undefined;
|
17
18
|
readonly sourcePath?: SourcePath | undefined;
|
@@ -9,6 +9,21 @@ export type SerializedObjectSchema = {
|
|
9
9
|
};
|
10
10
|
type ObjectSchemaProps = {
|
11
11
|
[key: string]: Schema<SelectorSource>;
|
12
|
+
} & {
|
13
|
+
/** Cannot create object with key: valPath. It is a reserved name */
|
14
|
+
valPath?: never;
|
15
|
+
/** Cannot create object with key: val. It is a reserved name */
|
16
|
+
val?: never;
|
17
|
+
/** Cannot create object with key: _type. It is a reserved name */
|
18
|
+
_type?: never;
|
19
|
+
/** Cannot create object with key: _ref. It is a reserved name */
|
20
|
+
_ref?: never;
|
21
|
+
/** Cannot create object with key: andThen. It is a reserved name */
|
22
|
+
andThen?: never;
|
23
|
+
/** Cannot create object with key: assert. It is a reserved name */
|
24
|
+
assert?: never;
|
25
|
+
/** Cannot create object with key: fold. It is a reserved name */
|
26
|
+
fold?: never;
|
12
27
|
};
|
13
28
|
type ObjectSchemaSrcOf<Props extends ObjectSchemaProps> = {
|
14
29
|
[key in keyof Props]: SelectorOfSchema<Props[key]>;
|
@@ -16,4 +16,24 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
|
|
16
16
|
nullable(): Schema<RichTextSource<O> | null>;
|
17
17
|
serialize(): SerializedSchema;
|
18
18
|
}
|
19
|
-
export declare const richtext: <O extends
|
19
|
+
export declare const richtext: <O extends Partial<{
|
20
|
+
style: Partial<{
|
21
|
+
bold: boolean;
|
22
|
+
italic: boolean;
|
23
|
+
lineThrough: boolean;
|
24
|
+
}>;
|
25
|
+
block: Partial<{
|
26
|
+
h1: boolean;
|
27
|
+
h2: boolean;
|
28
|
+
h3: boolean;
|
29
|
+
h4: boolean;
|
30
|
+
h5: boolean;
|
31
|
+
h6: boolean;
|
32
|
+
ul: boolean;
|
33
|
+
ol: boolean;
|
34
|
+
}>;
|
35
|
+
inline: Partial<{
|
36
|
+
a: boolean;
|
37
|
+
img: boolean;
|
38
|
+
}>;
|
39
|
+
}>>(options?: O | undefined) => Schema<RichTextSource<O>>;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const ValidationFix: readonly ["image:add-metadata", "image:replace-metadata", "file:add-metadata", "file:check-metadata"];
|
1
|
+
export declare const ValidationFix: readonly ["image:add-metadata", "image:replace-metadata", "file:add-metadata", "file:check-metadata", "fix:deprecated-richtext"];
|
2
2
|
export type ValidationFix = (typeof ValidationFix)[number];
|
@@ -15,7 +15,8 @@ import type { A } from "ts-toolbelt";
|
|
15
15
|
import { I18nSource, I18nCompatibleSource } from "../../source/future/i18n.js";
|
16
16
|
import { RemoteCompatibleSource, RemoteSource } from "../../source/future/remote.js";
|
17
17
|
import { FileSource } from "../../source/file.js";
|
18
|
-
import {
|
18
|
+
import { AllRichTextOptions, RichTextSource } from "../../source/richtext.js";
|
19
|
+
import { RichTextSelector } from "../richtext.js";
|
19
20
|
/**
|
20
21
|
* Selectors can be used to select parts of a Val module.
|
21
22
|
* Unlike queries, joins, aggregates etc is and will not be supported.
|
@@ -37,10 +38,10 @@ import { AnyRichTextOptions, RichText, RichTextSource } from "../../source/richt
|
|
37
38
|
* }));
|
38
39
|
*
|
39
40
|
*/
|
40
|
-
export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends I18nSource<infer L, infer S> ? I18nSelector<L, S> : T extends RemoteSource<infer S> ? S extends RemoteCompatibleSource ? RemoteSelector<S> : GenericSelector<Source, "Could not determine remote source"> : T extends FileSource ? FileSelector : T extends RichTextSource<infer O> ?
|
41
|
+
export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends I18nSource<infer L, infer S> ? I18nSelector<L, S> : T extends RemoteSource<infer S> ? S extends RemoteCompatibleSource ? RemoteSelector<S> : GenericSelector<Source, "Could not determine remote source"> : T extends FileSource ? FileSelector : T extends RichTextSource<infer O> ? RichTextSelector<O> : T extends SourceObject ? ObjectSelector<T> : T extends SourceArray ? ArraySelector<T> : T extends string ? StringSelector<T> : T extends number ? NumberSelector<T> : T extends boolean ? BooleanSelector<T> : T extends null ? PrimitiveSelector<null> : never;
|
41
42
|
export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSource[] | {
|
42
43
|
[key: string]: SelectorSource;
|
43
|
-
} | I18nSource<readonly string[], I18nCompatibleSource> | RemoteSource<RemoteCompatibleSource> | FileSource | RichTextSource<
|
44
|
+
} | I18nSource<readonly string[], I18nCompatibleSource> | RemoteSource<RemoteCompatibleSource> | FileSource | RichTextSource<AllRichTextOptions> | GenericSelector<Source>;
|
44
45
|
/**
|
45
46
|
* @internal
|
46
47
|
*/
|
@@ -10,13 +10,14 @@ import { Source, SourceArray, SourceObject, SourcePrimitive } from "../source/in
|
|
10
10
|
import { Schema } from "../schema/index.js";
|
11
11
|
import type { A } from "ts-toolbelt";
|
12
12
|
import { FileSource } from "../source/file.js";
|
13
|
-
import {
|
13
|
+
import { AllRichTextOptions, RichTextSource } from "../source/richtext.js";
|
14
14
|
import { ImageMetadata } from "../schema/image.js";
|
15
15
|
import { ImageSelector } from "./image.js";
|
16
|
-
|
16
|
+
import { RichTextSelector } from "./richtext.js";
|
17
|
+
export type Selector<T extends Source> = Source extends T ? GenericSelector<T> : T extends FileSource<infer M> ? M extends ImageMetadata ? ImageSelector : FileSelector<M> : T extends RichTextSource<infer O> ? RichTextSelector<O> : T extends SourceObject ? ObjectSelector<T> : T extends SourceArray ? ArraySelector<T> : T extends string ? StringSelector<T> : T extends number ? NumberSelector<T> : T extends boolean ? BooleanSelector<T> : T extends null ? PrimitiveSelector<null> : never;
|
17
18
|
export type SelectorSource = SourcePrimitive | undefined | readonly SelectorSource[] | {
|
18
19
|
[key: string]: SelectorSource;
|
19
|
-
} | FileSource | RichTextSource<
|
20
|
+
} | FileSource | RichTextSource<AllRichTextOptions> | GenericSelector<Source>;
|
20
21
|
/**
|
21
22
|
* @internal
|
22
23
|
*/
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { SourcePrimitive, VAL_EXTENSION, PhantomType } from "../index.js";
|
2
2
|
import { FileSource } from "../file.js";
|
3
3
|
import { I18nCompatibleSource, I18nSource } from "./i18n.js";
|
4
|
-
import {
|
4
|
+
import { AllRichTextOptions, RichTextSource } from "../richtext.js";
|
5
5
|
/**
|
6
6
|
* Remote sources cannot include other remote sources.
|
7
7
|
*/
|
8
|
-
export type RemoteCompatibleSource = SourcePrimitive | RemoteObject | RemoteArray | RichTextSource<
|
8
|
+
export type RemoteCompatibleSource = SourcePrimitive | RemoteObject | RemoteArray | RichTextSource<AllRichTextOptions> | FileSource | I18nSource<string[], I18nCompatibleSource>;
|
9
9
|
export type RemoteObject = {
|
10
10
|
[key in string]: RemoteCompatibleSource;
|
11
11
|
};
|
@@ -6,18 +6,25 @@ export type Source = SourcePrimitive | SourceObject | SourceArray | I18nSource<s
|
|
6
6
|
export type SourceObject = {
|
7
7
|
[key in string]: Source;
|
8
8
|
} & {
|
9
|
+
/** Reserved name */
|
9
10
|
fold?: never;
|
11
|
+
/** Reserved name */
|
10
12
|
assert?: never;
|
13
|
+
/** Reserved name */
|
11
14
|
andThen?: never;
|
15
|
+
/** Reserved name */
|
12
16
|
_ref?: never;
|
17
|
+
/** Reserved name */
|
13
18
|
_type?: never;
|
19
|
+
/** Reserved name */
|
14
20
|
val?: never;
|
21
|
+
/** Reserved name */
|
15
22
|
valPath?: never;
|
16
23
|
};
|
17
24
|
export type SourceArray = readonly Source[];
|
18
25
|
export type SourcePrimitive = string | number | boolean | null;
|
19
26
|
export declare const VAL_EXTENSION: "_type";
|
20
|
-
export declare function getValExtension(source: Source): false | "" | 0 | "file" | "remote" | "
|
27
|
+
export declare function getValExtension(source: Source): false | "" | 0 | "file" | "remote" | "i18n" | null | undefined;
|
21
28
|
/**
|
22
29
|
* A phantom type parameter is one that doesn't show up at runtime, but is checked statically (and only) at compile time.
|
23
30
|
*
|
@@ -1,96 +1,102 @@
|
|
1
|
-
import { VAL_EXTENSION } from "./index.js";
|
2
1
|
import { LinkSource } from "./link.js";
|
3
2
|
import { ImageSource } from "./image.js";
|
4
3
|
import { ImageMetadata } from "../schema/image.js";
|
5
4
|
import { FileSource } from "./file.js";
|
6
|
-
export type RichTextOptions = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
export type RichTextOptions = Partial<{
|
6
|
+
style: Partial<{
|
7
|
+
bold: boolean;
|
8
|
+
italic: boolean;
|
9
|
+
lineThrough: boolean;
|
10
|
+
}>;
|
11
|
+
block: Partial<{
|
12
|
+
h1: boolean;
|
13
|
+
h2: boolean;
|
14
|
+
h3: boolean;
|
15
|
+
h4: boolean;
|
16
|
+
h5: boolean;
|
17
|
+
h6: boolean;
|
18
|
+
ul: boolean;
|
19
|
+
ol: boolean;
|
20
|
+
}>;
|
21
|
+
inline: Partial<{
|
22
|
+
a: boolean;
|
23
|
+
img: boolean;
|
24
|
+
}>;
|
25
|
+
}>;
|
26
|
+
export type AllRichTextOptions = {
|
27
|
+
style: {
|
28
|
+
bold: true;
|
29
|
+
italic: true;
|
30
|
+
lineThrough: true;
|
31
|
+
};
|
32
|
+
block: {
|
33
|
+
h1: true;
|
34
|
+
h2: true;
|
35
|
+
h3: true;
|
36
|
+
h4: true;
|
37
|
+
h5: true;
|
38
|
+
h6: true;
|
39
|
+
ul: true;
|
40
|
+
ol: true;
|
41
|
+
};
|
42
|
+
inline: {
|
43
|
+
a: true;
|
44
|
+
img: true;
|
45
|
+
};
|
15
46
|
};
|
16
|
-
export type
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
ul: true;
|
21
|
-
ol: true;
|
22
|
-
lineThrough: true;
|
23
|
-
bold: true;
|
24
|
-
italic: true;
|
25
|
-
};
|
26
|
-
export type LineThrough<O extends RichTextOptions> = O["lineThrough"] extends true ? "line-through" : never;
|
27
|
-
export type Italic<O extends RichTextOptions> = O["italic"] extends true ? "italic" : never;
|
28
|
-
export type Bold<O extends RichTextOptions> = O["bold"] extends true ? "bold" : never;
|
29
|
-
export type Classes<O extends RichTextOptions> = LineThrough<O> | Italic<O> | Bold<O>;
|
47
|
+
export type LineThrough<O extends RichTextOptions> = NonNullable<O["style"]>["lineThrough"] extends true ? "line-through" : never;
|
48
|
+
export type Italic<O extends RichTextOptions> = NonNullable<O["style"]>["italic"] extends true ? "italic" : never;
|
49
|
+
export type Bold<O extends RichTextOptions> = NonNullable<O["style"]>["bold"] extends true ? "bold" : never;
|
50
|
+
export type Styles<O extends RichTextOptions> = LineThrough<O> | Italic<O> | Bold<O>;
|
30
51
|
export type ParagraphNode<O extends RichTextOptions> = {
|
31
52
|
tag: "p";
|
32
|
-
children: (string | SpanNode<O> | BrNode | LinkNode<O> | ImageNode<O>)[];
|
53
|
+
children: (string | SpanNode<O> | BrNode | LinkNode<O> | ImageNode<O> | CustomInlineNode<O>)[];
|
33
54
|
};
|
34
55
|
export type BrNode = {
|
35
56
|
tag: "br";
|
36
57
|
};
|
37
58
|
export type SpanNode<O extends RichTextOptions> = {
|
38
59
|
tag: "span";
|
39
|
-
|
60
|
+
styles: Styles<O>[];
|
40
61
|
children: [string];
|
41
62
|
};
|
42
|
-
type
|
63
|
+
export type ImageNode<O extends RichTextOptions> = NonNullable<O["inline"]>["img"] extends true ? {
|
43
64
|
tag: "img";
|
44
|
-
src:
|
45
|
-
|
46
|
-
height?: number;
|
47
|
-
width?: number;
|
48
|
-
mimeType?: string;
|
49
|
-
};
|
50
|
-
export type ImageNode<O extends RichTextOptions> = O["img"] extends true ? ImageTagNode : never;
|
65
|
+
src: ImageSource;
|
66
|
+
} : never;
|
51
67
|
type LinkTagNode<O extends RichTextOptions> = {
|
52
68
|
tag: "a";
|
53
69
|
href: string;
|
54
|
-
children: (string | SpanNode<O>)[];
|
70
|
+
children: (string | SpanNode<O> | ImageNode<O> | CustomInlineNode<O>)[];
|
55
71
|
};
|
56
|
-
export type LinkNode<O extends RichTextOptions> = O["a"] extends true ? LinkTagNode<O> : never;
|
57
|
-
|
72
|
+
export type LinkNode<O extends RichTextOptions> = NonNullable<O["inline"]>["a"] extends true ? LinkTagNode<O> : never;
|
73
|
+
type ListItemTagNode<O extends RichTextOptions> = {
|
58
74
|
tag: "li";
|
59
|
-
children: (
|
60
|
-
}
|
61
|
-
export type
|
75
|
+
children: (ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O>)[];
|
76
|
+
};
|
77
|
+
export type ListItemNode<O extends RichTextOptions> = NonNullable<O["block"]>["ul"] extends true ? ListItemTagNode<O> : never | NonNullable<O["block"]>["ol"] extends true ? ListItemTagNode<O> : never;
|
78
|
+
export type UnorderedListNode<O extends RichTextOptions> = NonNullable<O["block"]>["ul"] extends true ? {
|
62
79
|
tag: "ul";
|
63
|
-
dir?: "ltr" | "rtl";
|
64
80
|
children: ListItemNode<O>[];
|
65
81
|
} : never;
|
66
|
-
export type OrderedListNode<O extends RichTextOptions> = O["ol"] extends true ? {
|
82
|
+
export type OrderedListNode<O extends RichTextOptions> = NonNullable<O["block"]>["ol"] extends true ? {
|
67
83
|
tag: "ol";
|
68
|
-
dir?: "ltr" | "rtl";
|
69
84
|
children: ListItemNode<O>[];
|
70
85
|
} : never;
|
71
|
-
export type
|
72
|
-
tag:
|
73
|
-
children: (string | SpanNode<O>)[];
|
86
|
+
export type HeadingTagOf<S extends keyof NonNullable<NonNullable<O["block"]>>, O extends RichTextOptions> = NonNullable<NonNullable<O["block"]>>[S] extends true ? {
|
87
|
+
tag: S;
|
88
|
+
children: (string | SpanNode<O> | CustomInlineNode<O> | LinkNode<O> | BrNode | ImageNode<O>)[];
|
74
89
|
} : never;
|
75
|
-
export type
|
76
|
-
export type
|
90
|
+
export type HeadingNode<O extends RichTextOptions> = HeadingTagOf<"h1", O> | HeadingTagOf<"h2", O> | HeadingTagOf<"h3", O> | HeadingTagOf<"h4", O> | HeadingTagOf<"h5", O> | HeadingTagOf<"h6", O>;
|
91
|
+
export type CustomInlineNode<O extends RichTextOptions> = never;
|
92
|
+
export type CustomBlockNode<O extends RichTextOptions> = never;
|
93
|
+
export type RichTextNode<O extends RichTextOptions> = string | BlockNode<O> | ListItemNode<O> | BrNode | SpanNode<O> | LinkNode<O> | ImageNode<O> | CustomInlineNode<O>;
|
94
|
+
export type BlockNode<O extends RichTextOptions> = HeadingNode<O> | ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O> | CustomBlockNode<O>;
|
77
95
|
/**
|
78
|
-
*
|
96
|
+
* RichText as defined in a ValModule
|
79
97
|
**/
|
80
|
-
export type RichTextSource<O extends RichTextOptions> =
|
81
|
-
|
82
|
-
templateStrings: string[];
|
83
|
-
exprs: ((O["img"] extends true ? ImageSource : never) | (O["a"] extends true ? LinkSource : never))[];
|
84
|
-
};
|
85
|
-
/**
|
86
|
-
* RichText is accessible by users (after conversion via useVal / fetchVal)
|
87
|
-
* Internally it is a Selector
|
88
|
-
**/
|
89
|
-
export type RichText<O extends RichTextOptions> = {
|
90
|
-
[VAL_EXTENSION]: "richtext";
|
91
|
-
children: RootNode<O>[];
|
92
|
-
};
|
93
|
-
export declare function richtext<O extends RichTextOptions>(templateStrings: TemplateStringsArray, ...nodes: (ImageSource | LinkSource)[]): RichTextSource<O>;
|
98
|
+
export type RichTextSource<O extends RichTextOptions> = BlockNode<O>[];
|
99
|
+
export declare function richtext<O extends RichTextOptions>(templateStrings: TemplateStringsArray, ...nodes: (ImageSource | LinkSource)[]): RichTextSource<{}>;
|
94
100
|
export declare const RT_IMAGE_TAG = "rt_image";
|
95
101
|
export type RTImageMetadata = ImageMetadata;
|
96
102
|
export declare function image(ref: `/public/${string}`, metadata?: RTImageMetadata): FileSource<RTImageMetadata>;
|