Closed bartbutenaers closed 5 years ago
TODOs:
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:
var html = String.raw`
<script type="text/javascript" src="svg_utils.js"></script>
<div id='tooltip_` + config.id + `' display='none' style='position: absolute; display: none; background: cornsilk; border: 1px solid black; border-radius: 5px; padding: 2px;'></div>
<div id='svggraphics_` + config.id + `' ng-init='init(` + configAsJson + `)'>` + config.svgString + `</div>
`;
[EDIT]: The svg_utils.js file is quite large. So to avoid having to download it, it is better to do it like this:
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.