javascript - Why does selection[0].contents return undefined for a selected TextFrame in InDesign UXP? - Stack Overflow

I'm building a UXP panel for Adobe InDesign, and I'm trying to extract the contents of a sele

I'm building a UXP panel for Adobe InDesign, and I'm trying to extract the contents of a selected text frame using:

const selection = app.selection;
const selectedItem = selection[0];
const text = selectedItem.contents;

Although the item is confirmed to be a TextFrame, and there is clearly text inside it, the .contents property returns undefined. I’ve verified the selection object:

console.log('Selected:', selection);
console.log(Object.keys(selection));

Still, I'm not getting the expected text.

Is there something different in UXP or InDesign's API I should be aware of when accessing text frame content?

The full code, look like this code bellow:

function testTextFrameContents() {
  try {
    const selection = app.selection;

    if (!selection || selection.length === 0) {
      console.log("⚠️ Nothing is selected.");
      return;
    }

    const selectedItem = selection[0];

    console.log("

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744208498a4563222.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信