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) {
|
||||
initializing = true
|
||||
$.getScript(
|
||||
'vendor/mermaid/mermaid.min.js',
|
||||
function (data, stat, jqxhr) {
|
||||
// Find the cache-buster:
|
||||
let cacheBuster
|
||||
$('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({
|
||||
startOnLoad: false,
|
||||
theme: RED.settings.get('mermaid', {}).theme
|
||||
@ -24,7 +37,7 @@ RED.editor.mermaid = (function () {
|
||||
render(pending)
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const nodes = document.querySelectorAll(selector)
|
||||
|
Loading…
x
Reference in New Issue
Block a user