@erudit-js/prose 4.1.0 → 4.2.0-dev.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.
- package/dist/app/appElement.d.ts +7 -6
- package/dist/app/appElement.js +1 -1
- package/dist/app/composables/anchor.d.ts +7 -7
- package/dist/app/composables/appElement.d.ts +4 -4
- package/dist/app/composables/appElement.js +3 -3
- package/dist/app/composables/context.d.ts +3 -2
- package/dist/app/composables/elementIcon.d.ts +2 -2
- package/dist/app/composables/elementIcon.js +1 -1
- package/dist/app/composables/language.d.ts +2 -2
- package/dist/app/composables/language.js +1 -1
- package/dist/app/composables/storage.d.ts +4 -4
- package/dist/app/composables/storage.js +0 -4
- package/dist/app/default/Mix.vue +2 -2
- package/dist/app/default/Text.vue +2 -2
- package/dist/app/shared/Prose.vue +3 -3
- package/dist/app/shared/Render.vue +5 -14
- package/dist/app/shared/block/AsideMenu.vue +2 -2
- package/dist/app/shared/block/AsideMenuCopyLink.vue +1 -1
- package/dist/app/shared/block/Block.vue +4 -4
- package/dist/app/shared/inliner/Inliner.vue +2 -2
- package/dist/coreElement.d.ts +25 -7
- package/dist/coreElement.js +2 -2
- package/dist/elements/accent/Accent.vue +4 -4
- package/dist/elements/accent/AccentColumnSection.vue +2 -2
- package/dist/elements/accent/AccentRowSections.vue +2 -2
- package/dist/elements/accent/app.d.ts +3 -3
- package/dist/elements/accent/app.js +2 -2
- package/dist/elements/accent/core.d.ts +61 -300
- package/dist/elements/accent/core.js +83 -68
- package/dist/elements/callout/Callout.vue +4 -4
- package/dist/elements/callout/app.d.ts +1 -8
- package/dist/elements/callout/app.js +2 -2
- package/dist/elements/callout/core.d.ts +21 -59
- package/dist/elements/callout/core.js +18 -17
- package/dist/elements/caption/Caption.vue +3 -3
- package/dist/elements/caption/app.d.ts +1 -8
- package/dist/elements/caption/app.js +2 -2
- package/dist/elements/caption/core.d.ts +21 -99
- package/dist/elements/caption/core.js +18 -22
- package/dist/elements/details/Details.vue +3 -3
- package/dist/elements/details/app.d.ts +1 -8
- package/dist/elements/details/app.js +2 -2
- package/dist/elements/details/core.d.ts +18 -61
- package/dist/elements/details/core.js +16 -11
- package/dist/elements/diagram/Diagram.vue +14 -11
- package/dist/elements/diagram/app.d.ts +1 -29
- package/dist/elements/diagram/app.js +2 -2
- package/dist/elements/diagram/core.d.ts +14 -177
- package/dist/elements/diagram/core.js +5 -8
- package/dist/elements/emphasis/Emphasis.vue +3 -3
- package/dist/elements/emphasis/app.d.ts +1 -8
- package/dist/elements/emphasis/app.js +2 -2
- package/dist/elements/emphasis/core.d.ts +13 -76
- package/dist/elements/emphasis/core.js +8 -9
- package/dist/elements/flex/Flex.vue +3 -3
- package/dist/elements/flex/app.d.ts +1 -8
- package/dist/elements/flex/app.js +2 -2
- package/dist/elements/flex/core.d.ts +16 -58
- package/dist/elements/flex/core.js +6 -7
- package/dist/elements/gallery/Gallery.vue +3 -3
- package/dist/elements/gallery/app.d.ts +1 -22
- package/dist/elements/gallery/app.js +2 -2
- package/dist/elements/gallery/core.d.ts +11 -132
- package/dist/elements/gallery/core.js +4 -5
- package/dist/elements/heading/Heading.vue +3 -3
- package/dist/elements/heading/_global.d.ts +2 -2
- package/dist/elements/heading/app.d.ts +1 -8
- package/dist/elements/heading/app.js +2 -2
- package/dist/elements/heading/core.d.ts +13 -97
- package/dist/elements/heading/core.js +8 -8
- package/dist/elements/horizontalLine/app.d.ts +1 -8
- package/dist/elements/horizontalLine/app.js +2 -2
- package/dist/elements/horizontalLine/core.d.ts +9 -47
- package/dist/elements/horizontalLine/core.js +4 -5
- package/dist/elements/image/Image.vue +3 -3
- package/dist/elements/image/ImageElement.vue +4 -4
- package/dist/elements/image/app.d.ts +1 -15
- package/dist/elements/image/app.js +2 -2
- package/dist/elements/image/core.d.ts +29 -108
- package/dist/elements/image/core.js +12 -19
- package/dist/elements/image/storage.d.ts +1 -1
- package/dist/elements/image/storage.js +6 -6
- package/dist/elements/lineBreak/app.d.ts +1 -8
- package/dist/elements/lineBreak/app.js +2 -2
- package/dist/elements/lineBreak/core.d.ts +9 -47
- package/dist/elements/lineBreak/core.js +4 -5
- package/dist/elements/link/BlockLink.vue +4 -6
- package/dist/elements/link/Link.vue +4 -4
- package/dist/elements/link/core.d.ts +8 -7
- package/dist/elements/link/core.js +5 -4
- package/dist/elements/link/dependency/app.d.ts +1 -15
- package/dist/elements/link/dependency/app.js +3 -3
- package/dist/elements/link/dependency/core.d.ts +30 -108
- package/dist/elements/link/dependency/core.js +6 -8
- package/dist/elements/link/hook.d.ts +12 -0
- package/dist/elements/link/hook.js +45 -0
- package/dist/elements/link/reference/app.d.ts +1 -15
- package/dist/elements/link/reference/app.js +3 -3
- package/dist/elements/link/reference/core.d.ts +24 -103
- package/dist/elements/link/reference/core.js +6 -8
- package/dist/elements/link/storage.js +1 -1
- package/dist/elements/list/List.vue +7 -5
- package/dist/elements/list/_global.d.ts +3 -3
- package/dist/elements/list/app.d.ts +1 -15
- package/dist/elements/list/app.js +2 -2
- package/dist/elements/list/core.d.ts +33 -155
- package/dist/elements/list/core.js +20 -18
- package/dist/elements/math/app.d.ts +1 -15
- package/dist/elements/math/app.js +3 -3
- package/dist/elements/math/block.d.ts +31 -43
- package/dist/elements/math/block.js +10 -9
- package/dist/elements/math/components/BlockMath.vue +4 -4
- package/dist/elements/math/components/InlinerMath.vue +4 -4
- package/dist/elements/math/core.d.ts +25 -53
- package/dist/elements/math/core.js +3 -11
- package/dist/elements/math/inliner.d.ts +24 -36
- package/dist/elements/math/inliner.js +10 -12
- package/dist/elements/paragraph/Paragraph.vue +3 -3
- package/dist/elements/paragraph/app.d.ts +1 -8
- package/dist/elements/paragraph/app.js +2 -2
- package/dist/elements/paragraph/core.d.ts +12 -53
- package/dist/elements/paragraph/core.js +6 -7
- package/dist/elements/problem/app.d.ts +1 -29
- package/dist/elements/problem/app.js +4 -4
- package/dist/elements/problem/components/Problem.vue +3 -3
- package/dist/elements/problem/components/ProblemContent.vue +15 -21
- package/dist/elements/problem/components/ProblemExpanderSection.vue +2 -2
- package/dist/elements/problem/components/Problems.vue +11 -7
- package/dist/elements/problem/components/SubProblem.vue +3 -4
- package/dist/elements/problem/components/expanders/Check.vue +3 -3
- package/dist/elements/problem/components/expanders/Checks.vue +6 -3
- package/dist/elements/problem/components/expanders/DefaultPlusSections.vue +3 -7
- package/dist/elements/problem/components/expanders/Hint.vue +3 -3
- package/dist/elements/problem/composables/problemScript.d.ts +2 -2
- package/dist/elements/problem/core.d.ts +63 -299
- package/dist/elements/problem/core.js +9 -11
- package/dist/elements/problem/hook.d.ts +1 -0
- package/dist/elements/problem/hook.js +14 -0
- package/dist/elements/problem/problem.d.ts +20 -77
- package/dist/elements/problem/problem.js +6 -6
- package/dist/elements/problem/problemCheck.d.ts +33 -83
- package/dist/elements/problem/problemCheck.js +16 -10
- package/dist/elements/problem/problemContent.d.ts +54 -401
- package/dist/elements/problem/problemContent.js +47 -56
- package/dist/elements/problem/problemScript.d.ts +18 -10
- package/dist/elements/problem/problemScript.js +15 -26
- package/dist/elements/problem/problems.d.ts +29 -188
- package/dist/elements/problem/problems.js +11 -15
- package/dist/elements/problem/storage.d.ts +1 -1
- package/dist/elements/problem/storage.js +2 -3
- package/dist/elements/table/Table.vue +3 -3
- package/dist/elements/table/app.d.ts +1 -29
- package/dist/elements/table/app.js +2 -2
- package/dist/elements/table/core.d.ts +28 -309
- package/dist/elements/table/core.js +17 -29
- package/dist/elements/video/Video.vue +4 -4
- package/dist/elements/video/app.d.ts +1 -15
- package/dist/elements/video/app.js +2 -2
- package/dist/elements/video/core.d.ts +26 -106
- package/dist/elements/video/core.js +11 -16
- package/dist/elements/video/storage.d.ts +1 -1
- package/dist/elements/video/storage.js +2 -3
- package/dist/error.d.ts +3 -0
- package/dist/error.js +6 -0
- package/dist/include.d.ts +4 -4
- package/dist/include.js +6 -12
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/dist/rawElement.d.ts +9 -6
- package/dist/rawElement.js +4 -0
- package/dist/rawToProse/countSchemas.d.ts +1 -0
- package/dist/rawToProse/countSchemas.js +11 -0
- package/dist/rawToProse/hook.d.ts +39 -0
- package/dist/rawToProse/hook.js +6 -0
- package/dist/rawToProse/index.d.ts +34 -0
- package/dist/rawToProse/index.js +92 -0
- package/dist/rawToProse/uniqueTitles.d.ts +1 -0
- package/dist/rawToProse/uniqueTitles.js +11 -0
- package/dist/shared/filePath.js +2 -2
- package/dist/shared/paragraphWrap.d.ts +3 -3
- package/dist/shared/paragraphWrap.js +7 -12
- package/dist/slugify/index.d.ts +3 -1
- package/dist/slugify/index.js +5 -6
- package/dist/slugify/languages/en.js +1 -1
- package/dist/slugify/languages/ru.js +1 -1
- package/dist/snippet.d.ts +39 -33
- package/dist/snippet.js +139 -73
- package/dist/tag.d.ts +22 -19
- package/dist/tag.js +19 -15
- package/dist/toc.d.ts +12 -18
- package/dist/toc.js +120 -42
- package/package.json +7 -6
- package/dist/app/default/Inliners.vue +0 -11
- package/dist/context.d.ts +0 -4
- package/dist/context.js +0 -1
- package/dist/elements/link/step.d.ts +0 -16
- package/dist/elements/link/step.js +0 -36
- package/dist/elements/problem/step.d.ts +0 -5
- package/dist/elements/problem/step.js +0 -13
- package/dist/resolve.d.ts +0 -21
- package/dist/resolve.js +0 -102
- package/dist/resolveStep.d.ts +0 -9
- package/dist/resolveStep.js +0 -3
- package/dist/title.d.ts +0 -8
- package/dist/title.js +0 -6
- package/dist/utils/docs.d.ts +0 -1
- package/dist/utils/docs.js +0 -22
- package/types.d.ts +0 -4
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ProseElement, type Schema, type ToProseElement } from 'tsprose';
|
|
2
2
|
import { type UppercaseFirst } from '../../utils/case.js';
|
|
3
3
|
export interface AccentDefinition<TName extends string, TSectionNames extends readonly string[]> {
|
|
4
4
|
name: TName;
|
|
5
5
|
sectionNames: TSectionNames;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export interface AccentMainSchema<AccentName extends string = string> extends Schema {
|
|
8
|
+
name: `accentMain_${AccentName}`;
|
|
9
|
+
type: 'block';
|
|
8
10
|
linkable: false;
|
|
9
11
|
Data: undefined;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
Storage: undefined;
|
|
13
|
+
Children: Schema[];
|
|
14
|
+
}
|
|
15
|
+
export declare function isAccentMainElement(element: ProseElement): element is ToProseElement<AccentMainSchema>;
|
|
16
|
+
export interface AccentSectionSchema<AccentName extends string = string> extends Schema {
|
|
17
|
+
name: `accentSection_${AccentName}`;
|
|
18
|
+
type: 'block';
|
|
12
19
|
linkable: false;
|
|
13
20
|
Data: {
|
|
14
21
|
type: 'named';
|
|
@@ -17,324 +24,78 @@ export type AccentSectionSchema = Omit<BlockSchema, 'Data' | 'linkable'> & {
|
|
|
17
24
|
type: 'manual';
|
|
18
25
|
title: string;
|
|
19
26
|
};
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
Storage: undefined;
|
|
28
|
+
Children: Schema[];
|
|
29
|
+
}
|
|
30
|
+
export declare function isAccentSectionElement(element: ProseElement): element is ToProseElement<AccentSectionSchema>;
|
|
31
|
+
export interface AccentSchema<AccentName extends string = string> extends Schema {
|
|
32
|
+
name: `accent_${AccentName}`;
|
|
33
|
+
type: 'block';
|
|
22
34
|
linkable: true;
|
|
23
35
|
Data: {
|
|
24
36
|
title: string;
|
|
25
37
|
layout: 'column' | 'row';
|
|
26
38
|
};
|
|
27
|
-
|
|
39
|
+
Storage: undefined;
|
|
40
|
+
Children: [
|
|
41
|
+
AccentMainSchema<AccentName>,
|
|
42
|
+
...AccentSectionSchema<AccentName>[]
|
|
43
|
+
];
|
|
28
44
|
SectionNames: string[];
|
|
29
|
-
}
|
|
30
|
-
export declare function isAccentElement(element:
|
|
31
|
-
export declare function
|
|
32
|
-
|
|
33
|
-
export declare function defineAccentCore<const I extends string, const J extends string[], const TDefinition extends AccentDefinition<I, J>>(definition: TDefinition): {
|
|
34
|
-
_sectionNames: TDefinition["sectionNames"];
|
|
45
|
+
}
|
|
46
|
+
export declare function isAccentElement(element: any): element is ToProseElement<AccentSchema>;
|
|
47
|
+
export declare function defineAccentCore<const TName extends string, const TSectionNames extends string[]>(definition: AccentDefinition<TName, TSectionNames>): {
|
|
48
|
+
_sectionNames: TSectionNames;
|
|
35
49
|
accent: {
|
|
36
|
-
schema: {
|
|
37
|
-
|
|
38
|
-
type: "block";
|
|
39
|
-
linkable: true;
|
|
40
|
-
Data: {
|
|
41
|
-
title: string;
|
|
42
|
-
layout: "column" | "row";
|
|
43
|
-
};
|
|
44
|
-
Storage: undefined;
|
|
45
|
-
Children: [{
|
|
46
|
-
name: `accentMain_${TDefinition["name"]}`;
|
|
47
|
-
type: "block";
|
|
48
|
-
linkable: false;
|
|
49
|
-
Data: undefined;
|
|
50
|
-
Storage: undefined;
|
|
51
|
-
Children: AnySchema[];
|
|
52
|
-
}, ...{
|
|
53
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
54
|
-
type: "block";
|
|
55
|
-
linkable: false;
|
|
56
|
-
Data: {
|
|
57
|
-
type: "named";
|
|
58
|
-
name: string;
|
|
59
|
-
} | {
|
|
60
|
-
type: "manual";
|
|
61
|
-
title: string;
|
|
62
|
-
};
|
|
63
|
-
Storage: undefined;
|
|
64
|
-
Children: AnySchema[];
|
|
65
|
-
}[]];
|
|
66
|
-
} & {
|
|
67
|
-
SectionNames: TDefinition["sectionNames"];
|
|
50
|
+
schema: Omit<AccentSchema<TName>, "SectionNames"> & {
|
|
51
|
+
SectionNames: TSectionNames;
|
|
68
52
|
};
|
|
69
|
-
tag: import("
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
linkable: true;
|
|
73
|
-
Data: {
|
|
74
|
-
title: string;
|
|
75
|
-
layout: "column" | "row";
|
|
76
|
-
};
|
|
77
|
-
Storage: undefined;
|
|
78
|
-
Children: [{
|
|
79
|
-
name: `accentMain_${TDefinition["name"]}`;
|
|
80
|
-
type: "block";
|
|
81
|
-
linkable: false;
|
|
82
|
-
Data: undefined;
|
|
83
|
-
Storage: undefined;
|
|
84
|
-
Children: AnySchema[];
|
|
85
|
-
}, ...{
|
|
86
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
87
|
-
type: "block";
|
|
88
|
-
linkable: false;
|
|
89
|
-
Data: {
|
|
90
|
-
type: "named";
|
|
91
|
-
name: string;
|
|
92
|
-
} | {
|
|
93
|
-
type: "manual";
|
|
94
|
-
title: string;
|
|
95
|
-
};
|
|
96
|
-
Storage: undefined;
|
|
97
|
-
Children: AnySchema[];
|
|
98
|
-
}[]];
|
|
99
|
-
} & {
|
|
100
|
-
SectionNames: TDefinition["sectionNames"];
|
|
101
|
-
}, ({
|
|
53
|
+
tag: import("../../tag.js").ToEruditTag<Omit<AccentSchema<TName>, "SectionNames"> & {
|
|
54
|
+
SectionNames: TSectionNames;
|
|
55
|
+
}, UppercaseFirst<TName>, {
|
|
102
56
|
title: string;
|
|
103
|
-
} & (
|
|
57
|
+
} & ({
|
|
104
58
|
row?: true;
|
|
105
59
|
column?: undefined;
|
|
106
60
|
} | {
|
|
107
61
|
row?: undefined;
|
|
108
62
|
column?: true;
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
linkable: true;
|
|
114
|
-
Data: {
|
|
115
|
-
title: string;
|
|
116
|
-
layout: "column" | "row";
|
|
63
|
+
})>;
|
|
64
|
+
coreElement: {
|
|
65
|
+
readonly schema: Omit<AccentSchema<TName>, "SectionNames"> & {
|
|
66
|
+
SectionNames: TSectionNames;
|
|
117
67
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
type: "block";
|
|
122
|
-
linkable: false;
|
|
123
|
-
Data: undefined;
|
|
124
|
-
Storage: undefined;
|
|
125
|
-
Children: AnySchema[];
|
|
126
|
-
}, ...{
|
|
127
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
128
|
-
type: "block";
|
|
129
|
-
linkable: false;
|
|
130
|
-
Data: {
|
|
131
|
-
type: "named";
|
|
132
|
-
name: string;
|
|
133
|
-
} | {
|
|
134
|
-
type: "manual";
|
|
135
|
-
title: string;
|
|
136
|
-
};
|
|
137
|
-
Storage: undefined;
|
|
138
|
-
Children: AnySchema[];
|
|
139
|
-
}[]];
|
|
140
|
-
} & {
|
|
141
|
-
SectionNames: TDefinition["sectionNames"];
|
|
142
|
-
}, { [K in `${UppercaseFirst<TDefinition["name"]>}`]: Extract<import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}`, {
|
|
143
|
-
name: `accent_${TDefinition["name"]}`;
|
|
144
|
-
type: "block";
|
|
145
|
-
linkable: true;
|
|
146
|
-
Data: {
|
|
68
|
+
readonly tags: [import("../../tag.js").ToEruditTag<Omit<AccentSchema<TName>, "SectionNames"> & {
|
|
69
|
+
SectionNames: TSectionNames;
|
|
70
|
+
}, UppercaseFirst<TName>, {
|
|
147
71
|
title: string;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Storage: undefined;
|
|
157
|
-
Children: AnySchema[];
|
|
158
|
-
}, ...{
|
|
159
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
160
|
-
type: "block";
|
|
161
|
-
linkable: false;
|
|
162
|
-
Data: {
|
|
163
|
-
type: "named";
|
|
164
|
-
name: string;
|
|
165
|
-
} | {
|
|
166
|
-
type: "manual";
|
|
167
|
-
title: string;
|
|
168
|
-
};
|
|
169
|
-
Storage: undefined;
|
|
170
|
-
Children: AnySchema[];
|
|
171
|
-
}[]];
|
|
172
|
-
} & {
|
|
173
|
-
SectionNames: TDefinition["sectionNames"];
|
|
174
|
-
}, ({
|
|
175
|
-
title: string;
|
|
176
|
-
} & (({
|
|
177
|
-
row?: true;
|
|
178
|
-
column?: undefined;
|
|
179
|
-
} | {
|
|
180
|
-
row?: undefined;
|
|
181
|
-
column?: true;
|
|
182
|
-
}) & TagChildren)) & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>, {
|
|
183
|
-
tagName: K;
|
|
184
|
-
}>; }, undefined>;
|
|
72
|
+
} & ({
|
|
73
|
+
row?: true;
|
|
74
|
+
column?: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
row?: undefined;
|
|
77
|
+
column?: true;
|
|
78
|
+
})>];
|
|
79
|
+
};
|
|
185
80
|
};
|
|
186
81
|
main: {
|
|
187
|
-
schema:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Storage: undefined;
|
|
193
|
-
Children: AnySchema[];
|
|
82
|
+
schema: AccentMainSchema<TName>;
|
|
83
|
+
tag: import("../../tag.js").ToEruditTag<AccentMainSchema<TName>, `${UppercaseFirst<TName>}Main`, unknown>;
|
|
84
|
+
coreElement: {
|
|
85
|
+
readonly schema: AccentMainSchema<TName>;
|
|
86
|
+
readonly tags: [import("../../tag.js").ToEruditTag<AccentMainSchema<TName>, `${UppercaseFirst<TName>}Main`, unknown>];
|
|
194
87
|
};
|
|
195
|
-
tag: import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}Main`, {
|
|
196
|
-
name: `accentMain_${TDefinition["name"]}`;
|
|
197
|
-
type: "block";
|
|
198
|
-
linkable: false;
|
|
199
|
-
Data: undefined;
|
|
200
|
-
Storage: undefined;
|
|
201
|
-
Children: AnySchema[];
|
|
202
|
-
}, TagChildren>;
|
|
203
|
-
registryItem: import("@jsprose/core").RegistryItem<{
|
|
204
|
-
name: `accentMain_${TDefinition["name"]}`;
|
|
205
|
-
type: "block";
|
|
206
|
-
linkable: false;
|
|
207
|
-
Data: undefined;
|
|
208
|
-
Storage: undefined;
|
|
209
|
-
Children: AnySchema[];
|
|
210
|
-
}, { [K_1 in `${UppercaseFirst<TDefinition["name"]>}Main`]: Extract<import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}Main`, {
|
|
211
|
-
name: `accentMain_${TDefinition["name"]}`;
|
|
212
|
-
type: "block";
|
|
213
|
-
linkable: false;
|
|
214
|
-
Data: undefined;
|
|
215
|
-
Storage: undefined;
|
|
216
|
-
Children: AnySchema[];
|
|
217
|
-
}, TagChildren>, {
|
|
218
|
-
tagName: K_1;
|
|
219
|
-
}>; }, undefined>;
|
|
220
88
|
};
|
|
221
89
|
section: {
|
|
222
|
-
schema:
|
|
223
|
-
|
|
224
|
-
type: "block";
|
|
225
|
-
linkable: false;
|
|
226
|
-
Data: {
|
|
227
|
-
type: "named";
|
|
228
|
-
name: string;
|
|
229
|
-
} | {
|
|
230
|
-
type: "manual";
|
|
231
|
-
title: string;
|
|
232
|
-
};
|
|
233
|
-
Storage: undefined;
|
|
234
|
-
Children: AnySchema[];
|
|
235
|
-
};
|
|
236
|
-
tags: [import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}Section`, {
|
|
237
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
238
|
-
type: "block";
|
|
239
|
-
linkable: false;
|
|
240
|
-
Data: {
|
|
241
|
-
type: "named";
|
|
242
|
-
name: string;
|
|
243
|
-
} | {
|
|
244
|
-
type: "manual";
|
|
245
|
-
title: string;
|
|
246
|
-
};
|
|
247
|
-
Storage: undefined;
|
|
248
|
-
Children: AnySchema[];
|
|
249
|
-
}, {
|
|
90
|
+
schema: AccentSectionSchema<TName>;
|
|
91
|
+
tags: [import("../../tag.js").ToEruditTag<AccentSectionSchema<TName>, `${UppercaseFirst<TName>}Section`, {
|
|
250
92
|
title: string;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
Data: {
|
|
256
|
-
type: "named";
|
|
257
|
-
name: string;
|
|
258
|
-
} | {
|
|
259
|
-
type: "manual";
|
|
260
|
-
title: string;
|
|
261
|
-
};
|
|
262
|
-
Storage: undefined;
|
|
263
|
-
Children: AnySchema[];
|
|
264
|
-
}, TagChildren>; }[TDefinition["sectionNames"][number]][]];
|
|
265
|
-
registryItem: import("@jsprose/core").RegistryItem<{
|
|
266
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
267
|
-
type: "block";
|
|
268
|
-
linkable: false;
|
|
269
|
-
Data: {
|
|
270
|
-
type: "named";
|
|
271
|
-
name: string;
|
|
272
|
-
} | {
|
|
273
|
-
type: "manual";
|
|
274
|
-
title: string;
|
|
275
|
-
};
|
|
276
|
-
Storage: undefined;
|
|
277
|
-
Children: AnySchema[];
|
|
278
|
-
}, { [K_3 in (import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}Section`, {
|
|
279
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
280
|
-
type: "block";
|
|
281
|
-
linkable: false;
|
|
282
|
-
Data: {
|
|
283
|
-
type: "named";
|
|
284
|
-
name: string;
|
|
285
|
-
} | {
|
|
286
|
-
type: "manual";
|
|
93
|
+
}>, ...{ [K in TSectionNames[number]]: import("../../tag.js").ToEruditTag<AccentSectionSchema<TName>, `${UppercaseFirst<TName>}${UppercaseFirst<K>}`, unknown>; }[TSectionNames[number]][]];
|
|
94
|
+
coreElement: {
|
|
95
|
+
readonly schema: AccentSectionSchema<TName>;
|
|
96
|
+
readonly tags: [import("../../tag.js").ToEruditTag<AccentSectionSchema<TName>, `${UppercaseFirst<TName>}Section`, {
|
|
287
97
|
title: string;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
Children: AnySchema[];
|
|
291
|
-
}, {
|
|
292
|
-
title: string;
|
|
293
|
-
} & TagChildren> | { [K_2 in TDefinition["sectionNames"][number]]: import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}${UppercaseFirst<K_2>}`, {
|
|
294
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
295
|
-
type: "block";
|
|
296
|
-
linkable: false;
|
|
297
|
-
Data: {
|
|
298
|
-
type: "named";
|
|
299
|
-
name: string;
|
|
300
|
-
} | {
|
|
301
|
-
type: "manual";
|
|
302
|
-
title: string;
|
|
303
|
-
};
|
|
304
|
-
Storage: undefined;
|
|
305
|
-
Children: AnySchema[];
|
|
306
|
-
}, TagChildren>; }[TDefinition["sectionNames"][number]])["tagName"]]: Extract<import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}Section`, {
|
|
307
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
308
|
-
type: "block";
|
|
309
|
-
linkable: false;
|
|
310
|
-
Data: {
|
|
311
|
-
type: "named";
|
|
312
|
-
name: string;
|
|
313
|
-
} | {
|
|
314
|
-
type: "manual";
|
|
315
|
-
title: string;
|
|
316
|
-
};
|
|
317
|
-
Storage: undefined;
|
|
318
|
-
Children: AnySchema[];
|
|
319
|
-
}, {
|
|
320
|
-
title: string;
|
|
321
|
-
} & TagChildren>, {
|
|
322
|
-
tagName: K_3;
|
|
323
|
-
}> | Extract<{ [K_2 in TDefinition["sectionNames"][number]]: import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}${UppercaseFirst<K_2>}`, {
|
|
324
|
-
name: `accentSection_${TDefinition["name"]}`;
|
|
325
|
-
type: "block";
|
|
326
|
-
linkable: false;
|
|
327
|
-
Data: {
|
|
328
|
-
type: "named";
|
|
329
|
-
name: string;
|
|
330
|
-
} | {
|
|
331
|
-
type: "manual";
|
|
332
|
-
title: string;
|
|
333
|
-
};
|
|
334
|
-
Storage: undefined;
|
|
335
|
-
Children: AnySchema[];
|
|
336
|
-
}, TagChildren>; }[TDefinition["sectionNames"][number]], {
|
|
337
|
-
tagName: K_3;
|
|
338
|
-
}>; }, undefined>;
|
|
98
|
+
}>, ...{ [K in TSectionNames[number]]: import("../../tag.js").ToEruditTag<AccentSectionSchema<TName>, `${UppercaseFirst<TName>}${UppercaseFirst<K>}`, unknown>; }[TSectionNames[number]][]];
|
|
99
|
+
};
|
|
339
100
|
};
|
|
340
101
|
};
|
|
@@ -1,41 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineSchema, ensureTagChildren, isRawElement } from "tsprose";
|
|
2
2
|
import { defineEruditTag } from "../../tag.js";
|
|
3
3
|
import { uppercaseFirst } from "../../utils/case.js";
|
|
4
|
-
import {
|
|
4
|
+
import { paragraphWrap } from "../../shared/paragraphWrap.js";
|
|
5
|
+
import { EruditProseError } from "../../error.js";
|
|
6
|
+
import { defineProseCoreElement } from "../../coreElement.js";
|
|
5
7
|
function validateTitle(tagName, title) {
|
|
6
8
|
if (!title) {
|
|
7
|
-
throw new
|
|
9
|
+
throw new EruditProseError(`<${tagName}> requires non-empty title attribute!`);
|
|
8
10
|
}
|
|
9
11
|
}
|
|
10
|
-
export function isAccentElement(element) {
|
|
11
|
-
return element.schemaName.startsWith("accent_");
|
|
12
|
-
}
|
|
13
12
|
export function isAccentMainElement(element) {
|
|
14
|
-
return element.
|
|
13
|
+
return element.schema.name.startsWith("accentMain_");
|
|
15
14
|
}
|
|
16
15
|
export function isAccentSectionElement(element) {
|
|
17
|
-
return element.
|
|
16
|
+
return element.schema.name.startsWith("accentSection_");
|
|
17
|
+
}
|
|
18
|
+
export function isAccentElement(element) {
|
|
19
|
+
const name = element?.schema?.name;
|
|
20
|
+
if (!name) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return name.startsWith("accent_");
|
|
18
24
|
}
|
|
19
25
|
export function defineAccentCore(definition) {
|
|
20
26
|
// Accent name must start with lowercase
|
|
21
27
|
if (!/^[a-z]/.test(definition.name)) {
|
|
22
|
-
throw new
|
|
28
|
+
throw new EruditProseError(`
|
|
23
29
|
Invalid accent name "${definition.name}"!
|
|
24
30
|
Accent names should start with lower case letter.
|
|
25
31
|
`.trim());
|
|
26
32
|
}
|
|
27
33
|
for (const sectionName of definition.sectionNames) {
|
|
28
34
|
if (sectionName === "section" || sectionName === "main") {
|
|
29
|
-
throw new
|
|
35
|
+
throw new EruditProseError(`Section names "section" and "main" are reserved for accent "${definition.name}"!`);
|
|
30
36
|
}
|
|
31
37
|
// Section name must start with lowercase
|
|
32
38
|
if (!/^[a-z]/.test(sectionName)) {
|
|
33
|
-
throw new
|
|
39
|
+
throw new EruditProseError(`
|
|
34
40
|
Invalid section name "${sectionName}" for accent "${definition.name}"!
|
|
35
41
|
Section names should start with lower case letter.
|
|
36
42
|
`.trim());
|
|
37
43
|
}
|
|
38
44
|
}
|
|
45
|
+
const Name = uppercaseFirst(definition.name);
|
|
46
|
+
function applyBlockChildren(tagName, children, element) {
|
|
47
|
+
ensureTagChildren(tagName, children);
|
|
48
|
+
element.children = paragraphWrap(children) ?? children;
|
|
49
|
+
}
|
|
39
50
|
//
|
|
40
51
|
// Schemas
|
|
41
52
|
//
|
|
@@ -43,42 +54,32 @@ Section names should start with lower case letter.
|
|
|
43
54
|
name: `accentMain_${definition.name}`,
|
|
44
55
|
type: "block",
|
|
45
56
|
linkable: false
|
|
46
|
-
})
|
|
57
|
+
});
|
|
47
58
|
const sectionSchema = defineSchema({
|
|
48
59
|
name: `accentSection_${definition.name}`,
|
|
49
60
|
type: "block",
|
|
50
61
|
linkable: false
|
|
51
|
-
})
|
|
52
|
-
const
|
|
62
|
+
});
|
|
63
|
+
const baseAccentSchema = defineSchema({
|
|
53
64
|
name: `accent_${definition.name}`,
|
|
54
65
|
type: "block",
|
|
55
66
|
linkable: true
|
|
56
|
-
})
|
|
57
|
-
const
|
|
67
|
+
});
|
|
68
|
+
const accentSchema = baseAccentSchema;
|
|
58
69
|
//
|
|
59
70
|
// Tags
|
|
60
71
|
//
|
|
61
72
|
const mainTag = defineEruditTag({
|
|
62
|
-
tagName: `${
|
|
73
|
+
tagName: `${Name}Main`,
|
|
63
74
|
schema: mainSchema
|
|
64
75
|
})(({ tagName, element, children }) => {
|
|
65
|
-
|
|
66
|
-
element.children = children;
|
|
67
|
-
const paragraphWrap = tryParagraphWrap(children);
|
|
68
|
-
if (paragraphWrap) {
|
|
69
|
-
element.children = paragraphWrap;
|
|
70
|
-
}
|
|
76
|
+
applyBlockChildren(tagName, children, element);
|
|
71
77
|
});
|
|
72
78
|
const sectionTag = defineEruditTag({
|
|
73
|
-
tagName: `${
|
|
79
|
+
tagName: `${Name}Section`,
|
|
74
80
|
schema: sectionSchema
|
|
75
81
|
})(({ tagName, element, props, children }) => {
|
|
76
|
-
|
|
77
|
-
element.children = children;
|
|
78
|
-
const paragraphWrap = tryParagraphWrap(children);
|
|
79
|
-
if (paragraphWrap) {
|
|
80
|
-
element.children = paragraphWrap;
|
|
81
|
-
}
|
|
82
|
+
applyBlockChildren(tagName, children, element);
|
|
82
83
|
const title = props.title.trim();
|
|
83
84
|
validateTitle(tagName, title);
|
|
84
85
|
element.data = {
|
|
@@ -88,67 +89,81 @@ Section names should start with lower case letter.
|
|
|
88
89
|
});
|
|
89
90
|
function createSuffixSectionTag(suffix) {
|
|
90
91
|
return defineEruditTag({
|
|
91
|
-
tagName: `${
|
|
92
|
+
tagName: `${Name}${uppercaseFirst(suffix)}`,
|
|
92
93
|
schema: sectionSchema
|
|
93
94
|
})(({ tagName, element, children }) => {
|
|
94
|
-
|
|
95
|
-
element.children = children;
|
|
96
|
-
const paragraphWrap = tryParagraphWrap(children);
|
|
97
|
-
if (paragraphWrap) {
|
|
98
|
-
element.children = paragraphWrap;
|
|
99
|
-
}
|
|
95
|
+
applyBlockChildren(tagName, children, element);
|
|
100
96
|
element.data = {
|
|
101
97
|
type: "named",
|
|
102
98
|
name: suffix
|
|
103
99
|
};
|
|
104
100
|
});
|
|
105
101
|
}
|
|
106
|
-
const namedSectionTags = Object.fromEntries(definition.sectionNames.map((sectionName) =>
|
|
107
|
-
const sectionTag = createSuffixSectionTag(sectionName);
|
|
108
|
-
return [sectionName, sectionTag];
|
|
109
|
-
}));
|
|
102
|
+
const namedSectionTags = Object.fromEntries(definition.sectionNames.map((sectionName) => [sectionName, createSuffixSectionTag(sectionName)]));
|
|
110
103
|
const sectionTags = [sectionTag, ...Object.values(namedSectionTags)];
|
|
111
104
|
const accentTag = defineEruditTag({
|
|
112
|
-
tagName:
|
|
113
|
-
schema:
|
|
114
|
-
})(({ tagName, children, element, props
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
tagName: Name,
|
|
106
|
+
schema: accentSchema
|
|
107
|
+
})(({ tagName, children, element, props }) => {
|
|
108
|
+
ensureTagChildren(tagName, children);
|
|
109
|
+
let hasMainSchema = false;
|
|
110
|
+
let hasSectionSchema = false;
|
|
111
|
+
let hasOtherSchema = false;
|
|
112
|
+
for (const child of children) {
|
|
113
|
+
if (isRawElement(child, mainSchema)) {
|
|
114
|
+
if (hasMainSchema) {
|
|
115
|
+
throw new EruditProseError(`<${tagName}> can only have one <${mainTag.tagName}> child element!`);
|
|
116
|
+
}
|
|
117
|
+
hasMainSchema = true;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (isRawElement(child, sectionSchema)) {
|
|
121
|
+
hasSectionSchema = true;
|
|
122
|
+
continue;
|
|
120
123
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
hasOtherSchema = true;
|
|
125
|
+
}
|
|
126
|
+
if (hasOtherSchema) {
|
|
127
|
+
if (hasMainSchema || hasSectionSchema) {
|
|
128
|
+
throw new EruditProseError(`Cannot mix <${mainTag.tagName}> or <${sectionTag.tagName}> with other child elements inside <${tagName}>!`);
|
|
129
|
+
}
|
|
130
|
+
element.children = [mainTag({ children })];
|
|
131
|
+
} else {
|
|
132
|
+
let mainChild;
|
|
133
|
+
let sectionChildren = [];
|
|
134
|
+
for (const child of children) {
|
|
135
|
+
if (isRawElement(child, mainSchema)) {
|
|
136
|
+
mainChild = child;
|
|
137
|
+
} else if (isRawElement(child, sectionSchema)) {
|
|
138
|
+
sectionChildren.push(child);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!mainChild) {
|
|
142
|
+
throw new EruditProseError(`<${tagName}> requires a <${mainTag.tagName}> child element!`);
|
|
143
|
+
}
|
|
144
|
+
element.children = [mainChild, ...sectionChildren];
|
|
126
145
|
}
|
|
127
146
|
const title = props.title.trim();
|
|
128
147
|
validateTitle(tagName, title);
|
|
129
|
-
let layout = "column";
|
|
130
|
-
if (props.row === true) {
|
|
131
|
-
layout = "row";
|
|
132
|
-
}
|
|
133
148
|
element.data = {
|
|
134
149
|
title,
|
|
135
|
-
layout
|
|
150
|
+
layout: props.row === true ? "row" : "column"
|
|
136
151
|
};
|
|
137
152
|
element.title = title;
|
|
138
153
|
});
|
|
139
154
|
//
|
|
140
|
-
//
|
|
155
|
+
// Core Elements
|
|
141
156
|
//
|
|
142
|
-
const
|
|
157
|
+
const mainCoreElement = defineProseCoreElement({
|
|
143
158
|
schema: mainSchema,
|
|
144
159
|
tags: [mainTag]
|
|
145
160
|
});
|
|
146
|
-
const
|
|
161
|
+
const sectionCoreElement = defineProseCoreElement({
|
|
147
162
|
schema: sectionSchema,
|
|
148
163
|
tags: [sectionTag, ...Object.values(namedSectionTags)]
|
|
149
164
|
});
|
|
150
|
-
const
|
|
151
|
-
schema:
|
|
165
|
+
const accentCoreElement = defineProseCoreElement({
|
|
166
|
+
schema: accentSchema,
|
|
152
167
|
tags: [accentTag]
|
|
153
168
|
});
|
|
154
169
|
//
|
|
@@ -157,19 +172,19 @@ Section names should start with lower case letter.
|
|
|
157
172
|
return {
|
|
158
173
|
_sectionNames: definition.sectionNames,
|
|
159
174
|
accent: {
|
|
160
|
-
schema:
|
|
175
|
+
schema: accentSchema,
|
|
161
176
|
tag: accentTag,
|
|
162
|
-
|
|
177
|
+
coreElement: accentCoreElement
|
|
163
178
|
},
|
|
164
179
|
main: {
|
|
165
180
|
schema: mainSchema,
|
|
166
181
|
tag: mainTag,
|
|
167
|
-
|
|
182
|
+
coreElement: mainCoreElement
|
|
168
183
|
},
|
|
169
184
|
section: {
|
|
170
185
|
schema: sectionSchema,
|
|
171
186
|
tags: sectionTags,
|
|
172
|
-
|
|
187
|
+
coreElement: sectionCoreElement
|
|
173
188
|
}
|
|
174
189
|
};
|
|
175
190
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type {
|
|
2
|
+
import type { ToProseElement } from 'tsprose';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { CalloutSchema } from './core.js';
|
|
5
5
|
import { useElementStorage } from '../../app/composables/storage.js';
|
|
6
6
|
import { useFormatText } from '../../app/composables/formatText.js';
|
|
7
7
|
import Block from '../../app/shared/block/Block.vue';
|
|
8
8
|
import Render from '../../app/shared/Render.vue';
|
|
9
9
|
|
|
10
10
|
const { element } = defineProps<{
|
|
11
|
-
element:
|
|
11
|
+
element: ToProseElement<CalloutSchema>;
|
|
12
12
|
}>();
|
|
13
|
-
const calloutStorage = await useElementStorage
|
|
13
|
+
const calloutStorage = await useElementStorage(element);
|
|
14
14
|
const formatText = useFormatText();
|
|
15
15
|
</script>
|
|
16
16
|
|