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

This commit is contained in:
Frankie Huang 2025-04-18 04:47:33 +08:00
parent 3f693be1bd
commit ee74a79fef
3 changed files with 1339 additions and 1 deletions

View File

@ -632,7 +632,7 @@
_this.setToolbar(); _this.setToolbar();
editormd.loadScript(loadPath + "marked.min", function() { editormd.loadScript(loadPath + "marked", function() {
editormd.$marked = marked; editormd.$marked = marked;
@ -3674,6 +3674,29 @@
: ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "<p" + isTeXAddClass + ">" + this.atLink(this.emoji(text)) + "</p>\n" ); : ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "<p" + isTeXAddClass + ">" + this.atLink(this.emoji(text)) + "</p>\n" );
}; };
/**
* 解析 PlantUMLcode 示例
* @startuml
* participant User
* User -> Server: Reque
* Server --> User: Response
* @enduml
*
* @param {String} code
* @returns {Object} 生成后的 plantUML 图像
*/
markedRenderer.plantuml = function (code) {
/** loadQueues() plantumlEncoder
editormd.loadScript(loadPath + "plantuml-encoder.min", function() {
editormd.$plantumlEncoder = plantumlEncoder;
});
const encoded = editormd.$plantumlEncoder.encode(code);
return `<img src="https://www.plantuml.com/plantuml/svg/${encoded}" />`;
**/
return marked.Renderer.prototype.plantuml.apply(this, arguments);
};
markedRenderer.code = function (code, lang, escaped) { markedRenderer.code = function (code, lang, escaped) {
if (lang === "seq" || lang === "sequence") if (lang === "seq" || lang === "sequence")

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long