diff --git a/webui/package-lock.json b/webui/package-lock.json index a6c72f04a..a2e6fb701 100644 --- a/webui/package-lock.json +++ b/webui/package-lock.json @@ -27,7 +27,7 @@ "js-yaml": "^5.2.2", "kafkajs": "^2.2.4", "ldapts": "^9.0.0", - "markdown-it": "^14.2.0", + "markdown-it": "^15.0.0", "markdown-it-container": "^4.0.0", "mime-types": "^3.0.2", "mqtt": "^5.15.1", @@ -2498,12 +2498,12 @@ } }, "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", + "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", "license": "BSD-2-Clause", "engines": { - "node": ">=0.12" + "node": ">=20.19.0" }, "funding": { "url": "https://github.com/fb55/entities?sponsor=1" @@ -3799,9 +3799,9 @@ } }, "node_modules/linkify-it": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", - "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-6.1.0.tgz", + "integrity": "sha512-wJ/TwpSDTLepCrQoYWYIExIKg5Zchex2Nn5yk2mFnB+6PtdkHtyLx742md9csRjjOnGkKIS/RrbY7l8D6gT9Vw==", "funding": [ { "type": "github", @@ -3814,7 +3814,7 @@ ], "license": "MIT", "dependencies": { - "uc.micro": "^2.0.0" + "uc.micro": "^3.0.0" } }, "node_modules/local-pkg": { @@ -3881,9 +3881,9 @@ } }, "node_modules/markdown-it": { - "version": "14.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.3.2.tgz", - "integrity": "sha512-sHHjZ5fJKlgrG4qns2YwVcdNep35h5fERrfkD2YNsb9UFk0UIHarbiTaHKVMlPuWAoiilyK8Fv/jAm11slsY7Q==", + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.2.tgz", + "integrity": "sha512-q4IGxMv56jCqT4OCRCADBoDP3LO4MhmTXjFbphHPXs4g3j9Xg5RDnxqN8IF/3vIWEU+VCnUq+7JUg/cfy2E6Qw==", "funding": [ { "type": "github", @@ -3896,12 +3896,12 @@ ], "license": "MIT", "dependencies": { - "argparse": "^2.0.1", - "entities": "^4.5.0", - "linkify-it": "^5.0.2", - "mdurl": "^2.0.0", + "argparse": "^3.0.0", + "entities": "^8.0.0", + "linkify-it": "^6.0.0", + "mdurl": "^2.1.0", "punycode.js": "^2.3.1", - "uc.micro": "^2.1.0" + "uc.micro": "^3.0.0" }, "bin": { "markdown-it": "bin/markdown-it.mjs" @@ -3913,6 +3913,22 @@ "integrity": "sha512-HaNccxUH0l7BNGYbFbjmGpf5aLHAMTinqRZQAEQbMr2cdD3z91Q6kIo1oUn1CQndkT03jat6ckrdRYuwwqLlQw==", "license": "MIT" }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.2.tgz", + "integrity": "sha512-mFdDM6WqWKraGLsVb+C9CahPnzTXOefAOLq3jYcca2YZ8bEWpr++Tzj+zSaKW9+X9L5uSxcm1AZ3Y6aZJ09OhQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "PSF-2.0" + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -3923,9 +3939,9 @@ } }, "node_modules/mdurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", + "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==", "license": "MIT" }, "node_modules/media-typer": { @@ -5405,9 +5421,9 @@ } }, "node_modules/uc.micro": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-3.0.0.tgz", + "integrity": "sha512-U3PppEkleoTnIfi8BozMx3yju3qc/L6SwqWo2Sw+54PX+PX0q9I+r1Um5HCmqD7n9VDX5/v3vQH/AjA6deDdtw==", "license": "MIT" }, "node_modules/ufo": { diff --git a/webui/package.json b/webui/package.json index b97428fe1..ef0d8d0b6 100644 --- a/webui/package.json +++ b/webui/package.json @@ -37,7 +37,7 @@ "js-yaml": "^5.2.2", "kafkajs": "^2.2.4", "ldapts": "^9.0.0", - "markdown-it": "^14.2.0", + "markdown-it": "^15.0.0", "markdown-it-container": "^4.0.0", "mime-types": "^3.0.2", "mqtt": "^5.15.1", diff --git a/webui/src/composables/markdown-blockquote.ts b/webui/src/composables/markdown-blockquote.ts index 9474a8d2a..d5f77378a 100644 --- a/webui/src/composables/markdown-blockquote.ts +++ b/webui/src/composables/markdown-blockquote.ts @@ -1,4 +1,4 @@ -import type MarkdownIt from "markdown-it" +import type { MarkdownIt } from "markdown-it" export function MarkdownItBlockquote(md: MarkdownIt) { diff --git a/webui/src/composables/markdown-box.ts b/webui/src/composables/markdown-box.ts index 460e400e7..7a42b1a15 100644 --- a/webui/src/composables/markdown-box.ts +++ b/webui/src/composables/markdown-box.ts @@ -1,10 +1,7 @@ -import type { Options } from "markdown-it" -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs" -import type Renderer from "markdown-it/lib/renderer.mjs" +import type { MarkdownIt, MarkdownItOptions, Token, Renderer, RendererRule } from "markdown-it" -export function MarkdownItBox(md: MarkdownIt, opts: Options) { - var defaultRender = md.renderer.rules.fence!, +export function MarkdownItBox(md: MarkdownIt) { + var defaultRender: RendererRule = md.renderer.rules.fence, unescapeAll = md.utils.unescapeAll, boxExpr = /box=(\w*)/, noTitleExpre = /noTitle/, @@ -92,7 +89,7 @@ export function MarkdownItBox(md: MarkdownIt, opts: Options) { return undefined } - function fenceGroup(tokens: Token[], idx: number, options: Options, env: any, slf: Renderer): string { + function fenceGroup(tokens: Token[], idx: number, options: Required, env: any, slf: Renderer): string { if (!tokens[idx] || tokens[idx].hidden) { return ''; } const name = getAlertName(tokens[idx]) diff --git a/webui/src/composables/markdown-card.ts b/webui/src/composables/markdown-card.ts index 5df1899fc..be5b9d26f 100644 --- a/webui/src/composables/markdown-card.ts +++ b/webui/src/composables/markdown-card.ts @@ -1,10 +1,7 @@ -import type { Options } from "markdown-it" -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs" -import type Renderer from "markdown-it/lib/renderer.mjs" +import type { MarkdownIt, Token, Renderer, MarkdownItOptions } from "markdown-it" -export function MarkdownItCard(metadata: any): (md: MarkdownIt, opts: Options) => void { - return function(md: MarkdownIt, opts: Options): void { +export function MarkdownItCard(metadata: any): (md: MarkdownIt) => void { + return function(md: MarkdownIt): void { var defaultRender = md.renderer.rules.text!, card = /{{\s*card-grid\s.*}}/, kv = /([^\s=]+="[^"]*")/g @@ -26,7 +23,7 @@ export function MarkdownItCard(metadata: any): (md: MarkdownIt, opts: Options) = return data } - function text(tokens: Token[], idx: number, options: Options, env: any, slf: Renderer): string { + function text(tokens: Token[], idx: number, options: Required, env: any, slf: Renderer): string { if (!tokens[idx] || tokens[idx].hidden) { return ''; } const card = getCard(tokens[idx]) diff --git a/webui/src/composables/markdown-carousel.ts b/webui/src/composables/markdown-carousel.ts index 05c9c3011..b11ba25f8 100644 --- a/webui/src/composables/markdown-carousel.ts +++ b/webui/src/composables/markdown-carousel.ts @@ -1,10 +1,7 @@ -import type { Options } from "markdown-it" -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs" -import type Renderer from "markdown-it/lib/renderer.mjs" +import type { MarkdownIt, Token, Renderer, MarkdownItOptions } from "markdown-it" -export function MarkdownItCarousel(metadata: any): (md: MarkdownIt, opts: Options) => void { - return function(md: MarkdownIt, opts: Options): void { +export function MarkdownItCarousel(metadata: any): (md: MarkdownIt) => void { + return function(md: MarkdownIt): void { var defaultRender = md.renderer.rules.text!, carousel = /{{\s*carousel\s.*}}/, kv = /([^\s=]+="[^"]*")/g @@ -27,7 +24,7 @@ export function MarkdownItCarousel(metadata: any): (md: MarkdownIt, opts: Option return data } - function text(tokens: Token[], idx: number, options: Options, env: any, slf: Renderer): string { + function text(tokens: Token[], idx: number, options: Required, env: any, slf: Renderer): string { if (!tokens[idx] || tokens[idx].hidden) { return ''; } const carousel = getCarousel(tokens[idx]) diff --git a/webui/src/composables/markdown-cta-links.ts b/webui/src/composables/markdown-cta-links.ts index 2b2fedbad..31afd3fe4 100644 --- a/webui/src/composables/markdown-cta-links.ts +++ b/webui/src/composables/markdown-cta-links.ts @@ -1,10 +1,7 @@ -import type { Options } from "markdown-it" -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs" -import type Renderer from "markdown-it/lib/renderer.mjs" +import type { MarkdownIt, Token, Renderer, MarkdownItOptions } from "markdown-it" -export function MarkdownItCtaLinks(metadata: any): (md: MarkdownIt, opts: Options) => void { - return function(md: MarkdownIt, opts: Options): void { +export function MarkdownItCtaLinks(metadata: any): (md: MarkdownIt) => void { + return function(md: MarkdownIt): void { var defaultRender = md.renderer.rules.text!, cta = /{{\s*cta-grid\s.*}}/, kv = /([^\s=]+="[^"]*")/g @@ -26,7 +23,7 @@ export function MarkdownItCtaLinks(metadata: any): (md: MarkdownIt, opts: Option return data } - function text(tokens: Token[], idx: number, options: Options, env: any, slf: Renderer): string { + function text(tokens: Token[], idx: number, options: Required, env: any, slf: Renderer): string { if (!tokens[idx] || tokens[idx].hidden) { return ''; } const cta = getCta(tokens[idx]) diff --git a/webui/src/composables/markdown-image.ts b/webui/src/composables/markdown-image.ts index 56394720e..aa9c9169d 100644 --- a/webui/src/composables/markdown-image.ts +++ b/webui/src/composables/markdown-image.ts @@ -1,5 +1,4 @@ -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs" +import type { MarkdownIt, Token, Renderer, MarkdownItOptions } from "markdown-it" export function imageCaption(md: MarkdownIt) { @@ -15,7 +14,7 @@ export function imageCaption(md: MarkdownIt) { attr[1] = alt } img += ` ${attr[0]}="${attr[1]}"` - if (attr[0] === 'title') { + if (attr[0] === 'title' && typeof attr[1] === 'string') { title = attr[1] } } diff --git a/webui/src/composables/markdown-links.ts b/webui/src/composables/markdown-links.ts index a66e22f33..211e6dff0 100644 --- a/webui/src/composables/markdown-links.ts +++ b/webui/src/composables/markdown-links.ts @@ -1,37 +1,31 @@ -import type { Options } from "markdown-it" -import type MarkdownIt from "markdown-it" -import Token from "markdown-it/lib/token.mjs" +import type { MarkdownIt } from "markdown-it" import { useRoute } from "vue-router" -export function MarkdownItLinks(md: MarkdownIt, opts: Options) { +export function MarkdownItLinks(md: MarkdownIt) { - function replace(s: string): string{ + function replace(s: string): string { s = s.replace('.md', '') - const u = new URL(s, document.location.href) - return u.toString() + return new URL(s, document.location.href).toString() } const route = useRoute() - md.core.ruler.after('inline', 'link', function(state){ - state.tokens.forEach(function (blockToken: Token) { - if (blockToken.type === 'inline' && blockToken.children) { - blockToken.children.forEach(function (token: Token) { - if (token.type == 'link_open' && token.attrs) { - for (let attr of token.attrs){ - if (attr[0] == 'href' && attr[1].endsWith('.md')){ - attr[1] = replace(attr[1]) - } - else if (attr[0] == 'href' && attr[1].includes('.md#')){ - attr[1] = replace(attr[1]) - } - else if (attr[0] == 'href' && attr[1].startsWith('#')){ - attr[1] = route.path + attr[1] - } - } + md.core.ruler.after('inline', 'link', (state) => { + for (const blockToken of state.tokens) { + if (blockToken.type !== 'inline' || !blockToken.children) continue + + for (const token of blockToken.children) { + if (token.type !== 'link_open') continue + + const href = token.attrGet('href') + if (typeof href !== 'string') continue + + if (href.endsWith('.md') || href.includes('.md#')) { + token.attrSet('href', replace(href)) + } else if (href.startsWith('#')) { + token.attrSet('href', route.path + href) } - }) } - }) + } }) -}; \ No newline at end of file +} \ No newline at end of file diff --git a/webui/src/composables/markdown-tab-content.ts b/webui/src/composables/markdown-tab-content.ts index 96ea98fb0..41b44ff71 100644 --- a/webui/src/composables/markdown-tab-content.ts +++ b/webui/src/composables/markdown-tab-content.ts @@ -1,10 +1,7 @@ -import type MarkdownIt from "markdown-it" -import type { Options } from "markdown-it" -import container from "markdown-it-container" -import type { Renderer } from "markdown-it/dist/index.cjs.js" -import Token from 'markdown-it/lib/token.mjs' +import type { MarkdownIt, MarkdownItOptions, Renderer, Token } from "markdown-it" +import container from 'markdown-it-container' -export function MarkdownItTabContent(md: MarkdownIt, _opts: Options) { +export function MarkdownItTabContent(md: MarkdownIt) { md.core.ruler.push('test', function (state) { let hide = false @@ -89,7 +86,7 @@ export function MarkdownItTabContent(md: MarkdownIt, _opts: Options) { md.use(container, 'tabs', { validate: (params: any) => params.trim() === 'tabs', - render: (tokens: Token[], idx: number, options: Options, env: any, slf: Renderer) => { + render: (tokens: Token[], idx: number, options: Required, env: any, slf: Renderer) => { const token = tokens[idx]; if (token?.nesting === 1) { return '' diff --git a/webui/src/composables/markdown-table.ts b/webui/src/composables/markdown-table.ts index 55a6a5264..146298226 100644 --- a/webui/src/composables/markdown-table.ts +++ b/webui/src/composables/markdown-table.ts @@ -1,4 +1,4 @@ -import type MarkdownIt from "markdown-it" +import type { MarkdownIt } from "markdown-it" export function MarkdownItTable(md: MarkdownIt) { diff --git a/webui/src/composables/markdown-tabs.ts b/webui/src/composables/markdown-tabs.ts index c96f60e15..a287164ef 100644 --- a/webui/src/composables/markdown-tabs.ts +++ b/webui/src/composables/markdown-tabs.ts @@ -1,10 +1,7 @@ -import type { Options } from "markdown-it" -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs" -import type Renderer from "markdown-it/lib/renderer.mjs" +import type { MarkdownIt, Token, MarkdownItOptions, Renderer } from "markdown-it" -export function MarkdownItTabs(md: MarkdownIt, opts: Options) { +export function MarkdownItTabs(md: MarkdownIt) { var defaultRender = md.renderer.rules.fence!, unescapeAll = md.utils.unescapeAll, simple = /tab=([^\s]*)/, @@ -58,7 +55,7 @@ export function MarkdownItTabs(md: MarkdownIt, opts: Options) { return 'default' } - function fenceGroup(tokens: Token[], idx: number, options: Options, env: any, slf: Renderer): string { + function fenceGroup(tokens: Token[], idx: number, options: Required, env: any, slf: Renderer): string { const token = tokens[idx] if (!token || token.hidden) return '' diff --git a/webui/src/composables/markdown-title.ts b/webui/src/composables/markdown-title.ts index a62522eac..5099d5769 100644 --- a/webui/src/composables/markdown-title.ts +++ b/webui/src/composables/markdown-title.ts @@ -1,8 +1,6 @@ -import type { Options } from "markdown-it"; -import type MarkdownIt from "markdown-it" -import type Token from "markdown-it/lib/token.mjs"; +import type { MarkdownIt, Token } from "markdown-it" -export function MarkdownItTitle(meta: DocMeta): (md: MarkdownIt, opts: Options) => void { +export function MarkdownItTitle(meta: DocMeta): (md: MarkdownIt) => void { return function(md: MarkdownIt): void {