I am trying to create a plugin to generate a list. I use the setRangeListOptions() function.
figma.ui.onmessage = async (mesg) => {
await figma.loadFontAsync({ family: "Inter", style: "Regular" })
var text = figma.createText()
type TextListOptions = { type: "UNORDERED"};
text.setRangeListOptions(1, 2, globalThis.TextListOptions)
figma.closePlugin()
}
I’m creating a text node, but I can’t put a nested list in it.
At the same time, he writes that “TextListOptions” is declared, but has never been used.
And a warning:
You don’t have any text in the text field so there is no range to set the list to. Set text.characters="blablabla", then you can add a list to the existing text.
You picked the range from character at index 1 to index 2 (only character at index 1, the second in the characters string, will be in this range) and the warning tells you the range you picked is outside of the current character string length (which is 0, since you didn’t set any text on it).
Okay, I added the text
But the list does not appear, writes that the TextListOption is not used. How should I write it in the getRangeListOption() function?
Firstly, why are you using a type instead of a variable? What is globalThis? Also again you set the range outside of the length of the string. blabla is only 6 characters long but you are trying to make a range from 2nd to 10th character.