@vuepress/plugin-markdown-chart 2.0.0-rc.122 → 2.0.0-rc.124
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/lib/client/components/ChartJS.d.ts +55 -52
- package/lib/client/components/ChartJS.js +5 -3
- package/lib/client/components/ChartJS.js.map +1 -1
- package/lib/client/components/ECharts.d.ts +55 -52
- package/lib/client/components/ECharts.js +5 -4
- package/lib/client/components/ECharts.js.map +1 -1
- package/lib/client/components/FlowChart.d.ts +43 -40
- package/lib/client/components/FlowChart.js +2 -2
- package/lib/client/components/FlowChart.js.map +1 -1
- package/lib/client/components/MarkMap.d.ts +24 -21
- package/lib/client/components/MarkMap.js +2 -2
- package/lib/client/components/MarkMap.js.map +1 -1
- package/lib/client/components/Mermaid.d.ts +36 -33
- package/lib/client/components/Mermaid.js +2 -2
- package/lib/client/components/Mermaid.js.map +1 -1
- package/lib/client/index.d.ts +157 -154
- package/lib/client/index.js +1 -2
- package/lib/echarts-C9C0qkV9.js +2 -0
- package/lib/echarts-C9C0qkV9.js.map +1 -0
- package/lib/mermaid-BPRrFw7i.js +2 -0
- package/lib/mermaid-BPRrFw7i.js.map +1 -0
- package/lib/node/index.d.ts +164 -142
- package/lib/node/index.js +21 -13
- package/lib/node/index.js.map +1 -1
- package/package.json +36 -29
- package/lib/client/echarts-C40_Ts42.js +0 -2
- package/lib/client/echarts-C40_Ts42.js.map +0 -1
- package/lib/client/index.js.map +0 -1
- package/lib/client/mermaid-D26-9yYy.js +0 -2
- package/lib/client/mermaid-D26-9yYy.js.map +0 -1
|
@@ -1,58 +1,61 @@
|
|
|
1
|
-
import * as vue from
|
|
2
|
-
import { PropType, VNode } from
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { PropType, VNode } from "vue";
|
|
3
|
+
import "../styles/chartjs.css";
|
|
3
4
|
|
|
5
|
+
//#region src/client/components/ChartJS.d.ts
|
|
4
6
|
declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Chart config
|
|
9
|
+
*
|
|
10
|
+
* 图表配置
|
|
11
|
+
*/
|
|
12
|
+
config: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Chart title
|
|
18
|
+
*
|
|
19
|
+
* 图表标题
|
|
20
|
+
*/
|
|
21
|
+
title: StringConstructor;
|
|
22
|
+
/**
|
|
23
|
+
* Chart config type
|
|
24
|
+
*
|
|
25
|
+
* 图表配置类型
|
|
26
|
+
*/
|
|
27
|
+
type: {
|
|
28
|
+
type: PropType<"js" | "json">;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
29
31
|
}>, () => (VNode | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Chart config
|
|
34
|
+
*
|
|
35
|
+
* 图表配置
|
|
36
|
+
*/
|
|
37
|
+
config: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Chart title
|
|
43
|
+
*
|
|
44
|
+
* 图表标题
|
|
45
|
+
*/
|
|
46
|
+
title: StringConstructor;
|
|
47
|
+
/**
|
|
48
|
+
* Chart config type
|
|
49
|
+
*
|
|
50
|
+
* 图表配置类型
|
|
51
|
+
*/
|
|
52
|
+
type: {
|
|
53
|
+
type: PropType<"js" | "json">;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
54
56
|
}>> & Readonly<{}>, {
|
|
55
|
-
|
|
57
|
+
type: "js" | "json";
|
|
56
58
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
57
|
-
|
|
59
|
+
//#endregion
|
|
58
60
|
export { _default as default };
|
|
61
|
+
//# sourceMappingURL=ChartJS.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{LoadingIcon as e,decodeData as t,useDarkMode as n}from"@vuepress/helper/client";import{watchImmediate as r}from"@vueuse/core";import{defineComponent as i,h as a,nextTick as o,onMounted as s,onUnmounted as c,ref as l,shallowRef as u,useId as d}from"vue";import"../styles/chartjs.css";const f=(e,t)=>t===`json`?JSON.parse(e):Function(`\
|
|
2
|
+
let config,__chart_js_config__;
|
|
2
3
|
{
|
|
3
4
|
${e}
|
|
4
5
|
__chart_js_config__=config;
|
|
5
6
|
}
|
|
6
|
-
return __chart_js_config__
|
|
7
|
-
|
|
7
|
+
return __chart_js_config__;\
|
|
8
|
+
`)();var p=i({name:`ChartJS`,props:{config:{type:String,required:!0},title:String,type:{type:String,default:`json`}},setup(i){let p=n(),m=u(),h=d(),g=l(!1),_,v=()=>{_?.destroy(),_=null},y=async()=>{if(__VUEPRESS_SSR__)return;let{default:e}=await import(`chart.js/auto`);e.defaults.borderColor=p.value?`#ccc`:`#36A2EB`,e.defaults.color=p.value?`#fff`:`#000`,e.defaults.maintainAspectRatio=!1,_=new e(h,f(t(i.config),i.type))};return s(()=>{r(__VUEPRESS_DEV__?[()=>i.config,p]:p,async()=>{v(),await o(),await y(),g.value=!0},{flush:`post`})}),c(v),()=>[i.title?a(`div`,{class:`chartjs-title`},decodeURIComponent(i.title)):null,g.value?null:a(e,{class:`chartjs-loading`,height:192}),a(`div`,{ref:m,class:`chartjs-wrapper`,style:{display:g.value?`block`:`none`}},a(`canvas`,{id:h,height:400}))]}});export{p as default};
|
|
9
|
+
//# sourceMappingURL=ChartJS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartJS.js","sources":["../../../src/client/components/ChartJS.ts"],"sourcesContent":["import { LoadingIcon, decodeData, useDarkMode } from '@vuepress/helper/client'\nimport { watchImmediate } from '@vueuse/core'\nimport type { Chart, ChartConfiguration } from 'chart.js'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n useId,\n} from 'vue'\n\nimport '../styles/chartjs.css'\n\nconst parseChartConfig = (\n config: string,\n type: 'js' | 'json',\n): ChartConfiguration => {\n if (type === 'json') return JSON.parse(config) as ChartConfiguration\n\n //
|
|
1
|
+
{"version":3,"file":"ChartJS.js","names":[],"sources":["../../../src/client/components/ChartJS.ts"],"sourcesContent":["import { LoadingIcon, decodeData, useDarkMode } from '@vuepress/helper/client'\nimport { watchImmediate } from '@vueuse/core'\nimport type { Chart, ChartConfiguration } from 'chart.js'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n useId,\n} from 'vue'\n\nimport '../styles/chartjs.css'\n\nconst parseChartConfig = (\n config: string,\n type: 'js' | 'json',\n): ChartConfiguration => {\n if (type === 'json') return JSON.parse(config) as ChartConfiguration\n\n // oxlint-disable-next-line no-new-func, typescript/no-implied-eval\n const runner = new Function(\n `\\\nlet config,__chart_js_config__;\n{\n${config}\n__chart_js_config__=config;\n}\nreturn __chart_js_config__;\\\n`,\n ) as () => ChartConfiguration\n\n return runner()\n}\n\nexport default defineComponent({\n name: 'ChartJS',\n\n props: {\n /**\n * Chart config\n *\n * 图表配置\n */\n config: {\n type: String,\n required: true,\n },\n\n /**\n * Chart title\n *\n * 图表标题\n */\n title: String,\n\n /**\n * Chart config type\n *\n * 图表配置类型\n */\n type: {\n type: String as PropType<'js' | 'json'>,\n default: 'json',\n },\n },\n\n setup(props) {\n const isDarkMode = useDarkMode()\n const chartElement = shallowRef<HTMLElement>()\n const id = useId()\n const loaded = ref(false)\n\n let chartjs: Chart | null\n\n const destroyChart = (): void => {\n chartjs?.destroy()\n chartjs = null\n }\n\n const renderChart = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const { default: ChartJs } = await import(\n /* webpackChunkName: \"chart\" */ 'chart.js/auto'\n )\n\n ChartJs.defaults.borderColor = isDarkMode.value ? '#ccc' : '#36A2EB'\n ChartJs.defaults.color = isDarkMode.value ? '#fff' : '#000'\n ChartJs.defaults.maintainAspectRatio = false\n\n const chartConfig = decodeData(props.config)\n const data = parseChartConfig(chartConfig, props.type)\n\n chartjs = new ChartJs(id, data)\n }\n\n onMounted(() => {\n watchImmediate(\n __VUEPRESS_DEV__\n ? // config must be changed if type is changed, so no need to watch type\n [(): string => props.config, isDarkMode]\n : isDarkMode,\n async () => {\n destroyChart()\n await nextTick()\n await renderChart()\n loaded.value = true\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyChart)\n\n return (): (VNode | null)[] => [\n props.title\n ? h('div', { class: 'chartjs-title' }, decodeURIComponent(props.title))\n : null,\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'chartjs-loading', height: 192 }),\n h(\n 'div',\n {\n ref: chartElement,\n class: 'chartjs-wrapper',\n style: {\n display: loaded.value ? 'block' : 'none',\n },\n },\n h('canvas', {\n id,\n height: 400,\n }),\n ),\n ]\n },\n})\n"],"mappings":"kS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 +1,61 @@
|
|
|
1
|
-
import * as vue from
|
|
2
|
-
import { PropType, VNode } from
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { PropType, VNode } from "vue";
|
|
3
|
+
import "../styles/echarts.css";
|
|
3
4
|
|
|
5
|
+
//#region src/client/components/ECharts.d.ts
|
|
4
6
|
declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
/**
|
|
8
|
+
* ECharts config
|
|
9
|
+
*
|
|
10
|
+
* 图表配置
|
|
11
|
+
*/
|
|
12
|
+
config: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Chart title
|
|
18
|
+
*
|
|
19
|
+
* 图表标题
|
|
20
|
+
*/
|
|
21
|
+
title: StringConstructor;
|
|
22
|
+
/**
|
|
23
|
+
* Chart config type
|
|
24
|
+
*
|
|
25
|
+
* 图表配置类型
|
|
26
|
+
*/
|
|
27
|
+
type: {
|
|
28
|
+
type: PropType<"js" | "json">;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
29
31
|
}>, () => (VNode | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
/**
|
|
33
|
+
* ECharts config
|
|
34
|
+
*
|
|
35
|
+
* 图表配置
|
|
36
|
+
*/
|
|
37
|
+
config: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
required: true;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Chart title
|
|
43
|
+
*
|
|
44
|
+
* 图表标题
|
|
45
|
+
*/
|
|
46
|
+
title: StringConstructor;
|
|
47
|
+
/**
|
|
48
|
+
* Chart config type
|
|
49
|
+
*
|
|
50
|
+
* 图表配置类型
|
|
51
|
+
*/
|
|
52
|
+
type: {
|
|
53
|
+
type: PropType<"js" | "json">;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
54
56
|
}>> & Readonly<{}>, {
|
|
55
|
-
|
|
57
|
+
type: "js" | "json";
|
|
56
58
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
57
|
-
|
|
59
|
+
//#endregion
|
|
58
60
|
export { _default as default };
|
|
61
|
+
//# sourceMappingURL=ECharts.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import{LoadingIcon as
|
|
1
|
+
import{n as e}from"../../echarts-C9C0qkV9.js";import{LoadingIcon as t,decodeData as n}from"@vuepress/helper/client";import{useDebounceFn as r,useEventListener as i}from"@vueuse/core";import{defineComponent as a,h as o,nextTick as s,onMounted as c,onUnmounted as l,ref as u,shallowRef as d,watch as f}from"vue";import{onContentUpdated as p}from"vuepress/client";import"../styles/echarts.css";const m=(async()=>{}).constructor,h=(e,t,n,r)=>t===`js`?m(`echarts`,`myChart`,`\
|
|
2
|
+
let width,height,option,__echarts_config__;
|
|
2
3
|
{
|
|
3
|
-
${
|
|
4
|
+
${e}
|
|
4
5
|
__echarts_config__={width,height,option};
|
|
5
6
|
}
|
|
6
7
|
return __echarts_config__;
|
|
7
|
-
`)(n,
|
|
8
|
-
//# sourceMappingURL=ECharts.js.map
|
|
8
|
+
`)(n,r):Promise.resolve({option:JSON.parse(e)});var g=a({name:`ECharts`,props:{config:{type:String,required:!0},title:String,type:{type:String,default:`json`}},setup(a){let m=e(),g=d(),_=u(!1),v=null;i(`resize`,r(()=>{v?.resize()},100));let y=()=>{v?.dispose(),v=null},b=async()=>{if(__VUEPRESS_SSR__)return;let e=await import(`echarts`);m.isSetup||=(await m.setup?.(),!0),v=e.init(g.value);let{option:t,...r}=await h(n(a.config),a.type,e,v);v.resize(r),v.setOption({...m.option,...t})};return p(async e=>{e===`mounted`&&(await b(),_.value=!0)}),c(()=>{__VUEPRESS_DEV__&&f(()=>a.config,async()=>{y(),await s(),await b()},{flush:`post`})}),l(y),()=>[a.title?o(`div`,{class:`echarts-title`},decodeURIComponent(a.title)):null,o(`div`,{class:`echarts-wrapper`},[o(`div`,{ref:g,class:`echarts-container`}),_.value?null:o(t,{class:`echarts-loading`,height:360})])]}});export{g as default};
|
|
9
|
+
//# sourceMappingURL=ECharts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECharts.js","sources":["../../../src/client/components/ECharts.ts"],"sourcesContent":["import { LoadingIcon, decodeData } from '@vuepress/helper/client'\nimport { useDebounceFn, useEventListener } from '@vueuse/core'\nimport type { EChartsOption, EChartsType } from 'echarts'\nimport type * as ECharts from 'echarts'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport { onContentUpdated } from 'vuepress/client'\n\nimport { useEChartsConfig } from '../helpers/index.js'\nimport '../styles/echarts.css'\n\ninterface EChartsConfig {\n width?: number\n height?: number\n option: EChartsOption\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst AsyncFunction = (async (): Promise<void> => {}).constructor\n\nconst parseEChartsConfig = (\n config: string,\n type: 'js' | 'json',\n echarts: typeof ECharts,\n instance: EChartsType,\n): Promise<EChartsConfig> => {\n if (type === 'js') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call\n const runner = AsyncFunction(\n 'echarts',\n 'myChart',\n `\\\nlet width,height,option,__echarts_config__;\n{\n${config}\n__echarts_config__={width,height,option};\n}\nreturn __echarts_config__;\n`,\n )\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return runner(echarts, instance) as Promise<EChartsConfig>\n }\n\n return Promise.resolve({ option: JSON.parse(config) as EChartsOption })\n}\n\nexport default defineComponent({\n name: 'ECharts',\n\n props: {\n /**\n * ECharts config\n *\n * 图表配置\n */\n config: {\n type: String,\n required: true,\n },\n\n /**\n * Chart title\n *\n * 图表标题\n */\n title: String,\n\n /**\n * Chart config type\n *\n * 图表配置类型\n */\n type: {\n type: String as PropType<'js' | 'json'>,\n default: 'json',\n },\n },\n\n setup(props) {\n const echartsConfig = useEChartsConfig()\n const echartsContainer = shallowRef<HTMLElement>()\n\n const loaded = ref(false)\n\n let instance: EChartsType | null = null\n\n useEventListener(\n 'resize',\n useDebounceFn(() => {\n instance?.resize()\n }, 100),\n )\n\n const destroyECharts = (): void => {\n instance?.dispose()\n instance = null\n }\n\n const renderECharts = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const echarts = await import(/* webpackChunkName: \"echarts\" */ 'echarts')\n\n if (!echartsConfig.isSetup) {\n await echartsConfig.setup?.()\n echartsConfig.isSetup = true\n }\n\n instance = echarts.init(echartsContainer.value)\n\n const { option, ...size } = await parseEChartsConfig(\n decodeData(props.config),\n props.type,\n echarts,\n instance,\n )\n\n instance.resize(size)\n instance.setOption({ ...echartsConfig.option, ...option })\n }\n\n onContentUpdated(async (reason) => {\n if (reason === 'mounted') {\n await renderECharts()\n loaded.value = true\n }\n })\n\n onMounted(() => {\n if (!__VUEPRESS_DEV__) return\n\n // config must be changed if type is changed, so no need to watch it\n watch(\n () => props.config,\n async () => {\n destroyECharts()\n await nextTick()\n await renderECharts()\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyECharts)\n\n return (): (VNode | null)[] => [\n props.title\n ? h('div', { class: 'echarts-title' }, decodeURIComponent(props.title))\n : null,\n h('div', { class: 'echarts-wrapper' }, [\n h('div', {\n ref: echartsContainer,\n class: 'echarts-container',\n }),\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'echarts-loading', height: 360 }),\n ]),\n ]\n },\n})\n"],"
|
|
1
|
+
{"version":3,"file":"ECharts.js","names":[],"sources":["../../../src/client/components/ECharts.ts"],"sourcesContent":["import { LoadingIcon, decodeData } from '@vuepress/helper/client'\nimport { useDebounceFn, useEventListener } from '@vueuse/core'\nimport type { EChartsOption, EChartsType } from 'echarts'\n// oxlint-disable-next-line import/no-namespace\nimport type * as ECharts from 'echarts'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport { onContentUpdated } from 'vuepress/client'\n\nimport { useEChartsConfig } from '../helpers/index.js'\nimport '../styles/echarts.css'\n\ninterface EChartsConfig {\n width?: number\n height?: number\n option: EChartsOption\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst AsyncFunction = (async (): Promise<void> => {}).constructor\n\nconst parseEChartsConfig = (\n config: string,\n type: 'js' | 'json',\n echarts: typeof ECharts,\n instance: EChartsType,\n): Promise<EChartsConfig> => {\n if (type === 'js') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, new-cap\n const runner = AsyncFunction(\n 'echarts',\n 'myChart',\n `\\\nlet width,height,option,__echarts_config__;\n{\n${config}\n__echarts_config__={width,height,option};\n}\nreturn __echarts_config__;\n`,\n )\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n return runner(echarts, instance) as Promise<EChartsConfig>\n }\n\n return Promise.resolve({ option: JSON.parse(config) as EChartsOption })\n}\n\nexport default defineComponent({\n name: 'ECharts',\n\n props: {\n /**\n * ECharts config\n *\n * 图表配置\n */\n config: {\n type: String,\n required: true,\n },\n\n /**\n * Chart title\n *\n * 图表标题\n */\n title: String,\n\n /**\n * Chart config type\n *\n * 图表配置类型\n */\n type: {\n type: String as PropType<'js' | 'json'>,\n default: 'json',\n },\n },\n\n setup(props) {\n const echartsConfig = useEChartsConfig()\n const echartsContainer = shallowRef<HTMLElement>()\n\n const loaded = ref(false)\n\n let instance: EChartsType | null = null\n\n useEventListener(\n 'resize',\n useDebounceFn(() => {\n instance?.resize()\n }, 100),\n )\n\n const destroyECharts = (): void => {\n instance?.dispose()\n instance = null\n }\n\n const renderECharts = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const echarts = await import(/* webpackChunkName: \"echarts\" */ 'echarts')\n\n if (!echartsConfig.isSetup) {\n await echartsConfig.setup?.()\n echartsConfig.isSetup = true\n }\n\n instance = echarts.init(echartsContainer.value)\n\n const { option, ...size } = await parseEChartsConfig(\n decodeData(props.config),\n props.type,\n echarts,\n instance,\n )\n\n instance.resize(size)\n instance.setOption({ ...echartsConfig.option, ...option })\n }\n\n onContentUpdated(async (reason) => {\n if (reason === 'mounted') {\n await renderECharts()\n loaded.value = true\n }\n })\n\n onMounted(() => {\n if (!__VUEPRESS_DEV__) return\n\n // config must be changed if type is changed, so no need to watch it\n watch(\n () => props.config,\n async () => {\n destroyECharts()\n await nextTick()\n await renderECharts()\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyECharts)\n\n return (): (VNode | null)[] => [\n props.title\n ? h('div', { class: 'echarts-title' }, decodeURIComponent(props.title))\n : null,\n h('div', { class: 'echarts-wrapper' }, [\n h('div', {\n ref: echartsContainer,\n class: 'echarts-container',\n }),\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'echarts-loading', height: 360 }),\n ]),\n ]\n },\n})\n"],"mappings":"u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AC,CACrE,KACJ,EAAE,MAAO,CAAE,MAAO,kBAAmB,CAAE,CACrC,EAAE,MAAO,CACP,IAAK,EACL,MAAO,oBACR,CAAC,CACF,EAAO,MACH,KACA,EAAE,EAAa,CAAE,MAAO,kBAAmB,OAAQ,IAAK,CAAC,CAC9D,CAAC,CACH,EAEJ,CAAC"}
|
|
@@ -1,46 +1,49 @@
|
|
|
1
|
-
import * as vue from
|
|
2
|
-
import { PropType, VNode } from
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { PropType, VNode } from "vue";
|
|
3
|
+
import "../styles/flowchart.css";
|
|
3
4
|
|
|
5
|
+
//#region src/client/components/FlowChart.d.ts
|
|
4
6
|
declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Flowchart code content
|
|
9
|
+
*
|
|
10
|
+
* 流程图代码内容
|
|
11
|
+
*/
|
|
12
|
+
code: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Flowchart preset
|
|
18
|
+
*
|
|
19
|
+
* 流程图预设
|
|
20
|
+
*/
|
|
21
|
+
preset: {
|
|
22
|
+
type: PropType<"ant" | "pie" | "vue">;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
23
25
|
}>, () => (VNode | null)[], {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Flowchart code content
|
|
28
|
+
*
|
|
29
|
+
* 流程图代码内容
|
|
30
|
+
*/
|
|
31
|
+
code: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Flowchart preset
|
|
37
|
+
*
|
|
38
|
+
* 流程图预设
|
|
39
|
+
*/
|
|
40
|
+
preset: {
|
|
41
|
+
type: PropType<"ant" | "pie" | "vue">;
|
|
42
|
+
default: string;
|
|
43
|
+
};
|
|
42
44
|
}>> & Readonly<{}>, {
|
|
43
|
-
|
|
45
|
+
preset: "ant" | "pie" | "vue";
|
|
44
46
|
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
45
|
-
|
|
47
|
+
//#endregion
|
|
46
48
|
export { _default as default };
|
|
49
|
+
//# sourceMappingURL=FlowChart.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LoadingIcon as
|
|
2
|
-
//# sourceMappingURL=FlowChart.js.map
|
|
1
|
+
import{LoadingIcon as e,decodeData as t}from"@vuepress/helper/client";import{useDebounceFn as n,useEventListener as r}from"@vueuse/core";import{defineComponent as i,h as a,nextTick as o,onMounted as s,onUnmounted as c,ref as l,shallowRef as u,toRefs as d,useId as f,watch as p}from"vue";import{onContentUpdated as m}from"vuepress/client";import"../styles/flowchart.css";var h={x:0,y:0,"line-width":2,"line-length":40,"text-margin":8,"font-size":14,"font-color":`#8DA1AC`,"line-color":`#8DA1AC`,"element-color":`black`,fill:`white`,"yes-text":`Yes`,"no-text":`No`,"arrow-end":`block`,scale:1},g={...h,symbols:{start:{class:`start-element`,"font-color":`#fff`,fill:`#595959`,"line-width":0},end:{class:`end-element`,"font-color":`#fff`,fill:`#595959`,"line-width":0},operation:{class:`operation-element`,"font-color":`#fff`,fill:`#1890ff`,"line-width":0},inputoutput:{class:`inputoutput-element`,"font-color":`#fff`,fill:`#1890ff`,"line-width":0},subroutine:{class:`subroutine-element`,"font-color":`#fff`,fill:`#FF485E`,"element-color":`#fff`,"line-color":`red`},condition:{class:`condition-element`,"font-color":`#fff`,fill:`#FF485E`,"line-width":0},parallel:{class:`parallel-element`,"font-color":`#fff`,fill:`#1890ff`,"line-width":0}}},_={...h,"line-width":1,symbols:{start:{class:`start-element`,fill:`#ccc`,"line-color":`#5c6ac4`,"font-color":`#000`},end:{class:`end-element`,fill:`#ccc`,"line-color":`#5c6ac4`,"font-color":`#000`},operation:{class:`operation-element`,fill:`#f1f1f1`,"line-color":`#5c6ac4`,"font-color":`#000`},inputoutput:{class:`inputoutput-element`,fill:`#f1f1f1`,"line-color":`#5c6ac4`,"font-color":`#000`},subroutine:{class:`subroutine-element`,fill:`#f1f1f1`,"line-color":`#5c6ac4`,"font-color":`#000`},condition:{class:`condition-element`,fill:`#f1f1f1`,"line-color":`#5c6ac4`,"font-color":`#000`},parallel:{class:`parallel-element`,fill:`#f1f1f1`,"line-color":`#5c6ac4`,"font-color":`#000`}}};const v={ant:g,vue:{...h,symbols:{start:{class:`start-element`,"font-color":`#fff`,fill:`#2F495F`,"line-width":0},end:{class:`end-element`,"font-color":`#fff`,fill:`#2F495F`,"line-width":0},operation:{class:`operation-element`,"font-color":`#fff`,fill:`#00BC7D`,"line-width":0},inputoutput:{class:`inputoutput-element`,"font-color":`#fff`,fill:`#EB4D5D`,"line-width":0},subroutine:{class:`subroutine-element`,"font-color":`#fff`,fill:`#937AC4`,"element-color":`#fff`,"line-color":`red`},condition:{class:`condition-element`,"font-color":`#fff`,fill:`#FFB500`,"line-width":0},parallel:{class:`parallel-element`,"font-color":`#fff`,fill:`#2F495F`,"line-width":0}}},pie:_},y=e=>e<419?.8:e>1280?1:.9;var b=i({name:`FlowChart`,props:{code:{type:String,required:!0},preset:{type:String,default:`vue`}},setup(i){let h=f(),{code:g,preset:_}=d(i),b=u(),x=l(!1),S=l(1),C=null;r(`resize`,n(()=>{if(C){let e=y(window.innerWidth);S.value!==e&&(S.value=e,C.draw(h,{...v[i.preset],scale:e}))}},100));let w=()=>{C?.clean(),C=null},T=async()=>{if(__VUEPRESS_SSR__)return;let{parse:e}=await import(`flowchart.ts`);C=e(t(g.value)),S.value=y(window.innerWidth),x.value=!0,C.draw(h,{...v[i.preset],scale:S.value})};return m(async e=>{e===`mounted`&&await T()}),s(()=>{__VUEPRESS_DEV__&&p([g,_],async()=>{w(),await o(),await T()},{flush:`post`})}),c(w),()=>[x.value?null:a(e,{class:`flowchart-loading`,height:192}),a(`div`,{ref:b,class:[`flowchart-wrapper`,i.preset],id:h,style:{display:x.value?`block`:`none`}})]}});export{b as default};
|
|
2
|
+
//# sourceMappingURL=FlowChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowChart.js","sources":["../../../src/client/utils/flowchart-presets/base.ts","../../../src/client/utils/flowchart-presets/ant.ts","../../../src/client/utils/flowchart-presets/pie.ts","../../../src/client/utils/flowchart-presets/vue.ts","../../../src/client/utils/flowchart-presets/index.ts","../../../src/client/components/FlowChart.ts"],"sourcesContent":["export default {\n 'x': 0,\n 'y': 0,\n 'line-width': 2,\n 'line-length': 40,\n 'text-margin': 8,\n 'font-size': 14,\n 'font-color': '#8DA1AC',\n 'line-color': '#8DA1AC',\n 'element-color': 'black',\n 'fill': 'white',\n 'yes-text': 'Yes',\n 'no-text': 'No',\n 'arrow-end': 'block',\n 'scale': 1,\n}\n","import base from './base.js'\n\nexport default {\n ...base,\n\n // Style symbol types\n symbols: {\n start: {\n 'class': 'start-element',\n 'font-color': '#fff',\n 'fill': '#595959',\n 'line-width': 0,\n },\n end: {\n 'class': 'end-element',\n 'font-color': '#fff',\n 'fill': '#595959',\n 'line-width': 0,\n },\n operation: {\n 'class': 'operation-element',\n 'font-color': '#fff',\n 'fill': '#1890ff',\n 'line-width': 0,\n },\n inputoutput: {\n 'class': 'inputoutput-element',\n 'font-color': '#fff',\n 'fill': '#1890ff',\n 'line-width': 0,\n },\n subroutine: {\n 'class': 'subroutine-element',\n 'font-color': '#fff',\n 'fill': '#FF485E',\n 'element-color': '#fff',\n 'line-color': 'red',\n },\n condition: {\n 'class': 'condition-element',\n 'font-color': '#fff',\n 'fill': '#FF485E',\n 'line-width': 0,\n },\n parallel: {\n 'class': 'parallel-element',\n 'font-color': '#fff',\n 'fill': '#1890ff',\n 'line-width': 0,\n },\n },\n}\n","import base from './base.js'\n\nexport default {\n ...base,\n\n // Style symbol types\n 'line-width': 1,\n 'symbols': {\n start: {\n 'class': 'start-element',\n 'fill': '#ccc',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n end: {\n 'class': 'end-element',\n 'fill': '#ccc',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n operation: {\n 'class': 'operation-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n inputoutput: {\n 'class': 'inputoutput-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n subroutine: {\n 'class': 'subroutine-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n condition: {\n 'class': 'condition-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n parallel: {\n 'class': 'parallel-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n },\n}\n","import base from './base.js'\n\nexport default {\n ...base,\n\n // Style symbol types\n symbols: {\n start: {\n 'class': 'start-element',\n 'font-color': '#fff',\n 'fill': '#2F495F',\n 'line-width': 0,\n },\n end: {\n 'class': 'end-element',\n 'font-color': '#fff',\n 'fill': '#2F495F',\n 'line-width': 0,\n },\n operation: {\n 'class': 'operation-element',\n 'font-color': '#fff',\n 'fill': '#00BC7D',\n 'line-width': 0,\n },\n inputoutput: {\n 'class': 'inputoutput-element',\n 'font-color': '#fff',\n 'fill': '#EB4D5D',\n 'line-width': 0,\n },\n subroutine: {\n 'class': 'subroutine-element',\n 'font-color': '#fff',\n 'fill': '#937AC4',\n 'element-color': '#fff',\n 'line-color': 'red',\n },\n condition: {\n 'class': 'condition-element',\n 'font-color': '#fff',\n 'fill': '#FFB500',\n 'line-width': 0,\n },\n parallel: {\n 'class': 'parallel-element',\n 'font-color': '#fff',\n 'fill': '#2F495F',\n 'line-width': 0,\n },\n },\n}\n","/**\n * Forked from https://github.com/ulivz/vuepress-plugin-flowchart/tree/master/lib/presets\n *\n * MIT LICENSED\n */\n\nimport ant from './ant.js'\nimport pie from './pie.js'\nimport vue from './vue.js'\n\nexport const flowchartPresets = {\n ant,\n vue,\n pie,\n}\n","import { LoadingIcon, decodeData } from '@vuepress/helper/client'\nimport { useDebounceFn, useEventListener } from '@vueuse/core'\nimport type { Chart } from 'flowchart.ts'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n toRefs,\n useId,\n watch,\n} from 'vue'\nimport { onContentUpdated } from 'vuepress/client'\n\nimport { flowchartPresets } from '../utils/index.js'\n\nimport '../styles/flowchart.css'\n\nexport default defineComponent({\n name: 'FlowChart',\n\n props: {\n /**\n * Flowchart code content\n *\n * 流程图代码内容\n */\n code: { type: String, required: true },\n\n /**\n * Flowchart preset\n *\n * 流程图预设\n */\n preset: {\n type: String as PropType<'ant' | 'pie' | 'vue'>,\n default: 'vue',\n },\n },\n\n setup(props) {\n const id = useId()\n const { code, preset } = toRefs(props)\n const element = shallowRef<HTMLDivElement>()\n\n const loaded = ref(false)\n const scale = ref(1)\n\n let flowchart: Chart | null = null\n\n const getScale = (width: number): number =>\n width < 419 ? 0.8 : width > 1280 ? 1 : 0.9\n\n useEventListener(\n 'resize',\n useDebounceFn(() => {\n if (flowchart) {\n const newScale = getScale(window.innerWidth)\n\n if (scale.value !== newScale) {\n scale.value = newScale\n\n flowchart.draw(id, {\n ...flowchartPresets[props.preset],\n scale: newScale,\n })\n }\n }\n }, 100),\n )\n\n const destroyFlowChart = (): void => {\n flowchart?.clean()\n flowchart = null\n }\n\n const renderFlowChart = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const { parse } = await import(\n /* webpackChunkName: \"flowchart\" */ 'flowchart.ts'\n )\n\n flowchart = parse(decodeData(code.value))\n\n // Update scale\n scale.value = getScale(window.innerWidth)\n\n loaded.value = true\n\n // Draw svg to #id\n flowchart.draw(id, {\n ...flowchartPresets[props.preset],\n scale: scale.value,\n })\n }\n\n onContentUpdated(async (reason) => {\n if (reason === 'mounted') await renderFlowChart()\n })\n\n onMounted(() => {\n if (!__VUEPRESS_DEV__) return\n\n watch(\n [code, preset],\n async () => {\n destroyFlowChart()\n await nextTick()\n await renderFlowChart()\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyFlowChart)\n\n return (): (VNode | null)[] => [\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'flowchart-loading', height: 192 }),\n h('div', {\n ref: element,\n class: ['flowchart-wrapper', props.preset],\n id,\n style: {\n display: loaded.value ? 'block' : 'none',\n },\n }),\n ]\n },\n})\n"],"names":["l","o","base","r","t","flowchartPresets","ant","vue","pie","FlowChart","defineComponent","props","id","useId","code","preset","toRefs","element","shallowRef","loaded","ref","scale","flowchart","getScale","width","useEventListener","useDebounceFn","newScale","destroyFlowChart","renderFlowChart","parse","decodeData","onContentUpdated","reason","onMounted","watch","nextTick","onUnmounted","h","LoadingIcon"],"mappings":"kXAAA,IAAAA,EAAe,CACb,EAAK,EACL,EAAK,EACL,aAAc,EACd,cAAe,GACf,cAAe,EACf,YAAa,GACb,aAAc,UACd,aAAc,UACd,gBAAiB,QACjB,KAAQ,QACR,WAAY,MACZ,UAAW,KACX,YAAa,QACb,MAAS,CACX,ECbAC,EAA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,MAAQ,GAGfG,EAAU,KAAKV,EAAI,CACjB,GAAGP,EAAiBM,EAAM,MAAM,EAChC,MAAOU,EAAM,KACf,CAAC,CACH,EAEA,OAAAW,EAAiB,MAAOC,GAAW,CAC7BA,IAAW,WAAW,MAAMJ,EAAAA,CAClC,CAAC,EAEDK,EAAU,IAAM,CACT,kBAELC,EACE,CAACrB,EAAMC,CAAM,EACb,SAAY,CACVa,EAAAA,EACA,MAAMQ,IACN,MAAMP,EAAAA,CACR,EACA,CAAE,MAAO,MAAO,CAClB,CACF,CAAC,EAEDQ,EAAYT,CAAgB,EAErB,IAAwB,CAC7BT,EAAO,MACH,KACAmB,EAAEC,EAAa,CAAE,MAAO,oBAAqB,OAAQ,GAAI,CAAC,EAC9DD,EAAE,MAAO,CACP,IAAKrB,EACL,MAAO,CAAC,oBAAqBN,EAAM,MAAM,EACzC,GAAAC,EACA,MAAO,CACL,QAASO,EAAO,MAAQ,QAAU,MACpC,CACF,CAAC,CACH,CACF,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"FlowChart.js","names":["base","base","base"],"sources":["../../../src/client/utils/flowchart-presets/base.ts","../../../src/client/utils/flowchart-presets/ant.ts","../../../src/client/utils/flowchart-presets/pie.ts","../../../src/client/utils/flowchart-presets/vue.ts","../../../src/client/utils/flowchart-presets/index.ts","../../../src/client/components/FlowChart.ts"],"sourcesContent":["export default {\n 'x': 0,\n 'y': 0,\n 'line-width': 2,\n 'line-length': 40,\n 'text-margin': 8,\n 'font-size': 14,\n 'font-color': '#8DA1AC',\n 'line-color': '#8DA1AC',\n 'element-color': 'black',\n 'fill': 'white',\n 'yes-text': 'Yes',\n 'no-text': 'No',\n 'arrow-end': 'block',\n 'scale': 1,\n}\n","import base from './base.js'\n\nexport default {\n ...base,\n\n // Style symbol types\n symbols: {\n start: {\n 'class': 'start-element',\n 'font-color': '#fff',\n 'fill': '#595959',\n 'line-width': 0,\n },\n end: {\n 'class': 'end-element',\n 'font-color': '#fff',\n 'fill': '#595959',\n 'line-width': 0,\n },\n operation: {\n 'class': 'operation-element',\n 'font-color': '#fff',\n 'fill': '#1890ff',\n 'line-width': 0,\n },\n inputoutput: {\n 'class': 'inputoutput-element',\n 'font-color': '#fff',\n 'fill': '#1890ff',\n 'line-width': 0,\n },\n subroutine: {\n 'class': 'subroutine-element',\n 'font-color': '#fff',\n 'fill': '#FF485E',\n 'element-color': '#fff',\n 'line-color': 'red',\n },\n condition: {\n 'class': 'condition-element',\n 'font-color': '#fff',\n 'fill': '#FF485E',\n 'line-width': 0,\n },\n parallel: {\n 'class': 'parallel-element',\n 'font-color': '#fff',\n 'fill': '#1890ff',\n 'line-width': 0,\n },\n },\n}\n","import base from './base.js'\n\nexport default {\n ...base,\n\n // Style symbol types\n 'line-width': 1,\n 'symbols': {\n start: {\n 'class': 'start-element',\n 'fill': '#ccc',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n end: {\n 'class': 'end-element',\n 'fill': '#ccc',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n operation: {\n 'class': 'operation-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n inputoutput: {\n 'class': 'inputoutput-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n subroutine: {\n 'class': 'subroutine-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n condition: {\n 'class': 'condition-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n parallel: {\n 'class': 'parallel-element',\n 'fill': '#f1f1f1',\n 'line-color': '#5c6ac4',\n 'font-color': '#000',\n },\n },\n}\n","import base from './base.js'\n\nexport default {\n ...base,\n\n // Style symbol types\n symbols: {\n start: {\n 'class': 'start-element',\n 'font-color': '#fff',\n 'fill': '#2F495F',\n 'line-width': 0,\n },\n end: {\n 'class': 'end-element',\n 'font-color': '#fff',\n 'fill': '#2F495F',\n 'line-width': 0,\n },\n operation: {\n 'class': 'operation-element',\n 'font-color': '#fff',\n 'fill': '#00BC7D',\n 'line-width': 0,\n },\n inputoutput: {\n 'class': 'inputoutput-element',\n 'font-color': '#fff',\n 'fill': '#EB4D5D',\n 'line-width': 0,\n },\n subroutine: {\n 'class': 'subroutine-element',\n 'font-color': '#fff',\n 'fill': '#937AC4',\n 'element-color': '#fff',\n 'line-color': 'red',\n },\n condition: {\n 'class': 'condition-element',\n 'font-color': '#fff',\n 'fill': '#FFB500',\n 'line-width': 0,\n },\n parallel: {\n 'class': 'parallel-element',\n 'font-color': '#fff',\n 'fill': '#2F495F',\n 'line-width': 0,\n },\n },\n}\n","/**\n * Forked from https://github.com/ulivz/vuepress-plugin-flowchart/tree/master/lib/presets\n *\n * MIT LICENSED\n */\n\nimport ant from './ant.js'\nimport pie from './pie.js'\nimport vue from './vue.js'\n\nexport const flowchartPresets = {\n ant,\n vue,\n pie,\n}\n","import { LoadingIcon, decodeData } from '@vuepress/helper/client'\nimport { useDebounceFn, useEventListener } from '@vueuse/core'\nimport type { Chart } from 'flowchart.ts'\nimport type { PropType, VNode } from 'vue'\nimport {\n defineComponent,\n h,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n toRefs,\n useId,\n watch,\n} from 'vue'\nimport { onContentUpdated } from 'vuepress/client'\n\nimport { flowchartPresets } from '../utils/index.js'\n\nimport '../styles/flowchart.css'\n\nconst getScale = (width: number): number =>\n width < 419 ? 0.8 : width > 1280 ? 1 : 0.9\n\nexport default defineComponent({\n name: 'FlowChart',\n\n props: {\n /**\n * Flowchart code content\n *\n * 流程图代码内容\n */\n code: { type: String, required: true },\n\n /**\n * Flowchart preset\n *\n * 流程图预设\n */\n preset: {\n type: String as PropType<'ant' | 'pie' | 'vue'>,\n default: 'vue',\n },\n },\n\n setup(props) {\n const id = useId()\n const { code, preset } = toRefs(props)\n const element = shallowRef<HTMLDivElement>()\n\n const loaded = ref(false)\n const scale = ref(1)\n\n let flowchart: Chart | null = null\n\n useEventListener(\n 'resize',\n useDebounceFn(() => {\n if (flowchart) {\n const newScale = getScale(window.innerWidth)\n\n if (scale.value !== newScale) {\n scale.value = newScale\n\n flowchart.draw(id, {\n ...flowchartPresets[props.preset],\n scale: newScale,\n })\n }\n }\n }, 100),\n )\n\n const destroyFlowChart = (): void => {\n flowchart?.clean()\n flowchart = null\n }\n\n const renderFlowChart = async (): Promise<void> => {\n if (__VUEPRESS_SSR__) return\n\n const { parse } = await import(\n /* webpackChunkName: \"flowchart\" */ 'flowchart.ts'\n )\n\n flowchart = parse(decodeData(code.value))\n\n // Update scale\n scale.value = getScale(window.innerWidth)\n\n loaded.value = true\n\n // Draw svg to #id\n flowchart.draw(id, {\n ...flowchartPresets[props.preset],\n scale: scale.value,\n })\n }\n\n onContentUpdated(async (reason) => {\n if (reason === 'mounted') await renderFlowChart()\n })\n\n onMounted(() => {\n if (!__VUEPRESS_DEV__) return\n\n watch(\n [code, preset],\n async () => {\n destroyFlowChart()\n await nextTick()\n await renderFlowChart()\n },\n { flush: 'post' },\n )\n })\n\n onUnmounted(destroyFlowChart)\n\n return (): (VNode | null)[] => [\n loaded.value\n ? null\n : h(LoadingIcon, { class: 'flowchart-loading', height: 192 }),\n h('div', {\n ref: element,\n class: ['flowchart-wrapper', props.preset],\n id,\n style: {\n display: loaded.value ? 'block' : 'none',\n },\n }),\n ]\n },\n})\n"],"mappings":"kXAAA,IAAA,EAAe,CACb,EAAK,EACL,EAAK,EACL,aAAc,EACd,cAAe,GACf,cAAe,EACf,YAAa,GACb,aAAc,UACd,aAAc,UACd,gBAAiB,QACjB,KAAQ,QACR,WAAY,MACZ,UAAW,KACX,YAAa,QACb,MAAS,EACV,CCbD,EAAe,CACb,GAAGA,EAGH,QAAS,CACP,MAAO,CACL,MAAS,gBACT,aAAc,OACd,KAAQ,UACR,aAAc,EACf,CACD,IAAK,CACH,MAAS,cACT,aAAc,OACd,KAAQ,UACR,aAAc,EACf,CACD,UAAW,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EAAO,MACH,KACA,EAAE,EAAa,CAAE,MAAO,oBAAqB,OAAQ,IAAK,CAAC,CAC/D,EAAE,MAAO,CACP,IAAK,EACL,MAAO,CAAC,oBAAqB,EAAM,OAAO,CAC1C,KACA,MAAO,CACL,QAAS,EAAO,MAAQ,QAAU,OACnC,CACF,CAAC,CACH,EAEJ,CAAC"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import * as vue from
|
|
2
|
-
import { VNode } from
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { VNode } from "vue";
|
|
3
|
+
import "../styles/markmap.css";
|
|
3
4
|
|
|
5
|
+
//#region src/client/components/MarkMap.d.ts
|
|
4
6
|
declare const _default: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Markmap content
|
|
9
|
+
*
|
|
10
|
+
* Markmap
|
|
11
|
+
*/
|
|
12
|
+
content: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
14
16
|
}>, () => VNode, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Markmap content
|
|
19
|
+
*
|
|
20
|
+
* Markmap
|
|
21
|
+
*/
|
|
22
|
+
content: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
24
26
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
25
|
-
|
|
27
|
+
//#endregion
|
|
26
28
|
export { _default as default };
|
|
29
|
+
//# sourceMappingURL=MarkMap.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LoadingIcon as
|
|
2
|
-
//# sourceMappingURL=MarkMap.js.map
|
|
1
|
+
import{LoadingIcon as e,decodeData as t}from"@vuepress/helper/client";import{useDebounceFn as n,useEventListener as r}from"@vueuse/core";import{defineComponent as i,h as a,nextTick as o,onMounted as s,onUnmounted as c,ref as l,shallowRef as u,toRefs as d,watch as f}from"vue";import{onContentUpdated as p}from"vuepress/client";import"../styles/markmap.css";var m=i({name:`MarkMap`,props:{content:{type:String,required:!0}},setup(i){let{content:m}=d(i),h=u(),g=u(),_=l(!1),v=null;r(`resize`,n(()=>{v?.fit()},100));let y=()=>{v?.destroy(),v=null},b=async()=>{if(__VUEPRESS_SSR__)return;let[{Transformer:e},n,{Toolbar:r}]=await Promise.all([import(`markmap-lib`),import(`markmap-view`),import(`markmap-toolbar`)]),{Markmap:a,deriveOptions:o,loadJS:s,loadCSS:c}=n,l=new e,{frontmatter:u,features:d,root:f}=l.transform(t(i.content)),{styles:p,scripts:m}=l.getUsedAssets(d);await Promise.all([m?s(m,{getMarkmap:()=>n}):Promise.resolve(),p?c(p):Promise.resolve()]),v=a.create(g.value,o({maxWidth:240,...u?.markmap}));let{el:_}=r.create(v);await v.setData(f),await v.fit(),_.style.position=`absolute`,_.style.bottom=`0.5rem`,_.style.right=`0.5rem`,h.value.append(_)};return p(async e=>{e===`mounted`&&(await b(),_.value=!0)}),s(()=>{__VUEPRESS_DEV__&&f(m,async()=>{y(),await o(),await b()},{flush:`post`})}),c(y),()=>a(`div`,{class:`markmap-wrapper`,ref:h},[a(`svg`,{ref:g,class:`markmap-svg`}),_.value?null:a(e,{class:`markmap-loading`,height:360})])}});export{m as default};
|
|
2
|
+
//# sourceMappingURL=MarkMap.js.map
|