![](/img/trans.png)
[英]How to select all textframes in document, and retrieve the text in adobe indesign
[英]Select all text in thread in InDesign?
我試圖在InDesign CS4中選擇線程中的所有文本,以便可以使用doScript
在所選文本上調用另一個腳本(不是我自己創建的腳本)。 這個問題使我認為這是可能的。 我嘗試了frame.contents.select();
,但這會導致錯誤“ frame.contents.select不是函數”。
如何使用extendscript / javascript在InDesign中選擇線程的內容 ?
( Any_text_item ).contents
僅是純文本界面 ; 它不直接訪問InDesign的本機Text
對象 ,而是將文本與常規Javascript字符串進行相互轉換。 因此,選擇Javascript文本(如果可能)將不會對InDesign文檔本身中的文本產生任何影響。
要從任何文本框架(或其他對象)獲取所有主題文本,可以使用其parentStory
對象。 要選擇(本機)文本,請定位其texts[0]
屬性,並在其上使用select
:
frame.parentStory.texts[0].select();
如果可以找到“當前選擇”被選中的時間,則可以在其之前添加以下幾行: 1
if (app.selection.length == 1 && app.selection[0].hasOwnProperty("previousTextFrame"))
{
// alert ('we must be a text frame!');
app.selection[0].parentStory.texts[0].select();
}
例如,在腳本markdownId.jsx
,它緊鄰第29行,
tagset = findTagSet();
if (app.selection.length > 0)
{ // <- add the new lines immediately below this one, above the next
if (app.selection.length == 1 && app.selection[0].hasOwnProperty('baseline') && app.selection[0].length > 1)
¹最好測試一下您確定沒有 “有害”對象的屬性。 之前,我使用parentStory
但意識到純文本選擇也具有此屬性,因此常規選擇和文本框架之間沒有區別。 對於previousTextFrame
,可以確保只有文本框和文本路徑才是正確的對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.