').text(node.icon).appendTo(iconRow);
}
}
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js b/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js
index 121c53994..a0f8ce0fc 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/palette.js
@@ -142,9 +142,9 @@ RED.palette = (function() {
}
function setIcon(element,sf) {
- var icon_url = RED.utils.getNodeIcon(sf._def,sf);
+ var icon_url = RED.utils.getNodeIcon(sf._def);
var iconContainer = element.find(".palette_icon_container");
- RED.utils.createIconElement(icon_url, iconContainer, true);
+ RED.utils.createIconElement(icon_url, iconContainer, true, sf._def);
}
function escapeNodeType(nt) {
@@ -182,7 +182,7 @@ RED.palette = (function() {
if (def.icon) {
var icon_url = RED.utils.getNodeIcon(def);
var iconContainer = $('
',{class:"palette_icon_container"+(def.align=="right"?" palette_icon_container_right":"")}).appendTo(d);
- RED.utils.createIconElement(icon_url, iconContainer, true);
+ RED.utils.createIconElement(icon_url, iconContainer, true, def);
}
d.style.backgroundColor = RED.utils.getNodeColor(nt,def);
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/search.js b/packages/node_modules/@node-red/editor-client/src/js/ui/search.js
index cce7dddf3..e5fa59914 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/search.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/search.js
@@ -203,7 +203,7 @@ RED.search = (function() {
nodeDiv.css('backgroundColor',colour);
var iconContainer = $('
',{class:"palette_icon_container"}).appendTo(nodeDiv);
- RED.utils.createIconElement(icon_url, iconContainer, true);
+ RED.utils.createIconElement(icon_url, iconContainer, true, node._def, node);
var contentDiv = $('
',{class:"red-ui-search-result-description"}).appendTo(div);
if (node.z) {
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js b/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js
index 0e0ce98b3..a99d90b58 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js
@@ -133,7 +133,7 @@ RED.typeSearch = (function() {
nodeDiv.css('backgroundColor',colour);
var iconContainer = $('
',{class:"palette_icon_container"}).appendTo(nodeDiv);
- RED.utils.createIconElement(icon_url, iconContainer, false);
+ RED.utils.createIconElement(icon_url, iconContainer, false, def);
if (def.inputs > 0) {
$('
',{class:"red-ui-search-result-node-port"}).appendTo(nodeDiv);
diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js
index 7c4647045..77faf60ab 100644
--- a/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js
+++ b/packages/node_modules/@node-red/editor-client/src/js/ui/utils.js
@@ -767,10 +767,12 @@ RED.utils = (function() {
return RED.settings.apiRootUrl+"icons/node-red/alert.png"
} else if (node && node.icon) {
var iconPath = separateIconPath(node.icon);
- if (iconPath.module === "font-awesome") {
- return node.icon;
- } else if (isIconExists(iconPath)) {
- return RED.settings.apiRootUrl+"icons/" + node.icon;
+ if (isIconExists(iconPath)) {
+ if (iconPath.module === "font-awesome") {
+ return node.icon;
+ } else {
+ return RED.settings.apiRootUrl+"icons/" + node.icon;
+ }
}
}
@@ -895,10 +897,12 @@ RED.utils = (function() {
/**
* Create or update an icon element and append it to iconContainer.
* @param iconUrl - Url of icon.
- * @param iconContainer - icon container element with palette_icon_container class.
- * @param isLarge - whether the icon size is large.
+ * @param iconContainer - Icon container element with palette_icon_container class.
+ * @param isLarge - Whether the icon size is large.
+ * @param def - Default definition of a node.
+ * @param node - If the icon is a specific node instance, this parameter must be specified. If it is icon template such as an icon on the palette, this must be omitted.
*/
- function createIconElement(iconUrl, iconContainer, isLarge) {
+ function createIconElement(iconUrl, iconContainer, isLarge, def, node) {
// Removes the previous icon when icon was changed.
var iconElement = iconContainer.find(".palette_icon");
if (iconElement.length !== 0) {
@@ -912,13 +916,23 @@ RED.utils = (function() {
// Show either icon image or font-awesome icon
var iconPath = separateIconPath(iconUrl);
if (iconPath.module === "font-awesome") {
- var faIconElement = $('
').appendTo(iconContainer);
- var faLarge = isLarge ? "fa-lg " : "";
- faIconElement.addClass("palette_icon_fa fa fa-fw " + faLarge + iconPath.file);
- } else {
- var imageIconElement = $('
',{class:"palette_icon"}).appendTo(iconContainer);
- imageIconElement.css("backgroundImage", "url("+iconUrl+")");
+ var fontAwesomeUnicode = RED.nodes.fontAwesome.getIconUnicode(iconPath.file);
+ if (fontAwesomeUnicode) {
+ var faIconElement = $('
').appendTo(iconContainer);
+ var faLarge = isLarge ? "fa-lg " : "";
+ faIconElement.addClass("palette_icon_fa fa fa-fw " + faLarge + iconPath.file);
+ return;
+ }
+ // If the specified name is not defined in font-awesome, show the default icon.
+ if (def) {
+ var iconPath = RED.utils.getDefaultNodeIcon(def, node);
+ iconUrl = RED.settings.apiRootUrl+"icons/"+iconPath.module+"/"+iconPath.file;
+ } else {
+ iconUrl = RED.settings.apiRootUrl+"icons/node-red/arrow-in.png"
+ }
}
+ var imageIconElement = $('
',{class:"palette_icon"}).appendTo(iconContainer);
+ imageIconElement.css("backgroundImage", "url("+iconUrl+")");
}
return {