a或属性Note
的类型取决于注释是从 a还是 a获得的。为什么?如何在不知道它来自哪里的代码中干净地处理这个问题?parent
storyOffset
Text
Story
Note
以下脚本揭示了这种情况。
// INDESIGN CS6 8.1 VERSION
var doc = app.documents.add();
doc.pages.item(0).textFrames.add();
var story = doc.stories[0];
story.insertionPoints[0].contents = "x";
story.insertionPoints[0].notes.add();
var range = story.texts.itemByRange(story.characters.item(0),
story.characters.item(1));
alert( story .notes[0].parent.constructor.name); // "InsertionPoint"
alert( range .notes[0].parent.constructor.name); // "Array"
alert( story .notes[0].storyOffset.constructor.name); // "InsertionPoint"
alert( range .notes[0].storyOffset.constructor.name); // "Array"
// INCOPY CS6 8.1 VERSION
app.documents.add();
var story = app.selection[0].parentStory;
story.insertionPoints[0].contents = "x";
story.insertionPoints[0].notes.add();
var range = story.texts.itemByRange(story.characters.item(0),
story.characters.item(1));
alert( story .notes[0].parent.constructor.name); // "InsertionPoint"
alert( range .notes[0].parent.constructor.name); // "Array"
alert( story .notes[0].storyOffset.constructor.name); // "InsertionPoint"
alert( range .notes[0].storyOffset.constructor.name); // "Array"