feat: 更新 vue-editormd 源码,以支持 PlantUML 解析

This commit is contained in:
Frankie Huang 2025-04-19 18:18:57 +08:00
parent 3f693be1bd
commit cde8e73dd5
8 changed files with 51 additions and 5 deletions

View File

@ -631,6 +631,12 @@
return ;
}
if (settings.plantuml) {
editormd.loadScript(loadPath + "plantuml-encoder.min", function() {
editormd.$plantumlEncoder = plantumlEncoder;
});
}
if (settings.flowChart || settings.sequenceDiagram)
{
editormd.loadScript(loadPath + "raphael.min", function() {
@ -2121,6 +2127,7 @@
tex : settings.tex,
atLink : settings.atLink, // for @link
emailLink : settings.emailLink, // for mail address auto link
plantuml : settings.plantuml,
flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight,
@ -3518,6 +3525,7 @@
taskList : false, // Enable Github Flavored Markdown task lists
emoji : false, // :emoji: , Support Twemoji, fontAwesome, Editor.md logo emojis.
tex : false, // TeX(LaTeX), based on KaTeX
plantuml : false,
flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
};
@ -3756,7 +3764,11 @@
else if ( lang === "math" || lang === "latex" || lang === "katex")
{
return "<p class=\"" + editormd.classNames.tex + "\">" + code + "</p>";
}
}
else if ( lang === "plantuml" && settings.plantuml ) {
const encoded = editormd.$plantumlEncoder.encode(code);
return `<img src="https://www.plantuml.com/plantuml/svg/${encoded}" />`;
}
else
{
@ -4072,6 +4084,7 @@
pageBreak : settings.pageBreak,
atLink : settings.atLink, // for @link
emailLink : settings.emailLink, // for mail address auto link
plantuml : settings.plantuml,
flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight,

File diff suppressed because one or more lines are too long

View File

@ -561,6 +561,12 @@
return ;
}
if (settings.plantuml) {
editormd.loadScript(loadPath + "plantuml-encoder.min", function() {
editormd.$plantumlEncoder = plantumlEncoder;
});
}
if (settings.flowChart || settings.sequenceDiagram)
{
editormd.loadScript(loadPath + "raphael.min", function() {
@ -2052,6 +2058,7 @@
tex : settings.tex,
atLink : settings.atLink, // for @link
emailLink : settings.emailLink, // for mail address auto link
plantuml : settings.plantuml,
flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight,
@ -3449,6 +3456,7 @@
taskList : false, // Enable Github Flavored Markdown task lists
emoji : false, // :emoji: , Support Twemoji, fontAwesome, Editor.md logo emojis.
tex : false, // TeX(LaTeX), based on KaTeX
plantuml : false,
flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
};
@ -3687,7 +3695,11 @@
else if ( lang === "math" || lang === "latex" || lang === "katex")
{
return "<p class=\"" + editormd.classNames.tex + "\">" + code + "</p>";
}
}
else if ( lang === "plantuml" && settings.plantuml ) {
const encoded = editormd.$plantumlEncoder.encode(code);
return `<img src="https://www.plantuml.com/plantuml/svg/${encoded}" />`;
}
else
{
@ -4003,6 +4015,7 @@
pageBreak : settings.pageBreak,
atLink : settings.atLink, // for @link
emailLink : settings.emailLink, // for mail address auto link
plantuml : settings.plantuml,
flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -549,6 +549,12 @@
return ;
}
if (settings.plantuml) {
editormd.loadScript(loadPath + "plantuml-encoder.min", function() {
editormd.$plantumlEncoder = plantumlEncoder;
});
}
if (settings.flowChart || settings.sequenceDiagram)
{
editormd.loadScript(loadPath + "raphael.min", function() {
@ -2039,6 +2045,7 @@
tex : settings.tex,
atLink : settings.atLink, // for @link
emailLink : settings.emailLink, // for mail address auto link
plantuml : settings.plantuml,
flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight,
@ -3439,6 +3446,7 @@
taskList : false, // Enable Github Flavored Markdown task lists
emoji : false, // :emoji: , Support Twemoji, fontAwesome, Editor.md logo emojis.
tex : false, // TeX(LaTeX), based on KaTeX
plantuml : false,
flowChart : false, // flowChart.js only support IE9+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
};
@ -3677,7 +3685,11 @@
else if ( lang === "math" || lang === "latex" || lang === "katex")
{
return "<p class=\"" + editormd.classNames.tex + "\">" + code + "</p>";
}
}
else if ( lang === "plantuml" && settings.plantuml ) {
const encoded = editormd.$plantumlEncoder.encode(code);
return `<img src="https://www.plantuml.com/plantuml/svg/${encoded}" />`;
}
else
{
@ -3993,6 +4005,7 @@
pageBreak : settings.pageBreak,
atLink : settings.atLink, // for @link
emailLink : settings.emailLink, // for mail address auto link
plantuml : settings.plantuml,
flowChart : settings.flowChart,
sequenceDiagram : settings.sequenceDiagram,
previewCodeHighlight : settings.previewCodeHighlight,

View File

@ -148,6 +148,7 @@ export default {
htmlDecode: 'style,script,iframe|on*', // HTML
tocm: true, // Using [TOCM]
tex: true, // TeX
plantuml: true, // plantuml
flowChart: true, //
sequenceDiagram: true, // /
taskList: true,