@erudit-js/prose 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +6 -6
- package/dist/elements/link/core.js +4 -3
- 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 +27 -105
- 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 -58
- 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 +31 -4
- 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 +8 -7
- 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 → raw.d.ts} +0 -0
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineSchema, ensureTagBlockChildren, ensureTagChildren } from "tsprose";
|
|
2
2
|
import { defineEruditTag } from "../../tag.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 (
|
|
33
|
+
if ("ordered" in props) {
|
|
33
34
|
element.data = {
|
|
34
|
-
type: "
|
|
35
|
-
start: props.start
|
|
35
|
+
type: "ordered",
|
|
36
|
+
start: "start" in props ? props.start : 1
|
|
36
37
|
};
|
|
37
38
|
} else {
|
|
38
|
-
element.data = { type: "
|
|
39
|
+
element.data = { type: "unordered" };
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
|
-
|
|
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").
|
|
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 {
|
|
1
|
+
import { defineProseAppElement } from "../../app/appElement.js";
|
|
2
2
|
import { blockMathSchema } from "./block.js";
|
|
3
3
|
import { inlinerMathSchema } from "./inliner.js";
|
|
4
|
-
export default [
|
|
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
|
-
}),
|
|
12
|
+
}), defineProseAppElement({
|
|
13
13
|
schema: inlinerMathSchema,
|
|
14
14
|
component: () => import("./components/InlinerMath.vue"),
|
|
15
15
|
languages: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
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
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
}
|
|
54
|
-
export declare const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
} &
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
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 {
|
|
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
|
-
|
|
102
|
+
ensureTagChildren(tagName, children, textSchema);
|
|
101
103
|
const katex = normalizeKatex(children[0].data);
|
|
102
104
|
if (!katex) {
|
|
103
|
-
throw new
|
|
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
|
|
113
|
+
export const blockMathCoreElement = defineProseCoreElement({
|
|
112
114
|
schema: blockMathSchema,
|
|
113
115
|
tags: [BlockMath],
|
|
114
|
-
async
|
|
115
|
-
|
|
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 {
|
|
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:
|
|
14
|
+
element: ToProseElement<BlockMathSchema>;
|
|
15
15
|
}>();
|
|
16
16
|
|
|
17
17
|
const blockMathStorage =
|
|
18
|
-
(await useElementStorage
|
|
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 {
|
|
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
|
|
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:
|
|
14
|
+
element: ToProseElement<InlinerMathSchema>;
|
|
15
15
|
}>();
|
|
16
16
|
|
|
17
17
|
const inlinerMathStorage =
|
|
18
|
-
(await useElementStorage
|
|
18
|
+
(await useElementStorage(element)) ??
|
|
19
19
|
(await createInlinerMathStorage(element.data));
|
|
20
20
|
</script>
|
|
21
21
|
|
|
@@ -1,62 +1,34 @@
|
|
|
1
|
-
declare const _default: [{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
|
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
|
|
24
|
-
name:
|
|
25
|
-
type:
|
|
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 {
|
|
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
|
-
|
|
54
|
+
ensureTagChildren(tagName, children, textSchema);
|
|
56
55
|
const katex = normalizeKatex(children[0].data);
|
|
57
56
|
if (!katex) {
|
|
58
|
-
throw new
|
|
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
|
|
62
|
+
export const inlinerMathCoreElement = defineProseCoreElement({
|
|
64
63
|
schema: inlinerMathSchema,
|
|
65
64
|
tags: [M],
|
|
66
|
-
async
|
|
67
|
-
|
|
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 {
|
|
2
|
+
import type { ToProseElement } from 'tsprose';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
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:
|
|
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").
|
|
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 {
|
|
1
|
+
import { defineProseAppElement } from "../../app/appElement.js";
|
|
2
2
|
import { paragraphSchema } from "./core.js";
|
|
3
|
-
export default
|
|
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
|
|
2
|
-
export
|
|
3
|
-
name:
|
|
4
|
-
type:
|
|
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("
|
|
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
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
}
|
|
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;
|