@erudit-js/prose 4.1.1 → 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.
Files changed (208) hide show
  1. package/dist/app/appElement.d.ts +7 -6
  2. package/dist/app/appElement.js +1 -1
  3. package/dist/app/composables/anchor.d.ts +7 -7
  4. package/dist/app/composables/appElement.d.ts +4 -4
  5. package/dist/app/composables/appElement.js +3 -3
  6. package/dist/app/composables/context.d.ts +3 -2
  7. package/dist/app/composables/elementIcon.d.ts +2 -2
  8. package/dist/app/composables/elementIcon.js +1 -1
  9. package/dist/app/composables/language.d.ts +2 -2
  10. package/dist/app/composables/language.js +1 -1
  11. package/dist/app/composables/storage.d.ts +4 -4
  12. package/dist/app/composables/storage.js +0 -4
  13. package/dist/app/default/Mix.vue +2 -2
  14. package/dist/app/default/Text.vue +2 -2
  15. package/dist/app/shared/Prose.vue +3 -3
  16. package/dist/app/shared/Render.vue +5 -14
  17. package/dist/app/shared/block/AsideMenu.vue +2 -2
  18. package/dist/app/shared/block/AsideMenuCopyLink.vue +1 -1
  19. package/dist/app/shared/block/Block.vue +4 -4
  20. package/dist/app/shared/inliner/Inliner.vue +2 -2
  21. package/dist/coreElement.d.ts +25 -7
  22. package/dist/coreElement.js +2 -2
  23. package/dist/elements/accent/Accent.vue +4 -4
  24. package/dist/elements/accent/AccentColumnSection.vue +2 -2
  25. package/dist/elements/accent/AccentRowSections.vue +2 -2
  26. package/dist/elements/accent/app.d.ts +3 -3
  27. package/dist/elements/accent/app.js +2 -2
  28. package/dist/elements/accent/core.d.ts +61 -300
  29. package/dist/elements/accent/core.js +83 -68
  30. package/dist/elements/callout/Callout.vue +4 -4
  31. package/dist/elements/callout/app.d.ts +1 -8
  32. package/dist/elements/callout/app.js +2 -2
  33. package/dist/elements/callout/core.d.ts +21 -59
  34. package/dist/elements/callout/core.js +18 -17
  35. package/dist/elements/caption/Caption.vue +3 -3
  36. package/dist/elements/caption/app.d.ts +1 -8
  37. package/dist/elements/caption/app.js +2 -2
  38. package/dist/elements/caption/core.d.ts +21 -99
  39. package/dist/elements/caption/core.js +18 -22
  40. package/dist/elements/details/Details.vue +3 -3
  41. package/dist/elements/details/app.d.ts +1 -8
  42. package/dist/elements/details/app.js +2 -2
  43. package/dist/elements/details/core.d.ts +18 -61
  44. package/dist/elements/details/core.js +16 -11
  45. package/dist/elements/diagram/Diagram.vue +14 -11
  46. package/dist/elements/diagram/app.d.ts +1 -29
  47. package/dist/elements/diagram/app.js +2 -2
  48. package/dist/elements/diagram/core.d.ts +14 -177
  49. package/dist/elements/diagram/core.js +5 -8
  50. package/dist/elements/emphasis/Emphasis.vue +3 -3
  51. package/dist/elements/emphasis/app.d.ts +1 -8
  52. package/dist/elements/emphasis/app.js +2 -2
  53. package/dist/elements/emphasis/core.d.ts +13 -76
  54. package/dist/elements/emphasis/core.js +8 -9
  55. package/dist/elements/flex/Flex.vue +3 -3
  56. package/dist/elements/flex/app.d.ts +1 -8
  57. package/dist/elements/flex/app.js +2 -2
  58. package/dist/elements/flex/core.d.ts +16 -58
  59. package/dist/elements/flex/core.js +6 -7
  60. package/dist/elements/gallery/Gallery.vue +3 -3
  61. package/dist/elements/gallery/app.d.ts +1 -22
  62. package/dist/elements/gallery/app.js +2 -2
  63. package/dist/elements/gallery/core.d.ts +11 -132
  64. package/dist/elements/gallery/core.js +4 -5
  65. package/dist/elements/heading/Heading.vue +3 -3
  66. package/dist/elements/heading/_global.d.ts +2 -2
  67. package/dist/elements/heading/app.d.ts +1 -8
  68. package/dist/elements/heading/app.js +2 -2
  69. package/dist/elements/heading/core.d.ts +13 -97
  70. package/dist/elements/heading/core.js +8 -8
  71. package/dist/elements/horizontalLine/app.d.ts +1 -8
  72. package/dist/elements/horizontalLine/app.js +2 -2
  73. package/dist/elements/horizontalLine/core.d.ts +9 -47
  74. package/dist/elements/horizontalLine/core.js +4 -5
  75. package/dist/elements/image/Image.vue +3 -3
  76. package/dist/elements/image/ImageElement.vue +4 -4
  77. package/dist/elements/image/app.d.ts +1 -15
  78. package/dist/elements/image/app.js +2 -2
  79. package/dist/elements/image/core.d.ts +29 -108
  80. package/dist/elements/image/core.js +12 -19
  81. package/dist/elements/image/storage.d.ts +1 -1
  82. package/dist/elements/image/storage.js +6 -6
  83. package/dist/elements/lineBreak/app.d.ts +1 -8
  84. package/dist/elements/lineBreak/app.js +2 -2
  85. package/dist/elements/lineBreak/core.d.ts +9 -47
  86. package/dist/elements/lineBreak/core.js +4 -5
  87. package/dist/elements/link/BlockLink.vue +4 -6
  88. package/dist/elements/link/Link.vue +4 -4
  89. package/dist/elements/link/core.d.ts +6 -6
  90. package/dist/elements/link/core.js +4 -3
  91. package/dist/elements/link/dependency/app.d.ts +1 -15
  92. package/dist/elements/link/dependency/app.js +3 -3
  93. package/dist/elements/link/dependency/core.d.ts +27 -105
  94. package/dist/elements/link/dependency/core.js +6 -8
  95. package/dist/elements/link/hook.d.ts +12 -0
  96. package/dist/elements/link/hook.js +45 -0
  97. package/dist/elements/link/reference/app.d.ts +1 -15
  98. package/dist/elements/link/reference/app.js +3 -3
  99. package/dist/elements/link/reference/core.d.ts +24 -103
  100. package/dist/elements/link/reference/core.js +6 -8
  101. package/dist/elements/link/storage.js +1 -1
  102. package/dist/elements/list/List.vue +7 -5
  103. package/dist/elements/list/_global.d.ts +3 -3
  104. package/dist/elements/list/app.d.ts +1 -15
  105. package/dist/elements/list/app.js +2 -2
  106. package/dist/elements/list/core.d.ts +33 -155
  107. package/dist/elements/list/core.js +20 -18
  108. package/dist/elements/math/app.d.ts +1 -15
  109. package/dist/elements/math/app.js +3 -3
  110. package/dist/elements/math/block.d.ts +31 -43
  111. package/dist/elements/math/block.js +10 -9
  112. package/dist/elements/math/components/BlockMath.vue +4 -4
  113. package/dist/elements/math/components/InlinerMath.vue +4 -4
  114. package/dist/elements/math/core.d.ts +25 -53
  115. package/dist/elements/math/core.js +3 -11
  116. package/dist/elements/math/inliner.d.ts +24 -36
  117. package/dist/elements/math/inliner.js +10 -12
  118. package/dist/elements/paragraph/Paragraph.vue +3 -3
  119. package/dist/elements/paragraph/app.d.ts +1 -8
  120. package/dist/elements/paragraph/app.js +2 -2
  121. package/dist/elements/paragraph/core.d.ts +12 -53
  122. package/dist/elements/paragraph/core.js +6 -7
  123. package/dist/elements/problem/app.d.ts +1 -29
  124. package/dist/elements/problem/app.js +4 -4
  125. package/dist/elements/problem/components/Problem.vue +3 -3
  126. package/dist/elements/problem/components/ProblemContent.vue +15 -21
  127. package/dist/elements/problem/components/ProblemExpanderSection.vue +2 -2
  128. package/dist/elements/problem/components/Problems.vue +11 -7
  129. package/dist/elements/problem/components/SubProblem.vue +3 -4
  130. package/dist/elements/problem/components/expanders/Check.vue +3 -3
  131. package/dist/elements/problem/components/expanders/Checks.vue +6 -3
  132. package/dist/elements/problem/components/expanders/DefaultPlusSections.vue +3 -7
  133. package/dist/elements/problem/components/expanders/Hint.vue +3 -3
  134. package/dist/elements/problem/composables/problemScript.d.ts +2 -2
  135. package/dist/elements/problem/core.d.ts +63 -299
  136. package/dist/elements/problem/core.js +9 -11
  137. package/dist/elements/problem/hook.d.ts +1 -0
  138. package/dist/elements/problem/hook.js +14 -0
  139. package/dist/elements/problem/problem.d.ts +20 -77
  140. package/dist/elements/problem/problem.js +6 -6
  141. package/dist/elements/problem/problemCheck.d.ts +33 -83
  142. package/dist/elements/problem/problemCheck.js +16 -10
  143. package/dist/elements/problem/problemContent.d.ts +54 -401
  144. package/dist/elements/problem/problemContent.js +47 -56
  145. package/dist/elements/problem/problemScript.d.ts +18 -10
  146. package/dist/elements/problem/problemScript.js +15 -26
  147. package/dist/elements/problem/problems.d.ts +29 -188
  148. package/dist/elements/problem/problems.js +11 -15
  149. package/dist/elements/problem/storage.d.ts +1 -1
  150. package/dist/elements/problem/storage.js +2 -3
  151. package/dist/elements/table/Table.vue +3 -3
  152. package/dist/elements/table/app.d.ts +1 -29
  153. package/dist/elements/table/app.js +2 -2
  154. package/dist/elements/table/core.d.ts +28 -309
  155. package/dist/elements/table/core.js +17 -29
  156. package/dist/elements/video/Video.vue +4 -4
  157. package/dist/elements/video/app.d.ts +1 -15
  158. package/dist/elements/video/app.js +2 -2
  159. package/dist/elements/video/core.d.ts +26 -106
  160. package/dist/elements/video/core.js +11 -16
  161. package/dist/elements/video/storage.d.ts +1 -1
  162. package/dist/elements/video/storage.js +2 -3
  163. package/dist/error.d.ts +3 -0
  164. package/dist/error.js +6 -0
  165. package/dist/include.d.ts +4 -4
  166. package/dist/include.js +6 -12
  167. package/dist/index.d.ts +11 -11
  168. package/dist/index.js +11 -11
  169. package/dist/rawElement.d.ts +9 -6
  170. package/dist/rawElement.js +4 -0
  171. package/dist/rawToProse/countSchemas.d.ts +1 -0
  172. package/dist/rawToProse/countSchemas.js +11 -0
  173. package/dist/rawToProse/hook.d.ts +39 -0
  174. package/dist/rawToProse/hook.js +6 -0
  175. package/dist/rawToProse/index.d.ts +34 -0
  176. package/dist/rawToProse/index.js +92 -0
  177. package/dist/rawToProse/uniqueTitles.d.ts +1 -0
  178. package/dist/rawToProse/uniqueTitles.js +11 -0
  179. package/dist/shared/filePath.js +2 -2
  180. package/dist/shared/paragraphWrap.d.ts +3 -3
  181. package/dist/shared/paragraphWrap.js +7 -12
  182. package/dist/slugify/index.d.ts +3 -1
  183. package/dist/slugify/index.js +5 -6
  184. package/dist/slugify/languages/en.js +1 -1
  185. package/dist/slugify/languages/ru.js +1 -1
  186. package/dist/snippet.d.ts +39 -33
  187. package/dist/snippet.js +139 -73
  188. package/dist/tag.d.ts +22 -19
  189. package/dist/tag.js +19 -15
  190. package/dist/toc.d.ts +12 -18
  191. package/dist/toc.js +120 -42
  192. package/package.json +7 -6
  193. package/dist/app/default/Inliners.vue +0 -11
  194. package/dist/context.d.ts +0 -4
  195. package/dist/context.js +0 -1
  196. package/dist/elements/link/step.d.ts +0 -16
  197. package/dist/elements/link/step.js +0 -36
  198. package/dist/elements/problem/step.d.ts +0 -5
  199. package/dist/elements/problem/step.js +0 -13
  200. package/dist/resolve.d.ts +0 -21
  201. package/dist/resolve.js +0 -102
  202. package/dist/resolveStep.d.ts +0 -9
  203. package/dist/resolveStep.js +0 -3
  204. package/dist/title.d.ts +0 -8
  205. package/dist/title.js +0 -6
  206. package/dist/utils/docs.d.ts +0 -1
  207. package/dist/utils/docs.js +0 -22
  208. package/types.d.ts +0 -4
