Commit Graph
34 Commits
Author SHA1 Message Date
.CooCoo dbacda04ee Merge pull request #10698 from dotCooCoo/fix/script-text-spot-color
Scripts: a text color assigned in a CMYK document is compared as the document stores it
2026-12-03 08:47:10 -08:00
dotCooCoo 626994effd Scripts: a text color assigned in a CMYK document is compared as the document stores it
Assigning fillColor or strokeColor on a text range compared the color as
given with the paint the characters have. In a CMYK document an RGB color
is stored as CMYK, so assigning the RGB color the text already stores ran
text.setRangeStyle again and recorded an undo step that changed nothing.
The comparison now converts the color through the text's own document
(its color mode and color settings), so the same assignment records no
step, and text in a background RGB document keeps an RGB color assigned
to it.

The text paint setters came with #9304.
2026-12-02 23:25:17 -08:00
dotCooCoo 3d69c8d49a Scripts: removeAll cannot leave an image first in a group named Image Trace
textFrames.removeAll() and the removeAll() of a group's pageItems,
groupItems and compoundPathItems checked only clip groups whose mask
they release. Deleting the type or art below an image in an ordinary
group named Image Trace left the image first, so the group was read as
a tracing and the image dropped out of pageItems. Both now throw
"Only Image Trace can make a tracing" and delete nothing, checking the
whole set being deleted at once.
2026-12-02 22:58:00 -08:00
dotCooCoo 72e99d1c3b Merge main into feat/scripts-layer-text-frames 2026-12-02 21:17:26 -08:00
dotCooCoo 80569dc577 Scripts: deleting a clipping path cannot make a tracing
remove(), the document's pageItems.removeAll() and textFrames.removeAll()
release the mask of a clip group whose clipping path they delete. A clip
group named Image Trace with an image next above its clipping path then
became an ordinary group named as a tracing with an image first, which
reads as a tracing. They now throw "Only Image Trace can make a tracing"
and delete nothing in that case.

docs/mcp.md names the removeAll() collections that release a mask and
the ones that refuse to delete a clipping path instead.
2026-12-02 20:24:21 -08:00
dotCooCoo 0d8a56cfde Scripts: zOrderPosition reuses the layer list; textFrames.removeAll releases masks
- Layer.zOrderPosition reads the sibling list through the cached layer
  lists, so reading it for every layer of a loop lists the layers once.
  Each read is still charged for the search through the list.
- TextFrames.removeAll releases the mask of a group or layer whose
  clipping path is one of the type objects it deletes, as
  PageItems.removeAll and remove() do, so the object above the type is
  not made the clipping path.
- GroupItems.createFromFile checks that its collection is still there
  first, so a collection whose group was deleted throws "Stale page item"
  instead of the not-available message. docs/mcp.md says so.
2026-12-02 18:44:26 -08:00
dotCooCoo ff1333c756 Merge main into feat/scripts-layer-text-frames 2026-11-30 21:15:53 -08:00
dotCooCoo b833903e70 Merge main into feat/scripts-text-paint 2026-11-30 21:03:58 -08:00
dotCooCoo fe89d3f81e Scripts: list rebuilds count against the run, a stop is not masked, bad answers throw at the call
- pageItems, pathItems and textFrames build their list of a document again
  after every edit. The rebuild walked the whole document without counting
  anything against the run, so a loop that edits and reads a collection in a
  large document did unbounded host work. A rebuilt list now counts 16 bytes
  per object (as the selection's list does) against the run's host-call
  allowance, and the path and type lists count the page items they scan.
- An edit's own ordinary error was returned ahead of a stop (an uncatchable
  Abort) from putting back the selection or switching back to the active
  document, so a script could catch it and go on. A stop now comes first.
- An answer to a waiting call that could not be read as a value (nested too
  deep, too many entries) ended the run instead of being thrown at the call.
  It is now thrown there, where the script can catch it, and a ScriptUI dialog
  that waited for the answer stops showing, as when its host call fails.
