mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #4817 from node-red/mermaid-caching
Ensure mermaid.min.js is cached properly between loads of the editor
This commit is contained in:
commit
d7aa792f97
@ -11,9 +11,22 @@ RED.editor.mermaid = (function () {
|
|||||||
|
|
||||||
if (!initializing) {
|
if (!initializing) {
|
||||||
initializing = true
|
initializing = true
|
||||||
$.getScript(
|
// Find the cache-buster:
|
||||||
'vendor/mermaid/mermaid.min.js',
|
let cacheBuster
|
||||||
function (data, stat, jqxhr) {
|
$('script').each(function (i, el) {
|
||||||
|
if (!cacheBuster) {
|
||||||
|
const src = el.getAttribute('src')
|
||||||
|
const m = /\?v=(.+)$/.exec(src)
|
||||||
|
if (m) {
|
||||||
|
cacheBuster = m[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$.ajax({
|
||||||
|
url: `vendor/mermaid/mermaid.min.js?v=${cacheBuster}`,
|
||||||
|
dataType: "script",
|
||||||
|
cache: true,
|
||||||
|
success: function (data, stat, jqxhr) {
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
startOnLoad: false,
|
startOnLoad: false,
|
||||||
theme: RED.settings.get('mermaid', {}).theme
|
theme: RED.settings.get('mermaid', {}).theme
|
||||||
@ -24,7 +37,7 @@ RED.editor.mermaid = (function () {
|
|||||||
render(pending)
|
render(pending)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const nodes = document.querySelectorAll(selector)
|
const nodes = document.querySelectorAll(selector)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user