mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
let icons be settable by loading from server endpoint
This commit is contained in:
parent
eb940d6d57
commit
638d0d2f3f
@ -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";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user