BlockAPI provides methods for creating, manipulating, and querying design blocks. Design blocks are the fundamental building blocks of a scene - they represent visual elements like graphics, text, images, and containers.
API matches Web bindings: engine.block.*
Implements#
IBlockAPI
Constructors#
Block Lifecycle#
loadFromString()#
Loads blocks from a serialized string.
The blocks are not attached by default and won’t be visible until attached to a page or the scene. The UUID of the loaded blocks is replaced with a new one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
content |
string |
A string representing the given blocks. |
Returns#
Promise<number[]>
A promise that resolves with a list of handles representing the found blocks or an error.
Example#
const serializedBlocks = await engine.block.saveToString([pageBlockId]);// Later, load those blocksconst loadedBlocks = await engine.block.loadFromString(serializedBlocks);// Attach the first loaded block to the sceneengine.block.appendChild(sceneBlockId, loadedBlocks[0]);Implementation of#
IBlockAPI.loadFromStringSignature#
loadFromString(content: string): Promise<number[]>loadFromURL()#
Loads blocks from a URL.
The URL should point to a blocks file within an unzipped archive directory previously saved with block.saveToArchive.
The blocks are not attached by default and won’t be visible until attached to a page or the scene.
The UUID of the loaded blocks is replaced with a new one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
url |
string |
The URL to the blocks file |
options? |
AbortOptions |
An abortSignal that stops the load. The load then creates no block. |
Returns#
Promise<number[]>
A promise that resolves with a list of block handles
Example#
// Load blocks from a URLconst loadedBlocks = await engine.block.loadFromURL('https://example.com/blocks.blocks');// Attach the first loaded block to the sceneengine.block.appendChild(sceneBlockId, loadedBlocks[0]);Implementation of#
IBlockAPI.loadFromURLSignature#
loadFromURL(url: string, options?: AbortOptions): Promise<number[]>Block Export#
export()#
Exports a design block to a Blob.
The export of a page slice gives the part of its page inside the page slice, with the bleed of the page on
all four sides. At a fold, that bleed shows the content of the page slice beside it. The export of a hidden
page slice shows it and its content.
Performs an internal update to resolve the final layout for the blocks.
A page with playback/coverTimeEnabled set exports at its playback/coverTime, and its playback time
does not change. An export of a scene shows each page at its own time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block element to export. |
options? |
ExportOptions |
The options for exporting the block type, including mime type and export settings. |
Returns#
Promise<Blob>
A promise that resolves with the exported image or is rejected with an error.
Call Signature#
export( block, mimeType?,options?): Promise<Blob>;Exports a design block to a Blob. The export of a page slice gives the part of its page inside the page slice, with the bleed of the page on all four sides. At a fold, that bleed shows the content of the page slice beside it. The export of a hidden page slice shows it and its content.
Performs an internal update to resolve the final layout for the blocks.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block element to export. |
mimeType? |
"application/pdf" |
|
options? |
Omit<ExportOptions, "mimeType"> |
The options for exporting the block type |
Returns#
Promise<Blob>
A promise that resolves with the exported image or is rejected with an error.
Deprecated#
Use the new export signature instead
Example#
// Before migrationconst blob = await engine.block.export(blockId, MimeType.Png, { pngCompressionLevel: 5 })// After migrationconst blob = await engine.block.export(blockId, { mimeType: 'image/png', pngCompressionLevel: 5 })Signatures#
export(block: number, options?: ExportOptions): Promise<Blob>export(block: number, mimeType?: "application/pdf" | "application/octet-stream" | ImageMimeType, options?: Omit<ExportOptions, "mimeType">): Promise<Blob>exportPreview()#
Exports a small image of a block to show in your app. A preview does not count as an export.
The image is always WebP at quality 0.8 and keeps the block’s aspect ratio. A block larger than
262,144 pixels (512 × 512) in area is scaled down to fit. For a video, the preview is one still
frame. Use export for a file that you deliver.
Performs an internal update to resolve the final layout for the blocks. Will not complete as long as assets are in a pending state; asset loading progresses during engine updates.
A page with playback/coverTimeEnabled set shows its playback/coverTime, and its playback time
does not change.
A preview of a scene shows each page at its own time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block element to preview. |
Returns#
Promise<Blob>
A promise that resolves with the WebP image or is rejected with an error.
Signature#
exportPreview(block: number): Promise<Blob>exportToBuffer()#
Exports a design block as export does, but resolves with the encoded bytes instead of a Blob.
export does, but resolves with the encoded bytes instead of a Blob.const bytes = await engine.block.exportToBuffer(page, 'image/png');await fs.promises.writeFile('page.png', bytes);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block to export. |
mimeType |
string |
The MIME type of the output file. |
options? |
ExportOptions |
The export options, as export takes them. |
Returns#
Promise<Uint8Array<ArrayBufferLike>>
A promise that resolves with the encoded file.
Signature#
exportToBuffer(block: number, mimeType: string, options?: ExportOptions): Promise<Uint8Array<ArrayBufferLike>>exportWithColorMask()#
Exports a design block and a color mask to two separate buffers.
Removes all pixels that exactly match the given RGB color and replaces them with transparency. The output includes two buffers: the masked image and the mask itself.
A page with playback/coverTimeEnabled set exports at its playback/coverTime, and its playback time
does not change.
An export of a scene shows each page at its own time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block element to export. |
maskColorR |
number |
The red component of the special color mask color (0-1). |
maskColorG |
number |
The green component of the special color mask color (0-1). |
maskColorB |
number |
The blue component of the special color mask color (0-1). |
options? |
ExportOptions |
The options for exporting the block type. |
Returns#
Promise<Blob[]>
A promise that resolves with an array of two Uint8Arrays: [image, mask].
Call Signature#
exportWithColorMask( block, mimeType, maskColorR, maskColorG, maskColorB,options?): Promise<Blob[]>;Exports a design block and a color mask to two separate Blobs.
Performs an internal update to resolve the final layout for the blocks. Removes all pixels that exactly match the given RGB color and replaces them with transparency. The output includes two files: the masked image and the mask itself.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block element to export. |
mimeType |
"application/pdf" |
|
maskColorR |
number |
The red component of the special color mask color. |
maskColorG |
number |
The green component of the special color mask color. |
maskColorB |
number |
The blue component of the special color mask color. |
options? |
Omit<ExportOptions, "mimeType"> |
The options for exporting the block type. onProgress is ignored: a color mask export reports no progress. |
Returns#
Promise<Blob[]>
A promise that resolves with an array of the exported image and mask or is rejected with an error.
Deprecated#
Use the new exportWithColorMask signature instead
Example#
// Before migrationconst blob = await engine.block.exportWithColorMask( blockId, MimeType.Png, 0.5, 0, 0, { pngCompressionLevel: 5 });// After migrationconst blob = await engine.block.exportWithColorMask( blockId, 0.5, 0, 0, { mimeType: 'image/png', pngCompressionLevel: 5 });Signatures#
exportWithColorMask(block: number, maskColorR: number, maskColorG: number, maskColorB: number, options?: ExportOptions): Promise<Blob[]>exportWithColorMask(block: number, mimeType: "application/pdf" | "application/octet-stream" | ImageMimeType, maskColorR: number, maskColorG: number, maskColorB: number, options?: Omit<ExportOptions, "mimeType">): Promise<Blob[]>exportVideo()#
Exports a design block as a video file.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The page or the scene to export. A scene plays its pages one after the other, in the order of scene.getPages, each for its own duration. A page with a duration of zero does not appear. A hidden page does not appear either. The pages must have the same size, otherwise the export fails. |
options? |
VideoExportOptions |
The options for exporting the video, including mime type, h264 profile, level, bitrate, time offset, duration, framerate, target width and height. |
Returns#
Promise<Blob>
A promise that resolves with a video blob or is rejected with an error.
Note#
MP4 exports embed a PNG cover at the page cover time when playback/coverTimeEnabled is true, else at
the page playback position. coverTimeOffset overrides both.
An MP4 export of a scene uses its first frame as the cover.
Note: The export will run across multiple iterations of the update loop. In each iteration a frame is scheduled for encoding.
Example#
const page = engine.block.create('page');// Set up a progress tracking functionconst progressTracker = (renderedFrames, encodedFrames, totalFrames) => { console.log(`Progress: ${Math.round((encodedFrames / totalFrames) * 100)}%`);};const videoOptions = { framerate: 30, duration: 5 };const videoBlob = await engine.block.exportVideo(page, MimeType.Mp4, progressTracker, videoOptions);Call Signature#
exportVideo( block, mimeType?, progressCallback?,options?): Promise<Blob>;Exports a design block as a video file.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The page or the scene to export. A scene plays its pages one after the other, in the order of scene.getPages, each for its own duration. A page with a duration of zero does not appear. A hidden page does not appear either. The pages must have the same size, otherwise the export fails. |
mimeType? |
string |
The MIME type of the output video file. |
progressCallback? |
(numberOfRenderedFrames, numberOfEncodedFrames, totalNumberOfFrames) => void |
A callback which reports on the progress of the export. |
options? |
Omit<VideoExportOptions, "mimeType" |
"onProgress"> |
Returns#
Promise<Blob>
A promise that resolves with a video blob or is rejected with an error.
Note#
MP4 exports embed a PNG cover at the page cover time when playback/coverTimeEnabled is true, else at
the page playback position. coverTimeOffset overrides both.
An MP4 export of a scene uses its first frame as the cover.
Note: The export will run across multiple iterations of the update loop. In each iteration a frame is scheduled for encoding.
Deprecated#
Use the new exportVideo signature instead
Example#
// Before migrationconst blob = await engine.block.exportVideo(blockId, 'video/mp4', handleProgress, { targetWidth: 1920, targetHeight: 1080,})// After migrationconst blob = await engine.block.exportVideo(blockId, { mimeType: 'video/mp4', progressCallback: handleProgress, targetWidth: 1920, targetHeight: 1080,})Signatures#
exportVideo(block: number, options?: VideoExportOptions): Promise<Blob>exportVideo(block: number, mimeType?: string, progressCallback?: (numberOfRenderedFrames: number, numberOfEncodedFrames: number, totalNumberOfFrames: number) => void, options?: Omit<VideoExportOptions, "mimeType" | "onProgress">): Promise<Blob>exportVideoToBuffer()#
Exports a design block as a video file, as exportVideo does, but resolves with the encoded bytes instead of
a Blob.
exportVideo does, but resolves with the encoded bytes instead of
a Blob.const bytes = await engine.block.exportVideoToBuffer(page, 'video/mp4');await fs.promises.writeFile('page.mp4', bytes);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The page or the scene to export. |
mimeType |
string |
The MIME type of the output video file. |
options? |
VideoExportOptions |
The export options, as exportVideo takes them. |
progressCallback? |
(rendered, encoded, total) => void |
Called with the number of rendered frames, encoded frames and total frames. |
Returns#
Promise<Uint8Array<ArrayBufferLike>>
A promise that resolves with the encoded video.
Signature#
exportVideoToBuffer(block: number, mimeType: string, options?: VideoExportOptions, progressCallback?: (rendered: number, encoded: number, total: number) => void): Promise<Uint8Array<ArrayBufferLike>>exportAudioToBuffer()#
Exports a design block as an audio file, as exportAudio does, but resolves with the encoded bytes instead of
a Blob.
exportAudio does, but resolves with the encoded bytes instead of
a Blob.const bytes = await engine.block.exportAudioToBuffer(page, 'audio/wav');await fs.promises.writeFile('page.wav', bytes);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block to export. |
mimeType |
string |
The MIME type of the output audio file. |
options? |
AudioExportOptions |
The export options, as exportAudio takes them. |
Returns#
Promise<Uint8Array<ArrayBufferLike>>
A promise that resolves with the encoded audio.
Signature#
exportAudioToBuffer(block: number, mimeType: string, options?: AudioExportOptions): Promise<Uint8Array<ArrayBufferLike>>Block Layout#
getPositionX()#
Gets the X position of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The value of the x position.
Implementation of#
IBlockAPI.getPositionXSignature#
getPositionX(block: number): numbergetPositionY()#
Gets the Y position of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The value of the y position.
Implementation of#
IBlockAPI.getPositionYSignature#
getPositionY(block: number): numbergetPositionXMode()#
Gets the mode for the block’s X position.
On a page slice the mode is ‘Auto’, because the page sets its position.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
"Auto" | "Absolute" | "Percent"
The current mode for the x position: ‘Absolute’ or ‘Percent’.
Implementation of#
IBlockAPI.getPositionXModeSignature#
getPositionXMode(block: number): "Auto" | "Absolute" | "Percent"setPositionXMode()#
Sets the mode for the block’s X position.
engine.block.setPositionXMode(block, 'Percent');A page slice takes its position from its page, so the call fails with BLOCK.POSITION_PARENT_CONTROLLED on one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
mode |
"Auto" |
"Absolute" |
Returns#
void
Implementation of#
IBlockAPI.setPositionXModeSignature#
setPositionXMode(block: number, mode: "Auto" | "Absolute" | "Percent"): voidgetPositionYMode()#
Gets the mode for the block’s Y position.
On a page slice the mode is ‘Auto’, because the page sets its position.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
"Auto" | "Absolute" | "Percent"
The current mode for the y position: ‘Absolute’ or ‘Percent’.
Implementation of#
IBlockAPI.getPositionYModeSignature#
getPositionYMode(block: number): "Auto" | "Absolute" | "Percent"setPositionYMode()#
Sets the mode for the block’s Y position.
engine.block.setPositionYMode(block, 'Absolute');A page slice takes its position from its page, so the call fails with BLOCK.POSITION_PARENT_CONTROLLED on one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
mode |
"Auto" |
"Absolute" |
Returns#
void
Implementation of#
IBlockAPI.setPositionYModeSignature#
setPositionYMode(block: number, mode: "Auto" | "Absolute" | "Percent"): voidgetWidth()#
Gets the width of a block in the current width mode.
const width = engine.block.getWidth(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The value of the block’s width.
Implementation of#
IBlockAPI.getWidthSignature#
getWidth(block: number): numbergetWidthMode()#
Gets the mode for the block’s width.
const widthMode = engine.block.getWidthMode(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
"Auto" | "Absolute" | "Percent"
The current mode for the width: ‘Absolute’, ‘Percent’ or ‘Auto’.
Implementation of#
IBlockAPI.getWidthModeSignature#
getWidthMode(block: number): "Auto" | "Absolute" | "Percent"getHeight()#
Gets the height of a block in the current height mode.
const height = engine.block.getHeight(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The value of the block’s height.
Implementation of#
IBlockAPI.getHeightSignature#
getHeight(block: number): numbergetHeightMode()#
Gets the mode for the block’s height.
const heightMode = engine.block.getHeightMode(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
"Auto" | "Absolute" | "Percent"
The current mode for the height: ‘Absolute’, ‘Percent’ or ‘Auto’.
Implementation of#
IBlockAPI.getHeightModeSignature#
getHeightMode(block: number): "Auto" | "Absolute" | "Percent"getRotation()#
Gets the rotation of a block in the scene’s angle unit (radians by default).
The angle unit is configured via engine.scene.setAngleUnit().
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The block’s rotation around its center in the scene’s angle unit (radians by default).
Implementation of#
IBlockAPI.getRotationSignature#
getRotation(block: number): numbersetRotation()#
Sets the rotation of a block in the scene’s angle unit (radians by default).
Rotation is applied around the block’s center. The angle unit is configured via
engine.scene.setAngleUnit().
With the setting features/implicitUpdatesEnabled off, the call updates only when a block that
it reads has no layout yet, as right after an undo.
It reads the block, the members of a group and each transform parent. That update also lays out
every other pending change.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
value |
number |
The new rotation in the scene’s angle unit (radians by default). |
Returns#
void
Implementation of#
IBlockAPI.setRotationSignature#
setRotation(block: number, value: number): voidscale()#
Scales a block and its children proportionally.
This updates the position, size and style properties (e.g. stroke width) of the block and its children around the specified anchor point.
With the setting features/implicitUpdatesEnabled off, the call updates only when a block that
it reads has no layout yet, as right after an undo.
It reads the block, every child of it and each transform parent. That update also lays out
every other pending change.
// Scale a block to double its size, anchored at the center.engine.block.scale(block, 2.0, 0.5, 0.5);Scaling a page slice changes its size, and the page places its page slices again.
A scale of 0 or less on a page slice fails with BLOCK.PAGE_SLICE_SIZE_INVALID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block that should be scaled. |
scale |
number |
The scale factor to be applied to the current properties of the block. |
anchorX? |
number |
The relative position along the width of the block around which the scaling should occur (0=left, 0.5=center, 1=right). Defaults to 0. |
anchorY? |
number |
The relative position along the height of the block around which the scaling should occur (0=top, 0.5=center, 1=bottom). Defaults to 0. |
Returns#
void
Signature#
scale(block: number, scale: number, anchorX?: number, anchorY?: number): voidfillParent()#
Resizes and positions a block to fill its parent.
The crop values of the block are reset if it can be cropped. A block that follows a transform parent stops following it.
A page slice takes its position from its page, so the call fails with BLOCK.POSITION_PARENT_CONTROLLED on one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block that should fill its parent. |
Returns#
void
Signature#
fillParent(block: number): voidgetScreenSpaceBoundingBoxXYWH()#
Gets the screen-space bounding box for a set of blocks.
const boundingBox = engine.block.getScreenSpaceBoundingBoxXYWH([block]);Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
The block to query. |
Returns#
XYWHThe position and size of the bounding box.
Implementation of#
IBlockAPI.getScreenSpaceBoundingBoxXYWHSignature#
getScreenSpaceBoundingBoxXYWH(blocks: number[]): XYWHisLineOrigin()#
Checks whether a graphic block originated as a line shape. Survives the
line’s conversion to a vector path during vector-edit; resets only when
the shape is replaced by a non-line shape via setShape.
setShape.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if the block originated as a line shape, false otherwise.
Implementation of#
IBlockAPI.isLineOriginSignature#
isLineOrigin(block: number): booleanbringToFront()#
Brings a block to the front of its siblings.
Updates the sorting order so that the given block has the highest sorting order.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The id of the block to bring to the front. |
Returns#
void
Signature#
bringToFront(block: number): voidsendToBack()#
Sends a block to the back of its siblings.
Updates the sorting order so that the given block has the lowest sorting order.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The id of the block to send to the back. |
Returns#
void
Signature#
sendToBack(block: number): voidbringForward()#
Brings a block one layer forward.
Updates the sorting order to be higher than its next sibling.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The id of the block to bring forward. |
Returns#
void
Signature#
bringForward(block: number): voidsendBackward()#
Sends a block one layer backward.
Updates the sorting order to be lower than its previous sibling.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The id of the block to send backward. |
Returns#
void
Signature#
sendBackward(block: number): voidsetAlwaysOnTop()#
Sets a block to always be rendered on top of its siblings.
If true, this block’s sorting order is automatically adjusted to be higher than all other siblings without this property.
A page slice fails with BLOCK.TYPE_CANNOT_BE_ARRANGED, because its place in the page is its reading order.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
the block to update. |
enabled |
boolean |
whether the block shall be always-on-top. |
Returns#
void
Signature#
setAlwaysOnTop(block: number, enabled: boolean): voidsetAlwaysOnBottom()#
Sets a block to always be rendered below its siblings.
If true, this block’s sorting order is automatically adjusted to be lower than all other siblings without this property.
A page slice fails with BLOCK.TYPE_CANNOT_BE_ARRANGED, because its place in the page is its reading order.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
the block to update. |
enabled |
boolean |
whether the block shall always be below its siblings. |
Returns#
void
Signature#
setAlwaysOnBottom(block: number, enabled: boolean): voidisAlwaysOnTop()#
Checks if a block is set to always be on top.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
the block to query. |
Returns#
boolean
true if the block is set to be always-on-top, false otherwise.
Signature#
isAlwaysOnTop(block: number): booleanisAlwaysOnBottom()#
Checks if a block is set to always be on the bottom.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
the block to query. |
Returns#
boolean
true if the block is set to be always-on-bottom, false otherwise.
Signature#
isAlwaysOnBottom(block: number): booleanalignHorizontally()#
Aligns blocks horizontally.
Aligns multiple blocks within their bounding box or a single block to its parent.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
A non-empty array of block ids. |
alignment |
HorizontalTextAlignment |
How they should be aligned: ‘Left’, ‘Right’, or ‘Center’. |
Returns#
void
Signature#
alignHorizontally(blocks: number[], alignment: TextHorizontalAlignment): voidalignVertically()#
Aligns blocks vertically.
Aligns multiple blocks within their bounding box or a single block to its parent.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
A non-empty array of block ids. |
alignment |
VerticalTextAlignment |
How they should be aligned: ‘Top’, ‘Bottom’, or ‘Center’. |
Returns#
void
Signature#
alignVertically(blocks: number[], alignment: TextVerticalAlignment): voiddistributeHorizontally()#
Distributes blocks horizontally with even spacing.
Distributes multiple blocks horizontally within their bounding box.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
A non-empty array of block ids. |
Returns#
void
Signature#
distributeHorizontally(blocks: number[]): voiddistributeVertically()#
Distributes blocks vertically with even spacing.
Distributes multiple blocks vertically within their bounding box.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
A non-empty array of block ids. |
Returns#
void
Signature#
distributeVertically(blocks: number[]): voidisTransformLocked()#
Gets the transform-locked state of a block.
If true, the block’s transform can’t be changed. The lock covers the static transform: keyframe tracks on the position, rotation, size, scale, anchor or skew still animate a locked block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if transform locked, false otherwise.
Signature#
isTransformLocked(block: number): booleansetTransformLocked()#
Sets the transform-locked state of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
locked |
boolean |
Whether the block’s transform should be locked. |
Returns#
void
Signature#
setTransformLocked(block: number, locked: boolean): voidgetFrameX()#
Gets the final calculated X position of a block’s frame.
The position is only available after an internal update loop.
const frameX = engine.block.getFrameX(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The layout position on the x-axis.
Signature#
getFrameX(block: number): numbergetFrameY()#
Gets the final calculated Y position of a block’s frame.
The position is only available after an internal update loop.
const frameY = engine.block.getFrameY(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The layout position on the y-axis.
Signature#
getFrameY(block: number): numbergetFrameWidth()#
Gets the final calculated width of a block’s frame.
The width is only available after an internal update loop.
const frameWidth = engine.block.getFrameWidth(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The layout width.
Signature#
getFrameWidth(block: number): numbergetFrameHeight()#
Gets the final calculated height of a block’s frame.
The height is only available after an internal update loop.
const frameHeight = engine.block.getFrameHeight(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The layout height.
Signature#
getFrameHeight(block: number): numberBlock Selection & Visibility#
isVisible()#
Gets the visibility state of a block.
Reports the visibility you set, not the current view. A page that single page mode
takes out of view stays visible; use scene.getCurrentPages to read the view.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if visible, false otherwise.
Implementation of#
IBlockAPI.isVisibleSignature#
isVisible(block: number): booleansetVisible()#
Sets the visibility state of a block.
A hidden page slice hides the blocks that it owns, as a hidden parent hides its children. They show in no canvas and no export, and take no hit. It keeps its room in the page. The blocks keep their own visibility.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
visible |
boolean |
Whether the block shall be visible. |
Returns#
void
Implementation of#
IBlockAPI.setVisibleSignature#
setVisible(block: number, visible: boolean): voidsetSelected()#
Sets the selection state of a block.
A page slice and its page are never selected together: selecting one deselects the other.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
selected |
boolean |
Whether or not the block should be selected. |
Returns#
void
Implementation of#
IBlockAPI.setSelectedSignature#
setSelected(block: number, selected: boolean): voidisSelected()#
Gets the selection state of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if the block is selected, false otherwise.
Implementation of#
IBlockAPI.isSelectedSignature#
isSelected(block: number): booleanselect()#
Selects a block, deselecting all others.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to be selected. |
Returns#
void
Implementation of#
IBlockAPI.selectSignature#
select(block: number): voidBlock Appearance#
getFlipHorizontal()#
Gets the horizontal flip state of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
A boolean indicating whether the block is flipped horizontally.
Signature#
getFlipHorizontal(block: number): booleangetFlipVertical()#
Gets the vertical flip state of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
A boolean indicating whether the block is flipped vertically.
Signature#
getFlipVertical(block: number): booleansetFlipHorizontal()#
Sets the horizontal flip state of a block.
With the setting features/implicitUpdatesEnabled off, the call updates only when a block that
it reads has no layout yet, as right after an undo.
It reads the block, the members of a group and each transform parent. That update also lays out
every other pending change.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
flip |
boolean |
If the flip should be enabled. |
Returns#
void
Signature#
setFlipHorizontal(block: number, flip: boolean): voidsetFlipVertical()#
Sets the vertical flip state of a block.
With the setting features/implicitUpdatesEnabled off, the call updates only when a block that
it reads has no layout yet, as right after an undo.
It reads the block, the members of a group and each transform parent. That update also lays out
every other pending change.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
flip |
boolean |
If the flip should be enabled. |
Returns#
void
Signature#
setFlipVertical(block: number, flip: boolean): voidsupportsBlendMode()#
Checks if a block supports blend modes.
False for a page slice, which draws no blend mode.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports blend modes.
Implementation of#
IBlockAPI.supportsBlendModeSignature#
supportsBlendMode(block: number): booleangetBlendMode()#
Gets the blend mode of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose blend mode should be queried. |
Returns#
BlendMode
The blend mode.
Implementation of#
IBlockAPI.getBlendModeSignature#
getBlendMode(block: number): BlendModesetBlendMode()#
Sets the blend mode of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose blend mode should be set. |
mode |
BlendMode |
The blend mode to be set. |
Returns#
void
Implementation of#
IBlockAPI.setBlendModeSignature#
setBlendMode(block: number, mode: BlendMode): voidsupportsOpacity()#
Checks if a block supports opacity.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports opacity.
Implementation of#
IBlockAPI.supportsOpacitySignature#
supportsOpacity(block: number): booleangetOpacity()#
Gets the opacity of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose opacity should be queried. |
Returns#
number
The opacity value.
Implementation of#
IBlockAPI.getOpacitySignature#
getOpacity(block: number): numbersetOpacity()#
Sets the opacity of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose opacity should be set. |
opacity |
number |
The opacity to be set. The valid range is 0 to 1. |
Returns#
void
Implementation of#
IBlockAPI.setOpacitySignature#
setOpacity(block: number, opacity: number): voidisClipped()#
Gets the clipped state of a block.
If true, the block should clip its contents to its frame.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if clipped, false otherwise.
Implementation of#
IBlockAPI.isClippedSignature#
isClipped(block: number): booleansetClipped()#
Sets the clipped state of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
clipped |
boolean |
Whether the block should clips its contents to its frame. |
Returns#
void
Implementation of#
IBlockAPI.setClippedSignature#
setClipped(block: number, clipped: boolean): voidgetMatte()#
Gets the matte of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. Graphic, text and group blocks are supported. |
Returns#
BlockMatteThe matte source and mode, or null when the block has no matte.
Implementation of#
IBlockAPI.getMatteSignature#
getMatte(block: number): BlockMattesupportsBackgroundColor()#
Checks if a block supports a background color.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports a background color.
Signature#
supportsBackgroundColor(block: number): booleanisBackgroundColorEnabled()#
Checks if the background of a block is enabled.
const backgroundColorIsEnabled = engine.block.isBackgroundColorEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose background state should be queried. |
Returns#
boolean
True, if background is enabled.
Signature#
isBackgroundColorEnabled(block: number): booleansetBackgroundColorEnabled()#
Enables or disables the background of a block.
engine.block.setBackgroundColorEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose background should be enabled or disabled. |
enabled |
boolean |
If true, the background will be enabled. |
Returns#
void
Signature#
setBackgroundColorEnabled(block: number, enabled: boolean): voidBlock Fills#
supportsFill()#
Checks if a block supports a fill.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports a fill.
Implementation of#
IBlockAPI.supportsFillSignature#
supportsFill(block: number): booleangetFill()#
Gets the fill block attached to a given block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose fill block should be returned. |
Returns#
number
The block that currently defines the given block’s fill, or an invalid block if unset.
Check the result with isValid.
Implementation of#
IBlockAPI.getFillSignature#
getFill(block: number): numbersetFill()#
Sets the fill block for a given block.
The previous fill block is not destroyed automatically.
On a page slice, the call also enables the fill, because a new page slice has its fill disabled.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose fill should be changed. |
fill |
number |
The new fill block. |
Returns#
void
Implementation of#
IBlockAPI.setFillSignature#
setFill(block: number, fill: number): voidisFillEnabled()#
Checks if the fill of a block is enabled.
engine.block.isFillEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose fill state should be queried. |
Returns#
boolean
The fill state.
Implementation of#
IBlockAPI.isFillEnabledSignature#
isFillEnabled(block: number): booleansetFillEnabled()#
Enables or disables the fill of a block.
engine.block.setFillEnabled(block, false);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose fill should be enabled or disabled. |
enabled |
boolean |
If true, the fill will be enabled. |
Returns#
void
Implementation of#
IBlockAPI.setFillEnabledSignature#
setFillEnabled(block: number, enabled: boolean): voidgetFillSolidColor()#
Gets the solid fill color of a block as RGBA values.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose fill color should be queried. |
Returns#
RGBAThe fill color.
Implementation of#
IBlockAPI.getFillSolidColorSignature#
getFillSolidColor(block: number): RGBAsetFillSolidColor()#
Sets the solid fill color of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose fill color should be set. |
r |
number |
The red color component in the range of 0 to 1. |
g |
number |
The green color component in the range of 0 to 1. |
b |
number |
The blue color component in the range of 0 to 1. |
a? |
number |
The alpha color component in the range of 0 to 1. Defaults to 1. |
Returns#
void
Implementation of#
IBlockAPI.setFillSolidColorSignature#
setFillSolidColor(block: number, r: number, g: number, b: number, a?: number): voidgetGradientColorStops()#
Gets the color stops from a gradient property.
engine.block.getGradientColorStops(gradientFill, 'fill/gradient/colors');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
string |
The name of the property to query. |
Returns#
The gradient colors.
Implementation of#
IBlockAPI.getGradientColorStopsSignature#
getGradientColorStops(block: number, property: string): GradientColorStop[]setGradientColorStops()#
Sets the color stops for a gradient property.
engine.block.setGradientColorStops(gradientFill, 'fill/gradient/colors', [ { color: { r: 1.0, g: 0.8, b: 0.2, a: 1.0 }, stop: 0 }, { color: { r: 0.3, g: 0.4, b: 0.7, a: 1.0 }, stop: 1 }]);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
string |
The name of the property to set, e.g. ‘fill/gradient/colors’. |
stops |
GradientColorStop[] |
An array of gradient color stops. |
Returns#
void
Implementation of#
IBlockAPI.setGradientColorStopsSignature#
setGradientColorStops(block: number, property: string, stops: GradientColorStop[]): voidsupportsContentFillMode()#
Checks if a block supports content fill modes.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block has a content fill mode.
Signature#
supportsContentFillMode(block: number): booleangetContentFillMode()#
Gets the content fill mode of a block.
engine.block.getContentFillMode(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
"Crop" | "Cover" | "Contain"
The current mode: ‘Crop’, ‘Cover’ or ‘Contain’.
Signature#
getContentFillMode(block: number): "Crop" | "Cover" | "Contain"setContentFillMode()#
Sets the content fill mode of a block.
engine.block.setContentFillMode(image, 'Cover');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
mode |
"Crop" |
"Cover" |
Returns#
void
Signature#
setContentFillMode(block: number, mode: "Crop" | "Cover" | "Contain"): voidsetContentFillHorizontalAlignment()#
Sets the horizontal alignment of the content fill within a block.
Only affects ‘Contain’ and ‘Cover’ fill modes; has no visible effect in ‘Crop’ mode, where the user positions the content explicitly.
engine.block.setContentFillHorizontalAlignment(image, 'Left');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
alignment |
HorizontalContentFillAlignment |
The horizontal alignment: ‘Left’, ‘Center’ or ‘Right’. |
Returns#
void
Implementation of#
IBlockAPI.setContentFillHorizontalAlignmentSignature#
setContentFillHorizontalAlignment(block: number, alignment: HorizontalContentFillAlignment): voidgetContentFillHorizontalAlignment()#
Gets the horizontal alignment of the content fill within a block.
engine.block.getContentFillHorizontalAlignment(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
HorizontalContentFillAlignment
The current alignment: ‘Left’, ‘Center’ or ‘Right’.
Implementation of#
IBlockAPI.getContentFillHorizontalAlignmentSignature#
getContentFillHorizontalAlignment(block: number): HorizontalContentFillAlignmentsetContentFillVerticalAlignment()#
Sets the vertical alignment of the content fill within a block.
Only affects ‘Contain’ and ‘Cover’ fill modes; has no visible effect in ‘Crop’ mode, where the user positions the content explicitly.
engine.block.setContentFillVerticalAlignment(image, 'Top');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
alignment |
VerticalContentFillAlignment |
The vertical alignment: ‘Top’, ‘Center’ or ‘Bottom’. |
Returns#
void
Implementation of#
IBlockAPI.setContentFillVerticalAlignmentSignature#
setContentFillVerticalAlignment(block: number, alignment: VerticalContentFillAlignment): voidgetContentFillVerticalAlignment()#
Gets the vertical alignment of the content fill within a block.
engine.block.getContentFillVerticalAlignment(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
VerticalContentFillAlignment
The current alignment: ‘Top’, ‘Center’ or ‘Bottom’.
Implementation of#
IBlockAPI.getContentFillVerticalAlignmentSignature#
getContentFillVerticalAlignment(block: number): VerticalContentFillAlignmentgetSourceSet()#
Gets the source set from a block property.
const sourceSet = engine.block.getSourceSet(imageFill, 'fill/image/sourceSet');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block that should be queried. |
property |
SourceSetPropertyName |
The name of the property to query, e.g. ‘fill/image/sourceSet’. |
Returns#
Source[]
The block’s source set.
Implementation of#
IBlockAPI.getSourceSetSignature#
getSourceSet(block: number, property: SourceSetPropertyName): Source[]setSourceSet()#
Sets the source set for a block property.
The crop and content fill mode of the associated block will be reset to default values.
engine.block.setSourceSet(imageFill, 'fill/image/sourceSet', [{ uri: 'https://example.com/sample.jpg', width: 800, height: 600}]);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
SourceSetPropertyName |
The name of the property to set. |
sources |
Source[] |
The block’s new source set. |
Returns#
void
Implementation of#
IBlockAPI.setSourceSetSignature#
setSourceSet(block: number, property: SourceSetPropertyName, sources: Source[]): voidaddImageFileURIToSourceSet()#
Adds an image file URI to a source set property.
If an image with the same width already exists in the source set, it will be replaced.
await engine.block.addImageFileURIToSourceSet(imageFill, 'fill/image/sourceSet', 'https://example.com/sample.jpg');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
property |
SourceSetPropertyName |
The name of the property to modify. |
uri |
string |
The source to add to the source set. |
options? |
AbortOptions |
An abortSignal that stops the download of the image. The source set stays unchanged then. |
Returns#
Promise<void>
A promise that resolves when the operation is complete.
Implementation of#
IBlockAPI.addImageFileURIToSourceSetSignature#
addImageFileURIToSourceSet(block: number, property: SourceSetPropertyName, uri: string, options?: AbortOptions): Promise<void>addVideoFileURIToSourceSet()#
Adds a video file URI to a source set property.
If a video with the same width already exists in the source set, it will be replaced.
await engine.block.addVideoFileURIToSourceSet(videoFill, 'fill/video/sourceSet', 'https://example.com/sample.mp4');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
property |
SourceSetPropertyName |
The name of the property to modify. |
uri |
string |
The source to add to the source set. |
options? |
AbortOptions |
An abortSignal that stops the download of the video. The source set stays unchanged then. |
Returns#
Promise<void>
A promise that resolves when the operation is complete.
Implementation of#
IBlockAPI.addVideoFileURIToSourceSetSignature#
addVideoFileURIToSourceSet(block: number, property: SourceSetPropertyName, uri: string, options?: AbortOptions): Promise<void>getFillOverprint()#
Queries whether the fill of a block is marked as overprint for PDF export.
const overprint = engine.block.getFillOverprint(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block whose fill overprint flag should be queried. |
Returns#
boolean
The fill overprint flag.
Signature#
getFillOverprint(id: number): booleansetFillOverprint()#
Marks the fill of a block as overprint for PDF export.
The flag is only honored by the PDF writer when the fill uses a spot color (Separation/DeviceN). For process-color fills it is a silent no-op. On-screen rendering ignores the flag.
engine.block.setFillOverprint(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block whose fill overprint flag should be set. |
overprint |
boolean |
If true, the fill is marked as overprint in exported PDFs. |
Returns#
void
Signature#
setFillOverprint(id: number, overprint: boolean): voidBlock Shapes#
supportsShape()#
Checks if a block supports having a shape.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block has a shape property, an error otherwise.
Signature#
supportsShape(block: number): booleangetShape()#
Gets the shape block attached to a given block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose shape block should be returned. |
Returns#
number
The block that currently defines the given block’s shape, or an invalid block if unset.
Check the result with isValid.
Signature#
getShape(block: number): numbergetSubshapes()#
Gets the subshapes of a compound shape, in the order in which they combine.
const compound = engine.block.createShape('compound');engine.block.appendSubshape(compound, engine.block.createShape('rect'));const subshapes = engine.block.getSubshapes(compound);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The compound shape block to query. |
Returns#
number[]
The subshape blocks.
Signature#
getSubshapes(block: number): number[]removeSubshape()#
Removes the subshape at a given index from a compound shape. The subshape is not destroyed.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The compound shape block. |
index |
number |
The index of the subshape to remove. |
Returns#
void
Signature#
removeSubshape(block: number, index: number): voidBlock Text#
replaceText()#
Replaces a range of text in a text block.
engine.block.replaceText(text, 'Hello World');engine.block.replaceText(text, 'Alex', 6, 11);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block into which to insert the given text. |
text |
string |
The text which should replace the selected range in the block. |
from? |
number |
The start index of the UTF-16 range to replace. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range to replace. Defaults to the end of the current selection or text. |
Returns#
void
Implementation of#
IBlockAPI.replaceTextSignature#
replaceText(block: number, text: string, from?: number, to?: number): voidremoveText()#
Removes a range of text from a text block.
engine.block.removeText(text, 0, 6);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block from which the selected text should be removed. |
from? |
number |
The start index of the UTF-16 range to remove. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range to remove. Defaults to the end of the current selection or text. |
Returns#
void
Implementation of#
IBlockAPI.removeTextSignature#
removeText(block: number, from?: number, to?: number): voidgetTextAsHTML()#
Gets a range of a text block as HTML with its formatting, for the clipboard.
The HTML states the color, background color, weight, italic, decorations, script style, case, font size and
typeface of each run as inline CSS. It states the list style, list level and alignment of each paragraph. Other
apps read it on paste, and replaceTextWithHTML reads every property back. The typeface applies only when a
typeface of the scene holds its font file. The font size and the line height are CSS values, so other apps show them as the block does.
const html = engine.block.getTextAsHTML(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to read. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
string
The HTML, or an empty string for an empty range.
Implementation of#
IBlockAPI.getTextAsHTMLSignature#
getTextAsHTML(block: number, from?: number, to?: number): stringreplaceTextWithHTML()#
Replaces a range of a text block with the text and the formatting of HTML, such as the HTML of a paste.
HTML from getTextAsHTML sets every property it carries. Its typeface applies only when a typeface of the scene
holds its font file. Otherwise the text keeps the typeface at the cursor, with the weight and style of the source.
HTML of another app, such as Google Docs, Word, a web page or an Apple app, sets weight, italic and decorations.
It also sets the script style, case, colors, font size, letter spacing, line height, lists and alignment. A CSS
px is one pixel of a scene whose font size unit is 'Pixel'. The text takes the first font family of the HTML
that a typeface of the asset sources has. Without such a typeface, it keeps the typeface at the cursor.
A gray, black or white that covers the largest part of the text is the default color of that app. It is not
applied, and the same rule applies to the background color. A pasted paragraph without a list keeps the list of
the target paragraph. Without the text/character scope, only the text is inserted, with the style at the cursor.
Without the fill/change scope, or when the text color is bound to a variable, no color is pasted. When the font
size or the typeface of the block is bound to a variable, it is not pasted.
engine.block.replaceTextWithHTML(text, '<p><b>Hello</b> <i>world</i></p>');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block into which to insert the HTML. |
html |
string |
The HTML. Markup that is not supported keeps only its text. |
from? |
number |
The start index of the UTF-16 range to replace. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range to replace. If from is not negative and to is negative, the HTML is inserted at from. Otherwise it defaults to the end of the current selection or text. |
Returns#
void
Implementation of#
IBlockAPI.replaceTextWithHTMLSignature#
replaceTextWithHTML(block: number, html: string, from?: number, to?: number): voidgetTextFontSizes()#
Gets the unique font sizes within a range of text.
// Get all font sizesconst fontSizes = engine.block.getTextFontSizes(text);
// Get font sizes for a rangeconst fontSizes = engine.block.getTextFontSizes(text, 0, 10);
// With options objectconst sizesInPx = engine.block.getTextFontSizes(text, { unit: 'Pixel' });const sizesInRange = engine.block.getTextFontSizes(text, { unit: 'Millimeter', from: 5, to: 15 });Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose font sizes should be returned. |
options? |
TextFontSizeOptions |
An options object with unit, from, and to properties. |
Returns#
number[]
The ordered unique list of font sizes.
Implementation of#
IBlockAPI.getTextFontSizesCall Signature#
getTextFontSizes( block, from?, to?): number[];Parameters#
| Parameter | Type |
|---|---|
block |
number |
from? |
number |
to? |
number |
Returns#
number[]
Deprecated#
Use the options-object overload.
Implementation of#
IBlockAPI.getTextFontSizesSignatures#
getTextFontSizes(block: number, options?: TextFontSizeOptions): number[]getTextFontSizes(block: number, from?: number, to?: number): number[]setTextFontSize()#
Sets the font size for a range of text.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose font size should be changed. |
size |
number |
The new font size in points. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Deprecated#
Use the new signature with options object instead.
Example#
// Before migrationengine.block.setTextFontSize(text, 18, 0, 5);// After migrationengine.block.setTextFontSize(text, 18, { from: 0, to: 5 });Implementation of#
IBlockAPI.setTextFontSizeCall Signature#
setTextFontSize( block, size, options?): void;Sets the font size for a range of text.
// With numeric fontSize (in points)engine.block.setTextFontSize(text, 12, 0, 5);
// With font size and options objectengine.block.setTextFontSize(text, 16, { unit: 'Pixel' });engine.block.setTextFontSize(text, 24, { unit: 'Point', from: 0, to: 10 });Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose font size should be changed. |
size |
number |
The new font size value. |
options? |
TextFontSizeOptions |
An options object with unit, from, and to properties. |
Returns#
void
Implementation of#
IBlockAPI.setTextFontSizeSignatures#
setTextFontSize(block: number, size: number, from?: number, to?: number): voidsetTextFontSize(block: number, size: number, options?: TextFontSizeOptions): voidgetTextFontStyles()#
Gets the unique font styles within a range of text.
const fontStyles = engine.block.getTextFontStyles(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose font styles should be returned. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
The ordered unique list of font styles.
Signature#
getTextFontStyles(block: number, from?: number, to?: number): FontStyle[]setTextFontStyle()#
Sets the font style for a range of text.
engine.block.setTextFontStyle(text, 'italic', 0, 5);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose style should be changed. |
style |
FontStyle |
The new style of the selected text range. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
setTextFontStyle(block: number, style: FontStyle, from?: number, to?: number): voidgetTextFontWeights()#
Gets the unique font weights within a range of text.
const fontWeights = engine.block.getTextFontWeights(text, 0, 6);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose font weights should be returned. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
The ordered unique list of font weights.
Signature#
getTextFontWeights(block: number, from?: number, to?: number): FontWeight[]setTextFontWeight()#
Sets the font weight for a range of text.
engine.block.setTextFontWeight(text, 'bold', 0, 5);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose weight should be changed. |
weight |
FontWeight |
The new weight of the selected text range. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
setTextFontWeight(block: number, weight: FontWeight, from?: number, to?: number): voidsetTextFontWeightAndStyle()#
Sets the font weight and the font style for a range of text in one step.
Each run gets the font of its typeface with exactly this weight and style. Separate calls to
setTextFontWeight and setTextFontStyle pass through a face in between, so they fail when the typeface
lacks that face.
engine.block.setTextFontWeightAndStyle(text, 'bold', 'italic', 0, 5);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose weight and style should be changed. |
weight |
FontWeight |
The new weight of the selected text range. |
style |
FontStyle |
The new style of the selected text range. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Throws#
Error with code BLOCK.TEXT_UNSUPPORTED_FONT_FACE when the typeface of a run has no font with this
weight and style. That run keeps its font, and the other runs of the range change. A run with a font request
from setFontRequest takes the face into its request and gets no error.
Signature#
setTextFontWeightAndStyle(block: number, weight: FontWeight, style: FontStyle, from?: number, to?: number): voidgetTextColors()#
Gets the unique colors within a range of text.
const colorsInRange = engine.block.getTextColors(text, 2, 5);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose colors should be returned. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
Color[]
The ordered unique list of colors.
Implementation of#
IBlockAPI.getTextColorsSignature#
getTextColors(block: number, from?: number, to?: number): Color[]setTextColor()#
Sets the color for a range of text.
engine.block.setTextColor(text, { r: 0.0, g: 0.0, b: 0.0, a: 1.0 }, 1, 4);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose color should be changed. |
color |
Color |
The new color of the selected text range. |
from? |
number |
The start index of the UTF-16 range to change. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range to change. Defaults to the end of the current selection or text. |
Returns#
void
Implementation of#
IBlockAPI.setTextColorSignature#
setTextColor(block: number, color: Color, from?: number, to?: number): voidgetTextBackgroundColors()#
Gets the unique background colors within a range of text.
Text without a background color is reported as a fully transparent color.
const backgroundColorsInRange = engine.block.getTextBackgroundColors(text, 2, 5);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose background colors should be returned. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
Color[]
The ordered unique list of background colors.
Implementation of#
IBlockAPI.getTextBackgroundColorsSignature#
getTextBackgroundColors(block: number, from?: number, to?: number): Color[]setTextBackgroundColor()#
Sets the background color for a range of text.
The background is drawn as a rectangle behind each affected text run, or as a band along the curve for text
on a path.
A fully transparent color removes the background from the range.
The run background is independent of the block-level background color
(‘backgroundColor/color’); it is drawn on top of the block-level background.
engine.block.setTextBackgroundColor(text, { r: 1.0, g: 1.0, b: 0.0, a: 1.0 }, 1, 4);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose background color should be changed. |
color |
Color |
The new background color of the selected text range. |
from? |
number |
The start index of the UTF-16 range to change. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range to change. Defaults to the end of the current selection or text. |
Returns#
void
Implementation of#
IBlockAPI.setTextBackgroundColorSignature#
setTextBackgroundColor(block: number, color: Color, from?: number, to?: number): voidgetTextCases()#
Gets the unique text cases within a range of text.
const textCases = engine.block.getTextCases(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose text cases should be returned. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
TextCase[]
The ordered list of text cases.
Signature#
getTextCases(block: number, from?: number, to?: number): TextCase[]setTextCase()#
Sets the text case for a range of text.
engine.block.setTextCase(text, 'Titlecase');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose text case should be changed. |
textCase |
TextCase |
The new text case value. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
setTextCase(block: number, textCase: TextCase, from?: number, to?: number): voidgetTextScriptStyles()#
Gets the unique text script styles within a range of text.
const scriptStyles = engine.block.getTextScriptStyles(text);// e.g., ['Normal', 'Superscript']Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose script styles should be returned. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
The ordered list of unique script styles.
Signature#
getTextScriptStyles(block: number, from?: number, to?: number): ScriptStyle[]setTextScriptStyle()#
Sets the script style for a range of text.
Superscript and subscript text is scaled down and shifted off the regular baseline. The block properties ‘text/superscriptFontScale’, ‘text/superscriptVerticalShift’, ‘text/subscriptFontScale’ and ‘text/subscriptVerticalShift’ adjust the scale and shift.
engine.block.setTextScriptStyle(text, 'Superscript');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose script style should be changed. |
scriptStyle |
ScriptStyle |
The new script style. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
setTextScriptStyle(block: number, scriptStyle: ScriptStyle, from?: number, to?: number): voidgetTypefaces()#
Gets the unique typefaces within a range of text.
const currentTypefaces = engine.block.getTypefaces(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose typefaces should be queried. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
Typeface[]
The unique typefaces in the range.
Implementation of#
IBlockAPI.getTypefacesSignature#
getTypefaces(block: number, from?: number, to?: number): Typeface[]getTypeface()#
Gets the base typeface of a text block.
This does not return the typefaces of individual text runs.
const defaultTypeface = engine.block.getTypeface(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose typeface should be queried. |
Returns#
Typefacethe typeface property of the text block.
Implementation of#
IBlockAPI.getTypefaceSignature#
getTypeface(block: number): TypefacecanToggleBoldFont()#
Checks if the bold font weight can be toggled for a range of text.
Returns true if any part of the range is not bold and the bold font is available.
const canToggleBold = engine.block.canToggleBoldFont(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to check. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
boolean
Whether the font weight can be toggled.
Signature#
canToggleBoldFont(block: number, from?: number, to?: number): booleantoggleBoldFont()#
Toggles the font weight of a text range between bold and normal.
If any part of the range is not bold, the entire range becomes bold. If the entire range is already bold, it becomes normal.
engine.block.toggleBoldFont(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
toggleBoldFont(block: number, from?: number, to?: number): voidcanToggleItalicFont()#
Checks if the italic font style can be toggled for a range of text.
Returns true if any part of the range is not italic and the italic font is available.
const canToggleItalic = engine.block.canToggleItalicFont(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to check. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
boolean
Whether the font style can be toggled.
Signature#
canToggleItalicFont(block: number, from?: number, to?: number): booleantoggleItalicFont()#
Toggles the font style of a text range between italic and normal.
If any part of the range is not italic, the entire range becomes italic. If the entire range is already italic, it becomes normal.
engine.block.toggleItalicFont(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
toggleItalicFont(block: number, from?: number, to?: number): voidgetTextRenderDiagnostics()#
Gets the current fonts, missing glyphs and planar layout of a text block.
Run and missing-glyph ranges are half-open UTF-16 offsets in fontUsage.text,
after case transformations and template resolution. Effective font sizes use
the scene’s font-size unit. Layout includes hidden lines; its overshoot and
required height use local design units before strokes, effects and animations.
Layout is absent while resources are pending, without a current shape, or for
text on a path. resolved font usage does not guarantee glyph coverage.
This updates pending layout synchronously without changing serialized block
properties. It does not wait for downloads; use forceLoadResources first
when the snapshot must include loaded fonts.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
Returns#
TextRenderDiagnosticsThe current rendering diagnostics.
Throws#
If the block is invalid or is not text.
Implementation of#
IBlockAPI.getTextRenderDiagnosticsSignature#
getTextRenderDiagnostics(block: number): TextRenderDiagnosticsgetTextVisibleLineCount()#
Gets the number of visible lines in a text block.
const lineCount = engine.block.getTextVisibleLineCount(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose line count should be returned. |
Returns#
number
The number of lines in the text block.
Signature#
getTextVisibleLineCount(block: number): numbergetTextVisibleLineContent()#
Gets the text content of a visible line.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose line content should be returned. |
lineIndex |
number |
The index of the line whose content should be returned. |
Returns#
string
The text content of the line.
Signature#
getTextVisibleLineContent(block: number, lineIndex: number): stringgetTextVisibleLineGlobalBoundingBoxXYWH()#
Gets the global bounding box of a visible line of text.
The values are in the scene’s global coordinate space.
const lineBoundingBox = engine.block.getTextVisibleLineGlobalBoundingBoxXYWH(text, 0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose line bounding box should be returned. |
lineIndex |
number |
The index of the line whose bounding box should be returned. |
Returns#
XYWHThe bounding box of the line.
Signature#
getTextVisibleLineGlobalBoundingBoxXYWH(block: number, lineIndex: number): XYWHgetTextEffectiveHorizontalAlignment()#
Gets the effective horizontal alignment of a text block.
If the alignment is set to Auto, this returns the resolved alignment (Left or Right)
based on the text direction of the first logical run. This never returns ‘Auto’.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose effective alignment should be returned. |
Returns#
"Left" | "Right" | "Center" | "Justify"
The effective alignment (‘Left’, ‘Right’, ‘Center’, or ‘Justify’).
Only 'Auto' is resolved — 'Justify' is itself an effective alignment and is
returned verbatim.
Signature#
getTextEffectiveHorizontalAlignment(block: number): "Left" | "Right" | "Center" | "Justify"toggleTextDecorationUnderline()#
Toggles the underline decoration for a text range.
If any part of the range does not have underline, the entire range gets underline. If the entire range already has underline, it is removed. Other decoration lines (strikethrough, overline) on each text run are preserved.
engine.block.toggleTextDecorationUnderline(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
toggleTextDecorationUnderline(block: number, from?: number, to?: number): voidtoggleTextDecorationStrikethrough()#
Toggles the strikethrough decoration for a text range.
If any part of the range does not have strikethrough, the entire range gets strikethrough. If the entire range already has strikethrough, it is removed. Other decoration lines (underline, overline) on each text run are preserved.
engine.block.toggleTextDecorationStrikethrough(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
toggleTextDecorationStrikethrough(block: number, from?: number, to?: number): voidtoggleTextDecorationOverline()#
Toggles the overline decoration for a text range.
If any part of the range does not have overline, the entire range gets overline. If the entire range already has overline, it is removed. Other decoration lines (underline, strikethrough) on each text run are preserved.
engine.block.toggleTextDecorationOverline(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Signature#
toggleTextDecorationOverline(block: number, from?: number, to?: number): voidgetTextListStyle()#
Gets the list style for a specific paragraph of a text block.
const listStyle = engine.block.getTextListStyle(text, 0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose list style should be returned. |
paragraphIndex |
number |
The 0-based index of the paragraph. Must be non-negative: unlike the setter, a negative index throws. |
Returns#
ListStyleThe list style of the paragraph.
Signature#
getTextListStyle(block: number, paragraphIndex: number): ListStylesetTextListStyle()#
Sets the list style for a specific paragraph or all paragraphs of a text block.
engine.block.setTextListStyle(text, 'Unordered');engine.block.setTextListStyle(text, 'Ordered', 0, 2);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose list style should be changed. |
listStyle |
ListStyle |
The list style to apply. |
paragraphIndex? |
number |
The 0-based index of the paragraph to modify. Negative values apply to all paragraphs. |
listLevel? |
number |
Optional list nesting level to set atomically with the list style (0 = outermost). When omitted the existing list level of each paragraph is preserved. Has no visual effect when listStyle is ‘None’. |
Returns#
void
Signature#
setTextListStyle(block: number, listStyle: ListStyle, paragraphIndex?: number, listLevel?: number): voidgetTextListLevel()#
Gets the list nesting level for a specific paragraph of a text block.
const listLevel = engine.block.getTextListLevel(text, 0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose list level should be returned. |
paragraphIndex |
number |
The 0-based index of the paragraph. Must be non-negative: unlike the setter, a negative index throws. |
Returns#
number
The list nesting level of the paragraph.
Signature#
getTextListLevel(block: number, paragraphIndex: number): numbersetTextListLevel()#
Sets the list nesting level for a specific paragraph or all paragraphs of a text block.
engine.block.setTextListLevel(text, 1);engine.block.setTextListLevel(text, 2, 0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block whose list level should be changed. |
listLevel |
number |
The list nesting level (0 = outermost). |
paragraphIndex? |
number |
The 0-based index of the paragraph to modify. Negative values apply to all paragraphs. |
Returns#
void
Signature#
setTextListLevel(block: number, listLevel: number, paragraphIndex?: number): voidgetTextLineHeight()#
Returns the line height multiplier for a specific paragraph of a text block.
Returns the per-paragraph override if one is set, otherwise returns the block-level lineHeight.
const lineHeight = engine.block.getTextLineHeight(text, 0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
paragraphIndex |
number |
The 0-based index of the paragraph. Must be non-negative: unlike the setter, a negative index throws. |
Returns#
number
The line height multiplier for the paragraph.
Signature#
getTextLineHeight(block: number, paragraphIndex: number): numbersetTextLineHeight()#
Sets the line height multiplier for a specific paragraph or all paragraphs of a text block.
engine.block.setTextLineHeight(text, 1.5);engine.block.setTextLineHeight(text, 1.5, 0);engine.block.setTextLineHeight(text, null); // reset all paragraphs to block defaultParameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
lineHeight |
number |
The line height multiplier, or null to reset to the block-level default. |
paragraphIndex? |
number |
The 0-based index of the paragraph to modify. Negative values apply to all paragraphs. |
Returns#
void
Signature#
setTextLineHeight(block: number, lineHeight: number, paragraphIndex?: number): voidsetTextOnPath()#
Sets the SVG path that the text baseline follows.
Pass null to restore normal straight-line text layout.
null to restore normal straight-line text layout.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
svgPath |
string |
An SVG path string in the block’s local coordinate space, or null to clear. |
Returns#
void
Signature#
setTextOnPath(block: number, svgPath: string): voidgetTextOnPath()#
Gets the SVG path currently used as the text baseline.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
Returns#
string
The SVG path string, or null if no path is set.
Signature#
getTextOnPath(block: number): stringsetTextOnPathOffset()#
Sets the start offset along the baseline path as a proportion of the path length.
Values are clamped to [-1, 1]; 1 and -1 wrap back to the path start.
[-1, 1]; 1 and -1 wrap back to the path start.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
offset |
number |
The proportional offset. Positive values move the text forward along the path. |
Returns#
void
Signature#
setTextOnPathOffset(block: number, offset: number): voidgetTextOnPathOffset()#
Gets the start offset along the baseline path as a proportion of the path length.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
Returns#
number
The proportional offset in [-1, 1].
Signature#
getTextOnPathOffset(block: number): numbersetTextOnPathFlipped()#
Sets whether text is placed on the opposite side of the baseline path.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
flipped |
boolean |
When true, text sits on the underside of the curve and reads in the reverse direction. |
Returns#
void
Signature#
setTextOnPathFlipped(block: number, flipped: boolean): voidgetTextOnPathFlipped()#
Gets whether the text-on-path rendering is flipped.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
Returns#
boolean
true when text is on the underside of the curve.
Signature#
getTextOnPathFlipped(block: number): booleangetTextRuns()#
Gets all text runs within a range of text.
Each run represents a contiguous span of text with uniform formatting.
const runs = engine.block.getTextRuns(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The text block to query. |
options? |
TextFontSizeOptions |
The range in from and to, and the unit of the returned font sizes. |
Returns#
The ordered list of text runs covering the requested range.
Implementation of#
IBlockAPI.getTextRunsCall Signature#
getTextRuns( id, from?, to?): TextRunInfo[];Gets all text runs within a range of text.
Each run represents a contiguous span of text with uniform formatting.
const runs = engine.block.getTextRuns(text);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The text block to query. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
The ordered list of text runs covering the requested range.
Implementation of#
IBlockAPI.getTextRunsSignatures#
getTextRuns(id: number, options?: TextFontSizeOptions): TextRunInfo[]getTextRuns(id: number, from?: number, to?: number): TextRunInfo[]Block Video#
supportsDuration()#
Checks if a block supports a duration property.
False for a page slice, which always lasts as long as its page.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true if the block supports a duration property.
Implementation of#
IBlockAPI.supportsDurationSignature#
supportsDuration(block: number): booleangetDuration()#
Gets the playback duration of a block. For a scene, the sum of the durations of its pages, without the pages
hidden with setVisible(false).
setVisible(false).Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose duration should be returned. |
Returns#
number
The block’s duration in seconds.
Implementation of#
IBlockAPI.getDurationSignature#
getDuration(block: number): numbersetDuration()#
Sets the playback duration of a block.
The duration defines how long the block is active in the scene during playback.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose duration should be changed. |
duration |
number |
The new duration in seconds. Infinity is allowed; NaN or a negative value is an error. |
Returns#
void
Implementation of#
IBlockAPI.setDurationSignature#
setDuration(block: number, duration: number): voidsupportsTimeOffset()#
Checks if a block supports a time offset.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports a time offset.
Implementation of#
IBlockAPI.supportsTimeOffsetSignature#
supportsTimeOffset(block: number): booleangetTimeOffset()#
Gets the time offset of a block relative to its parent.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose time offset should be queried. |
Returns#
number
The time offset of the block in seconds.
Implementation of#
IBlockAPI.getTimeOffsetSignature#
getTimeOffset(block: number): numbersetTimeOffset()#
Sets the time offset of a block relative to its parent.
The time offset controls when the block first becomes active in the timeline.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose time offset should be changed. |
offset |
number |
The new time offset in seconds. |
Returns#
void
Implementation of#
IBlockAPI.setTimeOffsetSignature#
setTimeOffset(block: number, offset: number): voidsupportsTrim()#
Checks if a block supports trim properties.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports trim properties.
Signature#
supportsTrim(block: number): booleangetTrimOffset()#
Gets the trim offset of a block’s media content.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose trim offset should be queried. |
Returns#
number
the trim offset in seconds.
Signature#
getTrimOffset(block: number): numbersetTrimOffset()#
Sets the trim offset of a block’s media content.
This sets the time within the media clip where playback should begin.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose trim should be updated. |
offset |
number |
The new trim offset, measured in timeline seconds (scaled by playback rate). |
Returns#
void
Signature#
setTrimOffset(block: number, offset: number): voidgetTrimLength()#
Gets the trim length of a block’s media content.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The object whose trim length should be queried. |
Returns#
number
The trim length of the object in seconds.
Signature#
getTrimLength(block: number): numbersetTrimLength()#
Sets the trim length of a block’s media content.
This is the duration of the media clip that should be used for playback.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The object whose trim length should be updated. |
length |
number |
The new trim length in seconds. |
Returns#
void
Signature#
setTrimLength(block: number, length: number): voidsupportsPlaybackControl()#
Checks if a block supports playback controls.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
Whether the block supports playback control.
Signature#
supportsPlaybackControl(block: number): booleansupportsPlaybackTime()#
Checks if a block supports a playback time property.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
whether the block supports a playback time property.
Signature#
supportsPlaybackTime(block: number): booleangetPlaybackTime()#
Gets the current playback time of a block’s content.
During an export, this returns the time of the playhead and not the time of the exported frame.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The playback time of the block in seconds.
Signature#
getPlaybackTime(block: number): numbersetPlaybackTime()#
Sets the current playback time of a block’s content.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose playback time should be updated. |
time |
number |
The new playback time of the block in seconds. |
Returns#
void
Signature#
setPlaybackTime(block: number, time: number): voidisPlaying()#
Checks if a block is playing its content.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
whether the block is playing during playback.
Signature#
isPlaying(block: number): booleansetPlaying()#
Sets whether a block should play its content during active playback.
Note that playing a page switches the editor to the Playback edit mode. From 0.2 s after the start, a change to the position, size, rotation, fill or text of a content block ends that mode. So does a change to the opacity, adjustments, shape or volume of any block, the page included. The editor returns to the Transform edit mode, which stops the playback. While a page plays, only a change on that page counts. A change to a block on another page, or to a block that is not in the scene, keeps the playback running.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block that should be updated. |
playing |
boolean |
Whether the block should be playing its contents. |
Returns#
void
Signature#
setPlaying(block: number, playing: boolean): voidisLooping()#
Checks if a block’s media content is set to loop.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
Whether the block is looping.
Signature#
isLooping(block: number): booleansetLooping()#
Sets whether a block’s media content should loop.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block or video fill to update. |
looping |
boolean |
Whether the block should loop to the beginning or stop. |
Returns#
void
Signature#
setLooping(block: number, looping: boolean): voidgetPlaybackSpeed()#
Gets the playback speed multiplier of a block that supports playback control.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The playback speed multiplier.
Signature#
getPlaybackSpeed(block: number): numbersetPlaybackSpeed()#
Sets the playback speed multiplier of a block that supports playback control.
Note: This also adjusts the trim and duration of the block.
Video fills running faster than 3.0x are force muted until reduced to 3.0x or below.
An audio block that createAudioFromVideo extracts from a video faster than 3.0x keeps that speed and is force
muted too. This method still rejects a speed above 3.0x for it.
On a group, the speed changes no duration and acts only when group/composition is true:
the children then run that many times faster.
createAudioFromVideo extracts from a video faster than 3.0x keeps that speed and is force
muted too. This method still rejects a speed above 3.0x for it.
On a group, the speed changes no duration and acts only when group/composition is true:
the children then run that many times faster.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block, video fill or group to update. |
speed |
number |
The desired playback speed multiplier. Valid range is [0.25, 3.0] for audio blocks and [0.25, infinity) for video fills and groups. |
Returns#
void
Signature#
setPlaybackSpeed(block: number, speed: number): voidisMuted()#
Checks if a block’s audio is muted.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
Whether the block is muted.
Signature#
isMuted(block: number): booleansetMuted()#
Sets whether the audio of a block is muted.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block or video fill to update. |
muted |
boolean |
Whether the audio should be muted. |
Returns#
void
Signature#
setMuted(block: number, muted: boolean): voidgetVolume()#
Gets the audio volume of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The volume, ranging from 0.0 to 1.0.
Signature#
getVolume(block: number): numbersetVolume()#
Sets the audio volume of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block or video fill to update. |
volume |
number |
The desired volume, ranging from 0.0 to 1.0. |
Returns#
void
Signature#
setVolume(block: number, volume: number): voidsetAudioFadeIn()#
Sets an audio fade-in for a block. The audio ramps up from silence to the
block’s volume over the given duration at the start of the block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The audio block or video fill to update. |
duration |
number |
The fade-in duration in seconds. A value of 0 disables the fade-in and negative values are clamped to 0. Positive infinity is an error. |
easing? |
AnimationEasing |
The easing curve of the fade. Defaults to ‘Linear’. |
Returns#
void
Signature#
setAudioFadeIn(block: number, duration: number, easing?: AnimationEasing): voidsetAudioFadeOut()#
Sets an audio fade-out for a block. The audio ramps down from the block’s
volume to silence over the given duration at the end of the block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The audio block or video fill to update. |
duration |
number |
The fade-out duration in seconds. A value of 0 disables the fade-out and negative values are clamped to 0. Positive infinity is an error. |
easing? |
AnimationEasing |
The easing curve of the fade. Defaults to ‘Linear’. |
Returns#
void
Signature#
setAudioFadeOut(block: number, duration: number, easing?: AnimationEasing): voidisSoloPlaybackEnabled()#
Checks if solo playback is enabled for a block.
engine.block.isSoloPlaybackEnabled(videoFill);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block or fill to query. |
Returns#
boolean
Whether solo playback is enabled for this block.
Signature#
isSoloPlaybackEnabled(block: number): booleansetSoloPlaybackEnabled()#
Enables or disables solo playback for a block.
When enabled, only this block’s content will play while the rest of the scene remains paused.
engine.block.setSoloPlaybackEnabled(videoFill, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block or fill to update. |
enabled |
boolean |
Whether solo playback should be enabled. |
Returns#
void
Signature#
setSoloPlaybackEnabled(block: number, enabled: boolean): voidisForceMuted()#
Checks if a block’s audio is muted due to engine rules.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
Whether the block is force muted.
Signature#
isForceMuted(block: number): booleangetVideoWidth()#
Gets the width of a block’s video resource.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The video fill block. |
Returns#
number
The video width in pixels, or 0 for a file without a video track.
Signature#
getVideoWidth(block: number): numbergetVideoHeight()#
Gets the height of a block’s video resource.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The video fill block. |
Returns#
number
The video height in pixels, or 0 for a file without a video track.
Signature#
getVideoHeight(block: number): numbergetAVResourceTotalDuration()#
Gets the total duration of a block’s audio/video resource.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The video fill or audio block. |
Returns#
number
The video or audio file duration in seconds.
Signature#
getAVResourceTotalDuration(block: number): numbersupportsPageDurationSource()#
Checks if a block can be set as the page’s duration source.
Parameters#
| Parameter | Type | Description |
|---|---|---|
page |
number |
The page to check against. |
block |
number |
The block to query. |
Returns#
boolean
true, if the block can be marked as the page’s duration source.
Signature#
supportsPageDurationSource(page: number, block: number): booleansetPageDurationSource()#
Sets a block as the page’s duration source.
This causes the page’s total duration to be automatically determined by this block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
page |
number |
The page block for which it should be enabled. |
block |
number |
The block that should become the duration source. |
Returns#
void
Signature#
setPageDurationSource(page: number, block: number): voidremovePageDurationSource()#
Removes a block as the page’s duration source.
If a scene or page is given, it is deactivated for all blocks within it.
Parameters#
| Parameter | Type | Description |
|---|---|---|
page |
number |
The block whose duration source property should be removed. |
Returns#
void
Signature#
removePageDurationSource(page: number): voidisPageDurationSource()#
Checks if a block is the duration source for its page.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose duration source property should be queried. |
Returns#
boolean
true if the block is a duration source for a page.
Signature#
isPageDurationSource(block: number): booleancreateCaptionsFromURI()#
Creates new caption blocks from an SRT or VTT file URI.
Parameters#
| Parameter | Type | Description |
|---|---|---|
uri |
string |
The URI for the captions file to load. Supported file formats are: SRT and VTT. |
options? |
AbortOptions |
An abortSignal that stops the download of the file. No caption block is created then. |
Returns#
Promise<number[]>
A promise that resolves with a list of the created caption blocks.
Signature#
createCaptionsFromURI(uri: string, options?: AbortOptions): Promise<number[]>unstable_isAVResourceLoaded()#
Checks if a block’s audio/video resource is loaded.
A buffer:// source counts as loaded once the engine has read its file, with the images that a Lottie
references. A missing or empty buffer, or raw audio samples on an audio block, count as loaded.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The video fill or audio block. |
Returns#
boolean
The loading state of the resource. This API is experimental and may change or be removed in future versions.
Block Animations#
supportsAnimation()#
Checks if a block supports animation.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
Whether the block supports animation.
Signature#
supportsAnimation(block: number): booleangetInAnimation()#
Gets the “in” animation of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose “in” animation should be queried. |
Returns#
number
The “in” animation of the block, or an invalid block if unset.
Check the result with isValid.
Signature#
getInAnimation(block: number): numbersetInAnimation()#
Sets the “in” animation of a block.
The animation is removed from every other block that uses it.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose “in” animation should be set. |
animation |
number |
The animation to set. |
Returns#
void
Signature#
setInAnimation(block: number, animation: number): voidgetOutAnimation()#
Gets the “out” animation of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose “out” animation should be queried. |
Returns#
number
The “out” animation of the block, or an invalid block if unset.
Check the result with isValid.
Signature#
getOutAnimation(block: number): numbersetOutAnimation()#
Sets the “out” animation of a block.
The animation is removed from every other block that uses it.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose “out” animation should be set. |
animation |
number |
The animation to set. |
Returns#
void
Signature#
setOutAnimation(block: number, animation: number): voidgetLoopAnimation()#
Gets the “loop” animation of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose “loop” animation should be queried. |
Returns#
number
The “loop” animation of the block, or an invalid block if unset.
Check the result with isValid.
Signature#
getLoopAnimation(block: number): numbersetLoopAnimation()#
Sets the “loop” animation of a block.
The animation is removed from every other block that uses it.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose “loop” animation should be set. |
animation |
number |
The animation to set. |
Returns#
void
Signature#
setLoopAnimation(block: number, animation: number): voidsetKeyframes()#
Replaces the keyframes of a block property.
Keyframe times are normalized over the block’s duration, from 0 to 1, and the keyframes are sorted by time. A fill, shape or effect uses the duration of the block it is attached to. Setting the static value of the property does not change its keyframes.
The keyframes belong to the block that owns the property. Replacing a fill, shape or effect does not move them
to the new block. Scaling the block or changing the design unit also converts the keyframes of length
and position properties, such as corner radii and position. Rotating or flipping the block turns or mirrors
the keyframes of its position, rotation and skew with it. A group’s keyframes turn with the group. A turn other
than a half turn joins position/x and position/y tracks into one position track. They must share the
mode, the times and the easings, and no position track may exist. Other axis tracks cannot turn: their Absolute
values move with the block, and their Relative values stay.
A rotation track turns a graphic or text without an anchor around its frame center, as setRotation does.
With transform/anchor/x or transform/anchor/y set, even to 0, it turns around the anchor.
The vec2 properties position (a block) and shape/position (a shape) animate the /x and /y properties
together. Their spatialOut and spatialIn tangents curve the motion path. getVec2 and setVec2 read and
write their static value. A position/x or position/y track overrides that axis of a position track.
Position keyframes are in design units, also when the position mode is 'Percent'.
const fill = engine.block.getFill(block);engine.block.setKeyframes(fill, 'fill/color/value', [ { time: 0, value: { type: 'Color', value: { r: 1, g: 0, b: 0, a: 1 } } }, { time: 1, value: { type: 'Color', value: { r: 0, g: 0, b: 1, a: 1 } }, easing: { type: 'Hold' } }]);Required scope: ‘appearance/animation’ and the scope that the setter of the property needs, such as ‘layer/move’
for position or ‘layer/rotate’ for rotation. A transform/scale/x or transform/scale/y keyframe that shows a
scale with another sign than the static scale also needs ‘layer/flip’.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block that owns the property, for example a graphic, fill, shape or effect block. |
property |
string |
The property path. isPropertyAnimatable must return true for it. |
keyframes |
Keyframe[] |
At least one keyframe, with unique times from 0 to 1 and values of the property’s kind. |
mode? |
TrackMode |
'Absolute' replaces the static value, 'Relative' adds to it. Relative needs a float or vec2 property. Defaults to 'Absolute'. |
Returns#
void
Implementation of#
IBlockAPI.setKeyframesSignature#
setKeyframes(block: number, property: string, keyframes: Keyframe$1[], mode?: TrackMode): voidgetAnimatedProperties()#
Lists the properties of a block that have keyframes.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
string[]
The property paths, sorted.
Implementation of#
IBlockAPI.getAnimatedPropertiesSignature#
getAnimatedProperties(block: number): string[]isPropertyAnimatable()#
Checks whether a property of a block can have keyframes.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
property |
string |
The property path. |
Returns#
boolean
True when the block has the property and it is animatable. False for a property the block does not have.
Implementation of#
IBlockAPI.isPropertyAnimatableSignature#
isPropertyAnimatable(block: number, property: string): booleanBlock Groups#
group()#
Groups multiple blocks into a new group block.
The blocks keep their times on the timeline. The group spans from the earliest start to the latest end of the blocks, and their time offsets become relative to the group.
if (engine.block.isGroupable([block1, block2])) { const group = engine.block.group([block1, block2]);}Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
A non-empty array of block ids. |
Returns#
number
The block id of the created group.
Signature#
group(blocks: number[]): numberungroup()#
Ungroups a group block, releasing its children.
The children keep their times on the timeline, so their time offsets become relative to their new parent. A caption goes onto the first caption track of the page instead, at its time, and takes the track’s animations. Ungrouping creates the caption track when the page has none.
engine.block.ungroup(group);Parameters#
| Parameter | Type | Description |
|---|---|---|
group |
number |
The group id from a previous call to group. |
Returns#
void
Signature#
ungroup(group: number): voidisGroupable()#
Checks if a set of blocks can be grouped.
A scene block, a page or a page slice cannot be grouped, and neither can a block together with a group it sits inside, which would make that group a child of itself. A caption or a caption track cannot be grouped either, because a caption plays from the caption track of its page. Blocks that already belong to a group can be grouped again, which is how a group inside a group is made.
const groupable = engine.block.isGroupable([block1, block2])Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
An array of block ids. |
Returns#
boolean
Whether the blocks can be grouped together.
Signature#
isGroupable(blocks: number[]): booleanenterGroup()#
Changes selection to a block within a selected group.
Nothing happens if the target is not a group.
engine.block.enterGroup(group);Parameters#
| Parameter | Type | Description |
|---|---|---|
group |
number |
The group id from a previous call to group. |
Returns#
void
Signature#
enterGroup(group: number): voidexitGroup()#
Changes selection from a block to its parent group.
Nothing happens if the block is not part of a group.
engine.block.exitGroup(member1);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
A block id. |
Returns#
void
Signature#
exitGroup(block: number): voidBlock State#
isVisibleAtCurrentPlaybackTime()#
Checks if a block is visible at the current scene playback time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
Whether the block should be visible on the canvas at the current playback time.
Signature#
isVisibleAtCurrentPlaybackTime(block: number): booleanisIncludedInExport()#
Checks if a block is included in exports.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block is included on the exported result, false otherwise.
Signature#
isIncludedInExport(block: number): booleansetIncludedInExport()#
Sets whether a block should be included in exports.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose exportable state should be set. |
included |
boolean |
If true, the block will be included on the exported result. |
Returns#
void
Signature#
setIncludedInExport(block: number, included: boolean): voidreferencesAnyVariables()#
Checks if a block references any text variables.
This check does not recurse into children and ignores variable bindings.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block to inspect. |
Returns#
boolean
true if the block references variables and false otherwise.
Signature#
referencesAnyVariables(id: number): booleanBlock Crop#
supportsCrop()#
Checks if a block supports cropping.
engine.block.supportsCrop(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
true, if the block supports cropping.
Signature#
supportsCrop(block: number): booleanresetCrop()#
Resets the crop of a block to its default state.
The block’s content fill mode is set to ‘Cover’.
engine.block.resetCrop(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be reset. |
Returns#
void
Signature#
resetCrop(block: number): voidadjustCropToFillFrame()#
Adjusts the crop position and scale of the given image block to fill its crop frame, while maintaining the position and size of the crop frame.
On a page with a bleed, the content also covers the bleed, and the ratio includes the bleed.
This needs the setting page/imageFillCoversBleed, which is on by default.
page/imageFillCoversBleed, which is on by default.const adjustedScaleRatio = engine.block.adjustCropToFillFrame(image, 1.0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be adjusted. |
minScaleRatio |
number |
The minimal crop scale ratio to use. |
Returns#
number
The adjusted scale ratio.
Signature#
adjustCropToFillFrame(block: number, minScaleRatio: number): numbergetCropRotation()#
Gets the crop rotation of a block in the scene’s angle unit (radians by default).
const cropRotation = engine.block.getCropRotation(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop rotation should be queried. |
Returns#
number
The crop rotation in the scene’s angle unit (radians by default).
Signature#
getCropRotation(block: number): numbersetCropRotation()#
Sets the crop rotation of a block in the scene’s angle unit (radians by default).
engine.block.setCropRotation(image, Math.PI);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be set. |
rotation |
number |
The rotation in the scene’s angle unit (radians by default). |
Returns#
void
Signature#
setCropRotation(block: number, rotation: number): voidgetCropScaleX()#
Gets the horizontal crop scale of a block.
const scaleX = engine.block.getCropScaleX(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose scale should be queried. |
Returns#
number
The scale on the x axis.
Signature#
getCropScaleX(block: number): numbersetCropScaleX()#
Sets the horizontal crop scale of a block.
engine.block.setCropScaleX(image, 2.0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be set. |
scale |
number |
The scale in x direction. |
Returns#
void
Signature#
setCropScaleX(block: number, scale: number): voidgetCropScaleY()#
Gets the vertical crop scale of a block.
const scaleY = engine.block.getCropScaleY(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose scale should be queried. |
Returns#
number
The scale on the y axis.
Signature#
getCropScaleY(block: number): numbersetCropScaleY()#
Sets the vertical crop scale of a block.
engine.block.setCropScaleY(image, 1.5);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be set. |
scale |
number |
The scale in y direction. |
Returns#
void
Signature#
setCropScaleY(block: number, scale: number): voidgetCropScaleRatio()#
Gets the uniform crop scale ratio of a block.
On a page with a bleed, a ratio of 1 means that the content covers the page and its bleed.
This needs the setting page/imageFillCoversBleed, which is on by default.
page/imageFillCoversBleed, which is on by default.const cropScaleRatio = engine.block.getCropScaleRatio(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop scale ratio should be queried. |
Returns#
number
The crop scale ratio.
Signature#
getCropScaleRatio(block: number): numbersetCropScaleRatio()#
Sets the uniform crop scale ratio of a block.
This scales the content up or down from the center of the crop frame.
On a page with a bleed, the ratio and the center of the scale include the bleed.
This needs the setting page/imageFillCoversBleed, which is on by default.
engine.block.setCropScaleRatio(image, 3.0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be set. |
ratio |
number |
The crop scale ratio. |
Returns#
void
Signature#
setCropScaleRatio(block: number, ratio: number): voidgetCropTranslationX()#
Gets the horizontal crop translation of a block in percentage of the crop frame width.
const cropTranslationX = engine.block.getCropTranslationX(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose translation should be queried. |
Returns#
number
The translation on the x axis.
Signature#
getCropTranslationX(block: number): numbersetCropTranslationX()#
Sets the horizontal crop translation of a block in percentage of the crop frame width.
engine.block.setCropTranslationX(image, -1.0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be set. |
translation |
number |
The translation in x direction. |
Returns#
void
Signature#
setCropTranslationX(block: number, translation: number): voidgetCropTranslationY()#
Gets the vertical crop translation of a block in percentage of the crop frame height.
const cropTranslationY = engine.block.getCropTranslationY(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose translation should be queried. |
Returns#
number
The translation on the y axis.
Signature#
getCropTranslationY(block: number): numbersetCropTranslationY()#
Sets the vertical crop translation of a block in percentage of the crop frame height.
engine.block.setCropTranslationY(image, 1.0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be set. |
translation |
number |
The translation in y direction. |
Returns#
void
Signature#
setCropTranslationY(block: number, translation: number): voidisCropAspectRatioLocked()#
Checks if the crop aspect ratio is locked for a block.
When locked, crop handles will maintain the current aspect ratio during resize.
const isLocked = engine.block.isCropAspectRatioLocked(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if aspect ratio is locked, false otherwise.
Signature#
isCropAspectRatioLocked(block: number): booleansetCropAspectRatioLocked()#
Sets whether the crop aspect ratio should be locked for a block.
When enabled, crop handles will maintain the current aspect ratio. When disabled, free resizing is allowed.
engine.block.setCropAspectRatioLocked(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
locked |
boolean |
Whether aspect ratio should be locked. |
Returns#
void
Signature#
setCropAspectRatioLocked(block: number, locked: boolean): voidflipCropHorizontal()#
Flips the content horizontally within its crop frame.
engine.block.flipCropHorizontal(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be updated. |
Returns#
void
Signature#
flipCropHorizontal(block: number): voidflipCropVertical()#
Flips the content vertically within its crop frame.
engine.block.flipCropVertical(image);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose crop should be updated. |
Returns#
void
Signature#
flipCropVertical(block: number): voidcanRevertToOriginalRatio()#
Checks whether the “Original” crop preset (ContentAspectRatio) can be applied to a block.
ContentAspectRatio) can be applied to a block.This runs the same preliminary check the apply path performs: it resolves the intrinsic
content dimensions from the block’s image/video fill (an image fill resolves only from its
sourceSet; a video fill resolves from its sourceSet or the first decoded frame). Use it
to gate UI that would otherwise call the preset and fail — e.g. an unreplaced placeholder
image fill with an empty sourceSet.
const canRevert = engine.block.canRevertToOriginalRatio(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block to query. |
Returns#
boolean
True if the preset would resolve, false if it cannot (no/placeholder fill, empty sourceSet, video not yet decoded, or unsupported fill type).
Signature#
canRevertToOriginalRatio(id: number): booleanBlock Utils#
isAlignable()#
Checks if a set of blocks can be aligned.
A page slice cannot be aligned, so the result is false when blocks holds one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
An array of block ids. |
Returns#
boolean
Whether the blocks can be aligned.
Signature#
isAlignable(blocks: number[]): booleanisDistributable()#
Checks if a set of blocks can be distributed.
A page slice cannot be distributed, so the result is false when blocks holds one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
An array of block ids. |
Returns#
boolean
Whether the blocks can be distributed.
Signature#
isDistributable(blocks: number[]): booleanBlock Properties#
getBool()#
Gets a boolean property from a block.
engine.block.getBool(scene, 'scene/aspectRatioLock');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
BoolPropertyName |
The name of the property to query. |
Returns#
boolean
The value of the property.
Implementation of#
IBlockAPI.getBoolSignature#
getBool(block: number, property: BoolPropertyName): booleansetBool()#
Sets a boolean property on a block.
engine.block.setBool(scene, 'scene/aspectRatioLock', false);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
BoolPropertyName |
The name of the property to set. |
value |
boolean |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setBoolSignature#
setBool(block: number, property: BoolPropertyName, value: boolean): voidgetInt()#
Gets an integer property from a block.
engine.block.setInt(starShape, 'shape/star/points', points + 2);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
IntPropertyName |
The name of the property to query. |
Returns#
number
The value of the property.
Implementation of#
IBlockAPI.getIntSignature#
getInt(block: number, property: IntPropertyName): numbersetInt()#
Sets an integer property on a block.
engine.block.setInt(starShape, 'shape/star/points', points + 2);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
IntPropertyName |
The name of the property to set. |
value |
number |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setIntSignature#
setInt(block: number, property: IntPropertyName, value: number): voidgetFloat()#
Gets a float property from a block.
engine.block.getFloat(starShape, 'shape/star/innerDiameter');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
FloatPropertyName |
The name of the property to query. |
Returns#
number
The value of the property.
Implementation of#
IBlockAPI.getFloatSignature#
getFloat(block: number, property: FloatPropertyName): numbersetFloat()#
Sets a float property on a block.
engine.block.setFloat(text, "text/letterSpacing", 0.2);engine.block.setFloat(text, "text/lineHeight", 1.2);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
FloatPropertyName |
The name of the property to set. |
value |
number |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setFloatSignature#
setFloat(block: number, property: FloatPropertyName, value: number): voidgetDouble()#
Gets a double-precision float property from a block.
engine.block.getDouble(audio, 'playback/duration');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
DoublePropertyName |
The name of the property to query. |
Returns#
number
The value of the property.
Implementation of#
IBlockAPI.getDoubleSignature#
getDouble(block: number, property: DoublePropertyName): numbersetDouble()#
Sets a double-precision float property on a block.
engine.block.setDouble(audio, 'playback/duration', 1.0);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
DoublePropertyName |
The name of the property to set. |
value |
number |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setDoubleSignature#
setDouble(block: number, property: DoublePropertyName, value: number): voidgetVec2()#
Gets a vec2 property from a block.
const { x, y } = engine.block.getVec2(block, 'position');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
Vec2PropertyName |
The name of the property to query. |
Returns#
Vec2The value of the property.
Implementation of#
IBlockAPI.getVec2Signature#
getVec2(block: number, property: Vec2PropertyName): Vec2setVec2()#
Sets a vec2 property on a block. position sets position/x and position/y, and shape/position sets
shape/position/x and shape/position/y, with the checks of those properties. Either both components change
or neither does.
position sets position/x and position/y, and shape/position sets
shape/position/x and shape/position/y, with the checks of those properties. Either both components change
or neither does.engine.block.setVec2(block, 'position', { x: 100, y: 50 });Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
Vec2PropertyName |
The name of the property to set. |
value |
Vec2 |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setVec2Signature#
setVec2(block: number, property: Vec2PropertyName, value: Vec2): voidgetString()#
Gets a string property from a block.
engine.block.getString(text, 'text/text');engine.block.getString(imageFill, 'fill/image/imageFileURI');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
StringPropertyName |
The name of the property to query. |
Returns#
string
The value of the property.
Implementation of#
IBlockAPI.getStringSignature#
getString(block: number, property: StringPropertyName): stringsetString()#
Sets a string property on a block.
engine.block.setString(text, 'text/text', 'Hello World');engine.block.setString(imageFill, 'fill/image/imageFileURI', 'https://example.com/sample.jpg');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
StringPropertyName |
The name of the property to set. |
value |
string |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setStringSignature#
setString(block: number, property: StringPropertyName, value: string): voidgetColor()#
Gets a color property from a block.
engine.block.getColor(colorFill, 'fill/color/value');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be queried. |
property |
ColorPropertyName |
The name of the property to query. |
Returns#
ColorThe value of the property.
Implementation of#
IBlockAPI.getColorSignature#
getColor(block: number, property: ColorPropertyName): ColorsetColor()#
Sets a color property on a block.
// Set the block's fill color to white.engine.block.setColor(colorFill, 'fill/color/value', { r: 1, g: 1, b: 1, a: 1 });Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose property should be set. |
property |
ColorPropertyName |
The name of the property to set. |
value |
Color |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setColorSignature#
setColor(block: number, property: ColorPropertyName, value: Color): voidgetEnum()#
Gets an enum property from a block.
engine.block.getEnum(text, 'text/horizontalAlignment');engine.block.getEnum(text, 'text/verticalAlignment');Type Parameters#
| Type Parameter |
|---|
T extends keyof BlockEnumType |
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block whose property should be queried. |
property |
T |
The name of the property to query. |
Returns#
The value as a string.
Implementation of#
IBlockAPI.getEnumCall Signature#
getEnum(id, property): string;Gets an enum property from a block.
engine.block.getEnum(text, 'text/horizontalAlignment');engine.block.getEnum(text, 'text/verticalAlignment');Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block whose property should be queried. |
property |
string |
The name of the property to query. |
Returns#
string
The value as a string.
Implementation of#
IBlockAPI.getEnumSignatures#
getEnum(id: number, property: T): BlockEnumType[T]getEnum(id: number, property: string): stringfindAllProperties()#
Gets all available properties of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose properties should be queried. |
Returns#
string[]
A list of the property names.
Signature#
findAllProperties(block: number): string[]getPropertyType()#
Gets the type of a property by its name.
Parameters#
| Parameter | Type | Description |
|---|---|---|
property |
string |
The name of the property whose type should be queried. |
Returns#
PropertyTypeThe property type.
Signature#
getPropertyType(property: string): PropertyTypeisPropertyReadable()#
Checks if a property is readable.
Parameters#
| Parameter | Type | Description |
|---|---|---|
property |
string |
The name of the property to check. |
Returns#
boolean
Whether the property is readable. Returns false for unknown properties.
Signature#
isPropertyReadable(property: string): booleanisPropertyWritable()#
Checks if a property is writable.
Parameters#
| Parameter | Type | Description |
|---|---|---|
property |
string |
The name of the property to check. |
Returns#
boolean
Whether the property is writable. Returns false for unknown properties.
Signature#
isPropertyWritable(property: string): booleangetEnumValues()#
Gets all possible values of an enum property.
Type Parameters#
| Type Parameter | Default type |
|---|---|
T |
string |
Parameters#
| Parameter | Type | Description |
|---|---|---|
enumProperty |
string |
The name of the property whose enum values should be queried. |
Returns#
T[]
A list of the enum value names as a string array.
Signature#
getEnumValues(enumProperty: string): T[]Block Strokes#
getStrokeFill()#
Gets the fill block that paints the stroke of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke fill should be returned. Graphic blocks and pages are supported. |
Returns#
number
The fill block that paints the stroke, or null when the stroke uses its color.
Implementation of#
IBlockAPI.getStrokeFillSignature#
getStrokeFill(block: number): numbersetStrokeFill()#
Paints the stroke of a block with a fill block, for example a gradient, instead of the stroke color.
Color, gradient and stripe fills are supported; image, video and pixel stream fills are rejected. The previous stroke fill block is not destroyed automatically. The fill block may not be the block’s own fill. A stroke color with alpha 0 still hides the stroke; the fill’s own colors set the opacity otherwise.
Required scope: ‘stroke/change’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke should be painted. Graphic blocks and pages are supported. |
fill |
number |
The fill block, or null to paint the stroke with its color again. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeFillSignature#
setStrokeFill(block: number, fill: number): voidsupportsStroke()#
Checks if a block supports a stroke.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if the block supports a stroke.
Implementation of#
IBlockAPI.supportsStrokeSignature#
supportsStroke(block: number): booleanisStrokeEnabled()#
Checks if the stroke of a block is enabled.
const strokeIsEnabled = engine.block.isStrokeEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke state should be queried. |
Returns#
boolean
True if the block’s stroke is enabled.
Implementation of#
IBlockAPI.isStrokeEnabledSignature#
isStrokeEnabled(block: number): booleansetStrokeEnabled()#
Enables or disables the stroke of a block.
engine.block.setStrokeEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke should be enabled or disabled. |
enabled |
boolean |
If true, the stroke will be enabled. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeEnabledSignature#
setStrokeEnabled(block: number, enabled: boolean): voidgetStrokeColor()#
Gets the stroke color of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke color should be queried. |
Returns#
ColorThe stroke color.
Implementation of#
IBlockAPI.getStrokeColorSignature#
getStrokeColor(block: number): ColorsetStrokeColor()#
Sets the stroke color of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke color should be set. |
color |
Color |
The color to set. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeColorSignature#
setStrokeColor(block: number, color: Color): voidgetStrokeWidth()#
Gets the stroke width of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke width should be queried. |
Returns#
number
The stroke’s width.
Implementation of#
IBlockAPI.getStrokeWidthSignature#
getStrokeWidth(block: number): numbersetStrokeWidth()#
Sets the stroke width of a block.
When the dash pattern is a preset’s pattern at the old width, it is scaled to the new width. Any other dash pattern keeps its lengths.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke width should be set. |
width |
number |
The stroke width to be set. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeWidthSignature#
setStrokeWidth(block: number, width: number): voidgetStrokeStyle()#
Gets the stroke style of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke style should be queried. |
Returns#
StrokeStyle
The stroke’s style.
Signature#
getStrokeStyle(block: number): StrokeStylesetStrokeStyle()#
Sets the stroke style of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke style should be set. |
style |
StrokeStyle |
The stroke style to be set. |
Returns#
void
Signature#
setStrokeStyle(block: number, style: StrokeStyle): voidgetStrokePosition()#
Gets the stroke position of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke position should be queried. |
Returns#
StrokePosition
The stroke position.
Signature#
getStrokePosition(block: number): StrokePositionsetStrokePosition()#
Sets the stroke position of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke position should be set. |
position |
StrokePosition |
The stroke position to be set. |
Returns#
void
Signature#
setStrokePosition(block: number, position: StrokePosition): voidgetStrokeCornerGeometry()#
Gets the stroke corner geometry of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke corner geometry should be queried. |
Returns#
StrokeCornerGeometry
The stroke corner geometry.
Signature#
getStrokeCornerGeometry(block: number): StrokeCornerGeometrysetStrokeCornerGeometry()#
Sets the stroke corner geometry of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke corner geometry should be set. |
geometry |
StrokeCornerGeometry |
The stroke corner geometry to be set. |
Returns#
void
Signature#
setStrokeCornerGeometry(block: number, geometry: StrokeCornerGeometry): voidgetStrokeStartCap()#
Gets the cap geometry at the start of an open stroked path.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke start cap should be queried. |
Returns#
StrokeCap
The start cap.
Implementation of#
IBlockAPI.getStrokeStartCapSignature#
getStrokeStartCap(block: number): StrokeCapsetStrokeStartCap()#
Sets the cap geometry at the start of an open stroked path. Use this with
setStrokeEndCap to set distinct caps for each end of a stroke (for
set both ends at once and is preserved for backwards compatibility.
setStrokeEndCap to set distinct caps for each end of a stroke (for
set both ends at once and is preserved for backwards compatibility.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke start cap should be set. |
cap |
StrokeCap |
The cap geometry to use at the path start. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeStartCapSignature#
setStrokeStartCap(block: number, cap: StrokeCap): voidgetStrokeEndCap()#
Gets the cap geometry at the end of an open stroked path.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke end cap should be queried. |
Returns#
StrokeCap
The end cap.
Implementation of#
IBlockAPI.getStrokeEndCapSignature#
getStrokeEndCap(block: number): StrokeCapsetStrokeEndCap()#
Sets the cap geometry at the end of an open stroked path. Use this with
setStrokeStartCap to set distinct caps for each end of a stroke.
setStrokeStartCap to set distinct caps for each end of a stroke.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke end cap should be set. |
cap |
StrokeCap |
The cap geometry to use at the path end. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeEndCapSignature#
setStrokeEndCap(block: number, cap: StrokeCap): voidgetStrokeDashStartCap()#
Gets the cap geometry at the leading edge of each dash piece.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose dash start cap should be queried. |
Returns#
StrokeCap
The dash start cap.
Implementation of#
IBlockAPI.getStrokeDashStartCapSignature#
getStrokeDashStartCap(block: number): StrokeCapsetStrokeDashStartCap()#
Sets the cap geometry at the leading edge of each dash piece (excluding the
line’s actual start). Only takes effect when a dash pattern is active.
Distinct from setStrokeStartCap, which only applies to the start of the
open path itself.
setStrokeStartCap, which only applies to the start of the
open path itself.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose dash start cap should be set. |
cap |
StrokeCap |
The cap geometry to use at the leading edge of each dash piece. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeDashStartCapSignature#
setStrokeDashStartCap(block: number, cap: StrokeCap): voidgetStrokeDashEndCap()#
Gets the cap geometry at the trailing edge of each dash piece.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose dash end cap should be queried. |
Returns#
StrokeCap
The dash end cap.
Implementation of#
IBlockAPI.getStrokeDashEndCapSignature#
getStrokeDashEndCap(block: number): StrokeCapsetStrokeDashEndCap()#
Sets the cap geometry at the trailing edge of each dash piece (excluding the
line’s actual end). Only takes effect when a dash pattern is active. Distinct
from setStrokeEndCap, which only applies to the end of the open path itself.
setStrokeEndCap, which only applies to the end of the open path itself.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose dash end cap should be set. |
cap |
StrokeCap |
The cap geometry to use at the trailing edge of each dash piece. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeDashEndCapSignature#
setStrokeDashEndCap(block: number, cap: StrokeCap): voidgetStrokeDashArray()#
Gets the custom dash pattern of the block’s stroke.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke dash pattern should be queried. |
Returns#
number[]
The dash pattern, or an empty array if no custom pattern is set.
Implementation of#
IBlockAPI.getStrokeDashArraySignature#
getStrokeDashArray(block: number): number[]setStrokeDashArray()#
Sets a custom dash pattern for the block’s stroke. Semantics match SVG’s
stroke-dasharray: alternating on/off lengths in design-unit space. When the
pattern is non-empty it overrides the preset implied by StrokeStyle. Pass an
empty array to fall back to the preset.
stroke-dasharray: alternating on/off lengths in design-unit space. When the
pattern is non-empty it overrides the preset implied by StrokeStyle. Pass an
empty array to fall back to the preset.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke dash pattern should be set. |
dashArray |
number[] |
Alternating on/off lengths. Odd-length arrays are doubled to an even length, matching SVG behaviour. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeDashArraySignature#
setStrokeDashArray(block: number, dashArray: number[]): voidgetStrokeDashOffset()#
Gets the dash offset of the block’s stroke.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke dash offset should be queried. |
Returns#
number
The dash offset.
Implementation of#
IBlockAPI.getStrokeDashOffsetSignature#
getStrokeDashOffset(block: number): numbersetStrokeDashOffset()#
Sets the dash offset of the block’s stroke. Semantics match SVG’s
stroke-dashoffset. Ignored when the custom dash pattern is empty.
stroke-dashoffset. Ignored when the custom dash pattern is empty.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose stroke dash offset should be set. |
dashOffset |
number |
The dash offset in design-unit space. |
Returns#
void
Implementation of#
IBlockAPI.setStrokeDashOffsetSignature#
setStrokeDashOffset(block: number, dashOffset: number): voidgetStrokeOverprint()#
Queries whether the stroke of a block is marked as overprint for PDF export.
const overprint = engine.block.getStrokeOverprint(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block whose stroke overprint flag should be queried. |
Returns#
boolean
The stroke overprint flag.
Signature#
getStrokeOverprint(id: number): booleansetStrokeOverprint()#
Marks the stroke of a block as overprint for PDF export.
The flag is only honored by the PDF writer when the stroke uses a spot color (Separation/DeviceN). For process-color strokes it is a silent no-op. On-screen rendering ignores the flag.
engine.block.setStrokeOverprint(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block whose stroke overprint flag should be set. |
overprint |
boolean |
If true, the stroke is marked as overprint in exported PDFs. |
Returns#
void
Signature#
setStrokeOverprint(id: number, overprint: boolean): voidBlock Drop Shadow#
supportsDropShadow()#
Checks if a block supports a drop shadow.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True if the block supports a drop shadow.
Implementation of#
IBlockAPI.supportsDropShadowSignature#
supportsDropShadow(block: number): booleanisDropShadowEnabled()#
Checks if the drop shadow of a block is enabled.
const dropShadowIsEnabled = engine.block.isDropShadowEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow state should be queried. |
Returns#
boolean
True if the block’s drop shadow is enabled.
Implementation of#
IBlockAPI.isDropShadowEnabledSignature#
isDropShadowEnabled(block: number): booleansetDropShadowEnabled()#
Enables or disables the drop shadow of a block.
engine.block.setDropShadowEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow should be enabled or disabled. |
enabled |
boolean |
If true, the drop shadow will be enabled. |
Returns#
void
Implementation of#
IBlockAPI.setDropShadowEnabledSignature#
setDropShadowEnabled(block: number, enabled: boolean): voidgetDropShadowColor()#
Gets the drop shadow color of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow color should be queried. |
Returns#
ColorThe drop shadow color.
Implementation of#
IBlockAPI.getDropShadowColorSignature#
getDropShadowColor(block: number): ColorsetDropShadowColor()#
Sets the drop shadow color of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow color should be set. |
color |
Color |
The color to set. |
Returns#
void
Implementation of#
IBlockAPI.setDropShadowColorSignature#
setDropShadowColor(block: number, color: Color): voidgetDropShadowOffsetX()#
Gets the drop shadow’s horizontal offset.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s X offset should be queried. |
Returns#
number
The offset.
Signature#
getDropShadowOffsetX(block: number): numbersetDropShadowOffsetX()#
Sets the drop shadow’s horizontal offset.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s X offset should be set. |
offset |
number |
The X offset to be set. |
Returns#
void
Signature#
setDropShadowOffsetX(block: number, offset: number): voidgetDropShadowOffsetY()#
Gets the drop shadow’s vertical offset.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s Y offset should be queried. |
Returns#
number
The offset.
Signature#
getDropShadowOffsetY(block: number): numbersetDropShadowOffsetY()#
Sets the drop shadow’s vertical offset.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s Y offset should be set. |
offset |
number |
The Y offset to be set. |
Returns#
void
Signature#
setDropShadowOffsetY(block: number, offset: number): voidgetDropShadowBlurRadiusX()#
Gets the drop shadow’s horizontal blur radius.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s blur radius should be queried. |
Returns#
number
The blur radius.
Signature#
getDropShadowBlurRadiusX(block: number): numbersetDropShadowBlurRadiusX()#
Sets the drop shadow’s horizontal blur radius.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s blur radius should be set. |
radius |
number |
The blur radius to be set. |
Returns#
void
Signature#
setDropShadowBlurRadiusX(block: number, radius: number): voidgetDropShadowBlurRadiusY()#
Gets the drop shadow’s vertical blur radius.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s blur radius should be queried. |
Returns#
number
The blur radius.
Signature#
getDropShadowBlurRadiusY(block: number): numbersetDropShadowBlurRadiusY()#
Sets the drop shadow’s vertical blur radius.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s blur radius should be set. |
radius |
number |
The blur radius to be set. |
Returns#
void
Signature#
setDropShadowBlurRadiusY(block: number, radius: number): voidgetDropShadowClip()#
Gets the drop shadow’s clipping behavior.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s clipping should be queried. |
Returns#
boolean
The drop shadow’s clipping state.
Signature#
getDropShadowClip(block: number): booleansetDropShadowClip()#
Sets the drop shadow’s clipping behavior.
This only applies to shapes.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose drop shadow’s clip should be set. |
clip |
boolean |
The drop shadow’s clip to be set. |
Returns#
void
Signature#
setDropShadowClip(block: number, clip: boolean): voidBlock Effects#
supportsEffects()#
Checks if a block supports effects.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block can render effects, false otherwise.
Implementation of#
IBlockAPI.supportsEffectsSignature#
supportsEffects(block: number): booleangetEffects()#
Gets all effects attached to a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number[]
A list of effects or an error, if the block doesn’t support effects.
Implementation of#
IBlockAPI.getEffectsSignature#
getEffects(block: number): number[]appendEffect()#
Appends an effect to a block’s effect list.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to append the effect to. |
effect |
number |
The effect to append. |
Returns#
void
Implementation of#
IBlockAPI.appendEffectSignature#
appendEffect(block: number, effect: number): voidinsertEffect()#
Inserts an effect into a block’s effect list at a given index.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
effect |
number |
The effect to insert. |
index |
number |
The index at which the effect shall be inserted. |
Returns#
void
Implementation of#
IBlockAPI.insertEffectSignature#
insertEffect(block: number, effect: number, index: number): voidremoveEffect()#
Removes an effect from a block’s effect list at a given index.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to remove the effect from. |
index |
number |
The index where the effect is stored. |
Returns#
void
Implementation of#
IBlockAPI.removeEffectSignature#
removeEffect(block: number, index: number): voidisEffectEnabled()#
Queries if an effect block is enabled.
engine.block.isEffectEnabled(effects[0]);Parameters#
| Parameter | Type | Description |
|---|---|---|
effect |
number |
The ‘effect’ block to query. |
Returns#
boolean
True, if the effect is enabled. False otherwise.
Implementation of#
IBlockAPI.isEffectEnabledSignature#
isEffectEnabled(effect: number): booleansetEffectEnabled()#
Sets the enabled state of an effect block.
engine.block.setEffectEnabled(effects[0], false);Parameters#
| Parameter | Type | Description |
|---|---|---|
effect |
number |
The ‘effect’ block to update. |
enabled |
boolean |
The new state. |
Returns#
void
Implementation of#
IBlockAPI.setEffectEnabledSignature#
setEffectEnabled(effect: number, enabled: boolean): voidsetEffectSource()#
Sets the block that an effect reads, such as the map of a displacement map effect.
The source still draws on its own. It is read without its position and rotation, and also when it is hidden.
Required scope: ‘appearance/effect’ on every block the effect is attached to.
const effect = engine.block.createEffect('displacement_map');engine.block.setEffectSource(effect, mapBlock);Parameters#
| Parameter | Type | Description |
|---|---|---|
effect |
number |
The ‘effect’ block to update. Only the displacement map effect reads a source. |
source |
number |
A graphic, text or group block, or null to remove the source. |
Returns#
void
Implementation of#
IBlockAPI.setEffectSourceSignature#
setEffectSource(effect: number, source: number): voidgetEffectSource()#
Gets the block that an effect reads.
const mapBlock = engine.block.getEffectSource(effect);Parameters#
| Parameter | Type | Description |
|---|---|---|
effect |
number |
The ‘effect’ block to query. Only the displacement map effect reads a source. |
Returns#
number
The source block, or null when the effect has no source.
Implementation of#
IBlockAPI.getEffectSourceSignature#
getEffectSource(effect: number): numberBlock Text Animators#
supportsTextAnimators()#
Checks if a block supports text animators. Text and caption blocks do.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block supports text animators, false otherwise.
Implementation of#
IBlockAPI.supportsTextAnimatorsSignature#
supportsTextAnimators(block: number): booleangetTextAnimators()#
Gets the text animators of a block, in the order they apply.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
Returns#
number[]
The text animators of the block.
Throws#
Error if the block doesn’t support text animators.
Implementation of#
IBlockAPI.getTextAnimatorsSignature#
getTextAnimators(block: number): number[]appendTextAnimator()#
Appends a text animator to a block’s text animators. A text animator belongs to one block at a time.
Required scope: ‘appearance/animation’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to update. |
animator |
number |
The text animator to append. |
Returns#
void
Throws#
Error if the block doesn’t support text animators, or the block to append is not a text animator or already belongs to a block.
Implementation of#
IBlockAPI.appendTextAnimatorSignature#
appendTextAnimator(block: number, animator: number): voidinsertTextAnimator()#
Inserts a text animator into a block’s text animators at a given index. A text animator belongs to one block
at a time.
Required scope: ‘appearance/animation’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to update. |
animator |
number |
The text animator to insert. |
index |
number |
The index at which the text animator shall be inserted. |
Returns#
void
Throws#
Error if the block doesn’t support text animators, the block to insert is not a text animator or already belongs to a block, or the index is out of bounds.
Implementation of#
IBlockAPI.insertTextAnimatorSignature#
insertTextAnimator(block: number, animator: number, index: number): voidremoveTextAnimator()#
Removes the text animator at a given index from a block. The text animator is not destroyed.
Required scope: ‘appearance/animation’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to update. |
index |
number |
The index of the text animator to remove. |
Returns#
void
Throws#
Error if the block doesn’t support text animators or the index is out of bounds.
Implementation of#
IBlockAPI.removeTextAnimatorSignature#
removeTextAnimator(block: number, index: number): voidBlock Blur#
supportsBlur()#
Checks if a block supports blur.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block supports blur.
Implementation of#
IBlockAPI.supportsBlurSignature#
supportsBlur(block: number): booleangetBlur()#
Gets the blur block of a given design block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number
The ‘blur’ block, or an invalid block if unset.
Check the result with isValid.
Implementation of#
IBlockAPI.getBlurSignature#
getBlur(block: number): numbersetBlur()#
Sets the blur effect for a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
blur |
number |
A ‘blur’ block to apply. |
Returns#
void
Implementation of#
IBlockAPI.setBlurSignature#
setBlur(block: number, blur: number): voidisBlurEnabled()#
Checks if blur is enabled for a block.
const isBlurEnabled = engine.block.isBlurEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the blur is enabled. False otherwise.
Implementation of#
IBlockAPI.isBlurEnabledSignature#
isBlurEnabled(block: number): booleansetBlurEnabled()#
Enables or disables the blur effect on a block.
engine.block.setBlurEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
enabled |
boolean |
The new enabled value. |
Returns#
void
Implementation of#
IBlockAPI.setBlurEnabledSignature#
setBlurEnabled(block: number, enabled: boolean): voidBlock Placeholder#
isPlaceholderEnabled()#
Checks if the placeholder function for a block is enabled and can be selected by users in Adopter mode.
const placeholderIsEnabled = engine.block.isPlaceholderEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder function state should be queried. |
Returns#
boolean
The enabled state of the placeholder function.
Signature#
isPlaceholderEnabled(block: number): booleansetPlaceholderEnabled()#
Enables or disables the placeholder function for a block.
When set to true, the given block becomes selectable by users and its placeholder capabilities are enabled in Adopter mode.
engine.block.setPlaceholderEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder function should be enabled or disabled. |
enabled |
boolean |
Whether the function should be enabled or disabled. |
Returns#
void
Signature#
setPlaceholderEnabled(block: number, enabled: boolean): voidsupportsPlaceholderBehavior()#
Checks if a block supports placeholder behavior.
const placeholderBehaviorSupported = engine.block.supportsPlaceholderBehavior(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block supports placeholder behavior.
Signature#
supportsPlaceholderBehavior(block: number): booleanisPlaceholderBehaviorEnabled()#
Checks if the placeholder behavior for a block is enabled.
engine.block.setPlaceholderBehaviorEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder behavior state should be queried. |
Returns#
boolean
The enabled state of the placeholder behavior.
Signature#
isPlaceholderBehaviorEnabled(block: number): booleansetPlaceholderBehaviorEnabled()#
Enables or disables the placeholder behavior for a block.
When its fill block is set to true, an image block will act as a placeholder, showing a control overlay and a replacement button.
engine.block.setPlaceholderBehaviorEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder behavior should be enabled or disabled. |
enabled |
boolean |
Whether the placeholder behavior should be enabled or disabled. |
Returns#
void
Signature#
setPlaceholderBehaviorEnabled(block: number, enabled: boolean): voidsupportsPlaceholderControls()#
Checks if a block supports placeholder controls, e.g. a control overlay and a replacement button.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block supports placeholder controls.
Signature#
supportsPlaceholderControls(block: number): booleanisPlaceholderControlsOverlayEnabled()#
Checks if the placeholder overlay pattern is enabled.
const overlayEnabled = engine.block.isPlaceholderControlsOverlayEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder overlay visibility state should be queried. |
Returns#
boolean
The visibility state of the block’s placeholder overlay pattern.
Signature#
isPlaceholderControlsOverlayEnabled(block: number): booleansetPlaceholderControlsOverlayEnabled()#
Enables or disables the placeholder overlay pattern.
engine.block.setPlaceholderControlsOverlayEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder overlay should be enabled or disabled. |
enabled |
boolean |
Whether the placeholder overlay should be shown or not. |
Returns#
void
Signature#
setPlaceholderControlsOverlayEnabled(block: number, enabled: boolean): voidisPlaceholderControlsButtonEnabled()#
Checks if the placeholder button is enabled.
const buttonEnabled = engine.block.isPlaceholderControlsButtonEnabled(block);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder button visibility state should be queried. |
Returns#
boolean
The visibility state of the block’s placeholder button.
Signature#
isPlaceholderControlsButtonEnabled(block: number): booleansetPlaceholderControlsButtonEnabled()#
Enables or disables the placeholder button.
engine.block.setPlaceholderControlsButtonEnabled(block, true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose placeholder button should be shown or not. |
enabled |
boolean |
Whether the placeholder button should be shown or not. |
Returns#
void
Signature#
setPlaceholderControlsButtonEnabled(block: number, enabled: boolean): voidBlock Scopes#
isScopeEnabled()#
Checks if a scope is enabled for a block.
engine.block.isScopeEnabled(image, 'layer/move');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose scope state should be queried. |
scope |
string |
The scope to query. |
Returns#
boolean
The enabled state of the scope for the given block.
Signature#
isScopeEnabled(block: number, scope: string): booleansetScopeEnabled()#
Enables or disables a scope for a block.
// Allow the user to move the image block.engine.block.setScopeEnabled(image, 'layer/move', true);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose scope should be enabled or disabled. |
scope |
string |
The scope to enable or disable. |
enabled |
boolean |
Whether the scope should be enabled or disabled. |
Returns#
void
Signature#
setScopeEnabled(block: number, scope: string, enabled: boolean): voidisAllowedByScope()#
Checks if an operation is allowed by a block’s scopes.
// This will return true when the global scope is set to 'Defer'.engine.block.isAllowedByScope(image, 'layer/move');Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to check. |
scope |
string |
The scope to check. |
Returns#
boolean
Whether the scope is allowed for the given block.
Signature#
isAllowedByScope(block: number, scope: string): booleanBlock Boolean Operations#
combine()#
Performs a boolean operation on a set of blocks.
All blocks must be combinable. See isCombinable.
The parent, fill and sort order of the new block is that of the prioritized block.
When the prioritized block has no fill, the new block has none.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
The blocks to combine. They will be destroyed if “lifecycle/destroy” scope is enabled. |
operation |
BooleanOperation |
The boolean operation to perform. |
Returns#
number
The newly created block or an error.
Signature#
combine(blocks: number[], operation: BooleanOperation): numberisCombinable()#
Checks if a set of blocks can be combined using a boolean operation.
Only graphics blocks and text blocks can be combined. All blocks must have the “lifecycle/duplicate” scope enabled.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
An array of block ids. |
Returns#
boolean
Whether the blocks can be combined.
Signature#
isCombinable(blocks: number[]): booleanBlock Cutout#
createCutoutFromOperation()#
Creates a new cutout block by performing a boolean operation on existing cutout blocks.
Parameters#
| Parameter | Type | Description |
|---|---|---|
ids |
number[] |
The cutout blocks with which to perform to the operation. |
op |
CutoutOperation |
The boolean operation to perform. |
Returns#
number
The newly created block or an error.
Signature#
createCutoutFromOperation(ids: number[], op: CutoutOperation): numbercreateCutoutFromPath()#
Creates a cutout block from an SVG path string.
Parameters#
| Parameter | Type | Description |
|---|---|---|
pathData |
string |
An SVG string describing a path. |
Returns#
number
The newly created block or an error.
Signature#
createCutoutFromPath(pathData: string): numberBlock Analysis#
getDominantColors()#
Extracts the dominant colors from the rendered appearance of a block.
Performs an internal update to resolve the final layout for the block. Will not complete as long as assets are in a pending state; asset loading progresses during engine updates. Crops, color adjustments, and effects applied to the block are reflected in the returned palette. Fully or mostly transparent pixels are excluded from the analysis.
Parameters#
| Parameter | Type | Description |
|---|---|---|
handle |
number |
The design block element to analyze. Must be attached to a scene and render visible content. |
options? |
DominantColorsOptions |
See DominantColorsOptions. |
Returns#
Promise<DominantColor[]>
A promise that resolves with the dominant colors sorted by weight, descending.
Signature#
getDominantColors(handle: number, options?: DominantColorsOptions): Promise<DominantColor[]>Block Audio#
getAudioTrackCountFromVideo()#
Gets the number of available audio tracks in a video fill block.
const trackCount = engine.block.getAudioTrackCountFromVideo(videoBlock);console.log(`Video has ${trackCount} audio tracks`);Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The video fill block to examine. |
Returns#
number
The number of audio tracks.
Throws#
Will throw an error if the block is not a video fill or has no audio.
Signature#
getAudioTrackCountFromVideo(block: number): numbergetAudioInfoFromVideo()#
Gets information about all audio tracks from a video fill block.
// Get information about all audio tracksconst trackInfos = engine.block.getAudioInfoFromVideo(videoFillBlock);console.log(`Video has ${trackInfos.length} audio tracks`);
// Display track informationtrackInfos.forEach((track, index) => { console.log(`Track ${index}: ${track.channels} channels, ${track.sampleRate}Hz, ${track.language}`);});
// Use track info to create audio blocks selectivelyconst englishTracks = trackInfos.filter(track => track.language === 'eng');const audioBlocks = englishTracks.map(track => engine.block.createAudioFromVideo(videoFillBlock, track.trackIndex));Parameters#
| Parameter | Type | Description |
|---|---|---|
videoFillBlock |
number |
The video fill block to analyze for audio track information. |
Returns#
An array containing information about each audio track.
Throws#
Will throw an error if the block is not a video fill or has no audio.
Signature#
getAudioInfoFromVideo(videoFillBlock: number): AudioTrackInfo[]createAudioFromVideo()#
Creates a new audio block by extracting a specific audio track from a video fill block.
// Extract the first audio track (usually the main mix) with trim settingsconst audioBlock = engine.block.createAudioFromVideo(videoFillBlock, 0);
// Extract full audio track without trim settingsconst audioBlock = engine.block.createAudioFromVideo(videoFillBlock, 0, { keepTrimSettings: false });
// Extract a specific track, keep trim settings, and mute the original videoconst dialogueTrack = engine.block.createAudioFromVideo(videoFillBlock, 1, { keepTrimSettings: true, muteOriginalVideo: true });Note: The audio block can still load after this call returns. When the video file is not completely in memory,
for example an uploaded or a remote video, the audio comes from the file in the background. Until it is
complete, unstable_isAVResourceLoaded returns false, forceLoadAVResource waits for it, and the block is
pending once it is in the scene.
Parameters#
| Parameter | Type | Description |
|---|---|---|
videoFillBlock |
number |
The video fill block to extract audio from. |
trackIndex |
number |
The index of the audio track to extract (0-based). |
options? |
AudioFromVideoOptions |
Options for the audio extraction operation. |
Returns#
number
The handle of the newly created audio block with extracted audio from the specified track.
Throws#
Will throw an error if the track index is invalid or the block has no audio.
Signature#
createAudioFromVideo(videoFillBlock: number, trackIndex: number, options?: AudioFromVideoOptions): numbercreateAudiosFromVideo()#
Creates multiple audio blocks by extracting all audio tracks from a video fill block.
// Extract all audio tracks from a video with trim settingsconst audioBlocks = engine.block.createAudiosFromVideo(videoFillBlock);console.log(`Created ${audioBlocks.length} audio blocks`);
// Extract all tracks without trim settings (full audio)const audioBlocks = engine.block.createAudiosFromVideo(videoFillBlock, { keepTrimSettings: false });
// Extract all tracks with trim settings and mute the original videoconst audioBlocks = engine.block.createAudiosFromVideo(videoFillBlock, { keepTrimSettings: true, muteOriginalVideo: true });Note: The audio blocks can still load after this call returns, as with createAudioFromVideo.
Parameters#
| Parameter | Type | Description |
|---|---|---|
videoFillBlock |
number |
The video fill block to extract audio from. |
options? |
AudioFromVideoOptions |
Options for the audio extraction operation. |
Returns#
number[]
An array of handles for the newly created audio blocks, one per track.
Throws#
Will throw an error if the block has no audio or extraction fails.
Signature#
createAudiosFromVideo(videoFillBlock: number, options?: AudioFromVideoOptions): number[]Block Masks#
supportsMasks()#
Checks if a block supports masks. Graphic, text and group blocks do.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block supports masks, false otherwise.
Implementation of#
IBlockAPI.supportsMasksSignature#
supportsMasks(block: number): booleangetMasks()#
Gets the masks of a block, in the order in which they combine.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
number[]
The masks of the block.
Throws#
Error if the block does not support masks.
Implementation of#
IBlockAPI.getMasksSignature#
getMasks(block: number): number[]appendMask()#
Appends a mask to a block’s masks.
Required scope: ‘layer/clipping’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to mask. |
mask |
number |
The mask to append. A mask can be used by more than one block. |
Returns#
void
Throws#
Error if the block does not support masks or the mask is not a mask.
Implementation of#
IBlockAPI.appendMaskSignature#
appendMask(block: number, mask: number): voidinsertMask()#
Inserts a mask into a block’s masks at a given index.
Required scope: ‘layer/clipping’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to mask. |
mask |
number |
The mask to insert. A mask can be used by more than one block. |
index |
number |
The index in the range [0, number of masks]. The masks combine in the order of their indices. |
Returns#
void
Throws#
Error if the block does not support masks, the mask is not a mask or the index is out of range.
Implementation of#
IBlockAPI.insertMaskSignature#
insertMask(block: number, mask: number, index: number): voidremoveMask()#
Removes the mask at the given index from a block’s masks. The mask block is not destroyed.
Required scope: ‘layer/clipping’
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to remove the mask from. |
index |
number |
The index of the mask. |
Returns#
void
Throws#
Error if the block does not support masks or the index is out of range.
Implementation of#
IBlockAPI.removeMaskSignature#
removeMask(block: number, index: number): voidBlock Metadata#
hasMetadata()#
Checks if a block has metadata for a given key.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose metadata will be accessed. |
key |
string |
The key used to identify the desired piece of metadata. |
Returns#
boolean
Whether the key exists.
Implementation of#
IBlockAPI.hasMetadataSignature#
hasMetadata(block: number, key: string): booleangetMetadata()#
Gets a metadata value for a given key from a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose metadata will be accessed. |
key |
string |
The key used to identify the desired piece of metadata. |
Returns#
string
The value associated with the key.
Implementation of#
IBlockAPI.getMetadataSignature#
getMetadata(block: number, key: string): stringsetMetadata()#
Sets a metadata value for a given key on a block.
If the key does not exist, it will be added.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose metadata will be accessed. |
key |
string |
The key used to identify the desired piece of metadata. |
value |
string |
The value to set. |
Returns#
void
Implementation of#
IBlockAPI.setMetadataSignature#
setMetadata(block: number, key: string, value: string): voidremoveMetadata()#
Removes metadata for a given key from a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose metadata will be accessed. |
key |
string |
The key used to identify the desired piece of metadata. |
Returns#
void
Implementation of#
IBlockAPI.removeMetadataSignature#
removeMetadata(block: number, key: string): voidfindAllMetadata()#
Finds all metadata keys on a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose metadata will be accessed. |
Returns#
string[]
A list of all metadata keys on this block.
Implementation of#
IBlockAPI.findAllMetadataSignature#
findAllMetadata(block: number): string[]Block Modifiers#
supportsModifiers()#
Checks if a block supports modifiers. Every shape block does.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to query. |
Returns#
boolean
True, if the block supports modifiers, false otherwise.
Implementation of#
IBlockAPI.supportsModifiersSignature#
supportsModifiers(block: number): booleangetModifiers()#
Gets the modifiers of a shape, in the order they apply to its path.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The shape to query. |
Returns#
number[]
The modifiers of the shape.
Throws#
Error if the block doesn’t support modifiers.
Implementation of#
IBlockAPI.getModifiersSignature#
getModifiers(block: number): number[]appendModifier()#
Appends a modifier to a shape’s modifier list.
Required scope: ‘shape/change’ on every block that uses the shape.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The shape to update. |
modifier |
number |
The modifier to append. |
Returns#
void
Throws#
Error if the block doesn’t support modifiers or the block to append is not a modifier.
Implementation of#
IBlockAPI.appendModifierSignature#
appendModifier(block: number, modifier: number): voidinsertModifier()#
Inserts a modifier into a shape’s modifier list at a given index.
Required scope: ‘shape/change’ on every block that uses the shape.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The shape to update. |
modifier |
number |
The modifier to insert. |
index |
number |
The index at which the modifier shall be inserted. |
Returns#
void
Throws#
Error if the block doesn’t support modifiers, the block to insert is not a modifier, or the index is out of bounds.
Implementation of#
IBlockAPI.insertModifierSignature#
insertModifier(block: number, modifier: number, index: number): voidremoveModifier()#
Removes a modifier from a shape’s modifier list at a given index. The modifier is not destroyed.
Required scope: ‘shape/change’ on every block that uses the shape.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The shape to update. |
index |
number |
The index of the modifier to remove. |
Returns#
void
Throws#
Error if the block doesn’t support modifiers or the index is out of bounds.
Implementation of#
IBlockAPI.removeModifierSignature#
removeModifier(block: number, index: number): voidBlock Transitions#
createTransition()#
Creates a new transition block.
The created block is standalone until assigned to a clip with setTransition.
Once assigned, it is owned by that clip: it is destroyed together with the
clip, and the engine also destroys it automatically when the two clips stop
being timeline-adjacent on the track (e.g. after a manual gap is introduced).
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
TransitionType |
The type of transition to create. |
Returns#
number
The handle of the new transition instance.
Signature#
createTransition(type: TransitionType): numbersupportsTransition()#
Checks whether a clip can own an outgoing clip-to-clip transition.
Clips inside a video track qualify, group clips included. Audio, caption
and cutout blocks report false, and so do blocks outside a video track.
A group that holds only audio blocks reports false too.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The clip block to check. |
Returns#
boolean
Whether the block can own an outgoing transition.
Signature#
supportsTransition(block: number): booleangetTransition()#
Gets the outgoing transition assigned to a clip.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The outgoing clip whose transition relation should be queried. |
Returns#
number
The assigned transition block, or an invalid block if unset.
Check the result with isValid.
Signature#
getTransition(block: number): numbersetTransition()#
Assigns the outgoing transition of a clip.
A previously assigned transition block is detached but not destroyed
automatically. Throws an error if the given transition block is invalid or
already assigned to another clip. Both the clip and its following clip on
the track must support transitions, see supportsTransition. To clear a
clip’s transition, use removeTransition instead. A group clip on either
side ignores transition/overlap: the clips meet at the cut, and the saved
value stays.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The outgoing clip that owns the transition relation. |
transition |
number |
The transition block to assign. |
Returns#
void
Signature#
setTransition(block: number, transition: number): voidremoveTransition()#
Removes the outgoing transition of a clip.
The removed transition block is detached but not destroyed automatically. Removing from a clip without an assigned transition is a no-op.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The outgoing clip whose transition relation should be cleared. |
Returns#
void
Signature#
removeTransition(block: number): voidHelper#
setPosition()#
Update a block’s position.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
x |
number |
The new x position of the block. |
y |
number |
The new y position of the block. |
options? |
{ positionMode?: PositionMode; } |
Optional parameters for the position. Properties: - positionMode - The position mode: absolute, percent or undefined. |
options.positionMode? |
PositionMode |
- |
Returns#
void
Signature#
setPosition(block: number, x: number, y: number, options?: object): voidgetBackgroundTrack()#
Gets the background track of the current scene.
The background track is the track that determines the page duration.
Returns#
number
The ID of the background track, or null if none exists
Signature#
getBackgroundTrack(): numbermoveToBackgroundTrack()#
Moves a block to the background track.
This is useful for organizing content in video scenes where you want
certain elements to be part of the background layer.
The background track is the track that determines the page duration.
If no background track exists, one will be created automatically.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block to move to the background track |
Returns#
void
Signature#
moveToBackgroundTrack(block: number): voidOther#
create()#
Create a new block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
DesignBlockType |
The block type (e.g., ‘graphic’, ‘text’, ‘page’, ‘audio’). |
Returns#
number
The ID of the newly created block.
Note#
New text and graphic blocks use clip/defaultDurationValue (5 seconds by default). Duration is provisional until an engine update after placement and media loading initializes it once using clip/initialDurationMode. Waiting for forceLoadAVResource alone does not guarantee that update has run. An explicit setDuration call takes precedence. Finish parent and time-offset placement before that update. Custom asset callbacks that defer placement across updates must set the final duration explicitly.
Implementation of#
IBlockAPI.createSignature#
create(type: DesignBlockType): numbercreateFill()#
Create a new fill block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
FillType |
The fill type (e.g., ‘color’, ‘gradient/linear’, ‘gradient/radial’, ‘image’, ‘video’). |
Returns#
number
The ID of the newly created fill block.
Implementation of#
IBlockAPI.createFillSignature#
createFill(type: FillType): numbercreateShape()#
Create a new shape block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
ShapeType |
The shape type (e.g., ‘rect’, ‘ellipse’, ‘polygon’, ‘star’, ‘line’). |
Returns#
number
The ID of the newly created shape block.
Implementation of#
IBlockAPI.createShapeSignature#
createShape(type: ShapeType): numbercreateEffect()#
Create a new effect block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
EffectType |
The effect type (e.g., ‘adjustments’, ‘pixelize’, ‘glow’, ‘half_tone’). |
Returns#
number
The ID of the newly created effect block.
Implementation of#
IBlockAPI.createEffectSignature#
createEffect(type: EffectType): numbercreateMask()#
Create a new mask block. A mask cuts its block down to the area of the mask’s shape. Give the mask a shape with
setShape; a mask without a shape has no effect. Attach it with appendMask or insertMask.
setShape; a mask without a shape has no effect. Attach it with appendMask or insertMask.Returns#
number
The ID of the newly created mask block.
Implementation of#
IBlockAPI.createMaskSignature#
createMask(): numbercreateBlur()#
Create a new blur block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
BlurType |
The blur type (e.g., ‘uniform’, ‘linear’, ‘mirrored’, ‘radial’). |
Returns#
number
The ID of the newly created blur block.
Implementation of#
IBlockAPI.createBlurSignature#
createBlur(type: BlurType): numbercreateAnimation()#
Create a new animation block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
AnimationType |
The animation type. |
Returns#
number
The ID of the newly created animation block.
Implementation of#
IBlockAPI.createAnimationSignature#
createAnimation(type: AnimationType): numberduplicate()#
Duplicate an existing block.
Copies the current duration, even if initialization is pending on the original. The duplicate does not resume initialization.
A scene cannot be duplicated, and the call throws for it.
The duplicate of a page slice takes a copy of the blocks that the page slice owns on its
page. The call runs an internal update for a page slice on a page, also while
features/implicitUpdatesEnabled is off.
A block that a page slice owns gets its Percent position and size in design units in the copy.
The copy does not follow the size of its page.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block to duplicate. |
attachToParent? |
boolean |
Whether to attach the duplicate to the same parent (default: true). |
Returns#
number
The ID of the duplicated block.
Implementation of#
IBlockAPI.duplicateSignature#
duplicate(block: number, attachToParent?: boolean): numberdestroy()#
Destroy a block and release its resources.
A page slice destroys the blocks that it owns on its page, without a check of their scopes,
as a page destroys its children. This holds for the last page slice too: its page becomes an empty page without
page slices, at the same size. To keep the content, move the page slice out with movePageSliceOutOfPage first.
Destroying a page slice runs an internal update.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block to destroy. |
Returns#
void
Implementation of#
IBlockAPI.destroySignature#
destroy(block: number): voidisValid()#
Check if a block ID refers to a valid, existing block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID to check. |
Returns#
boolean
True if the block exists and is valid, false otherwise.
Implementation of#
IBlockAPI.isValidSignature#
isValid(block: number): booleanfindAll()#
Find all blocks in the scene.
Returns#
number[]
Array of all block IDs.
Implementation of#
IBlockAPI.findAllSignature#
findAll(): number[]findAllPlaceholders()#
Find all placeholder blocks in the scene.
Returns#
number[]
Array of placeholder block IDs.
Implementation of#
IBlockAPI.findAllPlaceholdersSignature#
findAllPlaceholders(): number[]findAllUnused()#
Find all blocks that are not part of the active scene tree (orphans).
Useful for diagnosing leaks where blocks are created with create(…)
but never appended to a parent.
create(…)
but never appended to a parent.Returns#
number[]
Array of unreferenced block IDs.
Signature#
findAllUnused(): number[]findAllInExclusionAreas()#
Get all blocks that overlap an exclusion area on their page.
The engine never moves a block to satisfy an exclusion area. A scene loaded from a file, or laid out through the API, can legitimately overlap one, and silently repositioning it would lose the author’s layout. Use this to warn or to highlight instead.
An exclusion area that is hidden, or that is not on a page, reports nothing. exclusionArea/constrains is not
read: an advisory exclusion area has no push, so a warning is the only thing it has. A group that
straddles an exclusion area is reported instead of the blocks inside it.
Returns#
number[]
Array of block IDs that overlap an exclusion area, sorted ascending.
Signature#
findAllInExclusionAreas(): number[]findByName()#
Find blocks by their name.
Parameters#
| Parameter | Type | Description |
|---|---|---|
name |
string |
The name to search for. |
Returns#
number[]
Array of matching block IDs.
Implementation of#
IBlockAPI.findByNameSignature#
findByName(name: string): number[]findByType()#
Find blocks by their type.
For the stack type, the result holds the scene when the scene arranges its pages. Do not destroy that
block: it is the scene.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
ObjectType |
The type to search for (e.g., ‘//ly.img.ubq/graphic’). |
Returns#
number[]
Array of matching block IDs.
Implementation of#
IBlockAPI.findByTypeSignature#
findByType(type: ObjectType): number[]findByKind()#
Find blocks by their kind.
Parameters#
| Parameter | Type | Description |
|---|---|---|
kind |
string |
The kind to search for (e.g., ‘image’, ‘text’, ‘sticker’). |
Returns#
number[]
Array of matching block IDs.
Implementation of#
IBlockAPI.findByKindSignature#
findByKind(kind: string): number[]findAllSelected()#
Find all currently selected blocks.
Returns#
number[]
Array of selected block IDs.
Implementation of#
IBlockAPI.findAllSelectedSignature#
findAllSelected(): number[]getParent()#
Get the parent of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
number
The ID of the parent block, or null if no parent.
Implementation of#
IBlockAPI.getParentSignature#
getParent(block: number): numbersetTransformParent()#
Make a block follow the transform of another block, or stop it from following one.
Only the transform is inherited, not opacity, visibility or stacking order.
A block whose transform is locked can neither get nor lose a link.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the graphic or text block that follows. |
parent |
number |
The ID of the graphic or text block to follow, or null to remove the link. |
Returns#
void
Implementation of#
IBlockAPI.setTransformParentSignature#
setTransformParent(block: number, parent: number): voidgetTransformParent()#
Get the block whose transform a block follows.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
number
The ID of the transform parent, or null if the block follows none.
Implementation of#
IBlockAPI.getTransformParentSignature#
getTransformParent(block: number): numbergetOwningPageSlice()#
Get the page slice that owns a block on its page.
A page slice has no children, so the block is a child of the page, or of a group on the page. The page slice under the center of the block owns it. On a fold, the earlier page slice owns it. A block outside the page belongs to the nearest page slice. A block in a group belongs where its group does. The call runs an internal update when the block has no frame. It does the same when the page has page slices that no update laid out yet.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
number
The ID of the page slice, or null for a block that is not on a page with page slices. A page and a page slice also give null.
Implementation of#
IBlockAPI.getOwningPageSliceSignature#
getOwningPageSlice(block: number): numbergetPageSlices()#
Get the page slices of a page, in reading order.
The list holds hidden page slices too. It is the order of the page slices among the children of the page.
Parameters#
| Parameter | Type | Description |
|---|---|---|
page |
number |
The ID of the page. |
Returns#
number[]
The IDs of the page slices. An empty list for a block without page slices.
Implementation of#
IBlockAPI.getPageSlicesSignature#
getPageSlices(page: number): number[]hasTransformAnchor()#
Check whether a block has its own anchor.
Setting transform/anchor/x or transform/anchor/y, even to 0, or giving one of them keyframes, gives a block an
anchor. A rotation keyframe track turns a block with an anchor around the anchor, and a block without one around
its frame center, as setRotation does.
transform/anchor/x or transform/anchor/y, even to 0, or giving one of them keyframes, gives a block an
anchor. A rotation keyframe track turns a block with an anchor around the anchor, and a block without one around
its frame center, as setRotation does.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of a graphic, text or caption block. |
Returns#
boolean
Whether the block has an anchor.
Implementation of#
IBlockAPI.hasTransformAnchorSignature#
hasTransformAnchor(block: number): booleanhasParent()#
Check if a block has a parent.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
boolean
True if the block has a parent.
Signature#
hasParent(block: number): booleangetChildren()#
Get all children of a block.
For a scene that arranges its pages, the list leaves out the camera.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the parent block. |
Returns#
number[]
Array of child block IDs.
Implementation of#
IBlockAPI.getChildrenSignature#
getChildren(block: number): number[]insertChild()#
Insert a child block at a specific index.
A move fails when it would put a block with a matte inside its matte source, or on another page than its source. A page slice takes no children, and it can only be a child of a page with a rect shape. A video scene takes no page slice.
A page slice that a block load or duplicate returns holds the blocks that it was saved
with. The next update moves them onto the page, into the new place of the page slice.
For a scene that arranges its pages, the index counts the children without the camera.
Parameters#
| Parameter | Type | Description |
|---|---|---|
parent |
number |
The ID of the parent block. |
child |
number |
The ID of the child block to insert. |
index |
number |
The index at which to insert the child. |
Returns#
void
Implementation of#
IBlockAPI.insertChildSignature#
insertChild(parent: number, child: number, index: number): voidmovePageSliceIntoPage()#
Moves a page without page slices, or a page slice of another page, into a page with page slices.
The content of the moved page or page slice moves along and keeps its ids. A moved page slice keeps its id. A
page becomes a new page slice, and its id becomes invalid.
The page slice keeps its size along the axis of page and takes the shared size across it.
The moved content is placed above the content of page, in its own order. When the move takes the last page
slice of its page, that page stays as an empty page without page slices.
The move fails when a content block would change the page slice that owns it.
Conversion keeps the supported appearance keyframes. Tracks of a page slice use the playback clock of its page.
Conversion refuses preset animations and other tracks, such as geometry and crop tracks.
convertSourceToPage refuses a remaining page slice with preset animations or keyframes.
Runs an internal update even when implicit updates are disabled. Records no undo step: call addUndoStep
after the move, as after any other edit. Fails while the engine switches the active history.
Parameters#
| Parameter | Type | Description |
|---|---|---|
pageOrPageSlice |
number |
A page without page slices, or a page slice of another page of the same scene. |
page |
number |
A page with page slices. |
index |
number |
The position of the moved page slice among the page slices of page, hidden ones too, in [0, number of page slices]. |
options? |
MovePageSliceOptions |
The options of the move. convertSourceToPage makes a source page with one page slice left a page without page slices. |
Returns#
number
The id of the moved page slice.
Signature#
movePageSliceIntoPage(pageOrPageSlice: number, page: number, index: number, options?: MovePageSliceOptions): numbermovePageSliceOutOfPage()#
Moves a page slice and its content to a new page without page slices.
The new page joins the parent of the source page. The id of the page slice becomes invalid. The content keeps
its ids. The page slices after it close the gap.
An enabled fill of the page slice stays. Otherwise the new page takes the fill of the source page when
convertSourceToPage acts, and a white fill when it does not.
When the move takes the last page slice, the source stays as an empty page without page slices.
Conversion keeps the supported appearance keyframes. Tracks of a page slice use the playback clock of its page.
Conversion refuses preset animations and other tracks, such as geometry and crop tracks.
convertSourceToPage refuses a remaining page slice with preset animations or keyframes.
Runs an internal update even when implicit updates are disabled. Records no undo step: call addUndoStep
after the move, as after any other edit. Fails while the engine switches the active history.
Parameters#
| Parameter | Type | Description |
|---|---|---|
pageSlice |
number |
A page slice of a page in a scene. |
index |
number |
The position of the new page among the pages of the scene, before the move, in [0, number of pages]. The source page counts. Other children of the scene do not count. |
options? |
MovePageSliceOptions |
The options of the move. convertSourceToPage makes a source page with one page slice left a page without page slices. |
Returns#
number
The id of the new page.
Signature#
movePageSliceOutOfPage(pageSlice: number, index: number, options?: MovePageSliceOptions): numberappendChild()#
Append a child block to the end of the parent’s children.
A move fails when it would put a block with a matte inside its matte source, or on another page than its source. A page slice takes no children, and it can only be a child of a page with a rect shape. A video scene takes no page slice.
A page slice that a block load or duplicate returns holds the blocks that it was saved
with. The next update moves them onto the page, into the new place of the page slice.
Parameters#
| Parameter | Type | Description |
|---|---|---|
parent |
number |
The ID of the parent block. |
child |
number |
The ID of the child block to append. |
Returns#
void
Implementation of#
IBlockAPI.appendChildSignature#
appendChild(parent: number, child: number): voidgetType()#
Get the type of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
ObjectTypeLonghandThe block type string (e.g., ‘//ly.img.ubq/graphic’).
Implementation of#
IBlockAPI.getTypeSignature#
getType(block: number): ObjectTypeLonghandgetKind()#
Get the kind of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
string
The block kind string (e.g., ‘image’, ‘text’, ‘sticker’).
Implementation of#
IBlockAPI.getKindSignature#
getKind(block: number): stringsetKind()#
Set the kind of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
kind |
string |
The new kind value. |
Returns#
void
Implementation of#
IBlockAPI.setKindSignature#
setKind(block: number, kind: string): voidgetName()#
Get the name of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
string
The block name.
Implementation of#
IBlockAPI.getNameSignature#
getName(block: number): stringsetName()#
Set the name of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
name |
string |
The new name. |
Returns#
void
Implementation of#
IBlockAPI.setNameSignature#
setName(block: number, name: string): voidgetUUID()#
Get the UUID of a block.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The ID of the block. |
Returns#
string
The block’s UUID string.
Implementation of#
IBlockAPI.getUUIDSignature#
getUUID(block: number): stringsetEnum()#
Setting scene/mode to Video fails with BLOCK.PAGE_SLICE_IN_VIDEO_SCENE when the scene holds a page slice.
scene/mode to Video fails with BLOCK.PAGE_SLICE_IN_VIDEO_SCENE when the scene holds a page slice.Type Parameters#
| Type Parameter |
|---|
T extends keyof BlockEnumType |
Parameters#
| Parameter | Type |
|---|---|
id |
number |
property |
T |
value |
BlockEnumType[T] |
Returns#
void
Implementation of#
IBlockAPI.setEnumCall Signature#
setEnum( id, property, value): void;Setting scene/mode to Video fails with BLOCK.PAGE_SLICE_IN_VIDEO_SCENE when the scene holds a page slice.
Parameters#
| Parameter | Type |
|---|---|
id |
number |
property |
string |
value |
string |
Returns#
void
Implementation of#
IBlockAPI.setEnumSignatures#
setEnum(id: number, property: T, value: BlockEnumType[T]): voidsetEnum(id: number, property: string, value: string): voidsetPositionX()#
Sets the x position of a block.
A page slice takes its position from its page, so the call fails with BLOCK.POSITION_PARENT_CONTROLLED on one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
value |
number |
The value of the x position. |
Returns#
void
Implementation of#
IBlockAPI.setPositionXSignature#
setPositionX(block: number, value: number): voidsetPositionY()#
Sets the y position of a block.
A page slice takes its position from its page, so the call fails with BLOCK.POSITION_PARENT_CONTROLLED on one.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
value |
number |
The value of the y position. |
Returns#
void
Implementation of#
IBlockAPI.setPositionYSignature#
setPositionY(block: number, value: number): voidsetWidth()#
Sets the width of a block in its width mode.
A new width of a page with page slices goes to its last page slice on a horizontal axis.
On a vertical axis, it goes to every page slice. A page slice that this shrinks stops at 25 pixels at the DPI of
the scene. So the page can end up wider than asked. A width of 0 or less on a page slice fails with
BLOCK.PAGE_SLICE_SIZE_INVALID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
value |
number |
The new width. |
maintainCrop? |
boolean |
Whether the crop values, if available, are adjusted. |
Returns#
void
Implementation of#
IBlockAPI.setWidthSignature#
setWidth(block: number, value: number, maintainCrop?: boolean): voidsetWidthMode()#
Sets the mode for the block’s width.
A switch between Absolute and Percent keeps the stored width and reads it in the new mode. Set the width
after the mode, without maintainCrop: otherwise the crop is adjusted from the size that the old number has
in the new mode. setSize changes the mode and the size in one call.
A page slice, and a page that holds page slices, take only the Absolute mode. Another mode fails with BLOCK.PAGE_SLICE_SIZE_MODE_INVALID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
mode |
"Auto" |
"Absolute" |
Returns#
void
Implementation of#
IBlockAPI.setWidthModeSignature#
setWidthMode(block: number, mode: "Auto" | "Absolute" | "Percent"): voidsetHeight()#
Sets the height of a block in its height mode.
A new height of a page with page slices goes to every page slice on a horizontal axis.
On a vertical axis, it goes to the last page slice. A page slice that this shrinks stops at 25 pixels at the
DPI of the scene. So the page can end up higher than asked. A height of 0 or less on a page slice fails
with BLOCK.PAGE_SLICE_SIZE_INVALID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
value |
number |
The new height. |
maintainCrop? |
boolean |
Whether the crop values, if available, are adjusted. |
Returns#
void
Implementation of#
IBlockAPI.setHeightSignature#
setHeight(block: number, value: number, maintainCrop?: boolean): voidsetHeightMode()#
Sets the mode for the block’s height.
A switch between Absolute and Percent keeps the stored height and reads it in the new mode. Set the height
after the mode, without maintainCrop: otherwise the crop is adjusted from the size that the old number has
in the new mode. setSize changes the mode and the size in one call.
A page slice, and a page that holds page slices, take only the Absolute mode. Another mode fails with BLOCK.PAGE_SLICE_SIZE_MODE_INVALID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
mode |
"Auto" |
"Absolute" |
Returns#
void
Implementation of#
IBlockAPI.setHeightModeSignature#
setHeightMode(block: number, mode: "Auto" | "Absolute" | "Percent"): voidsetSize()#
Update a block’s size.
The size of a group is always Absolute: a group takes width and height in design units and no sizeMode.
A group keeps its aspect ratio, so height decides its size.
A width or a height of 0 or less on a page slice fails with BLOCK.PAGE_SLICE_SIZE_INVALID.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to update. |
width |
number |
The new width of the block, in sizeMode if it is set and in the block’s width mode otherwise. |
height |
number |
The new height of the block, in sizeMode if it is set and in the block’s height mode otherwise. |
options? |
{ maintainCrop?: boolean; sizeMode?: SizeMode; } |
Optional parameters for the size. Properties: - maintainCrop - Whether or not the crop values, if available, should be automatically adjusted. A Percent size, left or top stays Percent. With a sizeMode, the crop is adjusted from the frame that the block has before the call. The call can run an internal update before it changes the block. - sizeMode - The size mode: Absolute, Percent or Auto. width and height are in this mode. Auto holds no size, so width and height make both axes Absolute again. |
options.maintainCrop? |
boolean |
- |
options.sizeMode? |
SizeMode |
- |
Returns#
void
Signature#
setSize(block: number, width: number, height: number, options?: object): voidresizeContentAware()#
Resizes blocks while adjusting content to fit.
A page with page slices scales every page slice by one factor. Full-page blocks still fill the spread. Other content uses one scale factor. It stays relative to the center of its page slice. A page slice returns an error, because its page sets its size. A spread with a zero width or height returns an error.
Performs an internal update to lay out pending changes, also with the
setting features/implicitUpdatesEnabled off. A block with no layout on a
page that single page mode hides returns an error.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
The blocks to resize. |
width |
number |
The new width of the blocks. |
height |
number |
The new height of the blocks. |
Returns#
void
Signature#
resizeContentAware(blocks: number[], width: number, height: number): voidgetGlobalBoundingBoxX()#
The x position of the block’s axis-aligned bounding box in the scene’s global coordinate space, whose origin is
at the top left.
A block with a transform parent is placed where its transform parents are at the current playback time. Its own transform stays static, like that of every other block. For such a block the call evaluates the animations of its transform parents at that time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose bounding box should be calculated. |
Returns#
number
Implementation of#
IBlockAPI.getGlobalBoundingBoxXSignature#
getGlobalBoundingBoxX(block: number): numbergetGlobalBoundingBoxY()#
The y position of the block’s axis-aligned bounding box in the scene’s global coordinate space, whose origin is
at the top left.
A block with a transform parent is placed where its transform parents are at the current playback time. Its own transform stays static, like that of every other block. For such a block the call evaluates the animations of its transform parents at that time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose bounding box should be calculated. |
Returns#
number
Implementation of#
IBlockAPI.getGlobalBoundingBoxYSignature#
getGlobalBoundingBoxY(block: number): numbergetGlobalBoundingBoxWidth()#
The width of the block’s axis-aligned bounding box in the scene’s global coordinate space, whose origin is
at the top left.
A block with a transform parent is placed where its transform parents are at the current playback time. Its own transform stays static, like that of every other block. For such a block the call evaluates the animations of its transform parents at that time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose bounding box should be calculated. |
Returns#
number
Implementation of#
IBlockAPI.getGlobalBoundingBoxWidthSignature#
getGlobalBoundingBoxWidth(block: number): numbergetGlobalBoundingBoxHeight()#
The height of the block’s axis-aligned bounding box in the scene’s global coordinate space, whose origin is
at the top left.
A block with a transform parent is placed where its transform parents are at the current playback time. Its own transform stays static, like that of every other block. For such a block the call evaluates the animations of its transform parents at that time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose bounding box should be calculated. |
Returns#
number
Implementation of#
IBlockAPI.getGlobalBoundingBoxHeightSignature#
getGlobalBoundingBoxHeight(block: number): numbercreateTextAnimator()#
Create a new text animator block. Add it to a text block with appendTextAnimator.
appendTextAnimator.Returns#
number
The ID of the newly created text animator block.
Implementation of#
IBlockAPI.createTextAnimatorSignature#
createTextAnimator(): numbercreateModifier()#
Create a new shape modifier block of the specified type.
Parameters#
| Parameter | Type | Description |
|---|---|---|
type |
ModifierType |
The modifier type (e.g., ‘trim’). |
Returns#
number
The ID of the newly created modifier block.
Implementation of#
IBlockAPI.createModifierSignature#
createModifier(type: ModifierType): numberconvertToComponent()#
Makes a block a main component, so that instances can follow it.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
Returns#
void
Signature#
convertToComponent(block: number): voidisComponent()#
Checks whether a block is a main component.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
Returns#
boolean
Signature#
isComponent(block: number): booleancreateInstance()#
Creates an instance of a main component. Attach it with appendChild. An instance follows every property that it does not override. Its children cannot be added, reordered or destroyed. Hide a child with setVisible.
appendChild. An instance follows every property that it does not override. Its children cannot be added, reordered or destroyed. Hide a child with setVisible.Parameters#
| Parameter | Type |
|---|---|
component |
number |
Returns#
number
Signature#
createInstance(component: number): numberisInstance()#
Checks whether a block is the top block of an instance.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
Returns#
boolean
Signature#
isInstance(block: number): booleangetMainComponent()#
Gets the main component of an instance.
Parameters#
| Parameter | Type |
|---|---|
instance |
number |
Returns#
number
Signature#
getMainComponent(instance: number): numberdetachInstance()#
Turns an instance into plain blocks that no longer follow the main component.
Parameters#
| Parameter | Type |
|---|---|
instance |
number |
Returns#
void
Signature#
detachInstance(instance: number): voidresetInstance()#
Removes all overrides of an instance.
Parameters#
| Parameter | Type |
|---|---|
instance |
number |
Returns#
void
Signature#
resetInstance(instance: number): voidcombineAsVariants()#
Moves main components into a new container as variants of one component.
Parameters#
| Parameter | Type |
|---|---|
components |
number[] |
Returns#
number
Signature#
combineAsVariants(components: number[]): numbersetVariantProperty()#
Sets the value of a variant property on a main component.
Parameters#
| Parameter | Type |
|---|---|
component |
number |
name |
string |
value |
string |
Returns#
void
Signature#
setVariantProperty(component: number, name: string, value: string): voidgetVariantProperty()#
Gets the value of a variant property of a main component.
Parameters#
| Parameter | Type |
|---|---|
component |
number |
name |
string |
Returns#
string
Signature#
getVariantProperty(component: number, name: string): stringfindAllVariantProperties()#
Gets the sorted names of the variant properties of a main component.
Parameters#
| Parameter | Type |
|---|---|
component |
number |
Returns#
string[]
Signature#
findAllVariantProperties(component: number): string[]setInstanceVariant()#
Switches an instance to the variant with this property value. Overrides stay, and layers match by name.
Parameters#
| Parameter | Type |
|---|---|
instance |
number |
name |
string |
value |
string |
Returns#
void
Signature#
setInstanceVariant(instance: number, name: string, value: string): voidaddComponentProperty()#
Publishes a property of a block inside a main component under a name that instances can set.
Parameters#
| Parameter | Type |
|---|---|
component |
number |
name |
string |
target |
number |
property |
string |
Returns#
void
Signature#
addComponentProperty(component: number, name: string, target: number, property: string): voidfindAllComponentProperties()#
Gets the sorted names of the published properties of a main component.
Parameters#
| Parameter | Type |
|---|---|
component |
number |
Returns#
string[]
Signature#
findAllComponentProperties(component: number): string[]setComponentProperty()#
Sets a published property on an instance as text. This is an override.
Parameters#
| Parameter | Type |
|---|---|
instance |
number |
name |
string |
value |
string |
Returns#
void
Signature#
setComponentProperty(instance: number, name: string, value: string): voidgetComponentProperty()#
Gets a published property of an instance as text.
Parameters#
| Parameter | Type |
|---|---|
instance |
number |
name |
string |
Returns#
string
Signature#
getComponentProperty(instance: number, name: string): stringsetShape()#
Sets the shape block for a given block. A page with page slices takes only a rect shape.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block whose shape should be changed. |
shape |
number |
The new shape. |
Returns#
void
Signature#
setShape(block: number, shape: number): voidinsertSubshape()#
Line shapes cannot be subshapes. The call fails when the shape tree would nest more than 128 shapes.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
subshape |
number |
index |
number |
Returns#
void
Signature#
insertSubshape(block: number, subshape: number, index: number): voidappendSubshape()#
Line shapes cannot be subshapes. The call fails when the shape tree would nest more than 128 shapes.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
subshape |
number |
Returns#
void
Signature#
appendSubshape(block: number, subshape: number): voidgetKeyframes()#
Returns an empty array for an animatable property without keyframes.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
property |
string |
Returns#
Keyframe[]
Throws#
BLOCK.KEYFRAMES_PROPERTY_NOT_ANIMATABLE when the property has no keyframes and
isPropertyAnimatable returns false.
Implementation of#
IBlockAPI.getKeyframesSignature#
getKeyframes(block: number, property: string): Keyframe$1[]getKeyframeMode()#
| Parameter | Type |
| —— | —— |
| block | number |
| property | string |
block | number |
| property | string |Returns#
TrackModeThrows#
BLOCK.KEYFRAMES_NO_TRACK when the property has no keyframes, or
BLOCK.KEYFRAMES_PROPERTY_NOT_ANIMATABLE when isPropertyAnimatable also returns false.
Implementation of#
IBlockAPI.getKeyframeModeSignature#
getKeyframeMode(block: number, property: string): TrackModegetAnimatedValue()#
A property without keyframes gives its static value.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
property |
string |
time |
number |
Returns#
KeyframeValueThrows#
BLOCK.KEYFRAMES_TIME_OUT_OF_RANGE for a time outside [0, 1], or
BLOCK.KEYFRAMES_PROPERTY_NOT_ANIMATABLE when the property has no keyframes and
isPropertyAnimatable returns false.
Implementation of#
IBlockAPI.getAnimatedValueSignature#
getAnimatedValue(block: number, property: string, time: number): KeyframeValueremoveKeyframes()#
Does nothing for an animatable property without keyframes.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
property |
string |
Returns#
void
Throws#
BLOCK.KEYFRAMES_PROPERTY_NOT_ANIMATABLE when the property has no keyframes and
isPropertyAnimatable returns false.
Implementation of#
IBlockAPI.removeKeyframesSignature#
removeKeyframes(block: number, property: string): voidsetMatte()#
Required scope: ‘layer/clipping’ on the block, and ‘layer/visibility’ on the source, which stops drawing on its
own.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
source |
number |
mode? |
MatteMode |
Returns#
void
Implementation of#
IBlockAPI.setMatteSignature#
setMatte(block: number, source: number, mode?: MatteMode): voidcreateFromSVG()#
Creates editable graphic blocks from SVG markup, such as the SVG code that Adobe Illustrator copies.
Each shape becomes a graphic block with a vector path shape, its fill and its stroke, in a group when there is
more than one. Embedded images, text, filters, masks and patterns become image fills of only that part.
The blocks are not attached to a parent. An SVG user unit is a pixel in a scene measured in pixels, and a point
in a scene measured in millimeters or inches.
Parameters#
| Parameter | Type | Description |
|---|---|---|
svg |
string |
The SVG markup. |
Returns#
number
The group, or the only block.
Throws#
An error when the SVG cannot be read, draws nothing, has more parts than one import creates, or has a part that cannot be drawn as an image.
Signature#
createFromSVG(svg: string): numbersetFontRequest()#
Sets a UTF-16 source-text request; omitted bounds set the entire block.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
request |
FontRequest |
from? |
number |
to? |
number |
Returns#
void
Implementation of#
IBlockAPI.setFontRequestSignature#
setFontRequest(block: number, request: FontRequest, from?: number, to?: number): voidgetFontRequests()#
Gets unique requests in the source selection, or the entire text without a selection.
Parameters#
| Parameter | Type |
|---|---|
block |
number |
from? |
number |
to? |
number |
Returns#
Implementation of#
IBlockAPI.getFontRequestsSignature#
getFontRequests(block: number, from?: number, to?: number): FontRequest[]setTypeface()#
| Parameter | Type |
| —— | —— |
| block | number |
| typeface | Typeface |
| from? | number |
| to? | number |
block | number |
| typeface | Typeface |
| from? | number |
| to? | number |Returns#
void
Note#
Saved scenes, archives, and blocks use content-based typeface IDs. Upgrade all readers to support these IDs before saving content with this engine.
Implementation of#
IBlockAPI.setTypefaceSignature#
setTypeface(block: number, typeface: Typeface, from?: number, to?: number): voidsetTextKerning()#
Set extra character-level kerning offset for a grapheme range. The
value is in em units (1.0 = one full em); 0.0 resets to no extra
offset. Matches the WASM engine’s BlockAPI.setTextKerning.
BlockAPI.setTextKerning.Parameters#
| Parameter | Type |
|---|---|
block |
number |
kerning |
number |
from? |
number |
to? |
number |
Returns#
void
Implementation of#
IBlockAPI.setTextKerningSignature#
setTextKerning(block: number, kerning: number, from?: number, to?: number): voidgetTextKernings()#
Return the unique kerning values seen across the grapheme range.
Mirrors getTextFontSizes / getTextFontStyles — [0] for a clean
block, [v1, v2, …] when the range spans multiple distinct values.
getTextFontSizes / getTextFontStyles — [0] for a clean
block, [v1, v2, …] when the range spans multiple distinct values.Parameters#
| Parameter | Type |
|---|---|
block |
number |
from? |
number |
to? |
number |
Returns#
number[]
Implementation of#
IBlockAPI.getTextKerningsSignature#
getTextKernings(block: number, from?: number, to?: number): number[]setTextOpenTypeFeatures()#
Sets the OpenType features of a text range, such as tnum for digits of equal width.
The list replaces the features that the range had, and an empty list removes them. When a tag repeats, the
last entry wins. The features apply after the ligature and kerning settings of the block, so an entry for
liga or kern overrides them in the range. A tag that the font does not have changes nothing.
editor.getFontInfo lists the features of a font.
Required scope: “text/character”
tnum for digits of equal width.
The list replaces the features that the range had, and an empty list removes them. When a tag repeats, the
last entry wins. The features apply after the ligature and kerning settings of the block, so an entry for
liga or kern overrides them in the range. A tag that the font does not have changes nothing.
editor.getFontInfo lists the features of a font.
Required scope: “text/character”Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
features |
OpenTypeFeature[] |
The features. Each tag has four ASCII characters. A value of 0 turns the feature off, 1 turns it on, and a larger value selects an alternate by its index. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Throws#
An error with the code BLOCK.TEXT_INVALID_OPENTYPE_TAG when a tag is not four ASCII characters, and
BLOCK.TEXT_TOO_MANY_OPENTYPE_SETTINGS when the list has more than 64 entries.
Implementation of#
IBlockAPI.setTextOpenTypeFeaturesSignature#
setTextOpenTypeFeatures(block: number, features: OpenTypeFeature[], from?: number, to?: number): voidgetTextOpenTypeFeatures()#
Returns the unique OpenType feature lists across a text range.
Each list holds one entry per tag, sorted by tag. A range without features returns one empty list.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
OpenTypeFeature[][]
Implementation of#
IBlockAPI.getTextOpenTypeFeaturesSignature#
getTextOpenTypeFeatures(block: number, from?: number, to?: number): OpenTypeFeature[][]setTextVariationAxes()#
Sets the variation axis values of a text range, such as wdth for the width of a variable font.
The list replaces the axis values that the range had, and an empty list removes them. When a tag repeats, the
last entry wins. An axis without a value keeps the value that the font file and the font weight and style
select. A wght entry overrides the font weight with any value, such as 450, and setTextFontWeight does not
remove it. An ital or slnt entry overrides the font style in the same way, and setTextFontStyle does not
remove it either. The font clamps a value to the range of its axis, and an axis that the font does not have changes
nothing. Values keep three decimals. editor.getFontInfo lists the axes of a font.
Required scope: “text/character”
wdth for the width of a variable font.
The list replaces the axis values that the range had, and an empty list removes them. When a tag repeats, the
last entry wins. An axis without a value keeps the value that the font file and the font weight and style
select. A wght entry overrides the font weight with any value, such as 450, and setTextFontWeight does not
remove it. An ital or slnt entry overrides the font style in the same way, and setTextFontStyle does not
remove it either. The font clamps a value to the range of its axis, and an axis that the font does not have changes
nothing. Values keep three decimals. editor.getFontInfo lists the axes of a font.
Required scope: “text/character”Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to modify. |
axes |
VariationAxisValue[] |
The axis values. Each tag has four ASCII characters. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
void
Throws#
An error with the code BLOCK.TEXT_INVALID_OPENTYPE_TAG when a tag is not four ASCII characters,
BLOCK.TEXT_INVALID_VARIATION_AXIS_VALUE when a value is not finite, and
BLOCK.TEXT_TOO_MANY_OPENTYPE_SETTINGS when the list has more than 64 entries.
Implementation of#
IBlockAPI.setTextVariationAxesSignature#
setTextVariationAxes(block: number, axes: VariationAxisValue[], from?: number, to?: number): voidgetTextVariationAxes()#
Returns the unique variation axis value lists across a text range.
Each list holds one entry per tag, sorted by tag. A range without axis values returns one empty list.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
from? |
number |
The start index of the UTF-16 range. Defaults to the start of the current selection or text. |
to? |
number |
The end index of the UTF-16 range. Defaults to the end of the current selection or text. |
Returns#
Implementation of#
IBlockAPI.getTextVariationAxesSignature#
getTextVariationAxes(block: number, from?: number, to?: number): VariationAxisValue[][]setTextBaselineShift()#
Set the baseline shift for a grapheme range, in design units. Positive
values move the glyphs up. Matches the node wasm binding’s
BlockAPI.setTextBaselineShift.
BlockAPI.setTextBaselineShift.Parameters#
| Parameter | Type |
|---|---|
block |
number |
baselineShift |
number |
from? |
number |
to? |
number |
Returns#
void
Implementation of#
IBlockAPI.setTextBaselineShiftSignature#
setTextBaselineShift(block: number, baselineShift: number, from?: number, to?: number): voidgetTextBaselineShifts()#
Return the unique baseline shift values seen across the grapheme range,
in design units. [0] for a clean block.
[0] for a clean block.Parameters#
| Parameter | Type |
|---|---|
block |
number |
from? |
number |
to? |
number |
Returns#
number[]
Implementation of#
IBlockAPI.getTextBaselineShiftsSignature#
getTextBaselineShifts(block: number, from?: number, to?: number): number[]setFont()#
| Parameter | Type |
| —— | —— |
| block | number |
| fontUri | string |
| typeface | Typeface |
block | number |
| fontUri | string |
| typeface | Typeface |Returns#
void
Note#
Saved scenes, archives, and blocks use content-based typeface IDs. Upgrade all readers to support these IDs before saving content with this engine.
Implementation of#
IBlockAPI.setFontSignature#
setFont(block: number, fontUri: string, typeface: Typeface): voidgetTextCursorRange()#
Returns the current text cursor range as UTF-16 indices. When no block
is currently being edited, returns { from: -1, to: -1 }.
{ from: -1, to: -1 }.Returns#
RangeSignature#
getTextCursorRange(): RangesetTextCursorRange()#
Sets the text cursor range. from/to are UTF-16 indices. Negative
values mean “from start” / “to end” (so { from: -1, to: -1 } selects
the entire text).
from/to are UTF-16 indices. Negative
values mean “from start” / “to end” (so { from: -1, to: -1 } selects
the entire text).Parameters#
| Parameter | Type |
|---|---|
range |
Range |
Returns#
void
Signature#
setTextCursorRange(range: Range): voidgetTextCharacterInkBoxes()#
Returns the tight ink-paint bounding box for each grapheme in the
range. One entry per grapheme in [from, to). Non-printable graphemes
(e.g. newline) get a zero-rect entry. Coordinates are in global
scene space.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
from? |
number |
Start UTF-16 index (-1 = start of cursor selection or 0). |
to? |
number |
End UTF-16 index (-1 = end of cursor selection or text length). |
Returns#
Implementation of#
IBlockAPI.getTextCharacterInkBoxesSignature#
getTextCharacterInkBoxes(block: number, from?: number, to?: number): CharacterInkBox[]getTextHorizontalAlignment()#
Returns the horizontal alignment override for a specific paragraph, or
the block-level alignment for negative paragraph indices. Returns
undefined when no override is set for the given paragraph.
undefined when no override is set for the given paragraph.Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The text block to query. |
paragraphIndex? |
number |
0-based paragraph index. Negative values return the block-level text/horizontalAlignment setting. |
Returns#
HorizontalTextAlignmentSignature#
getTextHorizontalAlignment(block: number, paragraphIndex?: number): TextHorizontalAlignmentsetTextHorizontalAlignment()#
Sets the horizontal alignment override for a specific paragraph of a text
block. Pass undefined for alignment to clear the paragraph-level
override. Negative paragraphIndex clears all paragraph overrides and
applies the alignment block-wide.
undefined for alignment to clear the paragraph-level
override. Negative paragraphIndex clears all paragraph overrides and
applies the alignment block-wide.Parameters#
| Parameter | Type |
|---|---|
block |
number |
alignment |
HorizontalTextAlignment |
paragraphIndex? |
number |
Returns#
void
Signature#
setTextHorizontalAlignment(block: number, alignment: TextHorizontalAlignment, paragraphIndex?: number): voidgetTextDecorations()#
Returns the ordered list of unique text-decoration configurations within
the given grapheme range. from / to are UTF-16 indices and are
converted to grapheme indices to match WASM semantics.
from / to are UTF-16 indices and are
converted to grapheme indices to match WASM semantics.Parameters#
| Parameter | Type |
|---|---|
block |
number |
from? |
number |
to? |
number |
Returns#
Signature#
getTextDecorations(block: number, from?: number, to?: number): TextDecorationConfig[]setTextDecoration()#
Sets the given text-decoration config for the given grapheme range. Set
lines: [‘None’] to clear all decorations.
lines: [‘None’] to clear all decorations.Parameters#
| Parameter | Type |
|---|---|
block |
number |
config |
TextDecorationConfig |
from? |
number |
to? |
number |
Returns#
void
Signature#
setTextDecoration(block: number, config: TextDecorationConfig, from?: number, to?: number): voidgetTextParagraphIndices()#
Returns the 0-based paragraph indices that overlap the given UTF-16 range.
Range is half-open: from inclusive, to exclusive. Negative values mean
“all paragraphs”. When from === to, returns the paragraph containing the
cursor at from.
from inclusive, to exclusive. Negative values mean
“all paragraphs”. When from === to, returns the paragraph containing the
cursor at from.Parameters#
| Parameter | Type |
|---|---|
block |
number |
from? |
number |
to? |
number |
Returns#
number[]
Signature#
getTextParagraphIndices(block: number, from?: number, to?: number): number[]split()#
Splits the block at the given time. The original block keeps the
leading portion; the trailing portion is returned as a newly
created block id (matches @cesdk/engine’s return contract).
@cesdk/engine’s return contract).Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The block to split. |
atTime |
number |
The time (seconds) at which to split. |
options? |
SplitOptions |
Split-behavior overrides. |
Returns#
number
The id of the newly created trailing block.
Remarks#
Matches @cesdk/engine’s SplitOptions shape:
attachToParent and selectNewBlock default to true,
createParentTrackIfNeeded defaults to false. Non-default values
are accepted for shape parity but not yet plumbed to the C++ binding
— when set, a warning is emitted so callers can detect the gap.
Signature#
split(block: number, atTime: number, options?: SplitOptions): numbergetState()#
The state of a block: its own state and that of its shape, fill, and effects.
A block whose CMYK or spot color needs the document CMYK profile is pending while that
profile loads.
With soft proofing on, a block that draws inside a page is pending while the proof profile
loads. It reports a SoftProof error only when it has no other error or pending state.
Runs an engine update for a resource that nothing asked for yet,
while the scene has a change to lay out.
A font set just before this call is then reported as pending.
An ‘Error’ state carries the catalog error of the failed load in engineError when the
engine knows it, such as a .lottie archive that cannot be read. It is an Error with the
fields of a thrown engine error.
SoftProof error only when it has no other error or pending state.
Runs an engine update for a resource that nothing asked for yet,
while the scene has a change to lay out.
A font set just before this call is then reported as pending.
An ‘Error’ state carries the catalog error of the failed load in engineError when the
engine knows it, such as a .lottie archive that cannot be read. It is an Error with the
fields of a thrown engine error.Parameters#
| Parameter | Type |
|---|---|
block |
number |
Returns#
BlockStateSignature#
getState(block: number): BlockStateexportToStream()#
Exports a design block into a stream, chunk by chunk. A PNG, JPEG or WebP export with
outputProfileMode or embedProfiles renders in one surface. It holds the whole encoded file in
memory before it writes the first chunk.
outputProfileMode or embedProfiles renders in one surface. It holds the whole encoded file in
memory before it writes the first chunk.A PNG, JPEG, WebP, TGA or raw export renders in strips, one strip in each engine update, and its size
is bound only by the limit of its format. With outputProfileMode or embedProfiles, a PNG, JPEG or WebP
export renders in one surface, which getMaxExportSize bounds. The next strip waits until writable is ready for more. PNG
and raw pixels are written as the strips render, and so is a JPEG above 358 megapixels. A smaller JPEG is
written at the end, because its Huffman tables need the whole image. WebP and TGA are written at the end.
A PDF is written page by page. Do not change the scene while the export runs. A later strip of another size fails with
ENCODE.STRIP_EXPORT_SCENE_CHANGED, but an edit that keeps the size, such as a color change, a move or
video playback, is not detected: the file then shows the scene before the edit in its first strips and
after it in the rest.
A page with playback/coverTimeEnabled set exports at its playback/coverTime, and its playback time
does not change. An export of a scene shows each page at its own time.
Parameters#
| Parameter | Type | Description |
|---|---|---|
block |
number |
The design block element to export. |
writable |
WritableStream<Uint8Array<ArrayBufferLike>> |
Receives the file, for example Writable.toWeb(fs.createWriteStream(path)). The stream is closed when the export succeeds and aborted when it fails. |
options? |
ExportOptions |
The export options, including mimeType. onProgress reports pages for a PDF and strips for a raster export of more than one strip. |
Returns#
Promise<void>
A promise that resolves once the whole file is written.
Signature#
exportToStream(block: number, writable: WritableStream<Uint8Array<ArrayBufferLike>>, options?: ExportOptions): Promise<void>exportAudio()#
Export an audio block. options.mimeType defaults to ‘audio/wav’.
options.mimeType defaults to ‘audio/wav’.Parameters#
| Parameter | Type |
|---|---|
block |
number |
options? |
AudioExportOptions |
Returns#
Promise<Blob>
Signature#
exportAudio(block: number, options?: AudioExportOptions): Promise<Blob>loadFromArchiveURL()#
Load blocks from an archive URL.
Also supports data URIs (data:application/zip;base64,…) which are converted to buffer:// protocol internally.
Parameters#
| Parameter | Type | Description |
|---|---|---|
url |
string |
The URL of the archive file, or a data URI containing base64-encoded archive data. |
options? |
AbortOptions |
An abortSignal that stops the load. The load then creates no block. |
Returns#
Promise<number[]>
A promise that resolves with an array of block IDs.
Signature#
loadFromArchiveURL(url: string, options?: AbortOptions): Promise<number[]>saveToString()#
Saves the given blocks to a serialized string.
Performs an internal update to lay out pending changes before the save.
While a font loads, its text is laid out with another font. When the text’s size follows its
content, blocks saved before the font arrives can differ from blocks saved after it. To compare
two saves, first await engine.block.forceLoadResources(blocks).
The source set entries that the engine makes are buffer:// resources that only this engine
holds. onDisallowedResourceScheme gets each of them, whatever allowedResourceSchemes holds.
The save leaves out each entry that the callback did not move to another address, and each
fill keeps them.
A page slice has no children, so the blocks that it owns on its page are saved as its
children. A page slice on a page among blocks makes the update run also while
features/implicitUpdatesEnabled is off.
A block among blocks is saved once, as a block of its own.
A block that a page slice owns is saved with its Percent position and size in design units.
The copy does not follow the size of its page.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
- |
allowedResourceSchemes? |
string[] |
- |
onDisallowedResourceScheme? |
(url, dataHash) => Promise<string> |
- |
options? |
AbortOptions |
An abortSignal that stops a save that waits for onDisallowedResourceScheme. |
Returns#
Promise<string>
A promise that resolves with the serialized blocks.
Implementation of#
IBlockAPI.saveToStringSignature#
saveToString(blocks: number[], allowedResourceSchemes?: string[], onDisallowedResourceScheme?: (url: string, dataHash: string) => Promise<string>, options?: AbortOptions): Promise<string>saveToArchive()#
Saves the given blocks and their assets to a zip archive.
Performs an internal update to lay out pending changes before the save.
While a font loads, its text is laid out with another font. When the text’s size follows its
content, blocks archived before the font arrives can differ from blocks archived after it. To
compare two archives, first await engine.block.forceLoadResources(blocks), then compare the
blocks.blocks files inside them. Each archive entry stores the time of the save.
A page slice has no children, so the blocks that it owns on its page are archived as its
children. A page slice on a page among blocks makes the update run also while
features/implicitUpdatesEnabled is off.
A block among blocks is archived once, as a block of its own.
A block that a page slice owns is saved with its Percent position and size in design units.
The copy does not follow the size of its page.
Parameters#
| Parameter | Type | Description |
|---|---|---|
blocks |
number[] |
- |
options? |
AbortOptions |
An abortSignal that stops the save. |
Returns#
Promise<Blob>
A promise that resolves with a Blob.
Implementation of#
IBlockAPI.saveToArchiveSignature#
saveToArchive(blocks: number[], options?: AbortOptions): Promise<Blob>forceLoadAVResource()#
Force-load the audio/video resource for an audio block or video-fill block.
Resolves once the asset is fully fetched and demuxed (so subsequent
exportVideo calls have data immediately available on frame 0). Without
this prime, the encoder can race ahead of the HTTP fetch and produce
silent audio / black-frame video segments.
A buffer:// source loads like a file. The call finishes once the engine can read the video, audio or
Lottie in the buffer, with the images that a Lottie references. It fails when the buffer holds no file that it
can read. A missing or empty buffer, or raw audio samples on an audio block, finish at once.
An abort ends the wait. It stops the download, unless a block or another call needs the file. The engine reads
every video fill at each update, so the download of a video fill goes on.
exportVideo calls have data immediately available on frame 0). Without
this prime, the encoder can race ahead of the HTTP fetch and produce
silent audio / black-frame video segments.
A buffer:// source loads like a file. The call finishes once the engine can read the video, audio or
Lottie in the buffer, with the images that a Lottie references. It fails when the buffer holds no file that it
can read. A missing or empty buffer, or raw audio samples on an audio block, finish at once.
An abort ends the wait. It stops the download, unless a block or another call needs the file. The engine reads
every video fill at each update, so the download of a video fill goes on.Parameters#
| Parameter | Type |
|---|---|
block |
number |
options? |
AbortOptions |
Returns#
Promise<void>
Signature#
forceLoadAVResource(block: number, options?: AbortOptions): Promise<void>forceLoadResources()#
Force-load every resource referenced by blocks. Useful before
exportVideo on a scene with multiple remote assets — saves N network
round-trips compared to calling forceLoadAVResource per block.
A page slice also loads the resources of the blocks that it owns on its page. The call runs no update, so a block that no update has placed on the page slice yet is left out.
Resolves once every resource has finished loading. It rejects when a resource fails to load, or
when the file of an image fill cannot be decoded. Of a source set, the load checks the smallest
raster entry or the largest SVG entry. It does not check a CMYK JPEG that has no color profile of
its own. The state of each block then reports the result.
An abort ends the wait, and stops each load that no block uses and no other call waits for.
blocks. Useful before
exportVideo on a scene with multiple remote assets — saves N network
round-trips compared to calling forceLoadAVResource per block.
A page slice also loads the resources of the blocks that it owns on its page. The call runs no update, so a block that no update has placed on the page slice yet is left out.
Resolves once every resource has finished loading. It rejects when a resource fails to load, or
when the file of an image fill cannot be decoded. Of a source set, the load checks the smallest
raster entry or the largest SVG entry. It does not check a CMYK JPEG that has no color profile of
its own. The state of each block then reports the result.
An abort ends the wait, and stops each load that no block uses and no other call waits for.Parameters#
| Parameter | Type |
|---|---|
blocks |
number[] |
options? |
AbortOptions |
Returns#
Promise<void>
Signature#
forceLoadResources(blocks: number[], options?: AbortOptions): Promise<void>applyAnimation()#
Apply an animation set (in/loop/out) to a block. Mirrors
@cesdk/engine’s BlockAPI.applyAnimation exactly.
@cesdk/engine’s BlockAPI.applyAnimation exactly.Parameters#
| Parameter | Type |
|---|---|
block |
number |
animation? |
AnimationOptions |
Returns#
void
Signature#
applyAnimation(block: number, animation?: AnimationOptions): voidapplyDropShadow()#
Apply a drop shadow effect to a block. Mirrors @cesdk/engine’s
BlockAPI.applyDropShadow exactly.
@cesdk/engine’s
BlockAPI.applyDropShadow exactly.Parameters#
| Parameter | Type |
|---|---|
block |
number |
options? |
DropShadowOptions |
Returns#
void
Signature#
applyDropShadow(block: number, options?: DropShadowOptions): voidaddImage()#
Add an image to the current page as a graphic block with an image fill.
Mirrors @cesdk/engine’s BlockAPI.addImage shape — same options bag,
same chained-call sequence.
@cesdk/engine’s BlockAPI.addImage shape — same options bag,
same chained-call sequence.Parameters#
| Parameter | Type |
|---|---|
url |
string |
options? |
AddImageOptions |
Returns#
Promise<number>
Remarks#
Unlike WASM (which uses new Image() to auto-detect size when
options.size is omitted), Node has no DOM Image global. In Node,
options.size must be supplied; calling without it throws a clear
error with the suggested fix.
Signature#
addImage(url: string, options?: AddImageOptions): Promise<number>addVideo()#
Add a video to the current page as a graphic block with a video fill.
Mirrors @cesdk/engine’s BlockAPI.addVideo shape.
@cesdk/engine’s BlockAPI.addVideo shape.Parameters#
| Parameter | Type |
|---|---|
url |
string |
width |
number |
height |
number |
options? |
AddVideoOptions |
Returns#
Promise<number>
Remarks#
Like addImage, requires explicit options.size in Node.
Signature#
addVideo(url: string, width: number, height: number, options?: AddVideoOptions): Promise<number>onStateChanged#
Subscribe to state changes on a set of blocks. Matches WASM’s
engine.block.onStateChanged(ids, callback) contract — pass an empty
array to monitor every block in the scene. The native C++ side
already implements this via subscribeToBlockState; this wrapper
exposes it on engine.block so portable consumers (e.g.
@imgly/psd-importer’s transient-relocation tests) can subscribe the
same way on both bindings.
engine.block.onStateChanged(ids, callback) contract — pass an empty
array to monitor every block in the scene. The native C++ side
already implements this via subscribeToBlockState; this wrapper
exposes it on engine.block so portable consumers (e.g.
@imgly/psd-importer’s transient-relocation tests) can subscribe the
same way on both bindings.Parameters#
| Parameter | Type |
|---|---|
ids |
number[] |
callback |
(ids) => void |
Returns#
A function to unsubscribe.
() => void
Implementation of#
IBlockAPI.onStateChangedonSelectionChanged#
Subscribe to selection changes. Matches WASM’s
engine.block.onSelectionChanged(callback) contract — fires when the
set of selected blocks changes. The native C++ side already implements
this via subscribeToSelectionChange; this wrapper exposes it so
portable consumers (selection-reactive UI) work on both bindings.
engine.block.onSelectionChanged(callback) contract — fires when the
set of selected blocks changes. The native C++ side already implements
this via subscribeToSelectionChange; this wrapper exposes it so
portable consumers (selection-reactive UI) work on both bindings.Parameters#
| Parameter | Type |
|---|---|
callback |
() => void |
Returns#
A function to unsubscribe.
() => void
Implementation of#
IBlockAPI.onSelectionChangedonClicked#
Subscribe to block clicks. Matches WASM’s
engine.block.onClicked((id) => …) contract. In a headless Node
context the engine never fires this event (no UI input), but the
subscription surface exists for API parity so the same code compiles
and runs against both bindings.
engine.block.onClicked((id) => …) contract. In a headless Node
context the engine never fires this event (no UI input), but the
subscription surface exists for API parity so the same code compiles
and runs against both bindings.Parameters#
| Parameter | Type |
|---|---|
callback |
(id) => void |
Returns#
A function to unsubscribe.
() => void
Implementation of#
IBlockAPI.onClickedcreateCutoutFromBlocks()#
Creates a cutout block from the contours of other blocks.
The path is derived from either existing vector paths or by vectorizing the block’s appearance.
Performs an internal update to lay out pending changes, because the cutout
reads the blocks’ layout. With the setting
features/implicitUpdatesEnabled off, the update runs only when a passed
block has no layout, and it then lays out all pending changes. A block with
no layout on a page that single page mode hides returns an error.
Parameters#
| Parameter | Type | Description |
|---|---|---|
ids |
number[] |
The blocks whose shape will serve as the basis for the cutout’s path. |
vectorizeDistanceThreshold? |
number |
Max deviation from the original contour during vectorization. |
simplifyDistanceThreshold? |
number |
Max deviation for path simplification. 0 disables simplification. |
useExistingShapeInformation? |
boolean |
If true, use existing vector paths. |
Returns#
number
The newly created block or an error.
Signature#
createCutoutFromBlocks(ids: number[], vectorizeDistanceThreshold?: number, simplifyDistanceThreshold?: number, useExistingShapeInformation?: boolean): numberunstable_setImportedImageDefinition()#
Attaches the color definition found beside the fill’s current JPEG bytes.
The engine then decodes the JPEG samples in the given color space, instead of reading the JPEG’s own metadata. Finish writing an image buffer before calling this method.
The definition describes the image bytes it was read from, so it applies only while the image
still holds them. A write that changes the bytes switches it off, and writing the same bytes
back switches it on again. There is no event for that; unstable_getImportedImageDefinition
returns an error while it is off.
The engine owns mask bytes and reuses identical content. Replace a mask through this method.
A write to a mask buffer makes it fail its hash check. An undo step retains its mask metadata and bytes.
Scene and block strings store mask URLs and metadata, not bytes.
Use onDisallowedResourceScheme to persist mask bytes and return durable URLs, or save an archive.
Allowing the buffer scheme stores references only. Retain or restore those buffers when reloading saved strings.
Loading another scene can release unused mask buffers.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The image fill. |
definition |
ImportedImageDefinitionInput |
The color definition of the fill’s current image. Unstable until the general design of image color provenance is settled. It then becomes stable or is replaced. |
Returns#
void
unstable_getImportedImageDefinition()#
Reads the color definition of the fill’s current image.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The image fill. |
Returns#
ImportedImageDefinitionInfoThe definition of the current image bytes.
Throws#
Error when no definition applies to the current image bytes. Unstable until the general design of image color provenance is settled. It then becomes stable or is replaced.
setVariableBinding()#
Binds a block property to a color, number, image or typeface variable, and applies
the variable’s current value. Changing the variable later updates the property.
Image variables bind only to fill/image/imageFileURI, fill/image/previewFileURI
and fill/video/fileURI. Typeface variables bind only to text/typeface and
caption/typeface. A direct write to a bound property fails with
BLOCK.PROPERTY_BOUND until the binding is removed. A bound typeface also locks
setTypeface and setFont. On a text block, a variable bound to fill/solid/color or
the font size sets every run of the text, and setTextColor or setTextFontSize fails
for any range. Keyframes, undo and scene loads still change it. Changing the
design unit converts a bound length. A number variable whose bound properties all
hold its value converts with them. Otherwise the variable keeps its value, and the
next variable write sets the lengths in the new unit.
fill/image/imageFileURI, fill/image/previewFileURI
and fill/video/fileURI. Typeface variables bind only to text/typeface and
caption/typeface. A direct write to a bound property fails with
BLOCK.PROPERTY_BOUND until the binding is removed. A bound typeface also locks
setTypeface and setFont. On a text block, a variable bound to fill/solid/color or
the font size sets every run of the text, and setTextColor or setTextFontSize fails
for any range. Keyframes, undo and scene loads still change it. Changing the
design unit converts a bound length. A number variable whose bound properties all
hold its value converts with them. Otherwise the variable keeps its value, and the
next variable write sets the lengths in the new unit.Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block that has the property. |
property |
string |
The property path, for example fill/color/value. |
key |
string |
The key of an existing color, number, image or typeface variable. |
Returns#
void
Implementation of#
IBlockAPI.setVariableBindingSignature#
setVariableBinding(id: number, property: string, key: string): voidgetVariableBinding()#
Gets the variable that a block property is bound to.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block that has the property. |
property |
string |
The property path. |
Returns#
string
The variable key, or null if the property is not bound.
Implementation of#
IBlockAPI.getVariableBindingSignature#
getVariableBinding(id: number, property: string): stringremoveVariableBinding()#
Removes the variable binding of a block property. The property keeps its value.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block that has the property. |
property |
string |
The property path. |
Returns#
void
Implementation of#
IBlockAPI.removeVariableBindingSignature#
removeVariableBinding(id: number, property: string): voidfindAllVariableBindings()#
Gets the properties of a block that are bound to a variable.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The block to inspect. |
Returns#
string[]
The bound property paths.
Implementation of#
IBlockAPI.findAllVariableBindingsSignature#
findAllVariableBindings(id: number): string[]setState()#
Sets the state of a block. While an image fill is pending, the engine adds no automatic
source set entries to it.
Parameters#
| Parameter | Type |
|---|---|
id |
number |
state |
BlockState |
Returns#
void
Signature#
setState(id: number, state: BlockState): voidgenerateVideoThumbnailSequence()#
Generates a sequence of video thumbnails; onFrame is called per frame.
Node has no ImageData, so each frame is a raw RGBA { data, width,
height } (see ThumbnailFrame). A frame arrives at the end of an engine
update.
onFrame is called per frame.
Node has no ImageData, so each frame is a raw RGBA { data, width,
height } (see ThumbnailFrame). A frame arrives at the end of an engine
update.Parameters#
| Parameter | Type |
|---|---|
id |
number |
thumbnailHeight |
number |
timeBegin |
number |
timeEnd |
number |
numberOfFrames |
number |
onFrame |
(frameIndex, result) => void |
Returns#
() => void
Signature#
generateVideoThumbnailSequence(id: number, thumbnailHeight: number, timeBegin: number, timeEnd: number, numberOfFrames: number, onFrame: (frameIndex: number, result: Error | ThumbnailFrame) => void): () => voidgenerateThumbnailAtTimeOffset()#
Generates a PNG thumbnail of the current page at a specific time, matching
@cesdk/node.
@cesdk/node.Parameters#
| Parameter | Type | Description |
|---|---|---|
height |
number |
Height of the thumbnail in scene design units (maximum 512). |
time |
number |
Time position in seconds to capture the thumbnail. |
Returns#
Promise<Blob>
The PNG thumbnail.
Throws#
Without a canvas that has a 2D context: Node.js has neither a DOM
nor an OffscreenCanvas. Use export with a target size instead.
Signature#
generateThumbnailAtTimeOffset(height: number, time: number): Promise<Blob>setNativePixelBuffer()#
Updates a pixel stream fill block from a browser canvas or video element,
as on the WASM engine.
Parameters#
| Parameter | Type | Description |
|---|---|---|
id |
number |
The pixel stream fill block. |
buffer |
unknown |
A canvas or video element to use as the pixel source. |
Returns#
void
Throws#
Always: Node.js has no canvas or video element.
Signature#
setNativePixelBuffer(id: number, buffer: unknown): voidgenerateAudioThumbnailSequence()#
Generates a sequence of audio waveform sample chunks. onChunk is called
per chunk with a Float32Array of samples, as on the WASM engine. A chunk
arrives at the end of an engine update, and no chunk arrives after a cancel.
onChunk is called
per chunk with a Float32Array of samples, as on the WASM engine. A chunk
arrives at the end of an engine update, and no chunk arrives after a cancel.Parameters#
| Parameter | Type |
|---|---|
id |
number |
samplesPerChunk |
number |
timeBegin |
number |
timeEnd |
number |
numberOfSamples |
number |
numberOfChannels |
number |
onChunk |
(chunkIndex, result) => void |
Returns#
() => void
Signature#
generateAudioThumbnailSequence(id: number, samplesPerChunk: number, timeBegin: number, timeEnd: number, numberOfSamples: number, numberOfChannels: number, onChunk: (chunkIndex: number, result: Error | Float32Array<ArrayBufferLike>) => void): () => void