I’m depending on specific names of my Text Layers, for localization and automation purposes, via in-house plugin code.
But if I edit the text on a Text Layer and make some words bold (for example), the Text Layer gets automatically renamed (to match the beginning of the text on the Layer).
This is wreaking havoc with my document structure - how can I disable this automatic renaming?
EDIT: See clarification below, my issue arises because I have renamed a lot of (previously unrenamed) layers programmatically via plugin script. I now want to find out how to set (by Sketch API) the same option/flag as when renaming manually, to prevent future auto-renaming when editing the plugin-renamed layer!
Thanks, this fixes the problem “locally”. However, I’m developing my own plugin and have used it to already rename a lot of layers “programatically”.
Apparently, manually changing the Layer name sets some option/flag on the Layer to prevent automatic renaming, but that does not happen when I rename the Layer via API.
For my workflow to become robust, I would need to be able to set this option/flag by plugin script, to make sure future manual edits will not unexpectedly change the Layer names.
Please advice, how I can access this setting by API…
NOTE: I’m fine with achieving this via .sketchObject etc, if I can just get a hint of where to look!
I believe the property you’re looking for is called nameIsFixed, which is unfortunately not supported by the JS API, but you may indeed access it via sketchObject like this:
textLayer.name = 'this name should stay as is'
textLayer.sketchObject.setNameIsFixed(true)
textLayer.text = 'modified text'