From 0cc46735e07662b8074aa8879c97cd6f8c001770 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 17 Mar 2025 15:11:11 +0700 Subject: [PATCH] feat: add video support --- package.json | 2 + pnpm-lock.yaml | 99 ++++++++++++++++++++++++++++++++ src/pages/00_manual/ViewPage.vue | 17 +++++- 3 files changed, 116 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ee806e89..1d0c4f28 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,8 @@ "markdown-it": "^14.1.0", "markdown-it-anchor": "^9.2.0", "markdown-it-highlightjs": "^4.2.0", + "markdown-it-html5-embed": "^1.0.0", + "markdown-it-html5-media": "^0.7.1", "markdown-it-image-figures": "^2.1.1", "markdown-it-video": "^0.6.3", "mime": "^4.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 033b3b16..af985e7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,12 @@ importers: markdown-it-highlightjs: specifier: ^4.2.0 version: 4.2.0 + markdown-it-html5-embed: + specifier: ^1.0.0 + version: 1.0.0 + markdown-it-html5-media: + specifier: ^0.7.1 + version: 0.7.1 markdown-it-image-figures: specifier: ^2.1.1 version: 2.1.1(markdown-it@14.1.0) @@ -1150,6 +1156,9 @@ packages: engines: {node: '>=10'} deprecated: This package is no longer supported. + argparse@1.0.10: + resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -1727,6 +1736,12 @@ packages: resolution: {integrity: sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg==} engines: {node: '>=6.9.0'} + entities@1.1.2: + resolution: {integrity: sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==} + + entities@2.1.0: + resolution: {integrity: sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==} + entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} @@ -2396,6 +2411,12 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} + linkify-it@2.2.0: + resolution: {integrity: sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==} + + linkify-it@3.0.3: + resolution: {integrity: sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==} + linkify-it@5.0.0: resolution: {integrity: sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==} @@ -2477,6 +2498,13 @@ packages: markdown-it-highlightjs@4.2.0: resolution: {integrity: sha512-NC7pXE8KkOl6xWJVRNt8p6wgJVznXKsE0HgYGdk6DD2tn1l4L9f0ALf3VIoGVkotNU1uGQatSxfBF1zZPUMmuQ==} + markdown-it-html5-embed@1.0.0: + resolution: {integrity: sha512-SPgugO/1+/9sZcgxoxijoTHSUpCUgFCNe1MSuTmDxDkV6NQrVzMclhRMFgE/rcHO+2rhIg3U7Oy80XA/E8ytpg==} + + markdown-it-html5-media@0.7.1: + resolution: {integrity: sha512-PfKFD+K1Vpw8+OwfV/VO6Y5Sy1xSS/F1BgbW8Q281LylBBoW47fm4k9Zh0IpsPpM3/HObBD6rooMTaMVlC3PqA==} + engines: {node: '>=10.0'} + markdown-it-image-figures@2.1.1: resolution: {integrity: sha512-mwXSQ2nPeVUzCMIE3HlLvjRioopiqyJLNph0pyx38yf9mpqFDhNGnMpAXF9/A2Xv0oiF2cVyg9xwfF0HNAz05g==} engines: {node: '>=12.0.0'} @@ -2486,13 +2514,24 @@ packages: markdown-it-video@0.6.3: resolution: {integrity: sha512-T4th1kwy0OcvyWSN4u3rqPGxvbDclpucnVSSaH3ZacbGsAts964dxokx9s/I3GYsrDCJs4ogtEeEeVP18DQj0Q==} + markdown-it@12.3.2: + resolution: {integrity: sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==} + hasBin: true + markdown-it@14.1.0: resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==} hasBin: true + markdown-it@8.4.2: + resolution: {integrity: sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==} + hasBin: true + md5.js@1.3.5: resolution: {integrity: sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==} + mdurl@1.0.1: + resolution: {integrity: sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==} + mdurl@2.0.0: resolution: {integrity: sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==} @@ -2556,6 +2595,9 @@ packages: resolution: {integrity: sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==} engines: {node: '>=8'} + mimoza@1.0.0: + resolution: {integrity: sha512-+j7SSye/hablu66K/jjeyPmk6WL8RoXfeZ+MMn37vSNDGuaWY/5wm10LpSpxAHX4kNoEwkTWYHba8ePVip+Hqg==} + minimalistic-assert@1.0.1: resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} @@ -3340,6 +3382,9 @@ packages: resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==} engines: {node: '>=0.10.0'} + sprintf-js@1.0.3: + resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + ssri@6.0.2: resolution: {integrity: sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==} @@ -3535,6 +3580,9 @@ packages: engines: {node: '>=14.17'} hasBin: true + uc.micro@1.0.6: + resolution: {integrity: sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==} + uc.micro@2.1.0: resolution: {integrity: sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==} @@ -4834,6 +4882,10 @@ snapshots: readable-stream: 3.6.2 optional: true + argparse@1.0.10: + dependencies: + sprintf-js: 1.0.3 + argparse@2.0.1: {} arr-diff@4.0.0: {} @@ -5523,6 +5575,10 @@ snapshots: memory-fs: 0.5.0 tapable: 1.1.3 + entities@1.1.2: {} + + entities@2.1.0: {} + entities@4.5.0: {} errno@0.1.8: @@ -6326,6 +6382,14 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 + linkify-it@2.2.0: + dependencies: + uc.micro: 1.0.6 + + linkify-it@3.0.3: + dependencies: + uc.micro: 1.0.6 + linkify-it@5.0.0: dependencies: uc.micro: 2.1.0 @@ -6411,12 +6475,29 @@ snapshots: dependencies: highlight.js: 11.11.1 + markdown-it-html5-embed@1.0.0: + dependencies: + markdown-it: 8.4.2 + mimoza: 1.0.0 + + markdown-it-html5-media@0.7.1: + dependencies: + markdown-it: 12.3.2 + markdown-it-image-figures@2.1.1(markdown-it@14.1.0): dependencies: markdown-it: 14.1.0 markdown-it-video@0.6.3: {} + markdown-it@12.3.2: + dependencies: + argparse: 2.0.1 + entities: 2.1.0 + linkify-it: 3.0.3 + mdurl: 1.0.1 + uc.micro: 1.0.6 + markdown-it@14.1.0: dependencies: argparse: 2.0.1 @@ -6426,12 +6507,22 @@ snapshots: punycode.js: 2.3.1 uc.micro: 2.1.0 + markdown-it@8.4.2: + dependencies: + argparse: 1.0.10 + entities: 1.1.2 + linkify-it: 2.2.0 + mdurl: 1.0.1 + uc.micro: 1.0.6 + md5.js@1.3.5: dependencies: hash-base: 3.1.0 inherits: 2.0.4 safe-buffer: 5.2.1 + mdurl@1.0.1: {} + mdurl@2.0.0: {} media-typer@0.3.0: {} @@ -6495,6 +6586,10 @@ snapshots: mimic-response@2.1.0: optional: true + mimoza@1.0.0: + dependencies: + mime-db: 1.52.0 + minimalistic-assert@1.0.1: {} minimalistic-crypto-utils@1.0.1: {} @@ -7366,6 +7461,8 @@ snapshots: dependencies: extend-shallow: 3.0.2 + sprintf-js@1.0.3: {} + ssri@6.0.2: dependencies: figgy-pudding: 3.5.2 @@ -7591,6 +7688,8 @@ snapshots: typescript@5.5.4: {} + uc.micro@1.0.6: {} + uc.micro@2.1.0: {} udsv@0.6.0: {} diff --git a/src/pages/00_manual/ViewPage.vue b/src/pages/00_manual/ViewPage.vue index c295703e..f12ba7bc 100644 --- a/src/pages/00_manual/ViewPage.vue +++ b/src/pages/00_manual/ViewPage.vue @@ -7,14 +7,18 @@ import { useRoute } from 'vue-router'; // @ts-expect-error import mditFigureWithPCaption from 'markdown-it-image-figures'; +// @ts-expect-error +import mditMedia from 'markdown-it-html5-media'; import mditAnchor from 'markdown-it-anchor'; import mditHighlight from 'markdown-it-highlightjs'; import { initLang, initTheme } from 'src/utils/ui'; +import { baseUrl } from 'src/stores/utils'; const ROUTE = useRoute(); const md = new MarkdownIt() .use(mditAnchor) + .use(mditMedia.html5Media) .use(mditHighlight, { hljs }) .use(mditFigureWithPCaption, { figcaption: 'alt' }); @@ -52,7 +56,9 @@ onUnmounted(() => { async function getContent() { if (!category.value || !page.value) return; - const res = await fetch(`/manual/${category.value}/${page.value}.md`); + const res = await fetch( + `${baseUrl}/manual/${category.value}/page/${page.value}`, + ); if (res && res.ok) { const text = await res.text(); @@ -108,7 +114,10 @@ async function scrollTo(id: string) { class="surface-1" v-html=" md.render( - content.replaceAll('images/', `/manual/${category}/images/`), + content.replaceAll( + 'assets/', + `${baseUrl}/manual/${category}/assets/`, + ), ) " > @@ -250,4 +259,8 @@ async function scrollTo(id: string) { font-weight: 600; padding: 0px 16px; } + +.markdown :deep(video) { + width: 100%; +}