let icons be settable by loading from server endpoint

This commit is contained in:
Dave Conway-Jones 2023-10-23 19:09:39 +01:00
parent eb940d6d57
commit 638d0d2f3f
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643

View File

@ -101,7 +101,7 @@ RED.utils = (function() {
renderer.code = function (code, lang) {
if(lang === "mermaid") {
// mermaid diagram rendering
// mermaid diagram rendering
if (mermaidIsEnabled === undefined) {
if (RED.settings.markdownEditor &&
RED.settings.markdownEditor.mermaid) {
@ -1118,6 +1118,22 @@ RED.utils = (function() {
if (def.category === 'subflows') {
return RED.settings.apiRootUrl+"icons/node-red/subflow.svg";
}
if (node?.type) {
// this regex might be too restrictive/specific but got to start somewhere
const re = new RegExp("^\/"+node.type+"\/icon\/.*\.svg$","i");
if (typeof def.icon === "function") {
try {
const di = def.icon.call(node);
if (re.test(di)) { return RED.settings.authTokensSuffix.replace(/-/,'/') + di; }
}
catch(e) { console.log("Bad Icon",e) }
}
else {
if (re.test(def.icon)) { return RED.settings.authTokensSuffix.replace(/-/,'/') + def.icon; }
}
}
return RED.settings.apiRootUrl+"icons/node-red/arrow-in.svg";
}