@erudit-js/prose 4.0.0-dev.4 → 4.0.0-dev.5
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/default/Inliners.vue +11 -11
- package/dist/app/default/Mix.vue +11 -11
- package/dist/app/default/Text.vue +25 -25
- package/dist/app/shared/Prose.vue +40 -40
- package/dist/app/shared/Render.vue +51 -51
- package/dist/app/shared/block/AsideMenu.vue +44 -44
- package/dist/app/shared/block/AsideMenuButton.vue +51 -53
- package/dist/app/shared/block/AsideMenuCopyLink.vue +40 -40
- package/dist/app/shared/block/AsideMenuSeparator.vue +3 -3
- package/dist/app/shared/block/Block.vue +270 -275
- package/dist/app/shared/inliner/Inliner.vue +11 -11
- package/dist/app/shared/photoswipe/style.css +22 -26
- package/dist/elements/accent/Accent.vue +88 -92
- package/dist/elements/accent/AccentColumnSection.vue +61 -61
- package/dist/elements/accent/AccentRowSections.vue +64 -65
- package/dist/elements/callout/Callout.vue +81 -85
- package/dist/elements/callout/_global.d.ts +15 -15
- package/dist/elements/caption/Caption.vue +44 -47
- package/dist/elements/caption/_global.d.ts +26 -26
- package/dist/elements/details/Details.vue +49 -50
- package/dist/elements/details/_global.d.ts +27 -27
- package/dist/elements/diagram/Diagram.vue +360 -374
- package/dist/elements/diagram/_global.d.ts +19 -19
- package/dist/elements/diagram/core.d.ts +0 -4
- package/dist/elements/diagram/core.js +1 -7
- package/dist/elements/emphasis/Emphasis.vue +25 -25
- package/dist/elements/emphasis/_global.d.ts +18 -18
- package/dist/elements/flex/Flex.vue +36 -38
- package/dist/elements/flex/_global.d.ts +23 -23
- package/dist/elements/gallery/Gallery.vue +56 -56
- package/dist/elements/gallery/_global.d.ts +18 -18
- package/dist/elements/heading/Heading.vue +44 -44
- package/dist/elements/heading/_global.d.ts +42 -45
- package/dist/elements/heading/core.js +7 -14
- package/dist/elements/horizontalLine/HorizontalLine.vue +6 -6
- package/dist/elements/horizontalLine/_global.d.ts +17 -17
- package/dist/elements/image/Image.vue +15 -15
- package/dist/elements/image/ImageElement.vue +80 -80
- package/dist/elements/image/_global.d.ts +18 -18
- package/dist/elements/lineBreak/LineBreak.vue +3 -3
- package/dist/elements/lineBreak/_global.d.ts +18 -18
- package/dist/elements/link/BlockLink.vue +108 -110
- package/dist/elements/link/Link.vue +92 -96
- package/dist/elements/link/dependency/_global.d.ts +47 -47
- package/dist/elements/link/reference/_global.d.ts +49 -49
- package/dist/elements/list/List.vue +58 -65
- package/dist/elements/list/_global.d.ts +50 -50
- package/dist/elements/math/_global.d.ts +72 -72
- package/dist/elements/math/_global.ts +3 -3
- package/dist/elements/math/components/BlockMath.vue +30 -30
- package/dist/elements/math/components/InlinerMath.vue +65 -65
- package/dist/elements/math/components/Katex.vue +88 -89
- package/dist/elements/math/components/MathGroup.vue +41 -41
- package/dist/elements/math/katex.js +17 -6
- package/dist/elements/paragraph/Paragraph.vue +25 -27
- package/dist/elements/paragraph/_global.d.ts +27 -27
- package/dist/elements/problem/_global.d.ts +112 -112
- package/dist/elements/problem/components/Problem.vue +22 -22
- package/dist/elements/problem/components/ProblemButton.vue +20 -21
- package/dist/elements/problem/components/ProblemContainer.vue +8 -8
- package/dist/elements/problem/components/ProblemContent.vue +356 -371
- package/dist/elements/problem/components/ProblemExpander.vue +7 -7
- package/dist/elements/problem/components/ProblemExpanderSection.vue +57 -57
- package/dist/elements/problem/components/ProblemHeader.vue +100 -102
- package/dist/elements/problem/components/Problems.vue +83 -87
- package/dist/elements/problem/components/SubProblem.vue +14 -14
- package/dist/elements/problem/components/expanders/Check.vue +153 -150
- package/dist/elements/problem/components/expanders/Checks.vue +146 -83
- package/dist/elements/problem/components/expanders/DefaultPlusSections.vue +38 -38
- package/dist/elements/problem/components/expanders/Hint.vue +26 -26
- package/dist/elements/problem/core.d.ts +23 -23
- package/dist/elements/problem/problemContent.d.ts +134 -30
- package/dist/elements/problem/problemContent.js +157 -197
- package/dist/elements/problem/problemScript.d.ts +2 -2
- package/dist/elements/problem/problemScript.js +2 -2
- package/dist/elements/problem/rng.d.ts +1 -1
- package/dist/elements/problem/rng.js +1 -1
- package/dist/elements/table/Table.vue +100 -102
- package/dist/elements/table/_global.d.ts +36 -36
- package/dist/elements/video/Video.vue +110 -109
- package/dist/elements/video/_global.d.ts +18 -18
- package/package.json +42 -43
- package/types.d.ts +4 -4
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diagrams written in [Mermaid](https://mermaid.js.org/syntax/flowchart.html) syntax.
|
|
3
|
-
*
|
|
4
|
-
* Diagrams can optionally have a `<Caption>` as their last child.
|
|
5
|
-
*
|
|
6
|
-
* @title Diagram
|
|
7
|
-
* @layout block
|
|
8
|
-
* @example
|
|
9
|
-
* ```tsx
|
|
10
|
-
* <Diagram>
|
|
11
|
-
* {`
|
|
12
|
-
* flowchart TD
|
|
13
|
-
* A[Start] --> B{Is it working?}
|
|
14
|
-
* `}
|
|
15
|
-
* <Caption>Simple flowchart diagram</Caption>
|
|
16
|
-
* </Diagram>
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export const Diagram = '_tag_';
|
|
1
|
+
/**
|
|
2
|
+
* Diagrams written in [Mermaid](https://mermaid.js.org/syntax/flowchart.html) syntax.
|
|
3
|
+
*
|
|
4
|
+
* Diagrams can optionally have a `<Caption>` as their last child.
|
|
5
|
+
*
|
|
6
|
+
* @title Diagram
|
|
7
|
+
* @layout block
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Diagram>
|
|
11
|
+
* {`
|
|
12
|
+
* flowchart TD
|
|
13
|
+
* A[Start] --> B{Is it working?}
|
|
14
|
+
* `}
|
|
15
|
+
* <Caption>Simple flowchart diagram</Caption>
|
|
16
|
+
* </Diagram>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export const Diagram = '_tag_';
|
|
@@ -177,10 +177,6 @@ declare const _default: {
|
|
|
177
177
|
}, TagChildren & import("../../toc.js").ObjPropToc & import("../../snippet.js").ObjPropSnippet>;
|
|
178
178
|
}, undefined>;
|
|
179
179
|
dependencies: {
|
|
180
|
-
mermaid: {
|
|
181
|
-
optimize: true;
|
|
182
|
-
transpile: true;
|
|
183
|
-
};
|
|
184
180
|
photoswipe: {
|
|
185
181
|
optimize: boolean;
|
|
186
182
|
transpile: boolean;
|
|
@@ -26,11 +26,5 @@ export const diagramRegistryItem = defineRegistryItem({
|
|
|
26
26
|
});
|
|
27
27
|
export default defineEruditProseCoreElement({
|
|
28
28
|
registryItem: diagramRegistryItem,
|
|
29
|
-
dependencies: {
|
|
30
|
-
...photoswipeDependency,
|
|
31
|
-
mermaid: {
|
|
32
|
-
optimize: true,
|
|
33
|
-
transpile: true
|
|
34
|
-
}
|
|
35
|
-
}
|
|
29
|
+
dependencies: { ...photoswipeDependency }
|
|
36
30
|
});
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { ProseElement } from '@jsprose/core';
|
|
3
|
-
|
|
4
|
-
import type { emphasisSchema } from './core.js';
|
|
5
|
-
import Render from '../../app/shared/Render.vue';
|
|
6
|
-
|
|
7
|
-
defineProps<{ element: ProseElement<typeof emphasisSchema> }>();
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<template>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ProseElement } from '@jsprose/core';
|
|
3
|
+
|
|
4
|
+
import type { emphasisSchema } from './core.js';
|
|
5
|
+
import Render from '../../app/shared/Render.vue';
|
|
6
|
+
|
|
7
|
+
defineProps<{ element: ProseElement<typeof emphasisSchema> }>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<strong
|
|
12
|
+
v-if="element.data.type === 'bold'"
|
|
13
|
+
:class="[
|
|
14
|
+
'font-semibold',
|
|
15
|
+
element.data?.accent
|
|
16
|
+
? 'text-(--accentText,var(--color-text-deep))'
|
|
17
|
+
: 'text-text-deep',
|
|
18
|
+
]"
|
|
19
|
+
>
|
|
20
|
+
<Render v-for="child of element.children" :element="child" />
|
|
21
|
+
</strong>
|
|
22
|
+
<i v-else>
|
|
23
|
+
<Render v-for="child of element.children" :element="child" />
|
|
24
|
+
</i>
|
|
25
|
+
</template>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* There are several ways to emphasize text:
|
|
3
|
-
* * `<B>` to make text bold
|
|
4
|
-
* * `<I>` to italicize text
|
|
5
|
-
*
|
|
6
|
-
* Do not overuse these elements, as too much emphasis singificantly reduces readability!
|
|
7
|
-
*
|
|
8
|
-
* @title Emphasis
|
|
9
|
-
* @layout inliner
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* <>
|
|
13
|
-
* Importart words can be <B>bolded</B> or <I>italicized</I> for emphasis.
|
|
14
|
-
* </>
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export const B = '_tag_';
|
|
18
|
-
export const I = '_tag_';
|
|
1
|
+
/**
|
|
2
|
+
* There are several ways to emphasize text:
|
|
3
|
+
* * `<B>` to make text bold
|
|
4
|
+
* * `<I>` to italicize text
|
|
5
|
+
*
|
|
6
|
+
* Do not overuse these elements, as too much emphasis singificantly reduces readability!
|
|
7
|
+
*
|
|
8
|
+
* @title Emphasis
|
|
9
|
+
* @layout inliner
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <>
|
|
13
|
+
* Importart words can be <B>bolded</B> or <I>italicized</I> for emphasis.
|
|
14
|
+
* </>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const B = '_tag_';
|
|
18
|
+
export const I = '_tag_';
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import type { ProseElement } from '@jsprose/core';
|
|
3
|
-
|
|
4
|
-
import type { flexSchema } from './core.js';
|
|
5
|
-
import Block from '../../app/shared/block/Block.vue';
|
|
6
|
-
import Render from '../../app/shared/Render.vue';
|
|
7
|
-
|
|
8
|
-
const { element } = defineProps<{ element: ProseElement<typeof flexSchema> }>();
|
|
9
|
-
|
|
10
|
-
const justify = (() => {
|
|
11
|
-
|
|
12
|
-
})();
|
|
13
|
-
|
|
14
|
-
const gap = (() => {
|
|
15
|
-
|
|
16
|
-
})();
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<template>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</Block>
|
|
38
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import type { ProseElement } from '@jsprose/core';
|
|
3
|
+
|
|
4
|
+
import type { flexSchema } from './core.js';
|
|
5
|
+
import Block from '../../app/shared/block/Block.vue';
|
|
6
|
+
import Render from '../../app/shared/Render.vue';
|
|
7
|
+
|
|
8
|
+
const { element } = defineProps<{ element: ProseElement<typeof flexSchema> }>();
|
|
9
|
+
|
|
10
|
+
const justify = (() => {
|
|
11
|
+
return element?.data?.justifyContent ?? 'center';
|
|
12
|
+
})();
|
|
13
|
+
|
|
14
|
+
const gap = (() => {
|
|
15
|
+
return element?.data?.gap ?? 'var(--spacing-big)';
|
|
16
|
+
})();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<Block :element>
|
|
21
|
+
<div
|
|
22
|
+
:style="{ justifyContent: justify, gap }"
|
|
23
|
+
class="flex flex-wrap items-center"
|
|
24
|
+
>
|
|
25
|
+
<template v-for="(item, i) of element.children">
|
|
26
|
+
<div
|
|
27
|
+
:style="{
|
|
28
|
+
flex: element.data?.flexes ? element.data.flexes[i] : undefined,
|
|
29
|
+
}"
|
|
30
|
+
>
|
|
31
|
+
<Render :element="item" />
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
</div>
|
|
35
|
+
</Block>
|
|
36
|
+
</template>
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flex allows to place items next to each other in a row.
|
|
3
|
-
* This is useful for grouping blocks with same context (images, diagrams, etc.), side-by-side comparisons, and similar layouts.
|
|
4
|
-
*
|
|
5
|
-
* By default items are placed at center with a small gap between them.
|
|
6
|
-
* Placement and gap can be customized via `justify` and `gap` props, which work the same way as CSS `justify-content` and `gap` properties.
|
|
7
|
-
*
|
|
8
|
-
* @title Flex
|
|
9
|
-
* @layout block
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* <Flex>
|
|
13
|
-
* <Image src={schema1} width="100px" />
|
|
14
|
-
* <Image src={schema2} width="75px" />
|
|
15
|
-
* </Flex>
|
|
16
|
-
*
|
|
17
|
-
* <Flex gap="40px" justify="space-between">
|
|
18
|
-
* <Image src={schema1} width="100px" />
|
|
19
|
-
* <Image src={schema2} width="75px" />
|
|
20
|
-
* </Flex>
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export const Flex = '_tag_';
|
|
1
|
+
/**
|
|
2
|
+
* Flex allows to place items next to each other in a row.
|
|
3
|
+
* This is useful for grouping blocks with same context (images, diagrams, etc.), side-by-side comparisons, and similar layouts.
|
|
4
|
+
*
|
|
5
|
+
* By default items are placed at center with a small gap between them.
|
|
6
|
+
* Placement and gap can be customized via `justify` and `gap` props, which work the same way as CSS `justify-content` and `gap` properties.
|
|
7
|
+
*
|
|
8
|
+
* @title Flex
|
|
9
|
+
* @layout block
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Flex>
|
|
13
|
+
* <Image src={schema1} width="100px" />
|
|
14
|
+
* <Image src={schema2} width="75px" />
|
|
15
|
+
* </Flex>
|
|
16
|
+
*
|
|
17
|
+
* <Flex gap="40px" justify="space-between">
|
|
18
|
+
* <Image src={schema1} width="100px" />
|
|
19
|
+
* <Image src={schema2} width="75px" />
|
|
20
|
+
* </Flex>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export const Flex = '_tag_';
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { ref } from 'vue';
|
|
3
|
-
import type { ProseElement } from '@jsprose/core';
|
|
4
|
-
|
|
5
|
-
import type { gallerySchema } from './core.js';
|
|
6
|
-
import { useElementStorage } from '../../app/composables/storage.js';
|
|
7
|
-
import { darkInvert, lightInvert } from '../../app/shared/invert.js';
|
|
8
|
-
import Block from '../../app/shared/block/Block.vue';
|
|
9
|
-
import ImageElement from '../image/ImageElement.vue';
|
|
10
|
-
|
|
11
|
-
const { element } = defineProps<{
|
|
12
|
-
|
|
13
|
-
}>();
|
|
14
|
-
|
|
15
|
-
const resolvedSources: string[] = [];
|
|
16
|
-
|
|
17
|
-
for (const child of element.children) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const activeI = ref<number>(0);
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<template>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import type { ProseElement } from '@jsprose/core';
|
|
4
|
+
|
|
5
|
+
import type { gallerySchema } from './core.js';
|
|
6
|
+
import { useElementStorage } from '../../app/composables/storage.js';
|
|
7
|
+
import { darkInvert, lightInvert } from '../../app/shared/invert.js';
|
|
8
|
+
import Block from '../../app/shared/block/Block.vue';
|
|
9
|
+
import ImageElement from '../image/ImageElement.vue';
|
|
10
|
+
|
|
11
|
+
const { element } = defineProps<{
|
|
12
|
+
element: ProseElement<typeof gallerySchema>;
|
|
13
|
+
}>();
|
|
14
|
+
|
|
15
|
+
const resolvedSources: string[] = [];
|
|
16
|
+
|
|
17
|
+
for (const child of element.children) {
|
|
18
|
+
const storage = await useElementStorage(child);
|
|
19
|
+
resolvedSources.push(storage.resolvedSrc);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const activeI = ref<number>(0);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<Block :element>
|
|
27
|
+
<div class="nice-scrollbars mb-normal flex overflow-auto">
|
|
28
|
+
<div class="gap-normal p-small m-auto flex">
|
|
29
|
+
<button
|
|
30
|
+
v-for="(image, i) of element.children"
|
|
31
|
+
@click="activeI = i"
|
|
32
|
+
:class="[
|
|
33
|
+
`aspect-square w-[70px] cursor-pointer overflow-hidden rounded-xl
|
|
34
|
+
border-2 transition-[border]`,
|
|
35
|
+
{
|
|
36
|
+
'border-border hocus:border-brand': activeI !== i,
|
|
37
|
+
'border-brand': activeI === i,
|
|
38
|
+
},
|
|
39
|
+
]"
|
|
40
|
+
>
|
|
41
|
+
<img
|
|
42
|
+
:src="resolvedSources[i]"
|
|
43
|
+
:class="[
|
|
44
|
+
'block object-cover',
|
|
45
|
+
{
|
|
46
|
+
[lightInvert]: image.data.invert === 'light',
|
|
47
|
+
[darkInvert]: image.data.invert === 'dark',
|
|
48
|
+
},
|
|
49
|
+
]"
|
|
50
|
+
/>
|
|
51
|
+
</button>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<ImageElement :element="element.children[activeI]" :key="activeI" />
|
|
55
|
+
</Block>
|
|
56
|
+
</template>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Galleries are used to display a collection of images in one place, not occupying too much vertical space.
|
|
3
|
-
*
|
|
4
|
-
* @title Gallery
|
|
5
|
-
* @layout block
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* // import foo from './assets/foo.svg';
|
|
9
|
-
* // import bar from './assets/bar.png';
|
|
10
|
-
* <Gallery>
|
|
11
|
-
* <Image src={foo} width="200px" />
|
|
12
|
-
* <Image src={bar} width="300px">
|
|
13
|
-
* <Caption>Bar image caption</Caption>
|
|
14
|
-
* </Image>
|
|
15
|
-
* </Gallery>
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export const Gallery = '_tag_';
|
|
1
|
+
/**
|
|
2
|
+
* Galleries are used to display a collection of images in one place, not occupying too much vertical space.
|
|
3
|
+
*
|
|
4
|
+
* @title Gallery
|
|
5
|
+
* @layout block
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // import foo from './assets/foo.svg';
|
|
9
|
+
* // import bar from './assets/bar.png';
|
|
10
|
+
* <Gallery>
|
|
11
|
+
* <Image src={foo} width="200px" />
|
|
12
|
+
* <Image src={bar} width="300px">
|
|
13
|
+
* <Caption>Bar image caption</Caption>
|
|
14
|
+
* </Image>
|
|
15
|
+
* </Gallery>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const Gallery = '_tag_';
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { h } from 'vue';
|
|
3
|
-
import type { ProseElement } from '@jsprose/core';
|
|
4
|
-
|
|
5
|
-
import { useFormatText } from '../../app/composables/formatText.js';
|
|
6
|
-
import type { headingSchema } from './core.js';
|
|
7
|
-
import Block from '../../app/shared/block/Block.vue';
|
|
8
|
-
|
|
9
|
-
const { element } = defineProps<{
|
|
10
|
-
|
|
11
|
-
}>();
|
|
12
|
-
|
|
13
|
-
const formatText = useFormatText();
|
|
14
|
-
|
|
15
|
-
const Tag = (() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})();
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<template>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</template>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { h } from 'vue';
|
|
3
|
+
import type { ProseElement } from '@jsprose/core';
|
|
4
|
+
|
|
5
|
+
import { useFormatText } from '../../app/composables/formatText.js';
|
|
6
|
+
import type { headingSchema } from './core.js';
|
|
7
|
+
import Block from '../../app/shared/block/Block.vue';
|
|
8
|
+
|
|
9
|
+
const { element } = defineProps<{
|
|
10
|
+
element: ProseElement<typeof headingSchema>;
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
const formatText = useFormatText();
|
|
14
|
+
|
|
15
|
+
const Tag = (() => {
|
|
16
|
+
switch (element.data.level) {
|
|
17
|
+
case 1:
|
|
18
|
+
return h('h2');
|
|
19
|
+
case 2:
|
|
20
|
+
return h('h3');
|
|
21
|
+
case 3:
|
|
22
|
+
return h('h4');
|
|
23
|
+
}
|
|
24
|
+
})();
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<Block :element class="mt-normal micro:mt-big first:mt-0">
|
|
29
|
+
<component
|
|
30
|
+
:is="Tag"
|
|
31
|
+
:class="[
|
|
32
|
+
'text-text-deep',
|
|
33
|
+
{
|
|
34
|
+
[`text-main-2xl border-border pb-small micro:pb-normal border-b
|
|
35
|
+
font-bold`]: element.data.level === 1,
|
|
36
|
+
'text-main-xl font-semibold': element.data.level === 2,
|
|
37
|
+
'text-main-lg font-medium': element.data.level === 3,
|
|
38
|
+
},
|
|
39
|
+
]"
|
|
40
|
+
>
|
|
41
|
+
{{ formatText(element.data.title) }}
|
|
42
|
+
</component>
|
|
43
|
+
</Block>
|
|
44
|
+
</template>
|
|
@@ -1,45 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Headings are used to split prose into sections:
|
|
3
|
-
* * `<H1>` - major sections, key parts of prose
|
|
4
|
-
* * `<H2>` - subsections
|
|
5
|
-
* * `<H3>` - sub-subsections (rarely used)
|
|
6
|
-
*
|
|
7
|
-
* Headings have special behavior:
|
|
8
|
-
* * Always appear in
|
|
9
|
-
* *
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* * **Don't** "
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export const H1 = '_tag_';
|
|
44
|
-
export const H2 = '_tag_';
|
|
45
|
-
export const H3 = '_tag_';
|
|
1
|
+
/**
|
|
2
|
+
* Headings are used to split prose into sections:
|
|
3
|
+
* * `<H1>` - major sections, key parts of prose
|
|
4
|
+
* * `<H2>` - subsections
|
|
5
|
+
* * `<H3>` - sub-subsections (rarely used)
|
|
6
|
+
*
|
|
7
|
+
* Headings have special behavior:
|
|
8
|
+
* * Always appear in Table of Contents
|
|
9
|
+
* * Automatically generate snippet titles so you don't have to manually write them.
|
|
10
|
+
*
|
|
11
|
+
* When adding heading to search make sure to specify a snippet title that will be understandable out of context.
|
|
12
|
+
* * **Don't** "Description" -> **Do** "Description of Euclidean algorithm"
|
|
13
|
+
* * **Don't** "Problem" -> **Do** "Problem with integers division"
|
|
14
|
+
*
|
|
15
|
+
* **Caution:** never use headings inside other blocks! They are only allowed at the top level of prose!
|
|
16
|
+
*
|
|
17
|
+
* @title Heading
|
|
18
|
+
* @layout block
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <H1>Pythagorean theorem</H1>
|
|
22
|
+
*
|
|
23
|
+
* // ... Content ...
|
|
24
|
+
*
|
|
25
|
+
* // Add heading in "Quick links" section
|
|
26
|
+
* <H2 snippet={{ quick: true }}>
|
|
27
|
+
* Triangles and squares
|
|
28
|
+
* </H2>
|
|
29
|
+
*
|
|
30
|
+
* // ... Content ...
|
|
31
|
+
*
|
|
32
|
+
* // Provide more specific title for search
|
|
33
|
+
* <H3 snippet={{ search: true, title: 'Pythagorean theorem in physics' }}>
|
|
34
|
+
* Usage in physics
|
|
35
|
+
* </H3>
|
|
36
|
+
*
|
|
37
|
+
* // ... Content ...
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const H1 = '_tag_';
|
|
41
|
+
export const H2 = '_tag_';
|
|
42
|
+
export const H3 = '_tag_';
|
|
@@ -9,22 +9,22 @@ export const headingSchema = defineSchema({
|
|
|
9
9
|
export const H1 = defineEruditTag({
|
|
10
10
|
tagName: "H1",
|
|
11
11
|
schema: headingSchema
|
|
12
|
-
})(({ tagName, element,
|
|
13
|
-
processHeadingElement(1, tagName,
|
|
12
|
+
})(({ tagName, element, children }) => {
|
|
13
|
+
processHeadingElement(1, tagName, element, children);
|
|
14
14
|
});
|
|
15
15
|
export const H2 = defineEruditTag({
|
|
16
16
|
tagName: "H2",
|
|
17
17
|
schema: headingSchema
|
|
18
|
-
})(({ tagName, element,
|
|
19
|
-
processHeadingElement(2, tagName,
|
|
18
|
+
})(({ tagName, element, children }) => {
|
|
19
|
+
processHeadingElement(2, tagName, element, children);
|
|
20
20
|
});
|
|
21
21
|
export const H3 = defineEruditTag({
|
|
22
22
|
tagName: "H3",
|
|
23
23
|
schema: headingSchema
|
|
24
|
-
})(({ tagName, element,
|
|
25
|
-
processHeadingElement(3, tagName,
|
|
24
|
+
})(({ tagName, element, children }) => {
|
|
25
|
+
processHeadingElement(3, tagName, element, children);
|
|
26
26
|
});
|
|
27
|
-
function processHeadingElement(level, tagName,
|
|
27
|
+
function processHeadingElement(level, tagName, element, children) {
|
|
28
28
|
ensureTagChild(tagName, children, textSchema);
|
|
29
29
|
const child = children[0];
|
|
30
30
|
const title = child.data.trim();
|
|
@@ -36,13 +36,6 @@ function processHeadingElement(level, tagName, props, element, children) {
|
|
|
36
36
|
title
|
|
37
37
|
};
|
|
38
38
|
element.title = title;
|
|
39
|
-
element.snippet ||= {};
|
|
40
|
-
element.snippet.search ??= true;
|
|
41
|
-
// Only auto-enable SEO if quick is set in props
|
|
42
|
-
// Otherwise explicitly disable it to prevent auto-enablement from search flag
|
|
43
|
-
if (!props.snippet?.quick) {
|
|
44
|
-
element.snippet.seo ??= false;
|
|
45
|
-
}
|
|
46
39
|
element.toc = { add: true };
|
|
47
40
|
}
|
|
48
41
|
export const headingRegistryItem = defineRegistryItem({
|