1
0
Fork 0
freesewing/packages/plugin-title/src/index.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-07-26 07:18:21 +00:00
import style from "./lib/style";
import { version, name } from "../package.json";
2018-07-22 18:54:58 +02:00
2018-07-26 07:18:21 +00:00
export default {
name: name,
version: version,
2018-07-22 18:54:58 +02:00
hooks: {
preRender: function(svg) {
svg.attributes.add("freesewing:plugin-title", version);
svg.style += style;
2018-07-22 18:54:58 +02:00
}
2018-07-26 07:18:21 +00:00
},
macros: {
title: function(so) {
let overwrite = true;
if (so.append) overwrite = false;
let prefix = "";
if (so.prefix) prefix = so.prefix;
this.points[`_${prefix}_titleNr`] = so.at
.attr("data-text", so.nr, overwrite)
.attr("data-text-class", "title-nr note fill-note");
let shift = 10;
if (so.title && so.title !== "") {
this.points[`_${prefix}_titleName`] = so.at
.shift(-90, 13)
.attr("data-text", so.title)
.attr("data-text-class", "title-name");
shift += 10;
}
this.points[`_${prefix}_titlePattern`] = so.at
.shift(-90, shift)
.attr("data-text", this.context.config.name)
.attr("data-text", "v" + this.context.config.version)
2018-07-26 07:18:21 +00:00
.attr("data-text-class", "title-pattern fill-note");
2018-07-22 18:54:58 +02:00
}
}
2018-07-26 07:18:21 +00:00
};