✨ Better support for insertText() hook
This commit is contained in:
parent
7d9df9f361
commit
91ae2946e4
2 changed files with 17 additions and 2 deletions
|
@ -32,6 +32,12 @@ Attributes.prototype.get = function(name) {
|
||||||
else return this.list[name].join(" ");
|
else return this.list[name].join(" ");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Retrieves an attribute as array*/
|
||||||
|
Attributes.prototype.getAsArray = function(name) {
|
||||||
|
if (typeof this.list[name] === "undefined") return false;
|
||||||
|
else return this.list[name];
|
||||||
|
};
|
||||||
|
|
||||||
/** Returns SVG code for attributes */
|
/** Returns SVG code for attributes */
|
||||||
Attributes.prototype.render = function() {
|
Attributes.prototype.render = function() {
|
||||||
let svg = "";
|
let svg = "";
|
||||||
|
|
11
src/svg.js
11
src/svg.js
|
@ -187,8 +187,17 @@ Svg.prototype.renderPathText = function(path) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Svg.prototype.renderText = function(point) {
|
Svg.prototype.renderText = function(point) {
|
||||||
this.text = point.attributes.get("data-text");
|
let text = point.attributes.getAsArray("data-text");
|
||||||
|
if (text !== false) {
|
||||||
|
let joint = "";
|
||||||
|
for (let string of text) {
|
||||||
|
this.text = string;
|
||||||
this.insertText();
|
this.insertText();
|
||||||
|
joint += this.text + " ";
|
||||||
|
}
|
||||||
|
this.text = joint;
|
||||||
|
this.insertText();
|
||||||
|
}
|
||||||
point.attributes.set("data-text-x", point.x);
|
point.attributes.set("data-text-x", point.x);
|
||||||
point.attributes.set("data-text-y", point.y);
|
point.attributes.set("data-text-y", point.y);
|
||||||
let lineHeight = point.attributes.get("data-text-lineheight") || 12;
|
let lineHeight = point.attributes.get("data-text-lineheight") || 12;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue