Last active
September 6, 2019 14:43
-
-
Save trych/cd4b9bb0f65064ea6f18b4fdba75eec3 to your computer and use it in GitHub Desktop.
Demonstrates how to retrieve a text object resembling the last text style range *within* a single line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#target indesign | |
// use on some text frame with several text style ranges in the first line | |
// if the text range continues into the second line, only the range within the first line will be returned | |
var l = app.activeDocument.textFrames.firstItem().lines.firstItem(); | |
var lir = getLastInlineRange(l); | |
app.select(lir); | |
function getLastInlineRange(l) { | |
var ltsr = l.textStyleRanges.lastItem(); | |
return ltsr.lines.length > 1 ? l.parentTextFrames[0].insertionPoints.itemByRange(ltsr.insertionPoints.firstItem().index, l.insertionPoints.lastItem().index) : ltsr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regarding the issues discussed in this Tweet.