@erudit-js/prose 4.3.0 → 4.3.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/shared/block/AsideMenu.vue +4 -1
- package/dist/elements/callout/Callout.vue +21 -0
- package/dist/elements/callout/core.d.ts +1 -0
- package/dist/elements/callout/storage.js +11 -1
- package/dist/elements/diagram/Diagram.vue +26 -5
- package/dist/slugify/languages/en.js +1 -1
- package/dist/slugify/languages/ru.js +1 -1
- package/package.json +5 -5
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed } from 'vue';
|
|
3
3
|
import type { ProseElement } from 'tsprose';
|
|
4
4
|
|
|
5
|
+
import { useProseContext } from '../../composables/context.js';
|
|
5
6
|
import { useElementPhrase } from '../../composables/language.js';
|
|
6
7
|
import AsideMenuSeparator from './AsideMenuSeparator.vue';
|
|
7
8
|
import AsideMenuCopyLink from './AsideMenuCopyLink.vue';
|
|
@@ -10,8 +11,10 @@ const { element } = defineProps<{
|
|
|
10
11
|
element: ProseElement;
|
|
11
12
|
}>();
|
|
12
13
|
|
|
14
|
+
const { setHtmlIds } = useProseContext();
|
|
15
|
+
|
|
13
16
|
const hasLink = computed(() => {
|
|
14
|
-
return Boolean(element.id);
|
|
17
|
+
return setHtmlIds && Boolean(element.id);
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
const hasButtons = computed(() => {
|
|
@@ -21,7 +21,18 @@ const formatText = useFormatText();
|
|
|
21
21
|
class="gap-big flex"
|
|
22
22
|
>
|
|
23
23
|
<div class="max-micro:hidden shrink-0">
|
|
24
|
+
<video
|
|
25
|
+
v-if="calloutStorage.videoIcon"
|
|
26
|
+
:src="calloutStorage.resolvedIconSrc"
|
|
27
|
+
autoplay
|
|
28
|
+
loop
|
|
29
|
+
muted
|
|
30
|
+
playsinline
|
|
31
|
+
class="outline-border size-[60px] rounded-full border-2
|
|
32
|
+
border-transparent object-cover outline-2"
|
|
33
|
+
/>
|
|
24
34
|
<img
|
|
35
|
+
v-else
|
|
25
36
|
:src="calloutStorage.resolvedIconSrc"
|
|
26
37
|
loading="lazy"
|
|
27
38
|
class="outline-border size-[60px] rounded-full border-2
|
|
@@ -39,7 +50,17 @@ const formatText = useFormatText();
|
|
|
39
50
|
class="gap-small mb-(--proseAsideWidth) flex items-center
|
|
40
51
|
px-(--proseAsideWidth) font-semibold"
|
|
41
52
|
>
|
|
53
|
+
<video
|
|
54
|
+
v-if="calloutStorage.videoIcon"
|
|
55
|
+
:src="calloutStorage.resolvedIconSrc"
|
|
56
|
+
autoplay
|
|
57
|
+
loop
|
|
58
|
+
muted
|
|
59
|
+
playsinline
|
|
60
|
+
class="micro:hidden size-[30px] shrink-0 rounded-full object-cover"
|
|
61
|
+
/>
|
|
42
62
|
<img
|
|
63
|
+
v-else
|
|
43
64
|
:src="calloutStorage.resolvedIconSrc"
|
|
44
65
|
class="micro:hidden size-[30px] shrink-0 rounded-full"
|
|
45
66
|
/>
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { projectRelFilePath } from "../../shared/filePath.js";
|
|
2
|
+
const videoExtensions = [
|
|
3
|
+
"mp4",
|
|
4
|
+
"webm",
|
|
5
|
+
"ogg"
|
|
6
|
+
];
|
|
2
7
|
export function createCalloutStorage(projectAbsPath, projectBaseUrl, calloutAbsoluteIconSrc) {
|
|
3
8
|
const resolvedIconSrc = projectBaseUrl + "file/" + projectRelFilePath(projectAbsPath, calloutAbsoluteIconSrc);
|
|
4
|
-
|
|
9
|
+
const ext = calloutAbsoluteIconSrc.split(".").pop()?.toLowerCase() ?? "";
|
|
10
|
+
const videoIcon = videoExtensions.includes(ext);
|
|
11
|
+
return {
|
|
12
|
+
resolvedIconSrc,
|
|
13
|
+
videoIcon
|
|
14
|
+
};
|
|
5
15
|
}
|
|
@@ -49,6 +49,8 @@ onMounted(async () => {
|
|
|
49
49
|
(/AppleWebKit/.test(ua) && !/Chrome/.test(ua)) ||
|
|
50
50
|
/\b(iPad|iPhone|iPod)\b/.test(ua);
|
|
51
51
|
|
|
52
|
+
prepareMarkdown();
|
|
53
|
+
|
|
52
54
|
if (hasLatex(diagramContent.value)) {
|
|
53
55
|
await prepareMathDiagram();
|
|
54
56
|
}
|
|
@@ -126,6 +128,29 @@ function hasLatex(content: string): boolean {
|
|
|
126
128
|
return latexRegex.display.test(content) || latexRegex.inline.test(content);
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
function prepareMarkdown() {
|
|
132
|
+
const mathPattern = /\$\$[\s\S]*?\$\$|\$(?!\$).*?(?<!\$)\$/g;
|
|
133
|
+
|
|
134
|
+
const applyMarkdown = (text: string): string => {
|
|
135
|
+
return text
|
|
136
|
+
.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>')
|
|
137
|
+
.replace(/\*(.+?)\*/g, '<i>$1</i>');
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const content = diagramContent.value;
|
|
141
|
+
const parts: string[] = [];
|
|
142
|
+
let lastIndex = 0;
|
|
143
|
+
|
|
144
|
+
for (const match of content.matchAll(mathPattern)) {
|
|
145
|
+
parts.push(applyMarkdown(content.slice(lastIndex, match.index)));
|
|
146
|
+
parts.push(match[0]);
|
|
147
|
+
lastIndex = match.index + match[0].length;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
parts.push(applyMarkdown(content.slice(lastIndex)));
|
|
151
|
+
diagramContent.value = parts.join('');
|
|
152
|
+
}
|
|
153
|
+
|
|
129
154
|
async function prepareMathDiagram() {
|
|
130
155
|
await import('katex/dist/katex.min.css');
|
|
131
156
|
const katex = await import('katex');
|
|
@@ -141,11 +166,7 @@ async function prepareMathDiagram() {
|
|
|
141
166
|
displayMode,
|
|
142
167
|
output: 'mathml',
|
|
143
168
|
})
|
|
144
|
-
.replace(/<mtd>/g, '<mtd style="padding: 0.2em 0;">')
|
|
145
|
-
.replace(
|
|
146
|
-
/<annotation encoding="application\/x-tex">[\s\S]*?<\/annotation>/g,
|
|
147
|
-
'',
|
|
148
|
-
);
|
|
169
|
+
.replace(/<mtd>/g, '<mtd style="padding: 0.2em 0;">');
|
|
149
170
|
});
|
|
150
171
|
};
|
|
151
172
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export default (text) => {
|
|
2
|
-
return text.replace(/(\p{Lu}{2,})(\p{Ll})/gu, "$1-$2").replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/(\p{L})(\d)/gu, "$1-$2").replace(/(\d)(\p{L})/gu, "$1-$2").toLowerCase().replace(/[
|
|
2
|
+
return text.replace(/(\p{Lu}{2,})(\p{Ll})/gu, "$1-$2").replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/(\p{L})(\d)/gu, "$1-$2").replace(/(\d)(\p{L})/gu, "$1-$2").toLowerCase().replace(/[^\p{L}0-9]/gu, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
3
3
|
};
|
|
@@ -34,5 +34,5 @@ export default (text) => {
|
|
|
34
34
|
ю: "yu",
|
|
35
35
|
я: "ya"
|
|
36
36
|
};
|
|
37
|
-
return text.replace(/(\p{Lu}{2,})(\p{Ll})/gu, "$1-$2").replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/(\p{L})(\d)/gu, "$1-$2").replace(/(\d)(\p{L})/gu, "$1-$2").toLowerCase().split("").map((char) => cyrillicToLatin[char] !== undefined ? cyrillicToLatin[char] : /[
|
|
37
|
+
return text.replace(/(\p{Lu}{2,})(\p{Ll})/gu, "$1-$2").replace(/(\p{Ll})(\p{Lu})/gu, "$1-$2").replace(/(\p{L})(\d)/gu, "$1-$2").replace(/(\d)(\p{L})/gu, "$1-$2").toLowerCase().split("").map((char) => cyrillicToLatin[char] !== undefined ? cyrillicToLatin[char] : /[\p{L}0-9]/u.test(char) ? char : "-").join("").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
38
38
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@erudit-js/prose",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.1",
|
|
5
5
|
"description": "📝 JSX prose subsystem for Erudit sites",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"prepack": "bun run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@erudit-js/core": "4.3.
|
|
35
|
+
"@erudit-js/core": "4.3.1",
|
|
36
36
|
"@floating-ui/vue": "^1.1.11",
|
|
37
37
|
"image-size": "^2.0.2",
|
|
38
|
-
"katex": "^0.16.
|
|
39
|
-
"mermaid": "^11.
|
|
38
|
+
"katex": "^0.16.38",
|
|
39
|
+
"mermaid": "^11.13.0",
|
|
40
40
|
"photoswipe": "^5.4.4",
|
|
41
41
|
"tsprose": "^1.0.1",
|
|
42
42
|
"vue": "latest"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"glob": "^13.0.6",
|
|
46
|
-
"oxc-transform": "0.
|
|
46
|
+
"oxc-transform": "0.119.0",
|
|
47
47
|
"ts-xor": "^1.3.0"
|
|
48
48
|
}
|
|
49
49
|
}
|