@@ -1,14 +1,21 @@
1
- import { type AnySchema, type BlockSchema, type ProseElement, type TagChildren } from '@jsprose/core';
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 type AccentMainSchema = Omit<BlockSchema, 'Data' | 'linkable'> & {
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
- export type AccentSectionSchema = Omit<BlockSchema, 'Data' | 'linkable'> & {
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
- export type AccentSchema = Omit<BlockSchema, 'Data' | 'Children' | 'linkable'> & {
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
- Children: (AccentMainSchema | AccentSectionSchema)[];
39
+ Storage: undefined;
40
+ Children: [
41
+ AccentMainSchema<AccentName>,
42
+ ...AccentSectionSchema<AccentName>[]
43
+ ];
28
44
  SectionNames: string[];
29
- };
30
- export declare function isAccentElement(element: ProseElement<AnySchema>): element is ProseElement<AccentSchema>;
31
- export declare function isAccentMainElement(element: ProseElement<AnySchema>): element is ProseElement<AccentMainSchema>;
32
- export declare function isAccentSectionElement(element: ProseElement<AnySchema>): element is ProseElement<AccentSectionSchema>;
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
- name: `accent_${TDefinition["name"]}`;
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("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}`, {
70
- name: `accent_${TDefinition["name"]}`;
71
- type: "block";
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
- }) & TagChildren)) & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
110
- registryItem: import("@jsprose/core").RegistryItem<{
111
- name: `accent_${TDefinition["name"]}`;
112
- type: "block";
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
- Storage: undefined;
119
- Children: [{
120
- name: `accentMain_${TDefinition["name"]}`;
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
- layout: "column" | "row";
149
- };
150
- Storage: undefined;
151
- Children: [{
152
- name: `accentMain_${TDefinition["name"]}`;
153
- type: "block";
154
- linkable: false;
155
- Data: undefined;
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
- name: `accentMain_${TDefinition["name"]}`;
189
- type: "block";
190
- linkable: false;
191
- Data: undefined;
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
- name: `accentSection_${TDefinition["name"]}`;
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
- } & TagChildren>, ...{ [K_2 in TDefinition["sectionNames"][number]]: import("@jsprose/core").Tag<`${UppercaseFirst<TDefinition["name"]>}${UppercaseFirst<K_2>}`, {
252
- name: `accentSection_${TDefinition["name"]}`;
253
- type: "block";
254
- linkable: false;
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
- Storage: undefined;
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 { defineRegistryItem, defineSchema, ensureTagChildren, ensureTagInlinerChildren, isRawElement, PROSE_REGISTRY, ProseError } from "@jsprose/core";
1
+ import { defineSchema, ensureTagChildren, isRawElement } from "tsprose";
2
2
  import { defineEruditTag } from "../../tag.js";
3
3
  import { uppercaseFirst } from "../../utils/case.js";
4
- import { tryParagraphWrap } from "../../shared/paragraphWrap.js";
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 ProseError(`<${tagName}> requires non-empty title attribute!`);
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.schemaName.startsWith("accentMain_");
13
+ return element.schema.name.startsWith("accentMain_");
15
14
  }
16
15
  export function isAccentSectionElement(element) {
17
- return element.schemaName.startsWith("accentSection_");
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 ProseError(`
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 ProseError(`Section names "section" and "main" are reserved for accent "${definition.name}"!`);
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 ProseError(`
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 accentSchema = defineSchema({
62
+ });
63
+ const baseAccentSchema = defineSchema({
53
64
  name: `accent_${definition.name}`,
54
65
  type: "block",
55
66
  linkable: true
56
- })();
57
- const typedAccentSchema = accentSchema;
67
+ });
68
+ const accentSchema = baseAccentSchema;
58
69
  //
59
70
  // Tags
60
71
  //
61
72
  const mainTag = defineEruditTag({
62
- tagName: `${uppercaseFirst(definition.name)}Main`,
73
+ tagName: `${Name}Main`,
63
74
  schema: mainSchema
64
75
  })(({ tagName, element, children }) => {
65
- ensureTagChildren(tagName, children);
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: `${uppercaseFirst(definition.name)}Section`,
79
+ tagName: `${Name}Section`,
74
80
  schema: sectionSchema
75
81
  })(({ tagName, element, props, children }) => {
76
- ensureTagChildren(tagName, children);
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: `${uppercaseFirst(definition.name)}${uppercaseFirst(suffix)}`,
92
+ tagName: `${Name}${uppercaseFirst(suffix)}`,
92
93
  schema: sectionSchema
93
94
  })(({ tagName, element, children }) => {
94
- ensureTagChildren(tagName, children);
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: `${uppercaseFirst(definition.name)}`,
113
- schema: typedAccentSchema
114
- })(({ tagName, children, element, props, registry }) => {
115
- try {
116
- ensureTagChildren(tagName, children, [mainSchema, sectionSchema]);
117
- element.children = children;
118
- if (!isRawElement(element.children[0], mainSchema)) {
119
- throw new ProseError(`<${tagName}> requires a <${mainTag.tagName}> as the first child element!`);
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
- } catch {
122
- element.children = [mainTag({
123
- __JSPROSE_registryProp: PROSE_REGISTRY,
124
- children
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
- // Registry Items
155
+ // Core Elements
141
156
  //
142
- const mainRegistryItem = defineRegistryItem({
157
+ const mainCoreElement = defineProseCoreElement({
143
158
  schema: mainSchema,
144
159
  tags: [mainTag]
145
160
  });
146
- const sectionRegistryItem = defineRegistryItem({
161
+ const sectionCoreElement = defineProseCoreElement({
147
162
  schema: sectionSchema,
148
163
  tags: [sectionTag, ...Object.values(namedSectionTags)]
149
164
  });
150
- const accentRegistryItem = defineRegistryItem({
151
- schema: typedAccentSchema,
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: typedAccentSchema,
175
+ schema: accentSchema,
161
176
  tag: accentTag,
162
- registryItem: accentRegistryItem
177
+ coreElement: accentCoreElement
163
178
  },
164
179
  main: {
165
180
  schema: mainSchema,
166
181
  tag: mainTag,
167
- registryItem: mainRegistryItem
182
+ coreElement: mainCoreElement
168
183
  },
169
184
  section: {
170
185
  schema: sectionSchema,
171
186
  tags: sectionTags,
172
- registryItem: sectionRegistryItem
187
+ coreElement: sectionCoreElement
173
188
  }
174
189
  };
175
190
  }
@@ -1,16 +1,16 @@
1
1
  <script lang="ts" setup>
2
- import type { ProseElement } from '@jsprose/core';
2
+ import type { ToProseElement } from 'tsprose';
3
3
 
4
- import type { calloutSchema } from './core.js';
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: ProseElement<typeof calloutSchema>;
11
+ element: ToProseElement<CalloutSchema>;
12
12
  }>();
13
- const calloutStorage = await useElementStorage<typeof calloutSchema>(element);
13
+ const calloutStorage = await useElementStorage(element);
14
14
  const formatText = useFormatText();
15
15
  </script>
16
16