-
-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
814abe5
commit 8706e0d
Showing
9 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,6 @@ | |
} | ||
|
||
.language-echarts, | ||
.language-plantuml, | ||
.language-mindmap { | ||
overflow: hidden; | ||
height: 420px; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,38 +5,32 @@ declare const plantumlEncoder: { | |
encode(options: string): string, | ||
}; | ||
|
||
export const plantumlRender = (element: HTMLElement, cdn = Constants.CDN, theme: string) => { | ||
export const plantumlRender = (element: HTMLElement, cdn = Constants.CDN) => { | ||
const plantumlElements = element.querySelectorAll(".language-plantuml"); | ||
if (plantumlElements.length === 0) { | ||
return; | ||
} | ||
addScript(`https://cdn.jsdelivr.net/gh/jmnote/plantuml[email protected]/dist/plantuml-encoder.min.js`, "vditorPlantumlEncoderScript").then(() => { | ||
addScript(`${cdn}/dist/js/plantuml/plantuml-encoder.min.js`, "vditorPlantumlScript").then(() => { | ||
plantumlElements.forEach((e: HTMLDivElement) => { | ||
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") || | ||
e.parentElement.classList.contains("vditor-ir__marker--pre")) { | ||
return; | ||
} | ||
const text = e.innerText.trim(); | ||
if (!text) { | ||
return; | ||
} | ||
try { | ||
if (e.getAttribute("data-processed") === "true") { | ||
return; | ||
} | ||
|
||
const encoded = plantumlEncoder.encode(text) | ||
const imageElement = document.createElement("IMG"); | ||
imageElement.setAttribute("loading", "lazy") | ||
imageElement.setAttribute("src", 'http://www.plantuml.com/plantuml/svg/~1' + encoded) | ||
e.parentNode.insertBefore(imageElement, e); | ||
e.style.display = 'none'; | ||
|
||
e.setAttribute("data-processed", "true"); | ||
} catch (error) { | ||
e.className = "vditor-reset--error"; | ||
e.innerHTML = `plantuml render error: <br>${error}`; | ||
} | ||
}); | ||
if (e.parentElement.classList.contains("vditor-wysiwyg__pre") || | ||
e.parentElement.classList.contains("vditor-ir__marker--pre")) { | ||
return; | ||
} | ||
const text = e.innerText.trim(); | ||
if (!text) { | ||
return; | ||
} | ||
try { | ||
const encoded = plantumlEncoder.encode(text); | ||
const imageElement = document.createElement("img"); | ||
imageElement.setAttribute("loading", "lazy"); | ||
imageElement.setAttribute("src", "http://www.plantuml.com/plantuml/svg/~1" + encoded); | ||
e.parentNode.insertBefore(imageElement, e); | ||
e.remove(); | ||
} catch (error) { | ||
e.className = "vditor-reset--error"; | ||
e.innerHTML = `plantuml render error: <br>${error}`; | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters