Figma插件里怎么获取当前选中图层的文本内容?
我在写一个Figma插件,想拿到用户当前选中的文本图层的内容,但总是报错说类型不对。我试了用figma.currentPage.selection拿到选中项,然后直接读.characters,结果控制台提示“Property ‘characters’ does not exist on type ‘SceneNode’”。
是不是得先判断节点类型?但我不知道具体该怎么写类型检查,求个能跑通的写法!
const selection = figma.currentPage.selection;
if (selection.length > 0) {
const node = selection[0];
// 这里怎么安全地取到文本内容?
console.log(node.characters);
}
暂无解答