-
Notifications
You must be signed in to change notification settings - Fork 116
Middlewares
Konrad Dzwinel edited this page Dec 17, 2018
·
1 revision
Middlewares can help you hook into some of the html-skechapp's internals.
Text overrides in existing symbols will be lost when updating an existing library since Sketch references the randomly generated object ID. A custom text ID can be set by adding a unique identifier to the text wrapper and using that in an onTextGenerate
callback, as shown below, or using the text as a unique identifier – in the form <Button>buttons/default</Button>
with using node.nodeValue
in the onTextGenerate
callback:
<Button data-sketch-id="buttons/default">
Default Button
</Button>
const layers = nodeToSketchLayers(node, {
onTextGenerate: ({ layer, node }) => {
const parentNode = node.parentNode;
if (parentNode && parentNode.dataset) {
const { sketchId } = parentNode.dataset;
if (sketchId) {
layer.setObjectID(`text:${sketchId}`);
}
}
}
});