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.
- A save of several files whose file access refuses one of them returns
the refusal before any file goes to the writer, so a writer that does
not check the file access writes nothing.
- close(SaveOptions.SAVECHANGES) throws before writing, and leaves the
document open, when the document's last save named some of its
artboards, since saving with those options again could leave changes
out of the file.
- The script check no longer treats an object literal's saveAs or
exportFile as the script's own when a function body assigns the
variable without declaring it, or when the script assigns it as a
property of this (the global object in global code and in a function
called without a receiver).
- The close-with-SAVECHANGES format test reads the saved PDF and checks
that it holds the change made after the first save.
- docs/mcp.md limits the "none of them is written" sentence for SVG
linked images to refusals found before the first write, and documents
the new close refusal.
Brings in main through #9019's branch. The PDF presets now come from the shared pdf crate, so a bracketed preset name is looked up with the app's name and "Default" names its default preset.
Document.close(SaveOptions.SAVECHANGES) now saves in the format the document was last saved in, so a PDF saved to a file whose extension names another format stays a PDF. An artboardRange with no parts, such as ',' or ' , ', now throws, as a range used for the save does.
- Document.fullName is a File for the document's file, and Document.path a
Folder for its folder. A document without a file has a fullName of a
File for its name in Folder.current and a path of "". Both throw
`Script file access denied` with the document's name when the
automation read roots do not allow the file.
- Document.saved reads whether the document has unsaved changes. Setting
it runs the new command document.setSaved, which records the document
as saved or as changed without saving it and adds no undo step.
- Document.close(saveOptions) closes a document without unsaved changes
with any SaveOptions value. With unsaved changes,
SaveOptions.DONOTSAVECHANGES closes it without them, and
SaveOptions.SAVECHANGES saves them first with file.saveAs, in the
format the file's extension names and after the write-access check
saveAs makes, and throws for a document without a file (a converted
or recovered one included). SaveOptions.PROMPTTOSAVECHANGES, the
default, throws, since a script cannot show the prompt.
- The script checker reports SaveOptions.SAVECHANGES under filesWritten
wherever the script reads it.
- A pDFPreset in square brackets, such as [Smallest File Size], names
the built-in preset of the name inside them.
- artboardRange takes a whole number from 1 as well as a string; any
other number throws.
- With saveMultipleArtboards true, a .ai or EPS save also writes each
artboard of the range to a file of its own. Without it the range is
not used, but text that is not a range of artboard numbers throws.
Document page: https://ai-scripting.docsforadobe.dev/jsobjref/Document/
- `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.
- saveAs, exportFile and app.open throw "<Class> has no option <name>" for a
property their option class's help page does not list, instead of leaving it
out. An undefined property is still left out, and PDFFileOptions also takes
its read-only typename and parent.
- The script checker no longer reports a file write for saveAs or exportFile
called on a variable holding the script's own object literal that defines
that method, with `.` or in brackets. It reports it again once the method is
assigned or deleted, the object is indexed with a computed key, or another
name may hold the object.
- The read-only file test checks the open-document grant on its own, with no
folder scope that also covers the file.
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.
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 save or export to a file that a File object holds open for writing throws "Script file is open for writing", and a command the script runs does not write such a file besides the one named (an SVG's images), so the bytes the File writes at the end of the run do not replace the output. horizontalScale and verticalScale take 1 to 776.19, since a raster export writes at least 0.01 pixels per point.
The script checker reports a document's saveAs and exportFile as file writes, and the host name check lists the save, export and open names, option classes and enumerations.
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.
Scripts save, export and open documents through Document.saveAs,
Document.exportFile and app.open, with IllustratorSaveOptions,
EPSSaveOptions, PDFSaveOptions, ExportOptionsPNG24, ExportOptionsJPEG,
ExportOptionsSVG and a PDFFileOptions record, the ExportType and related
enumerations, and app.userInteractionLevel. Each method runs file.saveAs,
document.export or document.open inside the run's transaction.
- A File argument reaches the host as its path only when the File class
made it: the path is held in an internal slot that scripts cannot set,
and a plain object that imitates a File is refused.
- Each path is checked as a File opened for reading or writing would be,
before the command runs, and the command's own reads and writes are then
held to the script's grants, leaving out the open documents' files.
A read-only file is not written over.
- Options a command maps are applied; a listed option that is not mapped
is accepted only at its documented default, and any other value, a bad
type or an out-of-range number throws before anything is written.
Without options, saveAs to a .ai, .eps or .pdf path and exportFile as
PNG24, JPEG or SVG use the defaults a new options object holds. With
pDFPreset named, a PDFSaveOptions option still at its default keeps the
preset's value. A raster export at 100% has one pixel per point.
- An export or save that writes several files, such as an SVG that writes
its embedded images beside it or an EPS with a file per artboard, checks
every path before writing the first.
Docs: docs/mcp.md, docs/target-app-parity.md.
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).