@vuepress/plugin-markdown-chart 2.0.0-rc.132 → 2.0.0-rc.134
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/client/index.d.ts +3 -4
- package/dist/node/index.d.ts +11 -11
- package/dist/node/index.js +3 -3
- package/dist/node/index.js.map +1 -1
- package/package.json +10 -10
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EChartsOption } from "echarts";
|
|
2
2
|
import { MermaidConfig } from "mermaid";
|
|
3
3
|
//#region src/client/helpers/echarts.d.ts
|
|
4
|
-
interface EChartsConfig {
|
|
4
|
+
export interface EChartsConfig {
|
|
5
5
|
/**
|
|
6
6
|
* ECharts global options
|
|
7
7
|
*
|
|
@@ -21,7 +21,7 @@ interface EChartsConfig {
|
|
|
21
21
|
*/
|
|
22
22
|
isSetup?: boolean;
|
|
23
23
|
}
|
|
24
|
-
declare const defineEChartsConfig: (config: EChartsConfig) => void;
|
|
24
|
+
export declare const defineEChartsConfig: (config: EChartsConfig) => void;
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/client/typings/mermaid.d.ts
|
|
27
27
|
interface MermaidThemeVariables {
|
|
@@ -159,7 +159,6 @@ type MermaidOptions = Omit<MermaidConfig, 'startOnLoad' | 'themeVariables'> & {
|
|
|
159
159
|
};
|
|
160
160
|
//#endregion
|
|
161
161
|
//#region src/client/helpers/mermaid.d.ts
|
|
162
|
-
declare const defineMermaidConfig: (options: MermaidOptions) => void;
|
|
162
|
+
export declare const defineMermaidConfig: (options: MermaidOptions) => void;
|
|
163
163
|
//#endregion
|
|
164
|
-
export { EChartsConfig, defineEChartsConfig, defineMermaidConfig };
|
|
165
164
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { MarkdownItPlantumlOptions } from "@mdit/plugin-plantuml";
|
|
|
2
2
|
import { PluginSimple, PluginWithOptions } from "markdown-it";
|
|
3
3
|
import { Plugin } from "vuepress/core";
|
|
4
4
|
//#region src/node/markdown-it-plugins/chartjs.d.ts
|
|
5
|
-
interface ChartJSPluginOptions {
|
|
5
|
+
export interface ChartJSPluginOptions {
|
|
6
6
|
/**
|
|
7
7
|
* Allow executing custom scripts inside Chart.js blocks.
|
|
8
8
|
*
|
|
@@ -36,10 +36,10 @@ interface ChartJSPluginOptions {
|
|
|
36
36
|
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
37
37
|
* @param options - Plugin options / 插件选项
|
|
38
38
|
*/
|
|
39
|
-
declare const chartjs: PluginWithOptions<ChartJSPluginOptions>;
|
|
39
|
+
export declare const chartjs: PluginWithOptions<ChartJSPluginOptions>;
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/node/markdown-it-plugins/echarts.d.ts
|
|
42
|
-
interface EChartsPluginOptions {
|
|
42
|
+
export interface EChartsPluginOptions {
|
|
43
43
|
/**
|
|
44
44
|
* Allow executing custom scripts inside ECharts blocks.
|
|
45
45
|
*
|
|
@@ -73,7 +73,7 @@ interface EChartsPluginOptions {
|
|
|
73
73
|
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
74
74
|
* @param options - Plugin options / 插件选项
|
|
75
75
|
*/
|
|
76
|
-
declare const echarts: PluginWithOptions<EChartsPluginOptions>;
|
|
76
|
+
export declare const echarts: PluginWithOptions<EChartsPluginOptions>;
|
|
77
77
|
//#endregion
|
|
78
78
|
//#region src/node/markdown-it-plugins/flowchart.d.ts
|
|
79
79
|
/**
|
|
@@ -83,7 +83,7 @@ declare const echarts: PluginWithOptions<EChartsPluginOptions>;
|
|
|
83
83
|
*
|
|
84
84
|
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
85
85
|
*/
|
|
86
|
-
declare const flowchart: PluginSimple;
|
|
86
|
+
export declare const flowchart: PluginSimple;
|
|
87
87
|
//#endregion
|
|
88
88
|
//#region src/node/markdown-it-plugins/markmap.d.ts
|
|
89
89
|
/**
|
|
@@ -93,7 +93,7 @@ declare const flowchart: PluginSimple;
|
|
|
93
93
|
*
|
|
94
94
|
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
95
95
|
*/
|
|
96
|
-
declare const markmap: PluginSimple;
|
|
96
|
+
export declare const markmap: PluginSimple;
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/node/markdown-it-plugins/mermaid.d.ts
|
|
99
99
|
interface MermaidOptions {
|
|
@@ -110,7 +110,7 @@ interface MermaidOptions {
|
|
|
110
110
|
* @param options - Mermaid options / Mermaid 选项
|
|
111
111
|
* @returns Formatted Mermaid content / 格式化的 Mermaid 内容
|
|
112
112
|
*/
|
|
113
|
-
declare const getMermaidContent: ({ diagram, content, title, indent }: MermaidOptions) => string;
|
|
113
|
+
export declare const getMermaidContent: ({ diagram, content, title, indent }: MermaidOptions) => string;
|
|
114
114
|
/**
|
|
115
115
|
* Mermaid markdown-it plugin
|
|
116
116
|
*
|
|
@@ -118,7 +118,7 @@ declare const getMermaidContent: ({ diagram, content, title, indent }: MermaidOp
|
|
|
118
118
|
*
|
|
119
119
|
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
120
120
|
*/
|
|
121
|
-
declare const mermaid: PluginSimple;
|
|
121
|
+
export declare const mermaid: PluginSimple;
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/node/markdown-it-plugins/plantuml.d.ts
|
|
124
124
|
/**
|
|
@@ -129,7 +129,7 @@ declare const mermaid: PluginSimple;
|
|
|
129
129
|
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
130
130
|
* @param options - PlantUML options / PlantUML 选项
|
|
131
131
|
*/
|
|
132
|
-
declare const plantuml: PluginWithOptions<MarkdownItPlantumlOptions[]>;
|
|
132
|
+
export declare const plantuml: PluginWithOptions<MarkdownItPlantumlOptions[]>;
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/node/options.d.ts
|
|
135
135
|
interface MarkdownChartPluginOptions {
|
|
@@ -233,7 +233,7 @@ declare module 'vuepress/markdown' {
|
|
|
233
233
|
* ],
|
|
234
234
|
* }
|
|
235
235
|
*/
|
|
236
|
-
declare const markdownChartPlugin: (options?: MarkdownChartPluginOptions) => Plugin;
|
|
236
|
+
export declare const markdownChartPlugin: (options?: MarkdownChartPluginOptions) => Plugin;
|
|
237
237
|
//#endregion
|
|
238
|
-
export {
|
|
238
|
+
export type { MarkdownChartPluginOptions };
|
|
239
239
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{container as e}from"@mdit/plugin-container";import{Logger as t,addViteOptimizeDepsExclude as n,addViteOptimizeDepsInclude as r,addViteSsrExternal as i,addViteSsrNoExternal as a,deepAssign as o,encodeData as s,ensureEndingSlash as c,isArray as l,isModuleAvailable as u}from"@vuepress/helper";import{colors as d,getDirname as f,path as p}from"vuepress/utils";import{plantuml as m}from"@mdit/plugin-plantuml";const h=(t,n)=>{let{allowScripts:r,allowAll:i,allowList:a=new Set}=n??{};e(t,{name:`chartjs`,
|
|
1
|
+
import{container as e}from"@mdit/plugin-container";import{Logger as t,addViteOptimizeDepsExclude as n,addViteOptimizeDepsInclude as r,addViteSsrExternal as i,addViteSsrNoExternal as a,deepAssign as o,encodeData as s,ensureEndingSlash as c,isArray as l,isModuleAvailable as u}from"@vuepress/helper";import{colors as d,getDirname as f,path as p}from"vuepress/utils";import{plantuml as m}from"@mdit/plugin-plantuml";const h=(t,n)=>{let{allowScripts:r,allowAll:i,allowList:a=new Set}=n??{};e(t,{name:`chartjs`,openRenderer:(e,t,n,o)=>{let c=e[t].info.trimStart().slice(7).trim(),l=`{}`,u=!1,f=!1,p=o?.filePathRelative??``;for(let n=t;n<e.length;n++){let{type:t,content:o,info:c}=e[n];if(t===`container_chartjs_close`){u&&!f&&(console.warn(`\
|
|
2
2
|
${d.magenta(`chartjs`)}: JavaScript in Chart.js block is found in ${d.cyan(p)}, ${d.red(`it is ignored for security reasons`)}.
|
|
3
3
|
To enable the chart, you must manually add it to allowlist, see https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/chartjs.html#syntax for details.
|
|
4
|
-
`),e[n].hidden=!0);break}o&&(t===`fence`&&(c===`json`?l=s(o):(c===`js`||c===`javascript`)&&(l=s(o),u=!0,r&&(i||a.has(p))&&(f=!0))),e[n].type=`chartjs_empty`,e[n].hidden=!0)}return u&&!f?``:`<ChartJS config="${l}"${c?` title="${encodeURIComponent(c)}"`:``}${u?` type="js"`:``}>`},
|
|
4
|
+
`),e[n].hidden=!0);break}o&&(t===`fence`&&(c===`json`?l=s(o):(c===`js`||c===`javascript`)&&(l=s(o),u=!0,r&&(i||a.has(p))&&(f=!0))),e[n].type=`chartjs_empty`,e[n].hidden=!0)}return u&&!f?``:`<ChartJS config="${l}"${c?` title="${encodeURIComponent(c)}"`:``}${u?` type="js"`:``}>`},closeRenderer:(e,t)=>e[t].hidden?``:`</ChartJS>`})},g=(e,t)=>{let{content:n,info:r}=e[t],[,i]=r.trim().split(`:`,2);return`<ECharts config="${s(n)}"${i?` title="${encodeURIComponent(i)}"`:``}></ECharts>`},_=(t,n)=>{let{allowScripts:r,allowAll:i,allowList:a=new Set}=n??{},{fence:o}=t.renderer.rules;t.renderer.rules.fence=(...e)=>{let[t,n]=e,{info:r}=t[n],[i]=r.split(`:`,2);return i===`echarts`?g(t,n):o(...e)},t.renderer.rules.echarts=g,e(t,{name:`echarts`,openRenderer:(e,t,n,o)=>{let c=e[t].info.trimStart().slice(7).trim(),l=`{}`,u=!1,f=!1,p=o?.filePathRelative??``;for(let n=t;n<e.length;n++){let{type:t,content:o,info:s}=e[n];if(t===`container_echarts_close`){u&&!f&&(console.warn(`\
|
|
5
5
|
${d.magenta(`[echarts]`)}: JavaScript in echarts block is found in ${d.cyan(p)}, ${d.red(`it is ignored for security reasons`)}.
|
|
6
6
|
To enable the chart, you must manually add it to allowlist, see https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/echarts.html#with-scripts for details.
|
|
7
|
-
`),e[n].hidden=!0);break}o&&(t===`fence`&&(s===`json`?l=o:(s===`js`||s===`javascript`)&&(l=o,u=!0,r&&(i||a.has(p))&&(f=!0))),e[n].type=`echarts_empty`,e[n].hidden=!0)}return u&&!f?``:`<ECharts config="${s(l)}"${c?` title="${encodeURIComponent(c)}"`:``}${u?` type="js"`:``}>`},
|
|
7
|
+
`),e[n].hidden=!0);break}o&&(t===`fence`&&(s===`json`?l=o:(s===`js`||s===`javascript`)&&(l=o,u=!0,r&&(i||a.has(p))&&(f=!0))),e[n].type=`echarts_empty`,e[n].hidden=!0)}return u&&!f?``:`<ECharts config="${s(l)}"${c?` title="${encodeURIComponent(c)}"`:``}${u?` type="js"`:``}>`},closeRenderer:(e,t)=>e[t].hidden?``:`</ECharts>`})},v=new Set([`ant`,`pie`,`vue`]),y=(e,t)=>{let{content:n,info:r}=e[t],[,i]=r.trim().split(`:`,2);return`<FlowChart code="${s(n)}" preset="${v.has(i)?i:`vue`}"></FlowChart>`},b=e=>{let{fence:t}=e.renderer.rules;e.renderer.rules.fence=(...e)=>{let[n,r]=e,{info:i}=n[r],[a]=i.split(`:`,2);return a===`flow`||a===`flowchart`?y(n,r):t(...e)},e.renderer.rules.flowchart=y},x=(e,t)=>`<MarkMap content="${s(e[t].content)}"></MarkMap>`,S=e=>{let{fence:t}=e.renderer.rules;e.renderer.rules.fence=(...e)=>{let[n,r]=e,{info:i}=n[r],[a]=i.split(`:`,2);return a===`markmap`?x(n,r):t(...e)},e.renderer.rules.markmap=x},C=(e,t)=>`<Mermaid code="${s(e[t].content)}"></Mermaid>`,w=({diagram:e=`mermaid`,content:t,title:n=``,indent:r=e!==`mermaid`})=>{let{frontmatter:i,body:a}=/^\s*---\n(?<frontmatter>[^]*?)\n---\n\n(?<body>[\s\S]*)/u.exec(t)?.groups??{frontmatter:``,body:t},o=(!n||/^title:\s*(?:.*)/mu.test(i)?i:`title: ${n}\n${i}`).trim();return`\
|
|
8
8
|
${o?`\
|
|
9
9
|
---
|
|
10
10
|
${o}
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_plantuml"],"sources":["../../src/node/markdown-it-plugins/chartjs.ts","../../src/node/markdown-it-plugins/echarts.ts","../../src/node/markdown-it-plugins/flowchart.ts","../../src/node/markdown-it-plugins/markmap.ts","../../src/node/markdown-it-plugins/mermaid.ts","../../src/node/markdown-it-plugins/plantuml.ts","../../src/node/utils.ts","../../src/node/prepareConfigFile.ts","../../src/node/markdownChartPlugin.ts"],"sourcesContent":["import { container } from '@mdit/plugin-container'\nimport { encodeData } from '@vuepress/helper'\nimport type { PluginWithOptions } from 'markdown-it'\nimport { colors } from 'vuepress/utils'\n\nexport interface ChartJSPluginOptions {\n /**\n * Allow executing custom scripts inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行自定义脚本。\n *\n * @default false\n */\n allowScripts?: boolean\n\n /**\n * Allow all scripts to be executed inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行所有脚本。\n *\n * @default false\n */\n allowAll?: boolean\n\n /**\n * List of files allowed to execute scripts inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行脚本的文件列表。\n *\n * @default new Set()\n */\n allowList?: Set<string>\n}\n\n/**\n * Chart.js markdown-it plugin\n *\n * Chart.js markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - Plugin options / 插件选项\n */\nexport const chartjs: PluginWithOptions<ChartJSPluginOptions> = (\n md,\n options,\n) => {\n const { allowScripts, allowAll, allowList = new Set() } = options ?? {}\n\n container(md, {\n name: 'chartjs',\n openRender: (tokens, index, _options, env) => {\n const title = tokens[index].info\n .trimStart()\n // \"chartjs\" length\n .slice(7)\n .trim()\n\n let config = '{}'\n let isJavaScript = false\n let isInAllowList = false\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment, typescript/no-unsafe-member-access\n const filePathRelative: string = env?.filePathRelative ?? ''\n\n for (let i = index; i < tokens.length; i++) {\n const { type, content, info } = tokens[i]\n\n if (type === 'container_chartjs_close') {\n if (isJavaScript && !isInAllowList) {\n // oxlint-disable-next-line no-console\n console.warn(\n `\\\n${colors.magenta('chartjs')}: JavaScript in Chart.js block is found in ${colors.cyan(filePathRelative)}, ${colors.red('it is ignored for security reasons')}.\nTo enable the chart, you must manually add it to allowlist, see https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/chartjs.html#syntax for details.\n`,\n )\n tokens[i].hidden = true\n }\n break\n }\n\n if (!content) continue\n if (type === 'fence') {\n if (info === 'json') {\n config = encodeData(content)\n } else if (info === 'js' || info === 'javascript') {\n config = encodeData(content)\n isJavaScript = true\n\n if (allowScripts && (allowAll || allowList.has(filePathRelative)))\n isInAllowList = true\n }\n }\n\n // Set to an unknown token type\n tokens[i].type = 'chartjs_empty'\n // Hide token\n tokens[i].hidden = true\n }\n\n if (isJavaScript && !isInAllowList) return ''\n\n return `<ChartJS config=\"${config}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }${isJavaScript ? ' type=\"js\"' : ''}>`\n },\n closeRender: (tokens, index) => (tokens[index].hidden ? '' : '</ChartJS>'),\n })\n}\n","import { container } from '@mdit/plugin-container'\nimport { encodeData } from '@vuepress/helper'\nimport type { PluginWithOptions } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\nimport { colors } from 'vuepress/utils'\n\nconst echartsRender = (tokens: Token[], index: number): string => {\n const { content, info } = tokens[index]\n const [, title] = info.trim().split(':', 2)\n\n return `<ECharts config=\"${encodeData(content)}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }></ECharts>`\n}\n\nexport interface EChartsPluginOptions {\n /**\n * Allow executing custom scripts inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行自定义脚本。\n *\n * @default false\n */\n allowScripts?: boolean\n\n /**\n * Allow all scripts to be executed inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行所有脚本。\n *\n * @default false\n */\n allowAll?: boolean\n\n /**\n * List of files allowed to execute scripts inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行脚本的文件列表。\n *\n * @default new Set()\n */\n allowList?: Set<string>\n}\n\n/**\n * ECharts markdown-it plugin\n *\n * ECharts markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - Plugin options / 插件选项\n */\nexport const echarts: PluginWithOptions<EChartsPluginOptions> = (\n md,\n options,\n) => {\n const { allowScripts, allowAll, allowList = new Set() } = options ?? {}\n\n // Handle ```echarts blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'echarts') return echartsRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.echarts = echartsRender\n\n container(md, {\n name: 'echarts',\n\n openRender: (tokens, index, _options, env) => {\n const title = tokens[index].info\n .trimStart()\n // 'echarts' length\n .slice(7)\n .trim()\n\n let config = '{}'\n let isJavaScript = false\n let isInAllowList = false\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment, typescript/no-unsafe-member-access\n const filePathRelative: string = env?.filePathRelative ?? ''\n\n for (let i = index; i < tokens.length; i++) {\n const { type, content, info } = tokens[i]\n\n if (type === 'container_echarts_close') {\n if (isJavaScript && !isInAllowList) {\n // oxlint-disable-next-line no-console\n console.warn(\n `\\\n${colors.magenta('[echarts]')}: JavaScript in echarts block is found in ${colors.cyan(filePathRelative)}, ${colors.red('it is ignored for security reasons')}.\nTo enable the chart, you must manually add it to allowlist, see https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/echarts.html#with-scripts for details.\n`,\n )\n tokens[i].hidden = true\n }\n break\n }\n\n if (!content) continue\n if (type === 'fence') {\n if (info === 'json') {\n config = content\n } else if (info === 'js' || info === 'javascript') {\n config = content\n isJavaScript = true\n\n if (allowScripts && (allowAll || allowList.has(filePathRelative)))\n isInAllowList = true\n }\n }\n\n // Set to an unknown token type\n tokens[i].type = 'echarts_empty'\n // Hide token\n tokens[i].hidden = true\n }\n\n if (isJavaScript && !isInAllowList) return ''\n\n return `<ECharts config=\"${encodeData(config)}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }${isJavaScript ? ' type=\"js\"' : ''}>`\n },\n closeRender: (tokens, index) => (tokens[index].hidden ? '' : '</ECharts>'),\n })\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\n\nconst SUPPORTED_PRESETS = new Set(['ant', 'pie', 'vue'])\n\nconst flowchartRender = (tokens: Token[], index: number): string => {\n const token = tokens[index]\n const { content, info } = token\n const [, preset] = info.trim().split(':', 2)\n\n return `<FlowChart code=\"${encodeData(content)}\" preset=\"${\n SUPPORTED_PRESETS.has(preset) ? preset : 'vue'\n }\"></FlowChart>`\n}\n\n/**\n * Flowchart markdown-it plugin\n *\n * Flowchart markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const flowchart: PluginSimple = (md) => {\n // Handle ```flow and ```flowchart blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'flow' || realInfo === 'flowchart')\n return flowchartRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.flowchart = flowchartRender\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\n\nconst markmapRender = (tokens: Token[], index: number): string =>\n `<MarkMap content=\"${encodeData(tokens[index].content)}\"></MarkMap>`\n\n/**\n * Markmap markdown-it plugin\n *\n * Markmap markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const markmap: PluginSimple = (md) => {\n // Handle ```markmap blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'markmap') return markmapRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.markmap = markmapRender\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type { RenderRule } from 'markdown-it/lib/renderer.mjs'\n\nconst mermaidRenderer: RenderRule = (tokens, index) =>\n `<Mermaid code=\"${encodeData(tokens[index].content)}\"></Mermaid>`\n\ninterface MermaidOptions {\n content: string\n diagram?: string\n title?: string\n indent?: boolean\n}\n\n/**\n * Get Mermaid content with proper formatting\n *\n * 获取格式化的 Mermaid 内容\n *\n * @param options - Mermaid options / Mermaid 选项\n * @returns Formatted Mermaid content / 格式化的 Mermaid 内容\n */\nexport const getMermaidContent = ({\n diagram = 'mermaid',\n content,\n title = '',\n indent = diagram !== 'mermaid',\n}: MermaidOptions): string => {\n const match = /^\\s*---\\n(?<frontmatter>[^]*?)\\n---\\n\\n(?<body>[\\s\\S]*)/u.exec(\n content,\n )\n\n const { frontmatter: originalFrontmatter, body: rest } = match?.groups ?? {\n frontmatter: '',\n body: content,\n }\n\n const frontmatter = (\n !title || /^title:\\s*(?:.*)/mu.test(originalFrontmatter)\n ? originalFrontmatter\n : `title: ${title}\\n${originalFrontmatter}`\n ).trim()\n\n return `\\\n${\n frontmatter\n ? `\\\n---\n${frontmatter}\n---\n\n`\n : ''\n}\\\n${\n diagram === 'mermaid'\n ? ''\n : `\\\n${diagram}\n`\n}\\\n${\n indent\n ? rest\n .split('\\n')\n .map((line) => (line ? ` ${line}` : ''))\n .join('\\n')\n : rest\n}\\\n`\n}\n\nconst getMermaid = (options: MermaidOptions): string =>\n `<Mermaid code=\"${encodeData(getMermaidContent(options))}\"${\n options.title ? ` title=\"${encodeData(options.title)}\"` : ''\n }></Mermaid>`\n\nconst DIAGRAM_MAP: Record<string, [diagramName: string, indent?: boolean]> = {\n 'block': ['', false],\n 'class': ['classDiagram'],\n 'c4c': ['C4Context'],\n 'er': ['erDiagram'],\n 'gantt': [''],\n 'git-graph': ['gitGraph'],\n 'journey': [''],\n 'mindmap': [''],\n 'kanban': [''],\n 'packet': ['', false],\n 'pie': [''],\n 'quadrant': ['quadrantChart'],\n 'requirement': ['requirementDiagram'],\n 'sankey': ['', false],\n 'sequence': ['sequenceDiagram'],\n 'state': ['stateDiagram-v2'],\n 'timeline': [''],\n\n // beta diagrams\n 'architecture': ['architecture-beta'],\n 'ishikawa': ['ishikawa-beta'],\n 'radar': ['radar-beta'],\n 'treemap': ['treemap-beta', false],\n 'treeview': ['treeView-beta'],\n 'venn': ['venn-beta', false],\n 'wardley': ['wardley-beta', false],\n 'xy': ['xychart', false],\n}\n\n/**\n * Mermaid markdown-it plugin\n *\n * Mermaid markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const mermaid: PluginSimple = (md) => {\n // Handle ```mermaid blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { content, info } = tokens[index]\n\n const fenceInfo = info.trim()\n\n if (fenceInfo === 'mermaid') return getMermaid({ content, indent: false })\n\n const [name, ...rest] = fenceInfo.split(' ')\n\n if (name in DIAGRAM_MAP) {\n return getMermaid({\n diagram: DIAGRAM_MAP[name][0] || name,\n title: rest.join(' '),\n content,\n indent: DIAGRAM_MAP[name][1] ?? true,\n })\n }\n\n return fence!(...args)\n }\n\n md.renderer.rules.mermaid = mermaidRenderer\n}\n","import type { MarkdownItPlantumlOptions } from '@mdit/plugin-plantuml'\nimport { plantuml as _plantuml } from '@mdit/plugin-plantuml'\nimport type { PluginWithOptions } from 'markdown-it'\n\n/**\n * PlantUML markdown-it plugin\n *\n * PlantUML markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - PlantUML options / PlantUML 选项\n */\nexport const plantuml: PluginWithOptions<MarkdownItPlantumlOptions[]> = (\n md,\n options = [\n 'chronology',\n 'gantt',\n 'json',\n 'latex',\n 'math',\n 'mindmap',\n 'regex',\n 'salt',\n 'uml',\n 'wbs',\n 'yaml',\n ].map((name) => ({ name })),\n) => {\n options.forEach((option) => {\n md.use(_plantuml, option)\n })\n}\n","import { Logger, ensureEndingSlash, isModuleAvailable } from '@vuepress/helper'\nimport { getDirname, path } from 'vuepress/utils'\n\nconst __dirname = getDirname(import.meta.url)\n\nexport const PLUGIN_NAME = '@vuepress/plugin-markdown-chart'\n\nexport const logger = new Logger(PLUGIN_NAME)\n\nexport const CLIENT_FOLDER = ensureEndingSlash(\n path.resolve(__dirname, '../client'),\n)\n\nexport const isInstalled = (pkg: string, hint = true): boolean => {\n const status = isModuleAvailable(pkg, import.meta)\n\n if (hint && !status)\n logger.error(`Package ${pkg} is not installed, please install it manually!`)\n\n return status\n}\n","import type { App } from 'vuepress/core'\n\nimport { CLIENT_FOLDER } from './utils.js'\n\nexport const prepareConfigFile = async (\n app: App,\n status: Record<string, boolean>,\n): Promise<string> => {\n const imports = new Set<string>()\n const enhances = new Set<string>()\n\n if (status.chartjs) {\n imports.add(`import ChartJS from \"${CLIENT_FOLDER}components/ChartJS.js\";`)\n enhances.add(`app.component(\"ChartJS\", ChartJS)`)\n }\n\n if (status.echarts) {\n imports.add(`import ECharts from \"${CLIENT_FOLDER}components/ECharts.js\";`)\n enhances.add(`app.component(\"ECharts\", ECharts);`)\n }\n\n if (status.flowchart) {\n imports.add(\n `import FlowChart from \"${CLIENT_FOLDER}components/FlowChart.js\";`,\n )\n\n enhances.add(`app.component(\"FlowChart\", FlowChart);`)\n }\n\n if (status.markmap) {\n imports.add(`import MarkMap from \"${CLIENT_FOLDER}components/MarkMap.js\";`)\n enhances.add(`app.component(\"MarkMap\", MarkMap);`)\n }\n\n if (status.mermaid) {\n imports.add(`import Mermaid from \"${CLIENT_FOLDER}components/Mermaid.js\";`)\n enhances.add(`app.component(\"Mermaid\", Mermaid);`)\n }\n\n return app.writeTemp(\n `markdown-chart/config.js`,\n `\\\nimport { defineClientConfig } from \"vuepress/client\";\n${[...imports.values()].join('\\n')}\n\nexport default defineClientConfig({\n enhance: ({ app }) => {\n${Array.from(enhances.values(), (item) =>\n item.split('\\n').map((line) => ` ${line}`),\n)\n .flat()\n .join('\\n')}\n },\n});\n`,\n )\n}\n","import {\n addViteOptimizeDepsExclude,\n addViteOptimizeDepsInclude,\n addViteSsrExternal,\n addViteSsrNoExternal,\n deepAssign,\n isArray,\n} from '@vuepress/helper'\nimport type { Plugin } from 'vuepress/core'\n\nimport {\n chartjs,\n echarts,\n flowchart,\n markmap,\n mermaid,\n plantuml,\n} from './markdown-it-plugins/index.js'\nimport type { MarkdownChartPluginOptions } from './options.js'\nimport { prepareConfigFile } from './prepareConfigFile.js'\nimport { PLUGIN_NAME, isInstalled, logger } from './utils.js'\n\ndeclare module 'vuepress/markdown' {\n interface MarkdownOptions {\n chart?: MarkdownChartPluginOptions\n }\n}\n\n/**\n * Markdown chart plugin\n *\n * Markdown 图表插件\n *\n * @example\n * import { markdownChartPlugin } from '@vuepress/plugin-markdown-chart'\n *\n * export default {\n * plugins: [\n * markdownChartPlugin({\n * chartjs: true,\n * echarts: true,\n * flowchart: true,\n * markmap: true,\n * mermaid: true,\n * plantuml: true,\n * }),\n * ],\n * }\n */\nexport const markdownChartPlugin =\n (options: MarkdownChartPluginOptions = {}): Plugin =>\n (app) => {\n const mergedOptions = deepAssign({}, app.options.markdown.chart, options)\n app.options.markdown.chart = mergedOptions\n\n if (app.env.isDebug) logger.info('Options:', mergedOptions)\n\n const getStatus = (\n key: keyof MarkdownChartPluginOptions,\n pkgs: string[] = [],\n ): boolean => {\n const enabled = Boolean(mergedOptions[key])\n const pkgInstalled = pkgs.every((pkg) =>\n isInstalled(pkg, Boolean(mergedOptions[key])),\n )\n\n return enabled && pkgInstalled\n }\n\n const status = {\n chartjs: getStatus('chartjs', ['chart.js']),\n echarts: getStatus('echarts', ['echarts']),\n flowchart: getStatus('flowchart', ['flowchart.ts']),\n markmap: getStatus('markmap', [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ]),\n mermaid: getStatus('mermaid', ['mermaid']),\n }\n\n return {\n name: PLUGIN_NAME,\n\n extendsMarkdown: (md) => {\n const {\n DANGEROUS_ALLOW_SCRIPT_EXECUTION,\n DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST,\n } = mergedOptions\n\n const scriptOptions = {\n allowScripts: DANGEROUS_ALLOW_SCRIPT_EXECUTION ?? false,\n allowAll: DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST === '*',\n allowList: new Set<string>(\n isArray(DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST)\n ? DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST.map((file) => {\n const result = file\n // normalize `\\` to `/` on Windows\n .replaceAll('\\\\', '/')\n // remove any leading slash\n .replace(/^\\//u, '')\n\n // ensure markdown extension\n return result.endsWith('.md') ? result : `${result}.md`\n })\n : [],\n ),\n }\n\n if (status.chartjs) md.use(chartjs, scriptOptions)\n if (status.echarts) md.use(echarts, scriptOptions)\n if (status.flowchart) md.use(flowchart)\n if (isArray(mergedOptions.plantuml))\n md.use(plantuml, mergedOptions.plantuml)\n else if (mergedOptions.plantuml) md.use(plantuml)\n if (status.markmap) md.use(markmap)\n if (status.mermaid) md.use(mermaid)\n },\n\n extendsBundlerOptions: (bundlerOptions: unknown) => {\n addViteSsrNoExternal(bundlerOptions, app, [\n '@vuepress/helper',\n 'fflate',\n ])\n\n if (status.chartjs) {\n addViteOptimizeDepsExclude(\n bundlerOptions,\n app,\n 'chart.js/auto/auto.mjs',\n )\n addViteSsrExternal(bundlerOptions, app, 'chart.js')\n }\n\n if (status.echarts) {\n addViteOptimizeDepsExclude(bundlerOptions, app, 'echarts')\n addViteSsrExternal(bundlerOptions, app, 'echarts')\n }\n\n if (status.flowchart) {\n addViteOptimizeDepsExclude(bundlerOptions, app, 'flowchart.ts')\n addViteSsrExternal(bundlerOptions, app, 'flowchart.ts')\n }\n\n if (status.markmap) {\n addViteOptimizeDepsInclude(bundlerOptions, app, [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ])\n addViteSsrExternal(bundlerOptions, app, [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ])\n }\n\n if (status.mermaid) {\n addViteOptimizeDepsExclude(\n bundlerOptions,\n app,\n 'mermaid/dist/mermaid.esm.min.mjs',\n )\n addViteSsrExternal(bundlerOptions, app, 'mermaid')\n }\n },\n\n clientConfigFile: () => prepareConfigFile(app, status),\n }\n }\n"],"mappings":"6ZA0CA,MAAa,GACX,EACA,IACG,CACH,GAAM,CAAE,eAAc,WAAU,YAAY,IAAI,KAAU,GAAW,CAAC,EAEtE,EAAU,EAAI,CACZ,KAAM,UACN,YAAa,EAAQ,EAAO,EAAU,IAAQ,CAC5C,IAAM,EAAQ,EAAO,EAAM,CAAC,KACzB,UAAU,CAAC,CAEX,MAAM,CAAC,CAAC,CACR,KAAK,EAEJ,EAAS,KACT,EAAe,GACf,EAAgB,GAGd,EAA2B,GAAK,kBAAoB,GAE1D,IAAK,IAAI,EAAI,EAAO,EAAI,EAAO,OAAQ,IAAK,CAC1C,GAAM,CAAE,OAAM,UAAS,QAAS,EAAO,GAEvC,GAAI,IAAS,0BAA2B,CAClC,GAAgB,CAAC,IAEnB,QAAQ,KACN;EACZ,EAAO,QAAQ,SAAS,EAAE,6CAA6C,EAAO,KAAK,CAAgB,EAAE,IAAI,EAAO,IAAI,oCAAoC,EAAE;;CAGhJ,EACA,EAAO,EAAE,CAAC,OAAS,IAErB,KACF,CAEK,IACD,IAAS,UACP,IAAS,OACX,EAAS,EAAW,CAAO,GAClB,IAAS,MAAQ,IAAS,gBACnC,EAAS,EAAW,CAAO,EAC3B,EAAe,GAEX,IAAiB,GAAY,EAAU,IAAI,CAAgB,KAC7D,EAAgB,MAKtB,EAAO,EAAE,CAAC,KAAO,gBAEjB,EAAO,EAAE,CAAC,OAAS,GACrB,CAIA,OAFI,GAAgB,CAAC,EAAsB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EAAgB,EAAK,CAC9C,cACA,kBACA,cACF,CAAC,EACD,EAAmB,EAAgB,EAAK,CACtC,cACA,kBACA,cACF,CAAC,GAGC,EAAO,UACT,EACE,EACA,EACA,kCACF,EACA,EAAmB,EAAgB,EAAK,SAAS,EAErD,EAEA,qBAAwB,EAAkB,EAAK,CAAM,CACvD,CACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_plantuml"],"sources":["../../src/node/markdown-it-plugins/chartjs.ts","../../src/node/markdown-it-plugins/echarts.ts","../../src/node/markdown-it-plugins/flowchart.ts","../../src/node/markdown-it-plugins/markmap.ts","../../src/node/markdown-it-plugins/mermaid.ts","../../src/node/markdown-it-plugins/plantuml.ts","../../src/node/utils.ts","../../src/node/prepareConfigFile.ts","../../src/node/markdownChartPlugin.ts"],"sourcesContent":["import { container } from '@mdit/plugin-container'\nimport { encodeData } from '@vuepress/helper'\nimport type { PluginWithOptions } from 'markdown-it'\nimport { colors } from 'vuepress/utils'\n\nexport interface ChartJSPluginOptions {\n /**\n * Allow executing custom scripts inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行自定义脚本。\n *\n * @default false\n */\n allowScripts?: boolean\n\n /**\n * Allow all scripts to be executed inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行所有脚本。\n *\n * @default false\n */\n allowAll?: boolean\n\n /**\n * List of files allowed to execute scripts inside Chart.js blocks.\n *\n * 允许在 Chart.js 块内执行脚本的文件列表。\n *\n * @default new Set()\n */\n allowList?: Set<string>\n}\n\n/**\n * Chart.js markdown-it plugin\n *\n * Chart.js markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - Plugin options / 插件选项\n */\nexport const chartjs: PluginWithOptions<ChartJSPluginOptions> = (\n md,\n options,\n) => {\n const { allowScripts, allowAll, allowList = new Set() } = options ?? {}\n\n container(md, {\n name: 'chartjs',\n openRenderer: (tokens, index, _options, env) => {\n const title = tokens[index].info\n .trimStart()\n // \"chartjs\" length\n .slice(7)\n .trim()\n\n let config = '{}'\n let isJavaScript = false\n let isInAllowList = false\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment, typescript/no-unsafe-member-access\n const filePathRelative: string = env?.filePathRelative ?? ''\n\n for (let i = index; i < tokens.length; i++) {\n const { type, content, info } = tokens[i]\n\n if (type === 'container_chartjs_close') {\n if (isJavaScript && !isInAllowList) {\n // oxlint-disable-next-line no-console\n console.warn(\n `\\\n${colors.magenta('chartjs')}: JavaScript in Chart.js block is found in ${colors.cyan(filePathRelative)}, ${colors.red('it is ignored for security reasons')}.\nTo enable the chart, you must manually add it to allowlist, see https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/chartjs.html#syntax for details.\n`,\n )\n tokens[i].hidden = true\n }\n break\n }\n\n if (!content) continue\n if (type === 'fence') {\n if (info === 'json') {\n config = encodeData(content)\n } else if (info === 'js' || info === 'javascript') {\n config = encodeData(content)\n isJavaScript = true\n\n if (allowScripts && (allowAll || allowList.has(filePathRelative)))\n isInAllowList = true\n }\n }\n\n // Set to an unknown token type\n tokens[i].type = 'chartjs_empty'\n // Hide token\n tokens[i].hidden = true\n }\n\n if (isJavaScript && !isInAllowList) return ''\n\n return `<ChartJS config=\"${config}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }${isJavaScript ? ' type=\"js\"' : ''}>`\n },\n closeRenderer: (tokens, index) =>\n tokens[index].hidden ? '' : '</ChartJS>',\n })\n}\n","import { container } from '@mdit/plugin-container'\nimport { encodeData } from '@vuepress/helper'\nimport type { PluginWithOptions } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\nimport { colors } from 'vuepress/utils'\n\nconst echartsRender = (tokens: Token[], index: number): string => {\n const { content, info } = tokens[index]\n const [, title] = info.trim().split(':', 2)\n\n return `<ECharts config=\"${encodeData(content)}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }></ECharts>`\n}\n\nexport interface EChartsPluginOptions {\n /**\n * Allow executing custom scripts inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行自定义脚本。\n *\n * @default false\n */\n allowScripts?: boolean\n\n /**\n * Allow all scripts to be executed inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行所有脚本。\n *\n * @default false\n */\n allowAll?: boolean\n\n /**\n * List of files allowed to execute scripts inside ECharts blocks.\n *\n * 允许在 ECharts 块内执行脚本的文件列表。\n *\n * @default new Set()\n */\n allowList?: Set<string>\n}\n\n/**\n * ECharts markdown-it plugin\n *\n * ECharts markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - Plugin options / 插件选项\n */\nexport const echarts: PluginWithOptions<EChartsPluginOptions> = (\n md,\n options,\n) => {\n const { allowScripts, allowAll, allowList = new Set() } = options ?? {}\n\n // Handle ```echarts blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'echarts') return echartsRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.echarts = echartsRender\n\n container(md, {\n name: 'echarts',\n\n openRenderer: (tokens, index, _options, env) => {\n const title = tokens[index].info\n .trimStart()\n // 'echarts' length\n .slice(7)\n .trim()\n\n let config = '{}'\n let isJavaScript = false\n let isInAllowList = false\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment, typescript/no-unsafe-member-access\n const filePathRelative: string = env?.filePathRelative ?? ''\n\n for (let i = index; i < tokens.length; i++) {\n const { type, content, info } = tokens[i]\n\n if (type === 'container_echarts_close') {\n if (isJavaScript && !isInAllowList) {\n // oxlint-disable-next-line no-console\n console.warn(\n `\\\n${colors.magenta('[echarts]')}: JavaScript in echarts block is found in ${colors.cyan(filePathRelative)}, ${colors.red('it is ignored for security reasons')}.\nTo enable the chart, you must manually add it to allowlist, see https://ecosystem.vuejs.press/plugins/markdown/markdown-chart/echarts.html#with-scripts for details.\n`,\n )\n tokens[i].hidden = true\n }\n break\n }\n\n if (!content) continue\n if (type === 'fence') {\n if (info === 'json') {\n config = content\n } else if (info === 'js' || info === 'javascript') {\n config = content\n isJavaScript = true\n\n if (allowScripts && (allowAll || allowList.has(filePathRelative)))\n isInAllowList = true\n }\n }\n\n // Set to an unknown token type\n tokens[i].type = 'echarts_empty'\n // Hide token\n tokens[i].hidden = true\n }\n\n if (isJavaScript && !isInAllowList) return ''\n\n return `<ECharts config=\"${encodeData(config)}\"${\n title ? ` title=\"${encodeURIComponent(title)}\"` : ''\n }${isJavaScript ? ' type=\"js\"' : ''}>`\n },\n closeRenderer: (tokens, index) =>\n tokens[index].hidden ? '' : '</ECharts>',\n })\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\n\nconst SUPPORTED_PRESETS = new Set(['ant', 'pie', 'vue'])\n\nconst flowchartRender = (tokens: Token[], index: number): string => {\n const token = tokens[index]\n const { content, info } = token\n const [, preset] = info.trim().split(':', 2)\n\n return `<FlowChart code=\"${encodeData(content)}\" preset=\"${\n SUPPORTED_PRESETS.has(preset) ? preset : 'vue'\n }\"></FlowChart>`\n}\n\n/**\n * Flowchart markdown-it plugin\n *\n * Flowchart markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const flowchart: PluginSimple = (md) => {\n // Handle ```flow and ```flowchart blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'flow' || realInfo === 'flowchart')\n return flowchartRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.flowchart = flowchartRender\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type Token from 'markdown-it/lib/token.mjs'\n\nconst markmapRender = (tokens: Token[], index: number): string =>\n `<MarkMap content=\"${encodeData(tokens[index].content)}\"></MarkMap>`\n\n/**\n * Markmap markdown-it plugin\n *\n * Markmap markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const markmap: PluginSimple = (md) => {\n // Handle ```markmap blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { info } = tokens[index]\n const [realInfo] = info.split(':', 2)\n\n if (realInfo === 'markmap') return markmapRender(tokens, index)\n\n return fence!(...args)\n }\n\n md.renderer.rules.markmap = markmapRender\n}\n","import { encodeData } from '@vuepress/helper'\nimport type { PluginSimple } from 'markdown-it'\nimport type { RenderRule } from 'markdown-it/lib/renderer.mjs'\n\nconst mermaidRenderer: RenderRule = (tokens, index) =>\n `<Mermaid code=\"${encodeData(tokens[index].content)}\"></Mermaid>`\n\ninterface MermaidOptions {\n content: string\n diagram?: string\n title?: string\n indent?: boolean\n}\n\n/**\n * Get Mermaid content with proper formatting\n *\n * 获取格式化的 Mermaid 内容\n *\n * @param options - Mermaid options / Mermaid 选项\n * @returns Formatted Mermaid content / 格式化的 Mermaid 内容\n */\nexport const getMermaidContent = ({\n diagram = 'mermaid',\n content,\n title = '',\n indent = diagram !== 'mermaid',\n}: MermaidOptions): string => {\n const match = /^\\s*---\\n(?<frontmatter>[^]*?)\\n---\\n\\n(?<body>[\\s\\S]*)/u.exec(\n content,\n )\n\n const { frontmatter: originalFrontmatter, body: rest } = match?.groups ?? {\n frontmatter: '',\n body: content,\n }\n\n const frontmatter = (\n !title || /^title:\\s*(?:.*)/mu.test(originalFrontmatter)\n ? originalFrontmatter\n : `title: ${title}\\n${originalFrontmatter}`\n ).trim()\n\n return `\\\n${\n frontmatter\n ? `\\\n---\n${frontmatter}\n---\n\n`\n : ''\n}\\\n${\n diagram === 'mermaid'\n ? ''\n : `\\\n${diagram}\n`\n}\\\n${\n indent\n ? rest\n .split('\\n')\n .map((line) => (line ? ` ${line}` : ''))\n .join('\\n')\n : rest\n}\\\n`\n}\n\nconst getMermaid = (options: MermaidOptions): string =>\n `<Mermaid code=\"${encodeData(getMermaidContent(options))}\"${\n options.title ? ` title=\"${encodeData(options.title)}\"` : ''\n }></Mermaid>`\n\nconst DIAGRAM_MAP: Record<string, [diagramName: string, indent?: boolean]> = {\n 'block': ['', false],\n 'class': ['classDiagram'],\n 'c4c': ['C4Context'],\n 'er': ['erDiagram'],\n 'gantt': [''],\n 'git-graph': ['gitGraph'],\n 'journey': [''],\n 'mindmap': [''],\n 'kanban': [''],\n 'packet': ['', false],\n 'pie': [''],\n 'quadrant': ['quadrantChart'],\n 'requirement': ['requirementDiagram'],\n 'sankey': ['', false],\n 'sequence': ['sequenceDiagram'],\n 'state': ['stateDiagram-v2'],\n 'timeline': [''],\n\n // beta diagrams\n 'architecture': ['architecture-beta'],\n 'ishikawa': ['ishikawa-beta'],\n 'radar': ['radar-beta'],\n 'treemap': ['treemap-beta', false],\n 'treeview': ['treeView-beta'],\n 'venn': ['venn-beta', false],\n 'wardley': ['wardley-beta', false],\n 'xy': ['xychart', false],\n}\n\n/**\n * Mermaid markdown-it plugin\n *\n * Mermaid markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n */\nexport const mermaid: PluginSimple = (md) => {\n // Handle ```mermaid blocks\n const { fence } = md.renderer.rules\n\n md.renderer.rules.fence = (...args): string => {\n const [tokens, index] = args\n const { content, info } = tokens[index]\n\n const fenceInfo = info.trim()\n\n if (fenceInfo === 'mermaid') return getMermaid({ content, indent: false })\n\n const [name, ...rest] = fenceInfo.split(' ')\n\n if (name in DIAGRAM_MAP) {\n return getMermaid({\n diagram: DIAGRAM_MAP[name][0] || name,\n title: rest.join(' '),\n content,\n indent: DIAGRAM_MAP[name][1] ?? true,\n })\n }\n\n return fence!(...args)\n }\n\n md.renderer.rules.mermaid = mermaidRenderer\n}\n","import type { MarkdownItPlantumlOptions } from '@mdit/plugin-plantuml'\nimport { plantuml as _plantuml } from '@mdit/plugin-plantuml'\nimport type { PluginWithOptions } from 'markdown-it'\n\n/**\n * PlantUML markdown-it plugin\n *\n * PlantUML markdown-it 插件\n *\n * @param md - MarkdownIt instance / MarkdownIt 实例\n * @param options - PlantUML options / PlantUML 选项\n */\nexport const plantuml: PluginWithOptions<MarkdownItPlantumlOptions[]> = (\n md,\n options = [\n 'chronology',\n 'gantt',\n 'json',\n 'latex',\n 'math',\n 'mindmap',\n 'regex',\n 'salt',\n 'uml',\n 'wbs',\n 'yaml',\n ].map((name) => ({ name })),\n) => {\n options.forEach((option) => {\n md.use(_plantuml, option)\n })\n}\n","import { Logger, ensureEndingSlash, isModuleAvailable } from '@vuepress/helper'\nimport { getDirname, path } from 'vuepress/utils'\n\nconst __dirname = getDirname(import.meta.url)\n\nexport const PLUGIN_NAME = '@vuepress/plugin-markdown-chart'\n\nexport const logger = new Logger(PLUGIN_NAME)\n\nexport const CLIENT_FOLDER = ensureEndingSlash(\n path.resolve(__dirname, '../client'),\n)\n\nexport const isInstalled = (pkg: string, hint = true): boolean => {\n const status = isModuleAvailable(pkg, import.meta)\n\n if (hint && !status)\n logger.error(`Package ${pkg} is not installed, please install it manually!`)\n\n return status\n}\n","import type { App } from 'vuepress/core'\n\nimport { CLIENT_FOLDER } from './utils.js'\n\nexport const prepareConfigFile = async (\n app: App,\n status: Record<string, boolean>,\n): Promise<string> => {\n const imports = new Set<string>()\n const enhances = new Set<string>()\n\n if (status.chartjs) {\n imports.add(`import ChartJS from \"${CLIENT_FOLDER}components/ChartJS.js\";`)\n enhances.add(`app.component(\"ChartJS\", ChartJS)`)\n }\n\n if (status.echarts) {\n imports.add(`import ECharts from \"${CLIENT_FOLDER}components/ECharts.js\";`)\n enhances.add(`app.component(\"ECharts\", ECharts);`)\n }\n\n if (status.flowchart) {\n imports.add(\n `import FlowChart from \"${CLIENT_FOLDER}components/FlowChart.js\";`,\n )\n\n enhances.add(`app.component(\"FlowChart\", FlowChart);`)\n }\n\n if (status.markmap) {\n imports.add(`import MarkMap from \"${CLIENT_FOLDER}components/MarkMap.js\";`)\n enhances.add(`app.component(\"MarkMap\", MarkMap);`)\n }\n\n if (status.mermaid) {\n imports.add(`import Mermaid from \"${CLIENT_FOLDER}components/Mermaid.js\";`)\n enhances.add(`app.component(\"Mermaid\", Mermaid);`)\n }\n\n return app.writeTemp(\n `markdown-chart/config.js`,\n `\\\nimport { defineClientConfig } from \"vuepress/client\";\n${[...imports.values()].join('\\n')}\n\nexport default defineClientConfig({\n enhance: ({ app }) => {\n${Array.from(enhances.values(), (item) =>\n item.split('\\n').map((line) => ` ${line}`),\n)\n .flat()\n .join('\\n')}\n },\n});\n`,\n )\n}\n","import {\n addViteOptimizeDepsExclude,\n addViteOptimizeDepsInclude,\n addViteSsrExternal,\n addViteSsrNoExternal,\n deepAssign,\n isArray,\n} from '@vuepress/helper'\nimport type { Plugin } from 'vuepress/core'\n\nimport {\n chartjs,\n echarts,\n flowchart,\n markmap,\n mermaid,\n plantuml,\n} from './markdown-it-plugins/index.js'\nimport type { MarkdownChartPluginOptions } from './options.js'\nimport { prepareConfigFile } from './prepareConfigFile.js'\nimport { PLUGIN_NAME, isInstalled, logger } from './utils.js'\n\ndeclare module 'vuepress/markdown' {\n interface MarkdownOptions {\n chart?: MarkdownChartPluginOptions\n }\n}\n\n/**\n * Markdown chart plugin\n *\n * Markdown 图表插件\n *\n * @example\n * import { markdownChartPlugin } from '@vuepress/plugin-markdown-chart'\n *\n * export default {\n * plugins: [\n * markdownChartPlugin({\n * chartjs: true,\n * echarts: true,\n * flowchart: true,\n * markmap: true,\n * mermaid: true,\n * plantuml: true,\n * }),\n * ],\n * }\n */\nexport const markdownChartPlugin =\n (options: MarkdownChartPluginOptions = {}): Plugin =>\n (app) => {\n const mergedOptions = deepAssign({}, app.options.markdown.chart, options)\n app.options.markdown.chart = mergedOptions\n\n if (app.env.isDebug) logger.info('Options:', mergedOptions)\n\n const getStatus = (\n key: keyof MarkdownChartPluginOptions,\n pkgs: string[] = [],\n ): boolean => {\n const enabled = Boolean(mergedOptions[key])\n const pkgInstalled = pkgs.every((pkg) =>\n isInstalled(pkg, Boolean(mergedOptions[key])),\n )\n\n return enabled && pkgInstalled\n }\n\n const status = {\n chartjs: getStatus('chartjs', ['chart.js']),\n echarts: getStatus('echarts', ['echarts']),\n flowchart: getStatus('flowchart', ['flowchart.ts']),\n markmap: getStatus('markmap', [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ]),\n mermaid: getStatus('mermaid', ['mermaid']),\n }\n\n return {\n name: PLUGIN_NAME,\n\n extendsMarkdown: (md) => {\n const {\n DANGEROUS_ALLOW_SCRIPT_EXECUTION,\n DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST,\n } = mergedOptions\n\n const scriptOptions = {\n allowScripts: DANGEROUS_ALLOW_SCRIPT_EXECUTION ?? false,\n allowAll: DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST === '*',\n allowList: new Set<string>(\n isArray(DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST)\n ? DANGEROUS_SCRIPT_EXECUTION_ALLOWLIST.map((file) => {\n const result = file\n // normalize `\\` to `/` on Windows\n .replaceAll('\\\\', '/')\n // remove any leading slash\n .replace(/^\\//u, '')\n\n // ensure markdown extension\n return result.endsWith('.md') ? result : `${result}.md`\n })\n : [],\n ),\n }\n\n if (status.chartjs) md.use(chartjs, scriptOptions)\n if (status.echarts) md.use(echarts, scriptOptions)\n if (status.flowchart) md.use(flowchart)\n if (isArray(mergedOptions.plantuml))\n md.use(plantuml, mergedOptions.plantuml)\n else if (mergedOptions.plantuml) md.use(plantuml)\n if (status.markmap) md.use(markmap)\n if (status.mermaid) md.use(mermaid)\n },\n\n extendsBundlerOptions: (bundlerOptions: unknown) => {\n addViteSsrNoExternal(bundlerOptions, app, [\n '@vuepress/helper',\n 'fflate',\n ])\n\n if (status.chartjs) {\n addViteOptimizeDepsExclude(\n bundlerOptions,\n app,\n 'chart.js/auto/auto.mjs',\n )\n addViteSsrExternal(bundlerOptions, app, 'chart.js')\n }\n\n if (status.echarts) {\n addViteOptimizeDepsExclude(bundlerOptions, app, 'echarts')\n addViteSsrExternal(bundlerOptions, app, 'echarts')\n }\n\n if (status.flowchart) {\n addViteOptimizeDepsExclude(bundlerOptions, app, 'flowchart.ts')\n addViteSsrExternal(bundlerOptions, app, 'flowchart.ts')\n }\n\n if (status.markmap) {\n addViteOptimizeDepsInclude(bundlerOptions, app, [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ])\n addViteSsrExternal(bundlerOptions, app, [\n 'markmap-lib',\n 'markmap-toolbar',\n 'markmap-view',\n ])\n }\n\n if (status.mermaid) {\n addViteOptimizeDepsExclude(\n bundlerOptions,\n app,\n 'mermaid/dist/mermaid.esm.min.mjs',\n )\n addViteSsrExternal(bundlerOptions, app, 'mermaid')\n }\n },\n\n clientConfigFile: () => prepareConfigFile(app, status),\n }\n }\n"],"mappings":"6ZA0CA,MAAa,GACX,EACA,IACG,CACH,GAAM,CAAE,eAAc,WAAU,YAAY,IAAI,KAAU,GAAW,CAAC,EAEtE,EAAU,EAAI,CACZ,KAAM,UACN,cAAe,EAAQ,EAAO,EAAU,IAAQ,CAC9C,IAAM,EAAQ,EAAO,EAAM,CAAC,KACzB,UAAU,CAAC,CAEX,MAAM,CAAC,CAAC,CACR,KAAK,EAEJ,EAAS,KACT,EAAe,GACf,EAAgB,GAGd,EAA2B,GAAK,kBAAoB,GAE1D,IAAK,IAAI,EAAI,EAAO,EAAI,EAAO,OAAQ,IAAK,CAC1C,GAAM,CAAE,OAAM,UAAS,QAAS,EAAO,GAEvC,GAAI,IAAS,0BAA2B,CAClC,GAAgB,CAAC,IAEnB,QAAQ,KACN;EACZ,EAAO,QAAQ,SAAS,EAAE,6CAA6C,EAAO,KAAK,CAAgB,EAAE,IAAI,EAAO,IAAI,oCAAoC,EAAE;;CAGhJ,EACA,EAAO,EAAE,CAAC,OAAS,IAErB,KACF,CAEK,IACD,IAAS,UACP,IAAS,OACX,EAAS,EAAW,CAAO,GAClB,IAAS,MAAQ,IAAS,gBACnC,EAAS,EAAW,CAAO,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,EAAgB,EAAK,SAAS,EACzD,EAAmB,EAAgB,EAAK,SAAS,GAG/C,EAAO,YACT,EAA2B,EAAgB,EAAK,cAAc,EAC9D,EAAmB,EAAgB,EAAK,cAAc,GAGpD,EAAO,UACT,EAA2B,EAAgB,EAAK,CAC9C,cACA,kBACA,cACF,CAAC,EACD,EAAmB,EAAgB,EAAK,CACtC,cACA,kBACA,cACF,CAAC,GAGC,EAAO,UACT,EACE,EACA,EACA,kCACF,EACA,EAAmB,EAAgB,EAAK,SAAS,EAErD,EAEA,qBAAwB,EAAkB,EAAK,CAAM,CACvD,CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/plugin-markdown-chart",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.134",
|
|
4
4
|
"description": "VuePress plugin - markdown chart",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chart",
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@mdit/plugin-container": "^
|
|
56
|
-
"@mdit/plugin-plantuml": "^
|
|
57
|
-
"@vuepress/helper": "2.0.0-rc.
|
|
58
|
-
"@vueuse/core": "^14.
|
|
59
|
-
"vue": "^3.5.
|
|
55
|
+
"@mdit/plugin-container": "^2.0.0",
|
|
56
|
+
"@mdit/plugin-plantuml": "^2.0.0",
|
|
57
|
+
"@vuepress/helper": "2.0.0-rc.134",
|
|
58
|
+
"@vueuse/core": "^14.4.0",
|
|
59
|
+
"vue": "^3.5.42"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@types/markdown-it": "^14.
|
|
63
|
-
"markdown-it": "^14.3.
|
|
62
|
+
"@types/markdown-it": "^14.2.0",
|
|
63
|
+
"markdown-it": "^14.3.1",
|
|
64
64
|
"markmap-common": "^0.18.9"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"markmap-toolbar": "^0.18.12",
|
|
72
72
|
"markmap-view": "^0.18.12",
|
|
73
73
|
"mermaid": "^11.14.0",
|
|
74
|
-
"vuepress": "2.0.0-rc.
|
|
74
|
+
"vuepress": "2.0.0-rc.31"
|
|
75
75
|
},
|
|
76
76
|
"peerDependenciesMeta": {
|
|
77
77
|
"chart.js": {
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"optional": true
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "938b80193c26fb617270f6d86729e52ee298da03"
|
|
100
100
|
}
|