@erudit-js/prose 4.1.0 → 4.2.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/appElement.d.ts +7 -6
- package/dist/app/appElement.js +1 -1
- package/dist/app/composables/anchor.d.ts +7 -7
- package/dist/app/composables/appElement.d.ts +4 -4
- package/dist/app/composables/appElement.js +3 -3
- package/dist/app/composables/context.d.ts +3 -2
- package/dist/app/composables/elementIcon.d.ts +2 -2
- package/dist/app/composables/elementIcon.js +1 -1
- package/dist/app/composables/language.d.ts +2 -2
- package/dist/app/composables/language.js +1 -1
- package/dist/app/composables/storage.d.ts +4 -4
- package/dist/app/composables/storage.js +0 -4
- package/dist/app/default/Mix.vue +2 -2
- package/dist/app/default/Text.vue +2 -2
- package/dist/app/shared/Prose.vue +3 -3
- package/dist/app/shared/Render.vue +5 -14
- package/dist/app/shared/block/AsideMenu.vue +2 -2
- package/dist/app/shared/block/AsideMenuCopyLink.vue +1 -1
- package/dist/app/shared/block/Block.vue +4 -4
- package/dist/app/shared/inliner/Inliner.vue +2 -2
- package/dist/coreElement.d.ts +25 -7
- package/dist/coreElement.js +2 -2
- package/dist/elements/accent/Accent.vue +4 -4
- package/dist/elements/accent/AccentColumnSection.vue +2 -2
- package/dist/elements/accent/AccentRowSections.vue +2 -2
- package/dist/elements/accent/app.d.ts +3 -3
- package/dist/elements/accent/app.js +2 -2
- package/dist/elements/accent/core.d.ts +61 -300
- package/dist/elements/accent/core.js +83 -68
- package/dist/elements/callout/Callout.vue +4 -4
- package/dist/elements/callout/app.d.ts +1 -8
- package/dist/elements/callout/app.js +2 -2
- package/dist/elements/callout/core.d.ts +21 -59
- package/dist/elements/callout/core.js +18 -17
- package/dist/elements/caption/Caption.vue +3 -3
- package/dist/elements/caption/app.d.ts +1 -8
- package/dist/elements/caption/app.js +2 -2
- package/dist/elements/caption/core.d.ts +21 -99
- package/dist/elements/caption/core.js +18 -22
- package/dist/elements/details/Details.vue +3 -3
- package/dist/elements/details/app.d.ts +1 -8
- package/dist/elements/details/app.js +2 -2
- package/dist/elements/details/core.d.ts +18 -61
- package/dist/elements/details/core.js +16 -11
- package/dist/elements/diagram/Diagram.vue +14 -11
- package/dist/elements/diagram/app.d.ts +1 -29
- package/dist/elements/diagram/app.js +2 -2
- package/dist/elements/diagram/core.d.ts +14 -177
- package/dist/elements/diagram/core.js +5 -8
- package/dist/elements/emphasis/Emphasis.vue +3 -3
- package/dist/elements/emphasis/app.d.ts +1 -8
- package/dist/elements/emphasis/app.js +2 -2
- package/dist/elements/emphasis/core.d.ts +13 -76
- package/dist/elements/emphasis/core.js +8 -9
- package/dist/elements/flex/Flex.vue +3 -3
- package/dist/elements/flex/app.d.ts +1 -8
- package/dist/elements/flex/app.js +2 -2
- package/dist/elements/flex/core.d.ts +16 -58
- package/dist/elements/flex/core.js +6 -7
- package/dist/elements/gallery/Gallery.vue +3 -3
- package/dist/elements/gallery/app.d.ts +1 -22
- package/dist/elements/gallery/app.js +2 -2
- package/dist/elements/gallery/core.d.ts +11 -132
- package/dist/elements/gallery/core.js +4 -5
- package/dist/elements/heading/Heading.vue +3 -3
- package/dist/elements/heading/_global.d.ts +2 -2
- package/dist/elements/heading/app.d.ts +1 -8
- package/dist/elements/heading/app.js +2 -2
- package/dist/elements/heading/core.d.ts +13 -97
- package/dist/elements/heading/core.js +8 -8
- package/dist/elements/horizontalLine/app.d.ts +1 -8
- package/dist/elements/horizontalLine/app.js +2 -2
- package/dist/elements/horizontalLine/core.d.ts +9 -47
- package/dist/elements/horizontalLine/core.js +4 -5
- package/dist/elements/image/Image.vue +3 -3
- package/dist/elements/image/ImageElement.vue +4 -4
- package/dist/elements/image/app.d.ts +1 -15
- package/dist/elements/image/app.js +2 -2
- package/dist/elements/image/core.d.ts +29 -108
- package/dist/elements/image/core.js +12 -19
- package/dist/elements/image/storage.d.ts +1 -1
- package/dist/elements/image/storage.js +6 -6
- package/dist/elements/lineBreak/app.d.ts +1 -8
- package/dist/elements/lineBreak/app.js +2 -2
- package/dist/elements/lineBreak/core.d.ts +9 -47
- package/dist/elements/lineBreak/core.js +4 -5
- package/dist/elements/link/BlockLink.vue +4 -6
- package/dist/elements/link/Link.vue +4 -4
- package/dist/elements/link/core.d.ts +8 -7
- package/dist/elements/link/core.js +5 -4
- package/dist/elements/link/dependency/app.d.ts +1 -15
- package/dist/elements/link/dependency/app.js +3 -3
- package/dist/elements/link/dependency/core.d.ts +30 -108
- package/dist/elements/link/dependency/core.js +6 -8
- package/dist/elements/link/hook.d.ts +12 -0
- package/dist/elements/link/hook.js +45 -0
- package/dist/elements/link/reference/app.d.ts +1 -15
- package/dist/elements/link/reference/app.js +3 -3
- package/dist/elements/link/reference/core.d.ts +24 -103
- package/dist/elements/link/reference/core.js +6 -8
- package/dist/elements/link/storage.js +1 -1
- package/dist/elements/list/List.vue +7 -5
- package/dist/elements/list/_global.d.ts +3 -3
- package/dist/elements/list/app.d.ts +1 -15
- package/dist/elements/list/app.js +2 -2
- package/dist/elements/list/core.d.ts +33 -155
- package/dist/elements/list/core.js +20 -18
- package/dist/elements/math/app.d.ts +1 -15
- package/dist/elements/math/app.js +3 -3
- package/dist/elements/math/block.d.ts +31 -43
- package/dist/elements/math/block.js +10 -9
- package/dist/elements/math/components/BlockMath.vue +4 -4
- package/dist/elements/math/components/InlinerMath.vue +4 -4
- package/dist/elements/math/core.d.ts +25 -53
- package/dist/elements/math/core.js +3 -11
- package/dist/elements/math/inliner.d.ts +24 -36
- package/dist/elements/math/inliner.js +10 -12
- package/dist/elements/paragraph/Paragraph.vue +3 -3
- package/dist/elements/paragraph/app.d.ts +1 -8
- package/dist/elements/paragraph/app.js +2 -2
- package/dist/elements/paragraph/core.d.ts +12 -53
- package/dist/elements/paragraph/core.js +6 -7
- package/dist/elements/problem/app.d.ts +1 -29
- package/dist/elements/problem/app.js +4 -4
- package/dist/elements/problem/components/Problem.vue +3 -3
- package/dist/elements/problem/components/ProblemContent.vue +15 -21
- package/dist/elements/problem/components/ProblemExpanderSection.vue +2 -2
- package/dist/elements/problem/components/Problems.vue +11 -7
- package/dist/elements/problem/components/SubProblem.vue +3 -4
- package/dist/elements/problem/components/expanders/Check.vue +3 -3
- package/dist/elements/problem/components/expanders/Checks.vue +6 -3
- package/dist/elements/problem/components/expanders/DefaultPlusSections.vue +3 -7
- package/dist/elements/problem/components/expanders/Hint.vue +3 -3
- package/dist/elements/problem/composables/problemScript.d.ts +2 -2
- package/dist/elements/problem/core.d.ts +63 -299
- package/dist/elements/problem/core.js +9 -11
- package/dist/elements/problem/hook.d.ts +1 -0
- package/dist/elements/problem/hook.js +14 -0
- package/dist/elements/problem/problem.d.ts +20 -77
- package/dist/elements/problem/problem.js +6 -6
- package/dist/elements/problem/problemCheck.d.ts +33 -83
- package/dist/elements/problem/problemCheck.js +16 -10
- package/dist/elements/problem/problemContent.d.ts +54 -401
- package/dist/elements/problem/problemContent.js +47 -56
- package/dist/elements/problem/problemScript.d.ts +18 -10
- package/dist/elements/problem/problemScript.js +15 -26
- package/dist/elements/problem/problems.d.ts +29 -188
- package/dist/elements/problem/problems.js +11 -15
- package/dist/elements/problem/storage.d.ts +1 -1
- package/dist/elements/problem/storage.js +2 -3
- package/dist/elements/table/Table.vue +3 -3
- package/dist/elements/table/app.d.ts +1 -29
- package/dist/elements/table/app.js +2 -2
- package/dist/elements/table/core.d.ts +28 -309
- package/dist/elements/table/core.js +17 -29
- package/dist/elements/video/Video.vue +4 -4
- package/dist/elements/video/app.d.ts +1 -15
- package/dist/elements/video/app.js +2 -2
- package/dist/elements/video/core.d.ts +26 -106
- package/dist/elements/video/core.js +11 -16
- package/dist/elements/video/storage.d.ts +1 -1
- package/dist/elements/video/storage.js +2 -3
- package/dist/error.d.ts +3 -0
- package/dist/error.js +6 -0
- package/dist/include.d.ts +4 -4
- package/dist/include.js +6 -12
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/dist/rawElement.d.ts +9 -6
- package/dist/rawElement.js +4 -0
- package/dist/rawToProse/countSchemas.d.ts +1 -0
- package/dist/rawToProse/countSchemas.js +11 -0
- package/dist/rawToProse/hook.d.ts +39 -0
- package/dist/rawToProse/hook.js +6 -0
- package/dist/rawToProse/index.d.ts +34 -0
- package/dist/rawToProse/index.js +92 -0
- package/dist/rawToProse/uniqueTitles.d.ts +1 -0
- package/dist/rawToProse/uniqueTitles.js +11 -0
- package/dist/shared/filePath.js +2 -2
- package/dist/shared/paragraphWrap.d.ts +3 -3
- package/dist/shared/paragraphWrap.js +7 -12
- package/dist/slugify/index.d.ts +3 -1
- package/dist/slugify/index.js +5 -6
- package/dist/slugify/languages/en.js +1 -1
- package/dist/slugify/languages/ru.js +1 -1
- package/dist/snippet.d.ts +39 -33
- package/dist/snippet.js +139 -73
- package/dist/tag.d.ts +22 -19
- package/dist/tag.js +19 -15
- package/dist/toc.d.ts +12 -18
- package/dist/toc.js +120 -42
- package/package.json +7 -6
- package/dist/app/default/Inliners.vue +0 -11
- package/dist/context.d.ts +0 -4
- package/dist/context.js +0 -1
- package/dist/elements/link/step.d.ts +0 -16
- package/dist/elements/link/step.js +0 -36
- package/dist/elements/problem/step.d.ts +0 -5
- package/dist/elements/problem/step.js +0 -13
- package/dist/resolve.d.ts +0 -21
- package/dist/resolve.js +0 -102
- package/dist/resolveStep.d.ts +0 -9
- package/dist/resolveStep.js +0 -3
- package/dist/title.d.ts +0 -8
- package/dist/title.js +0 -6
- package/dist/utils/docs.d.ts +0 -1
- package/dist/utils/docs.js +0 -22
- package/types.d.ts +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type AutoUnique, type DocumentUniques, type DocumentUniquesTemplate, type LinkableTag, type RawElement, type ToRawElement, type ToUnique, type Unique } from 'tsprose';
|
|
2
2
|
import { type ProblemSeed, ProblemRandom } from './rng.js';
|
|
3
3
|
import { type ProblemContentChild } from './problemContent.js';
|
|
4
4
|
export type CheckFunction = (args: {
|
|
@@ -8,24 +8,32 @@ export type CheckFunction = (args: {
|
|
|
8
8
|
}) => boolean;
|
|
9
9
|
export declare function insertProblemScriptId(scriptSrc: string, code: string): string;
|
|
10
10
|
export interface ProblemScriptDefinition {
|
|
11
|
-
uniques?:
|
|
11
|
+
uniques?: DocumentUniquesTemplate;
|
|
12
12
|
isGenerator?: boolean;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
uniques:
|
|
16
|
-
} : {}) & (
|
|
14
|
+
type ProblemContentFnArgs<TDef extends ProblemScriptDefinition> = (TDef['uniques'] extends DocumentUniquesTemplate ? {
|
|
15
|
+
uniques: DocumentUniques<TDef['uniques']>;
|
|
16
|
+
} : {}) & (TDef['isGenerator'] extends true ? {
|
|
17
17
|
initial: boolean;
|
|
18
18
|
random: ProblemRandom;
|
|
19
|
-
} : {})
|
|
20
|
-
|
|
19
|
+
} : {});
|
|
20
|
+
type ProblemContentFn<TDef extends ProblemScriptDefinition> = (args: ProblemContentFnArgs<TDef>) => RawElement | {
|
|
21
|
+
problemContent: RawElement;
|
|
21
22
|
check?: CheckFunction;
|
|
22
|
-
}
|
|
23
|
+
};
|
|
24
|
+
type ProblemScriptInstanceCreator<TDef extends ProblemScriptDefinition> = TDef['uniques'] extends DocumentUniquesTemplate ? (uniquesMapping: (() => AutoUnique) | {
|
|
25
|
+
[K in keyof TDef['uniques']]: ToUnique<TDef['uniques'][K] & LinkableTag> | (() => AutoUnique);
|
|
26
|
+
}) => ProblemScriptInstance : () => ProblemScriptInstance;
|
|
27
|
+
export declare function defineProblemScript(): (contentFn: ProblemContentFn<{}>) => ProblemScriptInstanceCreator<{}>;
|
|
28
|
+
export declare function defineProblemScript<const TDef extends ProblemScriptDefinition>(definition: TDef): (contentFn: ProblemContentFn<TDef>) => ProblemScriptInstanceCreator<TDef>;
|
|
29
|
+
export declare function defineProblemScript<const TDef extends ProblemScriptDefinition>(scriptSrc: string, definition?: TDef): (contentFn: ProblemContentFn<TDef>) => ProblemScriptInstanceCreator<TDef>;
|
|
23
30
|
export interface ProblemScriptInstance {
|
|
24
31
|
scriptSrc: string;
|
|
25
|
-
uniques: Record<string,
|
|
32
|
+
uniques: Record<string, Unique>;
|
|
26
33
|
isGenerator: boolean;
|
|
27
34
|
generate: (seed?: ProblemSeed) => {
|
|
28
|
-
problemContent:
|
|
35
|
+
problemContent: ToRawElement<ProblemContentChild>[];
|
|
29
36
|
check?: CheckFunction;
|
|
30
37
|
};
|
|
31
38
|
}
|
|
39
|
+
export {};
|
|
@@ -1,37 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { injectDocumentId, isRawElement } from "tsprose";
|
|
2
2
|
import { DEFAULT_SEED, ProblemRandom } from "./rng.js";
|
|
3
3
|
import { validateProblemContent } from "./problemContent.js";
|
|
4
|
+
import { EruditProseError } from "../../error.js";
|
|
4
5
|
//
|
|
5
6
|
// Problem Script Src
|
|
6
7
|
//
|
|
7
8
|
export function insertProblemScriptId(scriptSrc, code) {
|
|
8
|
-
|
|
9
|
-
return code.replace(/\bdefineProblemScript\(([\s\S]*?)\)/g, (fullMatch, argsContent) => {
|
|
10
|
-
const trimmed = argsContent.trim();
|
|
11
|
-
// If the first argument already looks like a string literal, skip.
|
|
12
|
-
if (/^['"`]/.test(trimmed)) {
|
|
13
|
-
return fullMatch;
|
|
14
|
-
}
|
|
15
|
-
const needsNoSpace = /^\s*\n/.test(argsContent);
|
|
16
|
-
const comma = needsNoSpace ? "," : ", ";
|
|
17
|
-
const newArgs = `'${scriptSrc}'${comma}${argsContent}`;
|
|
18
|
-
return `defineProblemScript(${newArgs})`;
|
|
19
|
-
});
|
|
9
|
+
return injectDocumentId(scriptSrc, code, "defineProblemScript");
|
|
20
10
|
}
|
|
11
|
+
// -- Implementation --
|
|
21
12
|
export function defineProblemScript(scriptSrcOrDefinition, maybeDefinition) {
|
|
22
13
|
let scriptSrc;
|
|
23
14
|
let definition;
|
|
24
15
|
if (typeof scriptSrcOrDefinition === "string") {
|
|
25
16
|
scriptSrc = scriptSrcOrDefinition;
|
|
26
|
-
definition = maybeDefinition;
|
|
17
|
+
definition = maybeDefinition ?? {};
|
|
27
18
|
} else {
|
|
28
|
-
throw new
|
|
19
|
+
throw new EruditProseError(`Problem script requires script ID to be manually specified or inserted at transform time!`);
|
|
29
20
|
}
|
|
30
21
|
function defineProblemContent(problemContentFn) {
|
|
31
|
-
function
|
|
22
|
+
function createInstance(uniquesMapping) {
|
|
32
23
|
const finalizedUniques = {};
|
|
33
24
|
if (definition.uniques) {
|
|
34
|
-
|
|
25
|
+
if (!uniquesMapping) {
|
|
26
|
+
throw new EruditProseError(`Problem script with uniques requires a uniques mapping!`);
|
|
27
|
+
}
|
|
35
28
|
if (typeof uniquesMapping === "function") {
|
|
36
29
|
for (const key in definition.uniques) {
|
|
37
30
|
finalizedUniques[key] = uniquesMapping();
|
|
@@ -43,10 +36,6 @@ export function defineProblemScript(scriptSrcOrDefinition, maybeDefinition) {
|
|
|
43
36
|
finalizedUniques[key] = mapping();
|
|
44
37
|
} else {
|
|
45
38
|
finalizedUniques[key] = mapping;
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
delete finalizedUniques[key].rawElement;
|
|
48
|
-
// @ts-expect-error
|
|
49
|
-
delete finalizedUniques[key].tag;
|
|
50
39
|
}
|
|
51
40
|
}
|
|
52
41
|
}
|
|
@@ -55,25 +44,25 @@ export function defineProblemScript(scriptSrcOrDefinition, maybeDefinition) {
|
|
|
55
44
|
scriptSrc,
|
|
56
45
|
uniques: finalizedUniques,
|
|
57
46
|
isGenerator: definition.isGenerator ?? false,
|
|
58
|
-
generate
|
|
47
|
+
generate(seed) {
|
|
59
48
|
const finalizedSeed = seed ?? DEFAULT_SEED;
|
|
60
|
-
const
|
|
49
|
+
const result = problemContentFn({
|
|
61
50
|
uniques: finalizedUniques,
|
|
62
51
|
...definition.isGenerator ? {
|
|
63
52
|
initial: finalizedSeed === DEFAULT_SEED,
|
|
64
53
|
random: new ProblemRandom(finalizedSeed)
|
|
65
54
|
} : {}
|
|
66
55
|
});
|
|
67
|
-
const problemContent = isRawElement(
|
|
56
|
+
const problemContent = isRawElement(result) ? result : result.problemContent;
|
|
68
57
|
validateProblemContent("[Problem Script]", problemContent.children);
|
|
69
58
|
return {
|
|
70
59
|
problemContent: problemContent.children,
|
|
71
|
-
check: !isRawElement(
|
|
60
|
+
check: !isRawElement(result) ? result.check : undefined
|
|
72
61
|
};
|
|
73
62
|
}
|
|
74
63
|
};
|
|
75
64
|
}
|
|
76
|
-
return
|
|
65
|
+
return createInstance;
|
|
77
66
|
}
|
|
78
67
|
return defineProblemContent;
|
|
79
68
|
}
|
|
@@ -1,212 +1,53 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type BlockSchema, type Schema, type Unique } from 'tsprose';
|
|
2
2
|
import { type ProblemContentChild } from './problemContent.js';
|
|
3
|
-
import { type ProblemInfo } from './shared.js';
|
|
3
|
+
import { type ProblemInfo, type ProblemInfoProps } from './shared.js';
|
|
4
4
|
import { type ProblemScriptStorage } from './storage.js';
|
|
5
5
|
import { type ProblemScriptInstance } from './problemScript.js';
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export declare const subProblemSchema: {
|
|
11
|
-
name: "subProblem";
|
|
12
|
-
type: "block";
|
|
13
|
-
linkable: false;
|
|
14
|
-
Data: SubProblemData;
|
|
15
|
-
Storage: ProblemScriptStorage;
|
|
16
|
-
Children: ProblemContentChild[];
|
|
17
|
-
};
|
|
18
|
-
export declare const SubProblem: import("@jsprose/core").Tag<"SubProblem", {
|
|
19
|
-
name: "subProblem";
|
|
20
|
-
type: "block";
|
|
6
|
+
export interface SubProblemSchema extends Schema {
|
|
7
|
+
name: 'subProblem';
|
|
8
|
+
type: 'block';
|
|
21
9
|
linkable: false;
|
|
22
10
|
Data: SubProblemData;
|
|
23
11
|
Storage: ProblemScriptStorage;
|
|
24
12
|
Children: ProblemContentChild[];
|
|
25
|
-
}
|
|
13
|
+
}
|
|
14
|
+
export interface SubProblemData {
|
|
26
15
|
label?: string;
|
|
27
|
-
|
|
16
|
+
scriptUniques?: Record<string, Unique>;
|
|
17
|
+
}
|
|
18
|
+
export declare const subProblemSchema: SubProblemSchema;
|
|
19
|
+
export declare const SubProblem: import("../../tag.js").ToEruditTag<SubProblemSchema, "SubProblem", {
|
|
20
|
+
label?: string;
|
|
21
|
+
} & ({
|
|
28
22
|
children: {};
|
|
29
23
|
script?: undefined;
|
|
30
|
-
}
|
|
31
|
-
label?: string;
|
|
32
|
-
} & {
|
|
24
|
+
} | {
|
|
33
25
|
script: ProblemScriptInstance;
|
|
34
26
|
children?: undefined;
|
|
35
27
|
})>;
|
|
36
|
-
export declare const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
linkable: false;
|
|
40
|
-
Data: SubProblemData;
|
|
41
|
-
Storage: ProblemScriptStorage;
|
|
42
|
-
Children: ProblemContentChild[];
|
|
43
|
-
}, {
|
|
44
|
-
SubProblem: import("@jsprose/core").Tag<"SubProblem", {
|
|
45
|
-
name: "subProblem";
|
|
46
|
-
type: "block";
|
|
47
|
-
linkable: false;
|
|
48
|
-
Data: SubProblemData;
|
|
49
|
-
Storage: ProblemScriptStorage;
|
|
50
|
-
Children: ProblemContentChild[];
|
|
51
|
-
}, ({
|
|
28
|
+
export declare const subProblemCoreElement: {
|
|
29
|
+
readonly schema: SubProblemSchema;
|
|
30
|
+
readonly tags: [import("../../tag.js").ToEruditTag<SubProblemSchema, "SubProblem", {
|
|
52
31
|
label?: string;
|
|
53
|
-
} & {
|
|
32
|
+
} & ({
|
|
54
33
|
children: {};
|
|
55
34
|
script?: undefined;
|
|
56
|
-
}
|
|
57
|
-
label?: string;
|
|
58
|
-
} & {
|
|
35
|
+
} | {
|
|
59
36
|
script: ProblemScriptInstance;
|
|
60
37
|
children?: undefined;
|
|
61
|
-
})
|
|
62
|
-
}, undefined>;
|
|
63
|
-
export declare const subProblemCoreElement: {
|
|
64
|
-
registryItem: import("@jsprose/core").RegistryItem<{
|
|
65
|
-
name: "subProblem";
|
|
66
|
-
type: "block";
|
|
67
|
-
linkable: false;
|
|
68
|
-
Data: SubProblemData;
|
|
69
|
-
Storage: ProblemScriptStorage;
|
|
70
|
-
Children: ProblemContentChild[];
|
|
71
|
-
}, {
|
|
72
|
-
SubProblem: import("@jsprose/core").Tag<"SubProblem", {
|
|
73
|
-
name: "subProblem";
|
|
74
|
-
type: "block";
|
|
75
|
-
linkable: false;
|
|
76
|
-
Data: SubProblemData;
|
|
77
|
-
Storage: ProblemScriptStorage;
|
|
78
|
-
Children: ProblemContentChild[];
|
|
79
|
-
}, ({
|
|
80
|
-
label?: string;
|
|
81
|
-
} & {
|
|
82
|
-
children: {};
|
|
83
|
-
script?: undefined;
|
|
84
|
-
}) | ({
|
|
85
|
-
label?: string;
|
|
86
|
-
} & {
|
|
87
|
-
script: ProblemScriptInstance;
|
|
88
|
-
children?: undefined;
|
|
89
|
-
})>;
|
|
90
|
-
}, undefined>;
|
|
91
|
-
};
|
|
92
|
-
export declare const problemsSchema: {
|
|
93
|
-
name: "problems";
|
|
94
|
-
type: "block";
|
|
95
|
-
linkable: true;
|
|
96
|
-
Data: ProblemInfo;
|
|
97
|
-
Storage: undefined;
|
|
98
|
-
Children: (BlockSchema | {
|
|
99
|
-
name: "subProblem";
|
|
100
|
-
type: "block";
|
|
101
|
-
linkable: false;
|
|
102
|
-
Data: SubProblemData;
|
|
103
|
-
Storage: ProblemScriptStorage;
|
|
104
|
-
Children: ProblemContentChild[];
|
|
105
|
-
})[];
|
|
38
|
+
})>];
|
|
106
39
|
};
|
|
107
|
-
export
|
|
108
|
-
name:
|
|
109
|
-
type:
|
|
40
|
+
export interface ProblemsSchema extends Schema {
|
|
41
|
+
name: 'problems';
|
|
42
|
+
type: 'block';
|
|
110
43
|
linkable: true;
|
|
111
44
|
Data: ProblemInfo;
|
|
112
45
|
Storage: undefined;
|
|
113
|
-
Children: (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Data: SubProblemData;
|
|
118
|
-
Storage: ProblemScriptStorage;
|
|
119
|
-
Children: ProblemContentChild[];
|
|
120
|
-
})[];
|
|
121
|
-
}, {
|
|
122
|
-
title: string;
|
|
123
|
-
level: import("./shared.js").ProblemLevel;
|
|
124
|
-
attributes?: (import("./shared.js").ProblemAttribute | import("./shared.js").ProblemCustomAttribute)[];
|
|
125
|
-
} & {
|
|
126
|
-
pretty?: true | undefined;
|
|
127
|
-
applied?: true | undefined;
|
|
128
|
-
method?: true | undefined;
|
|
129
|
-
inter?: true | undefined;
|
|
130
|
-
} & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
|
|
131
|
-
export declare const problemsRegistryItem: import("@jsprose/core").RegistryItem<{
|
|
132
|
-
name: "problems";
|
|
133
|
-
type: "block";
|
|
134
|
-
linkable: true;
|
|
135
|
-
Data: ProblemInfo;
|
|
136
|
-
Storage: undefined;
|
|
137
|
-
Children: (BlockSchema | {
|
|
138
|
-
name: "subProblem";
|
|
139
|
-
type: "block";
|
|
140
|
-
linkable: false;
|
|
141
|
-
Data: SubProblemData;
|
|
142
|
-
Storage: ProblemScriptStorage;
|
|
143
|
-
Children: ProblemContentChild[];
|
|
144
|
-
})[];
|
|
145
|
-
}, {
|
|
146
|
-
Problems: import("@jsprose/core").Tag<"Problems", {
|
|
147
|
-
name: "problems";
|
|
148
|
-
type: "block";
|
|
149
|
-
linkable: true;
|
|
150
|
-
Data: ProblemInfo;
|
|
151
|
-
Storage: undefined;
|
|
152
|
-
Children: (BlockSchema | {
|
|
153
|
-
name: "subProblem";
|
|
154
|
-
type: "block";
|
|
155
|
-
linkable: false;
|
|
156
|
-
Data: SubProblemData;
|
|
157
|
-
Storage: ProblemScriptStorage;
|
|
158
|
-
Children: ProblemContentChild[];
|
|
159
|
-
})[];
|
|
160
|
-
}, {
|
|
161
|
-
title: string;
|
|
162
|
-
level: import("./shared.js").ProblemLevel;
|
|
163
|
-
attributes?: (import("./shared.js").ProblemAttribute | import("./shared.js").ProblemCustomAttribute)[];
|
|
164
|
-
} & {
|
|
165
|
-
pretty?: true | undefined;
|
|
166
|
-
applied?: true | undefined;
|
|
167
|
-
method?: true | undefined;
|
|
168
|
-
inter?: true | undefined;
|
|
169
|
-
} & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
|
|
170
|
-
}, undefined>;
|
|
46
|
+
Children: (SubProblemSchema | BlockSchema)[];
|
|
47
|
+
}
|
|
48
|
+
export declare const problemsSchema: ProblemsSchema;
|
|
49
|
+
export declare const Problems: import("../../tag.js").ToEruditTag<ProblemsSchema, "Problems", ProblemInfoProps>;
|
|
171
50
|
export declare const problemsCoreElement: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
type: "block";
|
|
175
|
-
linkable: true;
|
|
176
|
-
Data: ProblemInfo;
|
|
177
|
-
Storage: undefined;
|
|
178
|
-
Children: (BlockSchema | {
|
|
179
|
-
name: "subProblem";
|
|
180
|
-
type: "block";
|
|
181
|
-
linkable: false;
|
|
182
|
-
Data: SubProblemData;
|
|
183
|
-
Storage: ProblemScriptStorage;
|
|
184
|
-
Children: ProblemContentChild[];
|
|
185
|
-
})[];
|
|
186
|
-
}, {
|
|
187
|
-
Problems: import("@jsprose/core").Tag<"Problems", {
|
|
188
|
-
name: "problems";
|
|
189
|
-
type: "block";
|
|
190
|
-
linkable: true;
|
|
191
|
-
Data: ProblemInfo;
|
|
192
|
-
Storage: undefined;
|
|
193
|
-
Children: (BlockSchema | {
|
|
194
|
-
name: "subProblem";
|
|
195
|
-
type: "block";
|
|
196
|
-
linkable: false;
|
|
197
|
-
Data: SubProblemData;
|
|
198
|
-
Storage: ProblemScriptStorage;
|
|
199
|
-
Children: ProblemContentChild[];
|
|
200
|
-
})[];
|
|
201
|
-
}, {
|
|
202
|
-
title: string;
|
|
203
|
-
level: import("./shared.js").ProblemLevel;
|
|
204
|
-
attributes?: (import("./shared.js").ProblemAttribute | import("./shared.js").ProblemCustomAttribute)[];
|
|
205
|
-
} & {
|
|
206
|
-
pretty?: true | undefined;
|
|
207
|
-
applied?: true | undefined;
|
|
208
|
-
method?: true | undefined;
|
|
209
|
-
inter?: true | undefined;
|
|
210
|
-
} & TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
|
|
211
|
-
}, undefined>;
|
|
51
|
+
readonly schema: ProblemsSchema;
|
|
52
|
+
readonly tags: [import("../../tag.js").ToEruditTag<ProblemsSchema, "Problems", ProblemInfoProps>];
|
|
212
53
|
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineSchema, ensureTagBlockChildren, isRawElement } from "tsprose";
|
|
2
2
|
import { validateProblemContent } from "./problemContent.js";
|
|
3
3
|
import { defineEruditTag } from "../../tag.js";
|
|
4
4
|
import { problemProps2Info } from "./shared.js";
|
|
5
|
-
import { defineEruditProseCoreElement } from "../../coreElement.js";
|
|
6
5
|
import { problemScriptStorageKey } from "./storage.js";
|
|
7
6
|
import "./problemScript.js";
|
|
7
|
+
import { EruditProseError } from "../../error.js";
|
|
8
|
+
import { defineProseCoreElement } from "../../coreElement.js";
|
|
8
9
|
export const subProblemSchema = defineSchema({
|
|
9
10
|
name: "subProblem",
|
|
10
11
|
type: "block",
|
|
11
12
|
linkable: false
|
|
12
|
-
})
|
|
13
|
+
});
|
|
13
14
|
export const SubProblem = defineEruditTag({
|
|
14
15
|
tagName: "SubProblem",
|
|
15
16
|
schema: subProblemSchema
|
|
@@ -20,7 +21,7 @@ export const SubProblem = defineEruditTag({
|
|
|
20
21
|
element.data.label = label;
|
|
21
22
|
}
|
|
22
23
|
if (props.script && children) {
|
|
23
|
-
throw new
|
|
24
|
+
throw new EruditProseError(`<${tagName}> cannot have both script and children!`);
|
|
24
25
|
}
|
|
25
26
|
if (props.script) {
|
|
26
27
|
element.data.scriptUniques = props.script.uniques;
|
|
@@ -31,24 +32,20 @@ export const SubProblem = defineEruditTag({
|
|
|
31
32
|
element.children = children;
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
|
-
export const
|
|
35
|
+
export const subProblemCoreElement = defineProseCoreElement({
|
|
35
36
|
schema: subProblemSchema,
|
|
36
37
|
tags: [SubProblem]
|
|
37
38
|
});
|
|
38
|
-
export const subProblemCoreElement = defineEruditProseCoreElement({ registryItem: subProblemRegistryItem });
|
|
39
|
-
//
|
|
40
|
-
// Problems
|
|
41
|
-
//
|
|
42
39
|
export const problemsSchema = defineSchema({
|
|
43
40
|
name: "problems",
|
|
44
41
|
type: "block",
|
|
45
42
|
linkable: true
|
|
46
|
-
})
|
|
43
|
+
});
|
|
47
44
|
export const Problems = defineEruditTag({
|
|
48
45
|
tagName: "Problems",
|
|
49
46
|
schema: problemsSchema
|
|
50
|
-
})(({ element, tagName, props, children
|
|
51
|
-
ensureTagBlockChildren(tagName, children
|
|
47
|
+
})(({ element, tagName, props, children }) => {
|
|
48
|
+
ensureTagBlockChildren(tagName, children);
|
|
52
49
|
const subProblemChildren = [];
|
|
53
50
|
const otherChildren = [];
|
|
54
51
|
for (const child of children) {
|
|
@@ -59,15 +56,14 @@ export const Problems = defineEruditTag({
|
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
if (subProblemChildren.length === 0) {
|
|
62
|
-
throw new
|
|
59
|
+
throw new EruditProseError(`<${tagName}> must have at least one <SubProblem> child!`);
|
|
63
60
|
}
|
|
64
61
|
element.children = [...otherChildren, ...subProblemChildren];
|
|
65
62
|
const problemInfo = problemProps2Info(props);
|
|
66
63
|
element.data = problemInfo;
|
|
67
64
|
element.title = problemInfo.title;
|
|
68
65
|
});
|
|
69
|
-
export const
|
|
66
|
+
export const problemsCoreElement = defineProseCoreElement({
|
|
70
67
|
schema: problemsSchema,
|
|
71
68
|
tags: [Problems]
|
|
72
69
|
});
|
|
73
|
-
export const problemsCoreElement = defineEruditProseCoreElement({ registryItem: problemsRegistryItem });
|
|
@@ -2,4 +2,4 @@ export type ProblemScriptStorage = {
|
|
|
2
2
|
resolvedScriptSrc: string;
|
|
3
3
|
} | undefined;
|
|
4
4
|
export declare function problemScriptStorageKey(scriptId: string): string;
|
|
5
|
-
export declare function createProblemScriptStorage(projectAbsPath: string, projectBaseUrl: string,
|
|
5
|
+
export declare function createProblemScriptStorage(projectAbsPath: string, projectBaseUrl: string, scriptRelSrc: string): ProblemScriptStorage;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { projectRelFilePath } from "../../shared/filePath.js";
|
|
2
1
|
export function problemScriptStorageKey(scriptId) {
|
|
3
2
|
return `problemScript:${scriptId}`;
|
|
4
3
|
}
|
|
5
|
-
export function createProblemScriptStorage(projectAbsPath, projectBaseUrl,
|
|
6
|
-
const resolvedSrc = projectBaseUrl + "api/problemScript/" +
|
|
4
|
+
export function createProblemScriptStorage(projectAbsPath, projectBaseUrl, scriptRelSrc) {
|
|
5
|
+
const resolvedSrc = projectBaseUrl + "api/problemScript/" + scriptRelSrc.replace(".tsx", "") + ".js";
|
|
7
6
|
return { resolvedScriptSrc: resolvedSrc };
|
|
8
7
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from 'vue';
|
|
3
|
-
import { isProseElement, type
|
|
3
|
+
import { isProseElement, type ToProseElement } from 'tsprose';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { TableSchema } from './core.js';
|
|
6
6
|
import { captionSchema } from '../caption/core.js';
|
|
7
7
|
import Render from '../../app/shared/Render.vue';
|
|
8
8
|
import Block from '../../app/shared/block/Block.vue';
|
|
9
9
|
import Caption from '../caption/Caption.vue';
|
|
10
10
|
|
|
11
11
|
const { element } = defineProps<{
|
|
12
|
-
element:
|
|
12
|
+
element: ToProseElement<TableSchema>;
|
|
13
13
|
}>();
|
|
14
14
|
|
|
15
15
|
const caption = computed(() => {
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
declare const _default: import("../../app/appElement.js").
|
|
2
|
-
name: "table";
|
|
3
|
-
type: "block";
|
|
4
|
-
linkable: true;
|
|
5
|
-
Data: undefined;
|
|
6
|
-
Storage: undefined;
|
|
7
|
-
Children: ({
|
|
8
|
-
name: "caption";
|
|
9
|
-
type: "inliner";
|
|
10
|
-
linkable: false;
|
|
11
|
-
Data: import("../caption/core.js").CaptionData | undefined;
|
|
12
|
-
Storage: undefined;
|
|
13
|
-
Children: import("@jsprose/core").InlinerSchema[];
|
|
14
|
-
} | {
|
|
15
|
-
name: "tableRow";
|
|
16
|
-
type: "inliner";
|
|
17
|
-
linkable: false;
|
|
18
|
-
Data: undefined;
|
|
19
|
-
Storage: undefined;
|
|
20
|
-
Children: {
|
|
21
|
-
name: "tableData";
|
|
22
|
-
type: "inliner";
|
|
23
|
-
linkable: false;
|
|
24
|
-
Data: undefined;
|
|
25
|
-
Storage: undefined;
|
|
26
|
-
Children: import("@jsprose/core").InlinerSchema[];
|
|
27
|
-
}[];
|
|
28
|
-
})[];
|
|
29
|
-
}>;
|
|
1
|
+
declare const _default: import("../../app/appElement.js").ProseAppElement<import("./core.js").TableSchema>;
|
|
30
2
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineProseAppElement } from "../../app/appElement.js";
|
|
2
2
|
import { tableSchema } from "./core.js";
|
|
3
|
-
export default
|
|
3
|
+
export default defineProseAppElement({
|
|
4
4
|
schema: tableSchema,
|
|
5
5
|
component: () => import("./Table.vue"),
|
|
6
6
|
languages: {
|