Main gave every class member a reflect type and page item handles a revert
count. The type classes now declare a type for each member, their members
that are not available yet use the unavailable form, TextFrame takes main's
contentVariable, and a text range looks its frame up at the document's
current revert count.
Review fixes:
- A text range length that ends inside a surrogate pair moves its end out
to the end of the character.
- textFrames.removeAll() refuses type on a locked artboard, as
pageItems.removeAll() does.
- Joining a story's text across its frames counts toward the run's data
limit.
- A test shows a script that catches a refused link goes on with the links
unchanged.
- `contents` on a text frame or text range takes a number and writes it as
`String(number)` gives it; other values still throw.
- Setting a text range's `length` moves its end and leaves the text as it
is (https://ai-scripting.docsforadobe.dev/jsobjref/TextRange/ lists it as
read/write). A value that is not a whole number from 0 to the units left
in the frame throws. Each read of a member that gives a range gives a new
object, so setting one range's length leaves the others alone.
- A text range has the paragraph attributes as well as the character
attributes, so `range.justification` reads and sets the paragraphs the
range touches.
- `characters`, `words` and `paragraphs` have `add(contents,
relativeObject?, insertionLocation?)` and `addBefore(contents)`
(https://ai-scripting.docsforadobe.dev/jsobjref/Words/), which insert the
text as one `text.editRange` and give its range. An added word is kept
apart from its neighbors by a space and an added paragraph by a
paragraph break; an empty string runs no command.
- `app.textFonts.getByName` also finds a bundled face by its PostScript
name.
Docs: docs/mcp.md, docs/target-app-parity.md.
CharacterStyle.applyTo returned early on any empty range, so on an empty
text frame it never reached charStyle.apply, which restyles the stored
runs of empty text. It now passes an empty frame through and keeps the
no-op only for an empty range inside text.
textFrames.removeAll() now stops with the same error as pageItems.removeAll()
and PageItem.remove() when a type object sits on a locked artboard, and
deletes nothing.
While a script runs a `command.batch`, the session kept the style lists
of every step that changed them, so each such step also made the next
edit copy the whole list. The session now keeps one copy of each open
document's lists, as the last step left them, and records the names of
the styles a step removed or renamed and the documents a step reverted.
The style objects check those names, so a style that a batch removes and
makes again, or renames and names back, is still a different style.
Stories read from different frames of one thread share one index of the
story's text while the document is unchanged, instead of each keeping its
own copy. A frame listed in two threads shares only with a story whose
frames match. Story.lines, insertionPoints, textRanges and textSelection
check the story first, so a story whose frame was deleted throws Stale
story.
The cross-document baseFrame test passes a rectangle of the other document
and checks the error and that the rectangle stays a path. docs/mcp.md no
longer says baseFrame and postFix throw, the text-frame entry in
docs/target-app-parity.md no longer lists stories and threading as missing,
and the M13 row in docs/roadmap.md lists text frames and stories.
- A style object goes stale when the steps of one `command.batch` remove
its style and add another under the same name, as it does when separate
`vc.run` calls do. The session notes each batch step's style lists while
a script runs, and the style objects check each of them.
- `add(name)` with all 4,096 style slots of the run taken throws before it
adds the style; with one slot left it adds it.
- `typename` of a removed style's `characterAttributes` or
`paragraphAttributes` throws `Stale style`, as its other members do.
- The style load commands refuse `data` over 64 MB without copying it.
- docs/mcp.md states the 64 MB limit for `data` and decoded `dataBase64`;
docs/gaps.md G6 and the docs/roadmap.md M13 row list the script text
and style members.
Text frames get nextFrame, previousFrame and story, and documents get stories, a
Stories collection with one story for each thread and each type object in no
thread. Assigning nextFrame or previousFrame links the last frame of one story
to the first frame of another, and null breaks the link with each frame keeping
its text; loops, links to the frame itself or into the middle of a story, point
type, frames of another document and hidden or locked frames are refused with
nothing changed. A story of two or more frames reads and writes its text across
its frames in UTF-16 units, and areaText and pathText take baseFrame and
postFix to thread the new frame to an existing one.
The new command text.thread.setNeighbor {id, side, neighbor} links or breaks
by id without a selection, for MCP, the CLI and vc.run.
A style object kept working after file.revert when the file read back held a style with the same name. Each style object now keeps the document's revert count, as text ranges do, and one made before a revert throws Stale style. The range style lists follow the per-paragraph entries of the text model, and the host name table lists the style classes.
A removal or rename whose result cannot reach the script is put back,
and style objects now follow a command only once it is kept. A failed
atomic object-model call puts style objects back with the documents.
document.characterStyles and document.paragraphStyles list a document's
styles, the Normal style first, and add, find and remove them. Each
CharacterStyle and ParagraphStyle has a name, its attributes, applyTo
with clearingOverrides, and remove; setting an attribute redefines the
style through charStyle.setAttrs or paraStyle.setAttrs. A text range's
characterStyles and paragraphStyles list the styles its text is in.
Style names are trimmed and must have 1 to 256 characters and no
control characters, one run names at most 4,096 styles, and a style
object throws Stale style once its style is removed or renamed by a
command. ParagraphStyle.characterAttributes is not available yet.
charStyle.load, paraStyle.load and textStyle.loadAll refuse a file
larger than 64 MB without reading it in full.
A text range kept working after file.revert when the file read back held the same text, because the frame's record compared only the text. The record now keeps the document's revert count, and a range made before a revert throws Stale text range.
- An edit over the end of a text range takes that end to the end of the
edit's new text, so a range the edit covers holds the new text instead
of becoming empty.
- The edit record keeps the frame's last 100,000 edits and drops only the
oldest one past that.
- A numeric leading set on characters with auto leading turns auto
leading off even when it equals the auto value.
- typename of a stale text range, its collections and attribute objects
throws Stale text range, as the other members do; TextFrames and
TextFont check their document and run first.
- createOutline() gives null when the type has nothing to outline,
instead of throwing after the command removed the frame.
- New frames, outlines and conversions read the new id from the
command's JSON result, so ids above 2^53 stay exact.
- Character attribute reads look up only the first style of the range.
- The font assignment test picks a font that draws "abc".
Docs: docs/mcp.md, docs/gaps.md (G6).
document.textFrames lists the document's type and makes point type, area
type and type on a path. A TextFrame gives its kind, contents, text range,
characters, words and paragraphs, outlines, and point and area conversion.
A TextRange gives its contents, offsets, sub-collections, character
attributes (size, leading, tracking, baseline shift, scales, rotation,
underline, strikethrough, font) and paragraph attributes (alignment,
indents, space before and after). app.textFonts lists the fonts.
Offsets count UTF-16 code units. A range follows edits made through these
objects and throws Stale text range after the frame's text changes
another way. Each change runs an existing text command inside the run's
transaction, and a value a range already has runs no command.
PageItem.tags and Document.tags give scripts the Tags and Tag objects
the scripting reference describes: name and value pairs on a page item,
read, added, renamed and deleted through the new object.tags,
object.tag.add, object.tag.set, object.tag.remove and
object.tag.removeAll commands, each one undo step. The native file keeps
the tags and their ids. On opening, each object keeps its first 64 tags
whose name and value are at most 65,536 bytes, and a tag whose id is
missing, out of range or repeated gets a new one. A deleted tag's id is
not given out again, so a script's Tag for it throws "Stale tag".
The undo history's memory estimate now counts the text an object's
attributes hold (note, URL, data, events, classes, foreign attributes
and tags).
- variable.setBinding refuses an embedded image only for an image variable,
so a script can bind an embedded image's visibility.
- A Dataset object stays usable after dataset.import, variable.loadLibrary
or variable.import leaves the document's data sets as they were, or the
import is put back; it goes stale only when the data sets change.
- script.check reports a document's exportVariables as filesWritten and
file.write, and the script host test lists the variable and data set
names the host adds.
Docs: docs/mcp.md.
A script's Document has variables, dataSets, activeDataset, variablesLocked,
importVariables(file) and exportVariables(file), with the Variables,
Variable, Datasets and Dataset classes and the VariableKind enumeration.
Every page item has visibilityVariable, and type, placed and raster images
and graphs have contentVariable. Each change runs a variable.* or dataset.*
command and joins the run's undo step; a value that changes nothing runs no
command.
- variable.setBinding binds one object's visibility or content slot to one
variable, or to none, in one undo step.
- dataset.update takes a name, to update a data set that is not the active
one without switching to it.
- A File crosses to the host as its path under a hidden key, and a plain
object that carries the key is refused. importVariables and
exportVariables check the path against what the script's own File
objects may read or write; the open documents' files do not count.
Docs: docs/mcp.md, docs/target-app-parity.md, docs/gaps.md (G6).