@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,49 +1,51 @@
1
- import { defineRegistryItem, defineSchema, ensureTagChildren } from "@jsprose/core";
1
+ import { defineSchema, ensureTagBlockChildren, ensureTagChildren } from "tsprose";
2
2
  import { defineEruditTag } from "../../tag.js";
3
- import { defineEruditProseCoreElements } from "../../coreElement.js";
4
- import { tryParagraphWrap } from "../../shared/paragraphWrap.js";
3
+ import { paragraphWrap } from "../../shared/paragraphWrap.js";
4
+ import { defineProseCoreElements } from "../../coreElement.js";
5
5
  export const listItemSchema = defineSchema({
6
6
  name: "listItem",
7
7
  type: "block",
8
8
  linkable: false
9
- })();
9
+ });
10
10
  export const Li = defineEruditTag({
11
11
  tagName: "Li",
12
12
  schema: listItemSchema
13
13
  })(({ tagName, element, children }) => {
14
- ensureTagChildren(tagName, children);
15
- element.children = children;
16
- const paragraphWrap = tryParagraphWrap(children);
17
- if (paragraphWrap) {
18
- element.children = paragraphWrap;
14
+ const wrap = paragraphWrap(children);
15
+ if (wrap) {
16
+ element.children = wrap;
17
+ } else {
18
+ ensureTagBlockChildren(tagName, children);
19
+ element.children = children;
19
20
  }
20
21
  });
21
22
  export const listSchema = defineSchema({
22
23
  name: "list",
23
24
  type: "block",
24
25
  linkable: true
25
- })();
26
+ });
26
27
  export const List = defineEruditTag({
27
28
  tagName: "List",
28
29
  schema: listSchema
29
30
  })(({ element, tagName, props, children }) => {
30
31
  ensureTagChildren(tagName, children, listItemSchema);
31
32
  element.children = children;
32
- if (props.type === "ol") {
33
+ if ("ordered" in props) {
33
34
  element.data = {
34
- type: "ol",
35
- start: props.start ?? 1
35
+ type: "ordered",
36
+ start: "start" in props ? props.start : 1
36
37
  };
37
38
  } else {
38
- element.data = { type: "ul" };
39
+ element.data = { type: "unordered" };
39
40
  }
40
41
  });
41
- export const listItemRegistryItem = defineRegistryItem({
42
+ //
43
+ // Core Elements
44
+ //
45
+ export default defineProseCoreElements({
42
46
  schema: listItemSchema,
43
47
  tags: [Li]
44
- });
45
- export const listRegistryItem = defineRegistryItem({
48
+ }, {
46
49
  schema: listSchema,
47
50
  tags: [List]
48
51
  });
49
- export default defineEruditProseCoreElements({ registryItem: listItemRegistryItem }, { registryItem: listRegistryItem });
@@ -1,16 +1,2 @@
1
- declare const _default: (import("../../app/appElement.js").AppElement<{
2
- name: "blockMath";
3
- type: "block";
4
- linkable: true;
5
- Data: import("./block.js").BlockMathData;
6
- Storage: import("./block.js").MathGroup;
7
- Children: undefined;
8
- }> | import("../../app/appElement.js").AppElement<{
9
- name: "inlinerMath";
10
- type: "inliner";
11
- linkable: true;
12
- Data: string;
13
- Storage: import("./inliner.js").InlinerMathStorage;
14
- Children: undefined;
15
- }>)[];
1
+ declare const _default: (import("../../app/appElement.js").ProseAppElement<import("./block.js").BlockMathSchema> | import("../../app/appElement.js").ProseAppElement<import("./inliner.js").InlinerMathSchema>)[];
16
2
  export default _default;
@@ -1,7 +1,7 @@
1
- import { defineEruditProseAppElement } from "../../app/appElement.js";
1
+ import { defineProseAppElement } from "../../app/appElement.js";
2
2
  import { blockMathSchema } from "./block.js";
3
3
  import { inlinerMathSchema } from "./inliner.js";
4
- export default [defineEruditProseAppElement({
4
+ export default [defineProseAppElement({
5
5
  schema: blockMathSchema,
6
6
  component: () => import("./components/BlockMath.vue"),
7
7
  languages: {
@@ -9,7 +9,7 @@ export default [defineEruditProseAppElement({
9
9
  ru: () => import("./languages/ru.js")
10
10
  },
11
11
  icon: () => import("./icon.svg?raw")
12
- }), defineEruditProseAppElement({
12
+ }), defineProseAppElement({
13
13
  schema: inlinerMathSchema,
14
14
  component: () => import("./components/InlinerMath.vue"),
15
15
  languages: {
@@ -1,4 +1,4 @@
1
- import { type TagChildren } from '@jsprose/core';
1
+ import { type RequiredChildren, type Schema } from 'tsprose';
2
2
  export declare const mathGroupTypes: readonly ["0", "small", "normal", "big"];
3
3
  export type MathGroupGapType = (typeof mathGroupTypes)[number] | 'custom';
4
4
  export type MathGroupAlignItems = 'top' | 'center' | 'bottom';
@@ -29,52 +29,40 @@ export interface MathGroup {
29
29
  parts: MathGroupPart[];
30
30
  }
31
31
  export declare function resolveMathGroups(katex: string, isTopLevel?: boolean): Promise<MathGroup | string>;
32
- export interface BlockMathData {
33
- katex: string;
34
- freeze?: boolean;
35
- }
36
- export declare const blockMathSchema: {
37
- name: "blockMath";
38
- type: "block";
39
- linkable: true;
40
- Data: BlockMathData;
41
- Storage: MathGroup;
42
- Children: undefined;
43
- };
44
- export declare const BlockMath: import("@jsprose/core").Tag<"BlockMath", {
45
- name: "blockMath";
46
- type: "block";
32
+ export interface BlockMathSchema extends Schema {
33
+ name: 'blockMath';
34
+ type: 'block';
47
35
  linkable: true;
48
36
  Data: BlockMathData;
49
37
  Storage: MathGroup;
50
38
  Children: undefined;
51
- }, {
39
+ }
40
+ export interface BlockMathData {
41
+ katex: string;
52
42
  freeze?: boolean;
53
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
54
- export declare const blockMathRegistryItem: import("@jsprose/core").RegistryItem<{
55
- name: "blockMath";
56
- type: "block";
57
- linkable: true;
58
- Data: BlockMathData;
59
- Storage: MathGroup;
60
- Children: undefined;
61
- }, {
62
- BlockMath: import("@jsprose/core").Tag<"BlockMath", {
63
- name: "blockMath";
64
- type: "block";
65
- linkable: true;
66
- Data: BlockMathData;
67
- Storage: MathGroup;
68
- Children: undefined;
69
- }, {
43
+ }
44
+ export declare const blockMathSchema: BlockMathSchema;
45
+ export declare const BlockMath: import("../../tag.js").ToEruditTag<BlockMathSchema, "BlockMath", {
46
+ freeze?: boolean;
47
+ } & RequiredChildren>;
48
+ export declare const blockMathCoreElement: {
49
+ readonly schema: BlockMathSchema;
50
+ readonly tags: [import("../../tag.js").ToEruditTag<BlockMathSchema, "BlockMath", {
70
51
  freeze?: boolean;
71
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
72
- }, (element: import("@jsprose/core").ProseElement<{
73
- name: "blockMath";
74
- type: "block";
75
- linkable: true;
76
- Data: BlockMathData;
77
- Storage: MathGroup;
78
- Children: undefined;
79
- }>) => Promise<MathGroup>>;
52
+ } & RequiredChildren>];
53
+ readonly createStorage: (element: {
54
+ schema: BlockMathSchema;
55
+ id: string;
56
+ data: BlockMathData;
57
+ storageKey: string;
58
+ children: undefined;
59
+ __TSPROSE_proseElement: true;
60
+ }) => Promise<MathGroup>;
61
+ readonly dependencies: {
62
+ katex: {
63
+ optimise: boolean;
64
+ transpile: boolean;
65
+ };
66
+ };
67
+ };
80
68
  export declare function createBlockMathStorage(katex: string): Promise<MathGroup>;
@@ -1,6 +1,8 @@
1
- import { defineRegistryItem, defineSchema, ensureTagChild, ProseError, textSchema } from "@jsprose/core";
2
- import { latexToHtml, normalizeKatex } from "./katex.js";
1
+ import { defineSchema, ensureTagChildren, textSchema } from "tsprose";
2
+ import { katexDependency, latexToHtml, normalizeKatex } from "./katex.js";
3
3
  import { defineEruditTag } from "../../tag.js";
4
+ import { EruditProseError } from "../../error.js";
5
+ import { defineProseCoreElement } from "../../coreElement.js";
4
6
  export const mathGroupTypes = [
5
7
  "0",
6
8
  "small",
@@ -92,15 +94,15 @@ export const blockMathSchema = defineSchema({
92
94
  name: "blockMath",
93
95
  type: "block",
94
96
  linkable: true
95
- })();
97
+ });
96
98
  export const BlockMath = defineEruditTag({
97
99
  tagName: "BlockMath",
98
100
  schema: blockMathSchema
99
101
  })(({ element, tagName, props, children }) => {
100
- ensureTagChild(tagName, children, textSchema);
102
+ ensureTagChildren(tagName, children, textSchema);
101
103
  const katex = normalizeKatex(children[0].data);
102
104
  if (!katex) {
103
- throw new ProseError(`<${tagName}> tag must contain non-empty KaTeX math expression.`);
105
+ throw new EruditProseError(`<${tagName}> tag must contain non-empty KaTeX math expression.`);
104
106
  }
105
107
  element.data = {
106
108
  katex,
@@ -108,12 +110,11 @@ export const BlockMath = defineEruditTag({
108
110
  };
109
111
  element.storageKey = `$$ ${katex} $$`;
110
112
  });
111
- export const blockMathRegistryItem = defineRegistryItem({
113
+ export const blockMathCoreElement = defineProseCoreElement({
112
114
  schema: blockMathSchema,
113
115
  tags: [BlockMath],
114
- async createStorage(element) {
115
- return createBlockMathStorage(element.data.katex);
116
- }
116
+ createStorage: async (element) => createBlockMathStorage(element.data.katex),
117
+ dependencies: katexDependency
117
118
  });
118
119
  export async function createBlockMathStorage(katex) {
119
120
  let result = {
@@ -1,21 +1,21 @@
1
1
  <script lang="ts" setup>
2
- import type { ProseElement } from '@jsprose/core';
2
+ import type { ToProseElement } from 'tsprose';
3
3
 
4
4
  import {
5
- type blockMathSchema,
6
5
  type MathGroup as _MathGroup,
7
6
  createBlockMathStorage,
7
+ type BlockMathSchema,
8
8
  } from '../block.js';
9
9
  import { useElementStorage } from '../../../app/composables/storage.js';
10
10
  import MathGroup from './MathGroup.vue';
11
11
  import Block from '../../../app/shared/block/Block.vue';
12
12
 
13
13
  const { element } = defineProps<{
14
- element: ProseElement<typeof blockMathSchema>;
14
+ element: ToProseElement<BlockMathSchema>;
15
15
  }>();
16
16
 
17
17
  const blockMathStorage =
18
- (await useElementStorage<typeof blockMathSchema>(element)) ??
18
+ (await useElementStorage(element)) ??
19
19
  (await createBlockMathStorage(element.data.katex));
20
20
 
21
21
  const mathGroup: _MathGroup = blockMathStorage;
@@ -1,21 +1,21 @@
1
1
  <script lang="ts" setup>
2
2
  import 'katex/dist/katex.min.css';
3
- import type { ProseElement } from '@jsprose/core';
3
+ import type { ToProseElement } from 'tsprose';
4
4
 
5
5
  import Inliner from '../../../app/shared/inliner/Inliner.vue';
6
6
  import {
7
7
  createInlinerMathStorage,
8
- type inlinerMathSchema,
8
+ type InlinerMathSchema,
9
9
  } from '../inliner.js';
10
10
  import { useElementStorage } from '../../../app/composables/storage.js';
11
11
  import Katex from './Katex.vue';
12
12
 
13
13
  const { element } = defineProps<{
14
- element: ProseElement<typeof inlinerMathSchema>;
14
+ element: ToProseElement<InlinerMathSchema>;
15
15
  }>();
16
16
 
17
17
  const inlinerMathStorage =
18
- (await useElementStorage<typeof inlinerMathSchema>(element)) ??
18
+ (await useElementStorage(element)) ??
19
19
  (await createInlinerMathStorage(element.data));
20
20
  </script>
21
21
 
@@ -1,62 +1,34 @@
1
- declare const _default: [{
2
- registryItem: import("@jsprose/core").RegistryItem<{
3
- name: "inlinerMath";
4
- type: "inliner";
5
- linkable: true;
6
- Data: string;
7
- Storage: import("./inliner.js").InlinerMathStorage;
8
- Children: undefined;
9
- }, {
10
- M: import("@jsprose/core").Tag<"M", {
11
- name: "inlinerMath";
12
- type: "inliner";
13
- linkable: true;
14
- Data: string;
15
- Storage: import("./inliner.js").InlinerMathStorage;
16
- Children: undefined;
17
- }, import("@jsprose/core").TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
18
- }, (element: import("@jsprose/core").ProseElement<{
19
- name: "inlinerMath";
20
- type: "inliner";
21
- linkable: true;
22
- Data: string;
23
- Storage: import("./inliner.js").InlinerMathStorage;
24
- Children: undefined;
25
- }>) => Promise<import("./inliner.js").InlinerMathStorage>>;
26
- dependencies: {
1
+ declare const _default: readonly [{
2
+ readonly schema: import("./block.js").BlockMathSchema;
3
+ readonly tags: [import("../../tag.js").ToEruditTag<import("./block.js").BlockMathSchema, "BlockMath", {
4
+ freeze?: boolean;
5
+ } & import("tsprose").RequiredChildren>];
6
+ readonly createStorage: (element: {
7
+ schema: import("./block.js").BlockMathSchema;
8
+ id: string;
9
+ data: import("./block.js").BlockMathData;
10
+ storageKey: string;
11
+ children: undefined;
12
+ __TSPROSE_proseElement: true;
13
+ }) => Promise<import("./block.js").MathGroup>;
14
+ readonly dependencies: {
27
15
  katex: {
28
16
  optimise: boolean;
29
17
  transpile: boolean;
30
18
  };
31
19
  };
32
20
  }, {
33
- registryItem: import("@jsprose/core").RegistryItem<{
34
- name: "blockMath";
35
- type: "block";
36
- linkable: true;
37
- Data: import("./block.js").BlockMathData;
38
- Storage: import("./block.js").MathGroup;
39
- Children: undefined;
40
- }, {
41
- BlockMath: import("@jsprose/core").Tag<"BlockMath", {
42
- name: "blockMath";
43
- type: "block";
44
- linkable: true;
45
- Data: import("./block.js").BlockMathData;
46
- Storage: import("./block.js").MathGroup;
47
- Children: undefined;
48
- }, {
49
- freeze?: boolean;
50
- } & import("@jsprose/core").TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
51
- }, (element: import("@jsprose/core").ProseElement<{
52
- name: "blockMath";
53
- type: "block";
54
- linkable: true;
55
- Data: import("./block.js").BlockMathData;
56
- Storage: import("./block.js").MathGroup;
57
- Children: undefined;
58
- }>) => Promise<import("./block.js").MathGroup>>;
59
- dependencies: {
21
+ readonly schema: import("./inliner.js").InlinerMathSchema;
22
+ readonly tags: [import("../../tag.js").ToEruditTag<import("./inliner.js").InlinerMathSchema, "M", import("tsprose").RequiredChildren>];
23
+ readonly createStorage: (element: {
24
+ schema: import("./inliner.js").InlinerMathSchema;
25
+ id: string;
26
+ data: string;
27
+ storageKey: string;
28
+ children: undefined;
29
+ __TSPROSE_proseElement: true;
30
+ }) => Promise<import("./inliner.js").InlinerMathStorage>;
31
+ readonly dependencies: {
60
32
  katex: {
61
33
  optimise: boolean;
62
34
  transpile: boolean;
@@ -1,11 +1,3 @@
1
- import { defineEruditProseCoreElements } from "../../coreElement.js";
2
- import { blockMathRegistryItem } from "./block.js";
3
- import { inlinerMathRegistryItem } from "./inliner.js";
4
- import { katexDependency } from "./katex.js";
5
- export default defineEruditProseCoreElements({
6
- registryItem: inlinerMathRegistryItem,
7
- dependencies: katexDependency
8
- }, {
9
- registryItem: blockMathRegistryItem,
10
- dependencies: katexDependency
11
- });
1
+ import { blockMathCoreElement } from "./block.js";
2
+ import { inlinerMathCoreElement } from "./inliner.js";
3
+ export default [blockMathCoreElement, inlinerMathCoreElement];
@@ -1,4 +1,4 @@
1
- import { type TagChildren } from '@jsprose/core';
1
+ import { type RequiredChildren, type Schema } from 'tsprose';
2
2
  export type InlinerMathType = 'katex' | 'text';
3
3
  interface InlinerMathBase {
4
4
  type: InlinerMathType;
@@ -20,45 +20,33 @@ export type InlinerMathStorage = InlinerMathKatex | InlinerMathText;
20
20
  * Try to use simple text mode for inline math as it is significantly better for SEO, faster and smaller.
21
21
  */
22
22
  export declare function tryTextInlinerMath(expression: string): InlinerMathText | undefined;
23
- export declare const inlinerMathSchema: {
24
- name: "inlinerMath";
25
- type: "inliner";
23
+ export interface InlinerMathSchema extends Schema {
24
+ name: 'inlinerMath';
25
+ type: 'inliner';
26
26
  linkable: true;
27
27
  Data: string;
28
28
  Storage: InlinerMathStorage;
29
29
  Children: undefined;
30
+ }
31
+ export declare const inlinerMathSchema: InlinerMathSchema;
32
+ export declare const M: import("../../tag.js").ToEruditTag<InlinerMathSchema, "M", RequiredChildren>;
33
+ export declare const inlinerMathCoreElement: {
34
+ readonly schema: InlinerMathSchema;
35
+ readonly tags: [import("../../tag.js").ToEruditTag<InlinerMathSchema, "M", RequiredChildren>];
36
+ readonly createStorage: (element: {
37
+ schema: InlinerMathSchema;
38
+ id: string;
39
+ data: string;
40
+ storageKey: string;
41
+ children: undefined;
42
+ __TSPROSE_proseElement: true;
43
+ }) => Promise<InlinerMathStorage>;
44
+ readonly dependencies: {
45
+ katex: {
46
+ optimise: boolean;
47
+ transpile: boolean;
48
+ };
49
+ };
30
50
  };
31
- export declare const M: import("@jsprose/core").Tag<"M", {
32
- name: "inlinerMath";
33
- type: "inliner";
34
- linkable: true;
35
- Data: string;
36
- Storage: InlinerMathStorage;
37
- Children: undefined;
38
- }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
39
- export declare const inlinerMathRegistryItem: import("@jsprose/core").RegistryItem<{
40
- name: "inlinerMath";
41
- type: "inliner";
42
- linkable: true;
43
- Data: string;
44
- Storage: InlinerMathStorage;
45
- Children: undefined;
46
- }, {
47
- M: import("@jsprose/core").Tag<"M", {
48
- name: "inlinerMath";
49
- type: "inliner";
50
- linkable: true;
51
- Data: string;
52
- Storage: InlinerMathStorage;
53
- Children: undefined;
54
- }, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
55
- }, (element: import("@jsprose/core").ProseElement<{
56
- name: "inlinerMath";
57
- type: "inliner";
58
- linkable: true;
59
- Data: string;
60
- Storage: InlinerMathStorage;
61
- Children: undefined;
62
- }>) => Promise<InlinerMathStorage>>;
63
51
  export declare function createInlinerMathStorage(katex: string): Promise<InlinerMathStorage>;
64
52
  export {};
@@ -1,6 +1,8 @@
1
- import { defineRegistryItem, defineSchema, ensureTagChild, ProseError, textSchema } from "@jsprose/core";
1
+ import { defineSchema, ensureTagChildren, textSchema } from "tsprose";
2
2
  import { defineEruditTag } from "../../tag.js";
3
- import { latexToHtml, normalizeKatex } from "./katex.js";
3
+ import { katexDependency, latexToHtml, normalizeKatex } from "./katex.js";
4
+ import { EruditProseError } from "../../error.js";
5
+ import { defineProseCoreElement } from "../../coreElement.js";
4
6
  /**
5
7
  * Apply typographical replacements to improve math rendering
6
8
  */
@@ -40,32 +42,28 @@ export function tryTextInlinerMath(expression) {
40
42
  }
41
43
  return undefined;
42
44
  }
43
- //
44
- //
45
- //
46
45
  export const inlinerMathSchema = defineSchema({
47
46
  name: "inlinerMath",
48
47
  type: "inliner",
49
48
  linkable: true
50
- })();
49
+ });
51
50
  export const M = defineEruditTag({
52
51
  tagName: "M",
53
52
  schema: inlinerMathSchema
54
53
  })(({ element, tagName, children }) => {
55
- ensureTagChild(tagName, children, textSchema);
54
+ ensureTagChildren(tagName, children, textSchema);
56
55
  const katex = normalizeKatex(children[0].data);
57
56
  if (!katex) {
58
- throw new ProseError(`<${tagName}> tag must contain non-empty KaTeX math expression.`);
57
+ throw new EruditProseError(`<${tagName}> tag must contain non-empty KaTeX math expression.`);
59
58
  }
60
59
  element.data = katex;
61
60
  element.storageKey = `$ ${katex} $`;
62
61
  });
63
- export const inlinerMathRegistryItem = defineRegistryItem({
62
+ export const inlinerMathCoreElement = defineProseCoreElement({
64
63
  schema: inlinerMathSchema,
65
64
  tags: [M],
66
- async createStorage(element) {
67
- return createInlinerMathStorage(element.data);
68
- }
65
+ createStorage: async (element) => createInlinerMathStorage(element.data),
66
+ dependencies: katexDependency
69
67
  });
70
68
  export async function createInlinerMathStorage(katex) {
71
69
  const tokens = tryTextInlinerMath(katex);
@@ -1,11 +1,11 @@
1
1
  <script setup lang="ts">
2
- import type { ProseElement } from '@jsprose/core';
2
+ import type { ToProseElement } from 'tsprose';
3
3
 
4
- import type { paragraphSchema } from './core.js';
4
+ import type { ParagraphSchema } from './core.js';
5
5
  import Block from '../../app/shared/block/Block.vue';
6
6
  import Render from '../../app/shared/Render.vue';
7
7
 
8
- defineProps<{ element: ProseElement<typeof paragraphSchema> }>();
8
+ defineProps<{ element: ToProseElement<ParagraphSchema> }>();
9
9
  </script>
10
10
 
11
11
  <template>
@@ -1,9 +1,2 @@
1
- declare const _default: import("../../app/appElement.js").AppElement<{
2
- name: "paragraph";
3
- type: "block";
4
- linkable: true;
5
- Data: import("./core.js").ParagraphData;
6
- Storage: undefined;
7
- Children: import("@jsprose/core").InlinerSchema[];
8
- }>;
1
+ declare const _default: import("../../app/appElement.js").ProseAppElement<import("./core.js").ParagraphSchema>;
9
2
  export default _default;
@@ -1,6 +1,6 @@
1
- import { defineEruditProseAppElement } from "../../app/appElement.js";
1
+ import { defineProseAppElement } from "../../app/appElement.js";
2
2
  import { paragraphSchema } from "./core.js";
3
- export default defineEruditProseAppElement({
3
+ export default defineProseAppElement({
4
4
  schema: paragraphSchema,
5
5
  component: () => import("./Paragraph.vue"),
6
6
  languages: {
@@ -1,67 +1,26 @@
1
- import { type InlinerSchema, type TagChildren } from '@jsprose/core';
2
- export declare const paragraphSchema: {
3
- name: "paragraph";
4
- type: "block";
1
+ import { type InlinerSchema, type Schema } from 'tsprose';
2
+ export interface ParagraphSchema extends Schema {
3
+ name: 'paragraph';
4
+ type: 'block';
5
5
  linkable: true;
6
6
  Data: ParagraphData;
7
7
  Storage: undefined;
8
8
  Children: InlinerSchema[];
9
- };
9
+ }
10
+ export declare const paragraphSchema: ParagraphSchema;
10
11
  export type ParagraphData = undefined | {
11
12
  center?: boolean;
12
13
  serif?: boolean;
13
14
  };
14
- export declare const P: import("@jsprose/core").Tag<"P", {
15
- name: "paragraph";
16
- type: "block";
17
- linkable: true;
18
- Data: ParagraphData;
19
- Storage: undefined;
20
- Children: InlinerSchema[];
21
- }, {
15
+ export declare const P: import("../../tag.js").ToEruditTag<ParagraphSchema, "P", {
22
16
  center?: true;
23
17
  serif?: true;
24
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
25
- export declare const paragraphRegistryItem: import("@jsprose/core").RegistryItem<{
26
- name: "paragraph";
27
- type: "block";
28
- linkable: true;
29
- Data: ParagraphData;
30
- Storage: undefined;
31
- Children: InlinerSchema[];
32
- }, {
33
- P: import("@jsprose/core").Tag<"P", {
34
- name: "paragraph";
35
- type: "block";
36
- linkable: true;
37
- Data: ParagraphData;
38
- Storage: undefined;
39
- Children: InlinerSchema[];
40
- }, {
18
+ }>;
19
+ declare const _default: {
20
+ readonly schema: ParagraphSchema;
21
+ readonly tags: [import("../../tag.js").ToEruditTag<ParagraphSchema, "P", {
41
22
  center?: true;
42
23
  serif?: true;
43
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
44
- }, undefined>;
45
- declare const _default: {
46
- registryItem: import("@jsprose/core").RegistryItem<{
47
- name: "paragraph";
48
- type: "block";
49
- linkable: true;
50
- Data: ParagraphData;
51
- Storage: undefined;
52
- Children: InlinerSchema[];
53
- }, {
54
- P: import("@jsprose/core").Tag<"P", {
55
- name: "paragraph";
56
- type: "block";
57
- linkable: true;
58
- Data: ParagraphData;
59
- Storage: undefined;
60
- Children: InlinerSchema[];
61
- }, {
62
- center?: true;
63
- serif?: true;
64
- } & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
65
- }, undefined>;
24
+ }>];
66
25
  };
67
26
  export default _default;