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

29 lines
892 B
JavaScript
Raw Normal View History

2018-07-22 18:54:58 +02:00
import style from './lib/style';
const VERSION = require('../package.json').version;
module.exports = {
hooks: {
preRenderSvg: function(next) {
// Without this, our custom attribute won't be valid
this.attributes.add("xmlns:freesewing-plugins", "http://freesewing.org/namespaces/freesewing-plugins");
this.attributes.add("freesewing-plugins:macro-title", VERSION);
this.style += style;
next();
}
}
, macros: {
title: function(next, so) {
let points = this.points;
so.at.attr('data-text', so.nr)
.attr('data-text-class', 'title-nr');
points.titleName = so.at.shift(-90, 20)
.attr('data-text', title)
.attr('data-text-class', 'title-name');
points.titlePattern = so.at.shift(-90, 40)
.attr('data-text', pattern)
.attr('data-text-class', 'title-pattern');
next();
}
}
}