You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
Currently the readme file contains a whole section about how to add a FontAwesome icon to the SVG drawing. Just wondering if we could simplify this process somehow?
One solution would be to allow the user to 'use' a 'definition' of an Fontawesome icon.
In the svg_utils file, the switch statement should get an extra entry at the end:
default:
return null;
At the end of the $scope.init function, the following code snippet should be added:
var textElements = $scope.svg.getElementsByTagName("text");
// Replace all FontAwesome icon names by their uniCode values
for (var i = 0; i < textElements.length; i++) {
var textElement = textElements[i];
var textContent = textElement.textContent.trim();
if (textContent.startsWith("fa-")) {
var uniCode = getUnicode(textContent);
if (uniCode) {
textElement.textContent = "&#x" + uniCode + ";";
}
else {
console.log("FontAwesome icon " + textContent + " is not supported by this node");
}
}
}
The $scope.init function is being called at client-side (i.e. inside the dashboard), so we need to load the svg_utils.js file (containing the getUnicode function) from the server . So probably:
Publish this script on the server, similar to my heatmap node code. Caution: I received an issue about that code snippet a few days ago, so we should implement that fix also here!
[EDIT]: The svg_utils.js file is quite large. So to avoid having to download it, it is better to do it like this:
In the loop create a list of textContent strings.
Do 1 call to the server to convert that list.
Loop again over the same text elements and replace the results
Currently the readme file contains a whole section about how to add a FontAwesome icon to the SVG drawing. Just wondering if we could simplify this process somehow?
One solution would be to allow the user to 'use' a 'definition' of an Fontawesome icon.
For example:
So the user uses a FontAwesome icon, and this node automatically adds (text element) definitions for all used icons.
The text was updated successfully, but these errors were encountered: