Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 39 additions & 23 deletions webui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion webui/src/composables/markdown-blockquote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type MarkdownIt from "markdown-it"
import type { MarkdownIt } from "markdown-it"

export function MarkdownItBlockquote(md: MarkdownIt) {

Expand Down
11 changes: 4 additions & 7 deletions webui/src/composables/markdown-box.ts
Original file line number Diff line number Diff line change
@@ -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/,
Expand Down Expand Up @@ -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<MarkdownItOptions>, env: any, slf: Renderer): string {
if (!tokens[idx] || tokens[idx].hidden) { return ''; }

const name = getAlertName(tokens[idx])
Expand Down
11 changes: 4 additions & 7 deletions webui/src/composables/markdown-card.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MarkdownItOptions>, env: any, slf: Renderer): string {
if (!tokens[idx] || tokens[idx].hidden) { return ''; }

const card = getCard(tokens[idx])
Expand Down
11 changes: 4 additions & 7 deletions webui/src/composables/markdown-carousel.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MarkdownItOptions>, env: any, slf: Renderer): string {
if (!tokens[idx] || tokens[idx].hidden) { return ''; }

const carousel = getCarousel(tokens[idx])
Expand Down
11 changes: 4 additions & 7 deletions webui/src/composables/markdown-cta-links.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<MarkdownItOptions>, env: any, slf: Renderer): string {
if (!tokens[idx] || tokens[idx].hidden) { return ''; }

const cta = getCta(tokens[idx])
Expand Down
5 changes: 2 additions & 3 deletions webui/src/composables/markdown-image.ts
Original file line number Diff line number Diff line change
@@ -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) {

Expand All @@ -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]
}
}
Expand Down
46 changes: 20 additions & 26 deletions webui/src/composables/markdown-links.ts
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
})
}
})
};
}
11 changes: 4 additions & 7 deletions webui/src/composables/markdown-tab-content.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<MarkdownItOptions>, env: any, slf: Renderer) => {
const token = tokens[idx];
if (token?.nesting === 1) {
return ''
Expand Down
2 changes: 1 addition & 1 deletion webui/src/composables/markdown-table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type MarkdownIt from "markdown-it"
import type { MarkdownIt } from "markdown-it"

export function MarkdownItTable(md: MarkdownIt) {

Expand Down
9 changes: 3 additions & 6 deletions webui/src/composables/markdown-tabs.ts
Original file line number Diff line number Diff line change
@@ -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]*)/,
Expand Down Expand Up @@ -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<MarkdownItOptions>, env: any, slf: Renderer): string {
const token = tokens[idx]
if (!token || token.hidden) return ''

Expand Down
6 changes: 2 additions & 4 deletions webui/src/composables/markdown-title.ts
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Loading