- The selection cost test also compares the host calls, under the same
  64 KiB limit for both documents.
2026-11-30 15:54:45 -08:00
dotCooCoo a447847245 Merge main into feat/scripts-layer-text-frames
Main took its own host class engine, member descriptions for reflect, a
topmost-first pageItems order, revert-aware handles and the New Document
More Settings rework. The merge keeps main's versions of crates/js and
crates/ui-egui/src/dialogs/new_document.rs and moves the branch onto them:

- The layers, groups, compound paths and artboards members carry their
  reflect types, and Layer gains toString. The Layer class from layers.rs
  replaces main's name-only Layer class.
- Layer, Layers, Artboard and container collection handles carry the
  document's revert count, so they go stale after File > Revert as page
  items do (a layer then throws "Stale page item", as main's tests expect).
- A layer's or group's pageItems and the GroupItems and CompoundPathItems
  collections read names, index and toString as the document's pageItems
  does on main.
- controlBounds keeps the branch's rule (anchors and handles of shown
  paths, a clip group's clipping path only) and main's zeros for an empty
  object.
- areaText and pathText into a layer or group keep main's threading.
- group.clipped is refused on a locked artboard, a compound path keeps
  itself when its pathItems are cleared, a path in a locked layer is not
  converted into a layer's textFrames, layers.removeAll refuses more rows
  than layer.delete takes, and a path moved into a pixel-aligned compound
  path is snapped.
- A compound path's pathItems read the typename PageItems, the class they
  are, and the TextFrames reflect types name a TextFrame from index and any
  type from parent.

Tests whose rule main changed now assert main's rule: pageItems and
textFrames list topmost first, an empty selection is an empty list, a
segment-only path is restored with no anchors (the objects stay selected,
order not asserted), and the members not available yet are swatches, not
views or layers. The branch's tests of its own host class engine in
crates/js were dropped with that engine, since main's implementation
replaces it.
2026-11-30 04:27:16 -08:00
dotCooCoo b270b62416 Scripts: answer review points on selection, opacity, text ranges and host classes
- A path saved with only segments selected is restored with its segments
  and the anchors at their ends, in its place in the selection, not with
  every anchor.
- layer.opacity compares the new value with the rounded value the getter
  reports, so 50.00009 at 50% is set.
- characters.add with a range of a removed frame throws "Stale text
  range" instead of a wrong-type error.
- `i in object` of a host class reads the indexer's raw answer and makes
  no object of it.
- define_host_classes checks the whole batch and reserves heap for the
  prototypes, constructors and member functions first, each property key
  once; a batch that fails later takes its classes and globals out again,
  so a corrected batch installs.
- The receiver and the arguments that are objects of host classes count
  toward the crossing limits, with class names counted in UTF-16 units.
- A hosted answer is checked for its limits and references, in the order
  it is written, before any object is made, so a refused answer leaves
  existing objects of host classes as they were.
- A waiting member's answer that cannot be made (an unknown class) is
  thrown at the waiting call, where the script can catch it.
- The array methods visit an object with a host indexer index by index,
  so slice and map see every index it answers.
- docs/mcp.md and docs/roadmap.md: an omitted or null presetSettings uses
  the startup preset; PLACEATEND in a clip group or a clipped layer goes
  directly above the clipping path; layer opacity reads rounded to 4
  decimals, and assigning the same opacity runs no command.
- Tests: the selection test checks the refused assignment inside the
  script, and the Missing Glyph Protection test fails when a bundled
  face is missing or falls back to another face instead of returning.
2026-11-29 22:52:46 -08:00
dotCooCoo 743e38ebf6 Scripts: path creation and paint edits replay as run; mixed picks keep their anchors
Scripted shapes record the layer they were drawn on, so replay does not
draw them behind other art or inside an isolated group. Paint edits on
objects keep the new-art defaults on replay, and a solid new-art color
copied to a path keeps its color model. An anchor picked next to a
selected segment stays selected and is listed by selectedPathPoints.
closed set on an empty path applies to its first points. Text fillColor
and strokeColor reflect as Color. Saved file.new steps keep the old row
rounding.
2026-11-29 00:08:13 -08:00
dotCooCoo 8c642f6ee0 Merge main into feat/scripts-text-paint 2026-11-28 23:07:33 -08:00
dotCooCoo d052deb5ca Merge main into feat/scripts-text-paint
Ports the PathItem, color and text members to main's reflected member form (name, HostMember, MemberInfo), and builds the text paint members on main's TextFrame members.
2026-11-28 18:46:13 -08:00
dotCooCoo 44c89a7912 Merge main into feat/scripts-api-d4b-text-styles 2026-11-28 18:11:24 -08:00
dotCooCoo 4999199bd5 Merge main into feat/scripts-api-d4c-threads-stories
# Conflicts:
#	crates/engine/src/script/dom.rs
#	crates/engine/src/script/dom/text.rs
#	crates/engine/src/tests.rs
#	crates/engine/src/tests/script_text.rs
#	crates/engine/tests/it/script_host_vs_scriptcheck.rs
#	docs/gaps.md
#	docs/mcp.md
#	docs/target-app-parity.md
2026-11-28 17:15:13 -08:00
dotCooCoo 31844b57dd Merge feat/scripts-api-d4-text into feat/scripts-api-d4b-text-styles 2026-11-28 16:13:51 -08:00
dotCooCoo 1d1c9464cf Merge main into feat/scripts-api-d4-text 2026-11-28 09:12:20 -08:00
dotCooCoo 269024e088 Merge main into feat/scripts-api-d4c-threads-stories
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.
2026-11-28 03:35:11 -08:00
dotCooCoo 2f786096a5 Scripts: path and type edits refuse objects on a locked artboard
- A point edit (anchor, leftDirection, rightDirection, setEntirePath)
  and a paint, stroke or transform change of a path on a locked
  artboard changed it, although its editable property reads false.
  They now throw "Cannot edit PathItem <id>: it is on a locked
  artboard" with nothing changed.
- A text edit, createOutline() or a point/area conversion of type on a
  locked artboard, and areaText() or pathText() given a hidden or
  locked path, now throw "Cannot edit" with nothing changed.
- A point assigned more than 4,000,000 pt from the origin was queued
  without a check and written by a later call. It now throws a range
  error when it is assigned, and the path keeps its points.
2026-11-28 00:54:54 -08:00
dotCooCoo af7bf8bc69 Scripts: textFrames.removeAll() refuses type on a locked artboard
- textFrames.removeAll() deleted a text frame on a locked artboard,
  although its editable property reads false. It now throws "cannot
  delete objects on a locked artboard" with the ids before anything is
  deleted, as pathItems.removeAll() and remove() do.
- add(contents, relativeObject) with a text range of a removed frame
  threw a type error. It now throws "Stale text range"; only an
  argument of another class gets the type error.
- The hidden or locked edit test starts each case from a fresh frame,
  and checks run sizes and justification after each refused edit. The
  add test also checks the text of the frame the script edits.
2026-11-28 00:03:32 -08:00
dotCooCoo db059c1be4 Merge main into feat/scripts-api-d4-text 2026-11-26 00:22:24 -08:00
dotCooCoo e4992df1ef Merge feat/scripts-api-d4-text into feat/scripts-api-d4c-threads-stories 2026-11-26 00:06:20 -08:00
dotCooCoo a22c730c03 Scripts: text edits refuse hidden or locked type, and lists start with the topmost frame
- Text edits (contents, added text, character and paragraph attributes)
  throw Cannot edit with nothing changed when the frame, or a layer or
  group it is in, is hidden or locked.
- Text added after a range that ends inside a character goes after that
  character, and styling an empty range changes nothing.
- Point changes that wait are written before a call that is put back on
  failure, and before the points of another path are read, so a failed
  call does not drop them.
- A new path's id is read exactly from the command's result.
- A saved or Recent preset's rows above 1,000 read as 1,000, so file.new
  takes the preset as file.newPresets lists it.
- textFrames lists type topmost first, as pageItems does on main; the
  tests and docs/mcp.md follow.
2026-11-25 21:21:28 -08:00
dotCooCoo f0c2c946b9 Scripts: keep clipping paths at the bottom and take handles into controlBounds
- node.move refuses to move the clipping path of a clip group or clipping
  layer until the mask is released, and a row moved to index 0 of a clip
  group goes directly above the clipping path. PageItem.move refuses a
  place behind a clipping path.
- controlBounds takes in the anchors and direction handles of the shown
  paths in the item; hidden paths, guides and clipped art are left out.
- Setting opacity to a value that differs from the current one only past
  the reported precision now sets it.
- Text added after a range that ends inside a character goes after the
  whole character.
- textFrames.removeAll() throws and deletes nothing when a type object is
  on a locked artboard.
- Layer lists are kept while the document is unchanged and are charged by
  the rows they look at; getByName is charged by the items it scans.
- The offset tables of text frame indexes are kept within 64 MiB per run;
  tables past it are made again when the frame is next read.
- The handles of host class objects count toward the script heap limit.
- Tests: the file-open test quotes the path as a JS string, the font
  lookup test clears the message between its two checks, and the
  collection test pins its host-call count. A new test covers a path
  node.move puts into a pixel-aligned compound path.
- Docs: docs/mcp.md, the M13 roadmap row and the scripts entries in
  docs/target-app-parity.md describe what scripts have now.
2026-11-25 03:58:43 -08:00
dotCooCoo c70eb7fc98 Scripts: character attributes set the fill and stroke of text
A text range and its characterAttributes now have fillColor, strokeColor
and strokeWeight. The colors take and give the same color objects as a
path's fill and stroke; a NoColor takes the paint away, and a color out
of range or of a kind that cannot be assigned yet throws with nothing
changed. strokeWeight is 0 to 1000 points and reads in document points
on scaled type. Setting the value a range already has records no undo
step.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-25 02:53:40 -08:00
dotCooCoo 2356ffe747 Scripts: layers and groups give their own text frames
Layer.textFrames and GroupItem.textFrames threw "not available yet".
They now give a TextFrames collection with the members of the
document's: length, [i], index, getByName, add, pointText, areaText,
pathText and removeAll. It lists the type directly in the layer or
group, topmost first, as the layer's other collections do, and new type
goes on top of the layer's or group's contents whatever the current
layer. A hidden or locked layer or group throws and changes nothing.

text.create takes a parent: a shown, unlocked layer or group that the
new type goes on top of, whatever the drawing mode. Area type and type
on a path are moved there with node.move in the same step.

Docs: docs/mcp.md, docs/target-app-parity.md.
2026-11-24 17:55:12 -08:00
dotCooCoo 1a21617e73 Scripts: text ranges take a number as contents, a new length and paragraph attributes
- `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.
2026-11-23 11:25:06 -08:00
dotCooCoo 8e23d74985 Scripts: textFrames.removeAll() refuses type on a locked artboard
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.
2026-11-22 03:42:20 -08:00
dotCooCoo d82fe4e8d9 Scripts: nextFrame, previousFrame, story and document.stories for threaded type
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.
2026-11-21 18:54:45 -08:00
dotCooCoo 69448d0c23 Scripts: character and paragraph styles for scripts
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.
2026-11-21 18:10:34 -08:00
dotCooCoo b7893282ba Scripts: text ranges made before File > Revert go stale
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.
2026-11-21 17:28:30 -08:00
dotCooCoo c691279f72 Scripts: covered text ranges hold the new text, and text members report stale ranges
- 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).
2026-11-21 14:50:30 -08:00
dotCooCoo 7c9b2a85a2 Scripts: text frames, text ranges and fonts for scripts
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.
2026-11-21 13:55:18 -08:00