feat(plugin-annotations): Allow overriding classes, set name/nr in store
This commit is contained in:
parent
577af2df6b
commit
e60362935c
1 changed files with 22 additions and 7 deletions
|
@ -11,6 +11,14 @@ const macroDefaults = {
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
title: 'title',
|
title: 'title',
|
||||||
|
classes: {
|
||||||
|
cutlist: 'text-md fill-current',
|
||||||
|
date: 'text-sm fill-current',
|
||||||
|
for: 'fill-current font-bold',
|
||||||
|
name: 'fill-note',
|
||||||
|
nr: 'text-4xl fill-note font-bold',
|
||||||
|
title: 'text-lg fill-current font-bold',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -47,7 +55,12 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
/*
|
/*
|
||||||
* Merge macro defaults with user-provided config
|
* Merge macro defaults with user-provided config
|
||||||
*/
|
*/
|
||||||
const so = { ...macroDefaults, ...config }
|
const so = {
|
||||||
|
...macroDefaults,
|
||||||
|
...config,
|
||||||
|
classes: macroDefaults.classes,
|
||||||
|
}
|
||||||
|
if (config.classes) so.classes = { ...so.classes, ...config.classes }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Take global scale setting into account
|
* Take global scale setting into account
|
||||||
|
@ -94,8 +107,9 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
points[ids.nr] = so.at
|
points[ids.nr] = so.at
|
||||||
.clone()
|
.clone()
|
||||||
.attr('data-text', so.nr, so.append ? false : true)
|
.attr('data-text', so.nr, so.append ? false : true)
|
||||||
.attr('data-text-class', 'text-4xl fill-note font-bold ' + so.align)
|
.attr('data-text-class', `${so.classes.nr} ${so.align}`)
|
||||||
.attr('data-text-transform', transform)
|
.attr('data-text-transform', transform)
|
||||||
|
store.set(['partNumbers', part.name], so.nr)
|
||||||
} else delete ids.nr
|
} else delete ids.nr
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -106,9 +120,10 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
.clone()
|
.clone()
|
||||||
.shift(-90, shift)
|
.shift(-90, shift)
|
||||||
.attr('data-text', so.title, so.append ? false : true)
|
.attr('data-text', so.title, so.append ? false : true)
|
||||||
.attr('data-text-class', 'text-lg fill-current font-bold ' + so.align)
|
.attr('data-text-class', `${so.classes.title} ${so.align}`)
|
||||||
.attr('data-text-transform', transform)
|
.attr('data-text-transform', transform)
|
||||||
shift += so.dy
|
shift += so.dy
|
||||||
|
store.set(['partTitles', part.name], so.title)
|
||||||
} else delete ids.title
|
} else delete ids.title
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -134,7 +149,7 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
.clone()
|
.clone()
|
||||||
.shift(-90, shift)
|
.shift(-90, shift)
|
||||||
.attr('data-text', 'plugin:cut')
|
.attr('data-text', 'plugin:cut')
|
||||||
.attr('data-text-class', 'text-md fill-current ' + so.align)
|
.attr('data-text-class', `${so.classes.cutlist} ${so.align}`)
|
||||||
.attr('data-text-transform', transform)
|
.attr('data-text-transform', transform)
|
||||||
.addText(cut)
|
.addText(cut)
|
||||||
shift += so.dy
|
shift += so.dy
|
||||||
|
@ -174,7 +189,7 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
store.data?.version || 'noVersion'
|
store.data?.version || 'noVersion'
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
.attr('data-text-class', 'fill-note ' + so.align)
|
.attr('data-text-class', `${so.classes.name} ${so.align}`)
|
||||||
.attr('data-text-transform', transform)
|
.attr('data-text-transform', transform)
|
||||||
shift += so.dy
|
shift += so.dy
|
||||||
|
|
||||||
|
@ -185,7 +200,7 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
points[ids.for] = so.at
|
points[ids.for] = so.at
|
||||||
.shift(-90, shift)
|
.shift(-90, shift)
|
||||||
.attr('data-text', `(${store.data.for})`)
|
.attr('data-text', `(${store.data.for})`)
|
||||||
.attr('data-text-class', 'fill-current font-bold ' + so.align)
|
.attr('data-text-class', `${so.classes.for} ${so.align}`)
|
||||||
shift += so.dy
|
shift += so.dy
|
||||||
} else delete ids.for
|
} else delete ids.for
|
||||||
|
|
||||||
|
@ -203,7 +218,7 @@ const addTitleMacro = function (config, { Point, points, scale, locale, store, p
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.attr('data-text-class', 'text-sm fill-current ' + so.align)
|
.attr('data-text-class', `${so.classes.date} ${so.align}`)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store all IDs in the store so we can remove this macro with rmtitle
|
* Store all IDs in the store so we can remove this macro with rmtitle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue