Search Docs
Loading...
Skip to content

Class: BlockAPI

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#

Constructor#


| Parameter | Type | | —— | —— | | engine | NativeEngine |

Returns#

BlockAPI

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 blocks
const loadedBlocks = await engine.block.loadFromString(serializedBlocks);
// Attach the first loaded block to the scene
engine.block.appendChild(sceneBlockId, loadedBlocks[0]);

Implementation of#

IBlockAPI.loadFromString

Signature#

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 URL
const loadedBlocks = await engine.block.loadFromURL('https://example.com/blocks.blocks');
// Attach the first loaded block to the scene
engine.block.appendChild(sceneBlockId, loadedBlocks[0]);

Implementation of#

IBlockAPI.loadFromURL

Signature#

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 migration
const blob = await engine.block.export(blockId, MimeType.Png, { pngCompressionLevel: 5 })
// After migration
const 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.

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 migration
const blob = await engine.block.exportWithColorMask(
blockId,
MimeType.Png,
0.5,
0,
0,
{
pngCompressionLevel: 5
}
);
// After migration
const 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 function
const 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 migration
const blob = await engine.block.exportVideo(blockId, 'video/mp4', handleProgress, {
targetWidth: 1920,
targetHeight: 1080,
})
// After migration
const 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.

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.

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.getPositionX

Signature#

getPositionX(block: number): number

getPositionY()#


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.getPositionY

Signature#

getPositionY(block: number): number

getPositionXMode()#


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.getPositionXMode

Signature#

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.setPositionXMode

Signature#

setPositionXMode(block: number, mode: "Auto" | "Absolute" | "Percent"): void

getPositionYMode()#


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.getPositionYMode

Signature#

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.setPositionYMode

Signature#

setPositionYMode(block: number, mode: "Auto" | "Absolute" | "Percent"): void

getWidth()#


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.getWidth

Signature#

getWidth(block: number): number

getWidthMode()#


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.getWidthMode

Signature#

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.getHeight

Signature#

getHeight(block: number): number

getHeightMode()#


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.getHeightMode

Signature#

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.getRotation

Signature#

getRotation(block: number): number

setRotation()#


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.setRotation

Signature#

setRotation(block: number, value: number): void

scale()#


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): void

fillParent()#


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): void

getScreenSpaceBoundingBoxXYWH()#


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#

XYWH

The position and size of the bounding box.

Implementation of#

IBlockAPI.getScreenSpaceBoundingBoxXYWH

Signature#

getScreenSpaceBoundingBoxXYWH(blocks: number[]): XYWH

isLineOrigin()#


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.

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.isLineOrigin

Signature#

isLineOrigin(block: number): boolean

bringToFront()#


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): void

sendToBack()#


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): void

bringForward()#


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): void

sendBackward()#


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): void

setAlwaysOnTop()#


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): void

setAlwaysOnBottom()#


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): void

isAlwaysOnTop()#


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): boolean

isAlwaysOnBottom()#


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): boolean

alignHorizontally()#


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): void

alignVertically()#


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): void

distributeHorizontally()#


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[]): void

distributeVertically()#


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[]): void

isTransformLocked()#


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): boolean

setTransformLocked()#


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): void

getFrameX()#


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): number

getFrameY()#


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): number

getFrameWidth()#


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): number

getFrameHeight()#


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): number

Block 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.isVisible

Signature#

isVisible(block: number): boolean

setVisible()#


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.setVisible

Signature#

setVisible(block: number, visible: boolean): void

setSelected()#


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.setSelected

Signature#

setSelected(block: number, selected: boolean): void

isSelected()#


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.isSelected

Signature#

isSelected(block: number): boolean

select()#


Selects a block, deselecting all others.

Parameters#

Parameter Type Description
block number The block to be selected.

Returns#

void

Implementation of#

IBlockAPI.select

Signature#

select(block: number): void

Block 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): boolean

getFlipVertical()#


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): boolean

setFlipHorizontal()#


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): void

setFlipVertical()#


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): void

supportsBlendMode()#


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.supportsBlendMode

Signature#

supportsBlendMode(block: number): boolean

getBlendMode()#


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.getBlendMode

Signature#

getBlendMode(block: number): BlendMode

setBlendMode()#


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.setBlendMode

Signature#

setBlendMode(block: number, mode: BlendMode): void

supportsOpacity()#


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.supportsOpacity

Signature#

supportsOpacity(block: number): boolean

getOpacity()#


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.getOpacity

Signature#

getOpacity(block: number): number

setOpacity()#


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.setOpacity

Signature#

setOpacity(block: number, opacity: number): void

isClipped()#


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.isClipped

Signature#

isClipped(block: number): boolean

setClipped()#


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.setClipped

Signature#

setClipped(block: number, clipped: boolean): void

getMatte()#


Gets the matte of a block.

Parameters#

Parameter Type Description
block number The block to query. Graphic, text and group blocks are supported.

Returns#

BlockMatte

The matte source and mode, or null when the block has no matte.

Implementation of#

IBlockAPI.getMatte

Signature#

getMatte(block: number): BlockMatte

supportsBackgroundColor()#


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): boolean

isBackgroundColorEnabled()#


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): boolean

setBackgroundColorEnabled()#


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): void

Block 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.supportsFill

Signature#

supportsFill(block: number): boolean

getFill()#


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.getFill

Signature#

getFill(block: number): number

setFill()#


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.setFill

Signature#

setFill(block: number, fill: number): void

isFillEnabled()#


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.isFillEnabled

Signature#

isFillEnabled(block: number): boolean

setFillEnabled()#


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.setFillEnabled

Signature#

setFillEnabled(block: number, enabled: boolean): void

getFillSolidColor()#


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#

RGBA

The fill color.

Implementation of#

IBlockAPI.getFillSolidColor

Signature#

getFillSolidColor(block: number): RGBA

setFillSolidColor()#


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.setFillSolidColor

Signature#

setFillSolidColor(block: number, r: number, g: number, b: number, a?: number): void

getGradientColorStops()#


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#

GradientColorStop[]

The gradient colors.

Implementation of#

IBlockAPI.getGradientColorStops

Signature#

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.setGradientColorStops

Signature#

setGradientColorStops(block: number, property: string, stops: GradientColorStop[]): void

supportsContentFillMode()#


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): boolean

getContentFillMode()#


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"): void

setContentFillHorizontalAlignment()#


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.setContentFillHorizontalAlignment

Signature#

setContentFillHorizontalAlignment(block: number, alignment: HorizontalContentFillAlignment): void

getContentFillHorizontalAlignment()#


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.getContentFillHorizontalAlignment

Signature#

getContentFillHorizontalAlignment(block: number): HorizontalContentFillAlignment

setContentFillVerticalAlignment()#


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.setContentFillVerticalAlignment

Signature#

setContentFillVerticalAlignment(block: number, alignment: VerticalContentFillAlignment): void

getContentFillVerticalAlignment()#


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.getContentFillVerticalAlignment

Signature#

getContentFillVerticalAlignment(block: number): VerticalContentFillAlignment

getSourceSet()#


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.getSourceSet

Signature#

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.setSourceSet

Signature#

setSourceSet(block: number, property: SourceSetPropertyName, sources: Source[]): void

addImageFileURIToSourceSet()#


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.addImageFileURIToSourceSet

Signature#

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.addVideoFileURIToSourceSet

Signature#

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): boolean

setFillOverprint()#


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): void

Block 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): boolean

getShape()#


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): number

getSubshapes()#


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): void

Block 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.replaceText

Signature#

replaceText(block: number, text: string, from?: number, to?: number): void

removeText()#


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.removeText

Signature#

removeText(block: number, from?: number, to?: number): void

getTextAsHTML()#


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.getTextAsHTML

Signature#

getTextAsHTML(block: number, from?: number, to?: number): string

replaceTextWithHTML()#


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.replaceTextWithHTML

Signature#

replaceTextWithHTML(block: number, html: string, from?: number, to?: number): void

getTextFontSizes()#


Gets the unique font sizes within a range of text.

// Get all font sizes
const fontSizes = engine.block.getTextFontSizes(text);
// Get font sizes for a range
const fontSizes = engine.block.getTextFontSizes(text, 0, 10);
// With options object
const 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.getTextFontSizes

Call 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.getTextFontSizes

Signatures#

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 migration
engine.block.setTextFontSize(text, 18, 0, 5);
// After migration
engine.block.setTextFontSize(text, 18, { from: 0, to: 5 });
Implementation of#
IBlockAPI.setTextFontSize

Call 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 object
engine.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.setTextFontSize

Signatures#

setTextFontSize(block: number, size: number, from?: number, to?: number): void
setTextFontSize(block: number, size: number, options?: TextFontSizeOptions): void

getTextFontStyles()#


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#

FontStyle[]

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): void

getTextFontWeights()#


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#

FontWeight[]

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): void

setTextFontWeightAndStyle()#


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): void

getTextColors()#


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.getTextColors

Signature#

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.setTextColor

Signature#

setTextColor(block: number, color: Color, from?: number, to?: number): void

getTextBackgroundColors()#


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.getTextBackgroundColors

Signature#

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.setTextBackgroundColor

Signature#

setTextBackgroundColor(block: number, color: Color, from?: number, to?: number): void

getTextCases()#


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): void

getTextScriptStyles()#


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#

ScriptStyle[]

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): void

getTypefaces()#


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.getTypefaces

Signature#

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#

Typeface

the typeface property of the text block.

Implementation of#

IBlockAPI.getTypeface

Signature#

getTypeface(block: number): Typeface

canToggleBoldFont()#


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): boolean

toggleBoldFont()#


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): void

canToggleItalicFont()#


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): boolean

toggleItalicFont()#


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): void

getTextRenderDiagnostics()#


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#

TextRenderDiagnostics

The current rendering diagnostics.

Throws#

If the block is invalid or is not text.

Implementation of#

IBlockAPI.getTextRenderDiagnostics

Signature#

getTextRenderDiagnostics(block: number): TextRenderDiagnostics

getTextVisibleLineCount()#


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): number

getTextVisibleLineContent()#


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): string

getTextVisibleLineGlobalBoundingBoxXYWH()#


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#

XYWH

The bounding box of the line.

Signature#

getTextVisibleLineGlobalBoundingBoxXYWH(block: number, lineIndex: number): XYWH

getTextEffectiveHorizontalAlignment()#


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): void

toggleTextDecorationStrikethrough()#


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): void

toggleTextDecorationOverline()#


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): void

getTextListStyle()#


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#

ListStyle

The list style of the paragraph.

Signature#

getTextListStyle(block: number, paragraphIndex: number): ListStyle

setTextListStyle()#


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): void

getTextListLevel()#


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): number

setTextListLevel()#


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): void

getTextLineHeight()#


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): number

setTextLineHeight()#


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 default

Parameters#

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): void

setTextOnPath()#


Sets the SVG path that the text baseline follows. Pass 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): void

getTextOnPath()#


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): string

setTextOnPathOffset()#


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.

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): void

getTextOnPathOffset()#


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): number

setTextOnPathFlipped()#


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): void

getTextOnPathFlipped()#


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): boolean

getTextRuns()#


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#

TextRunInfo[]

The ordered list of text runs covering the requested range.

Implementation of#
IBlockAPI.getTextRuns

Call 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#

TextRunInfo[]

The ordered list of text runs covering the requested range.

Implementation of#
IBlockAPI.getTextRuns

Signatures#

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.supportsDuration

Signature#

supportsDuration(block: number): boolean

getDuration()#


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).

Parameters#

Parameter Type Description
block number The block whose duration should be returned.

Returns#

number

The block’s duration in seconds.

Implementation of#

IBlockAPI.getDuration

Signature#

getDuration(block: number): number

setDuration()#


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.setDuration

Signature#

setDuration(block: number, duration: number): void

supportsTimeOffset()#


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.supportsTimeOffset

Signature#

supportsTimeOffset(block: number): boolean

getTimeOffset()#


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.getTimeOffset

Signature#

getTimeOffset(block: number): number

setTimeOffset()#


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.setTimeOffset

Signature#

setTimeOffset(block: number, offset: number): void

supportsTrim()#


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): boolean

getTrimOffset()#


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): number

setTrimOffset()#


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): void

getTrimLength()#


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): number

setTrimLength()#


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): void

supportsPlaybackControl()#


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): boolean

supportsPlaybackTime()#


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): boolean

getPlaybackTime()#


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): number

setPlaybackTime()#


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): void

isPlaying()#


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): boolean

setPlaying()#


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): void

isLooping()#


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): boolean

setLooping()#


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): void

getPlaybackSpeed()#


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): number

setPlaybackSpeed()#


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.

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): void

isMuted()#


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): boolean

setMuted()#


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): void

getVolume()#


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): number

setVolume()#


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): void

setAudioFadeIn()#


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): void

setAudioFadeOut()#


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): void

isSoloPlaybackEnabled()#


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): boolean

setSoloPlaybackEnabled()#


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): void

isForceMuted()#


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): boolean

getVideoWidth()#


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): number

getVideoHeight()#


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): number

getAVResourceTotalDuration()#


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): number

supportsPageDurationSource()#


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): boolean

setPageDurationSource()#


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): void

removePageDurationSource()#


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): void

isPageDurationSource()#


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): boolean

createCaptionsFromURI()#


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): boolean

getInAnimation()#


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): number

setInAnimation()#


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): void

getOutAnimation()#


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): number

setOutAnimation()#


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): void

getLoopAnimation()#


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): number

setLoopAnimation()#


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): void

setKeyframes()#


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.setKeyframes

Signature#

setKeyframes(block: number, property: string, keyframes: Keyframe$1[], mode?: TrackMode): void

getAnimatedProperties()#


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.getAnimatedProperties

Signature#

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.isPropertyAnimatable

Signature#

isPropertyAnimatable(block: number, property: string): boolean

Block 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[]): number

ungroup()#


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): void

isGroupable()#


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[]): boolean

enterGroup()#


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): void

exitGroup()#


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): void

Block 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): boolean

isIncludedInExport()#


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): boolean

setIncludedInExport()#


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): void

referencesAnyVariables()#


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): boolean

Block 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): boolean

resetCrop()#


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): void

adjustCropToFillFrame()#


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.

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): number

getCropRotation()#


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): number

setCropRotation()#


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): void

getCropScaleX()#


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): number

setCropScaleX()#


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): void

getCropScaleY()#


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): number

setCropScaleY()#


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): void

getCropScaleRatio()#


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.

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): number

setCropScaleRatio()#


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): void

getCropTranslationX()#


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): number

setCropTranslationX()#


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): void

getCropTranslationY()#


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): number

setCropTranslationY()#


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): void

isCropAspectRatioLocked()#


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): boolean

setCropAspectRatioLocked()#


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): void

flipCropHorizontal()#


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): void

flipCropVertical()#


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): void

canRevertToOriginalRatio()#


Checks whether the “Original” crop preset (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): boolean

Block 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[]): boolean

isDistributable()#


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[]): boolean

Block 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.getBool

Signature#

getBool(block: number, property: BoolPropertyName): boolean

setBool()#


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.setBool

Signature#

setBool(block: number, property: BoolPropertyName, value: boolean): void

getInt()#


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.getInt

Signature#

getInt(block: number, property: IntPropertyName): number

setInt()#


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.setInt

Signature#

setInt(block: number, property: IntPropertyName, value: number): void

getFloat()#


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.getFloat

Signature#

getFloat(block: number, property: FloatPropertyName): number

setFloat()#


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.setFloat

Signature#

setFloat(block: number, property: FloatPropertyName, value: number): void

getDouble()#


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.getDouble

Signature#

getDouble(block: number, property: DoublePropertyName): number

setDouble()#


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.setDouble

Signature#

setDouble(block: number, property: DoublePropertyName, value: number): void

getVec2()#


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#

Vec2

The value of the property.

Implementation of#

IBlockAPI.getVec2

Signature#

getVec2(block: number, property: Vec2PropertyName): Vec2

setVec2()#


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.

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.setVec2

Signature#

setVec2(block: number, property: Vec2PropertyName, value: Vec2): void

getString()#


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.getString

Signature#

getString(block: number, property: StringPropertyName): string

setString()#


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.setString

Signature#

setString(block: number, property: StringPropertyName, value: string): void

getColor()#


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#

Color

The value of the property.

Implementation of#

IBlockAPI.getColor

Signature#

getColor(block: number, property: ColorPropertyName): Color

setColor()#


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.setColor

Signature#

setColor(block: number, property: ColorPropertyName, value: Color): void

getEnum()#


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#

BlockEnumType[T]

The value as a string.

Implementation of#
IBlockAPI.getEnum

Call 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.getEnum

Signatures#

getEnum(id: number, property: T): BlockEnumType[T]
getEnum(id: number, property: string): string

findAllProperties()#


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#

PropertyType

The property type.

Signature#

getPropertyType(property: string): PropertyType

isPropertyReadable()#


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): boolean

isPropertyWritable()#


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): boolean

getEnumValues()#


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.getStrokeFill

Signature#

getStrokeFill(block: number): number

setStrokeFill()#


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.setStrokeFill

Signature#

setStrokeFill(block: number, fill: number): void

supportsStroke()#


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.supportsStroke

Signature#

supportsStroke(block: number): boolean

isStrokeEnabled()#


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.isStrokeEnabled

Signature#

isStrokeEnabled(block: number): boolean

setStrokeEnabled()#


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.setStrokeEnabled

Signature#

setStrokeEnabled(block: number, enabled: boolean): void

getStrokeColor()#


Gets the stroke color of a block.

Parameters#

Parameter Type Description
block number The block whose stroke color should be queried.

Returns#

Color

The stroke color.

Implementation of#

IBlockAPI.getStrokeColor

Signature#

getStrokeColor(block: number): Color

setStrokeColor()#


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.setStrokeColor

Signature#

setStrokeColor(block: number, color: Color): void

getStrokeWidth()#


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.getStrokeWidth

Signature#

getStrokeWidth(block: number): number

setStrokeWidth()#


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.setStrokeWidth

Signature#

setStrokeWidth(block: number, width: number): void

getStrokeStyle()#


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): StrokeStyle

setStrokeStyle()#


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): void

getStrokePosition()#


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): StrokePosition

setStrokePosition()#


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): void

getStrokeCornerGeometry()#


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): StrokeCornerGeometry

setStrokeCornerGeometry()#


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): void

getStrokeStartCap()#


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.getStrokeStartCap

Signature#

getStrokeStartCap(block: number): StrokeCap

setStrokeStartCap()#


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.

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.setStrokeStartCap

Signature#

setStrokeStartCap(block: number, cap: StrokeCap): void

getStrokeEndCap()#


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.getStrokeEndCap

Signature#

getStrokeEndCap(block: number): StrokeCap

setStrokeEndCap()#


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.

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.setStrokeEndCap

Signature#

setStrokeEndCap(block: number, cap: StrokeCap): void

getStrokeDashStartCap()#


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.getStrokeDashStartCap

Signature#

getStrokeDashStartCap(block: number): StrokeCap

setStrokeDashStartCap()#


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.

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.setStrokeDashStartCap

Signature#

setStrokeDashStartCap(block: number, cap: StrokeCap): void

getStrokeDashEndCap()#


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.getStrokeDashEndCap

Signature#

getStrokeDashEndCap(block: number): StrokeCap

setStrokeDashEndCap()#


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.

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.setStrokeDashEndCap

Signature#

setStrokeDashEndCap(block: number, cap: StrokeCap): void

getStrokeDashArray()#


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.getStrokeDashArray

Signature#

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.

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.setStrokeDashArray

Signature#

setStrokeDashArray(block: number, dashArray: number[]): void

getStrokeDashOffset()#


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.getStrokeDashOffset

Signature#

getStrokeDashOffset(block: number): number

setStrokeDashOffset()#


Sets the dash offset of the block’s stroke. Semantics match SVG’s 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.setStrokeDashOffset

Signature#

setStrokeDashOffset(block: number, dashOffset: number): void

getStrokeOverprint()#


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): boolean

setStrokeOverprint()#


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): void

Block 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.supportsDropShadow

Signature#

supportsDropShadow(block: number): boolean

isDropShadowEnabled()#


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.isDropShadowEnabled

Signature#

isDropShadowEnabled(block: number): boolean

setDropShadowEnabled()#


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.setDropShadowEnabled

Signature#

setDropShadowEnabled(block: number, enabled: boolean): void

getDropShadowColor()#


Gets the drop shadow color of a block.

Parameters#

Parameter Type Description
block number The block whose drop shadow color should be queried.

Returns#

Color

The drop shadow color.

Implementation of#

IBlockAPI.getDropShadowColor

Signature#

getDropShadowColor(block: number): Color

setDropShadowColor()#


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.setDropShadowColor

Signature#

setDropShadowColor(block: number, color: Color): void

getDropShadowOffsetX()#


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): number

setDropShadowOffsetX()#


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): void

getDropShadowOffsetY()#


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): number

setDropShadowOffsetY()#


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): void

getDropShadowBlurRadiusX()#


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): number

setDropShadowBlurRadiusX()#


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): void

getDropShadowBlurRadiusY()#


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): number

setDropShadowBlurRadiusY()#


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): void

getDropShadowClip()#


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): boolean

setDropShadowClip()#


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): void

Block 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.supportsEffects

Signature#

supportsEffects(block: number): boolean

getEffects()#


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.getEffects

Signature#

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.appendEffect

Signature#

appendEffect(block: number, effect: number): void

insertEffect()#


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.insertEffect

Signature#

insertEffect(block: number, effect: number, index: number): void

removeEffect()#


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.removeEffect

Signature#

removeEffect(block: number, index: number): void

isEffectEnabled()#


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.isEffectEnabled

Signature#

isEffectEnabled(effect: number): boolean

setEffectEnabled()#


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.setEffectEnabled

Signature#

setEffectEnabled(effect: number, enabled: boolean): void

setEffectSource()#


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.setEffectSource

Signature#

setEffectSource(effect: number, source: number): void

getEffectSource()#


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.getEffectSource

Signature#

getEffectSource(effect: number): number

Block 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.supportsTextAnimators

Signature#

supportsTextAnimators(block: number): boolean

getTextAnimators()#


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.getTextAnimators

Signature#

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.appendTextAnimator

Signature#

appendTextAnimator(block: number, animator: number): void

insertTextAnimator()#


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.insertTextAnimator

Signature#

insertTextAnimator(block: number, animator: number, index: number): void

removeTextAnimator()#


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.removeTextAnimator

Signature#

removeTextAnimator(block: number, index: number): void

Block 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.supportsBlur

Signature#

supportsBlur(block: number): boolean

getBlur()#


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.getBlur

Signature#

getBlur(block: number): number

setBlur()#


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.setBlur

Signature#

setBlur(block: number, blur: number): void

isBlurEnabled()#


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.isBlurEnabled

Signature#

isBlurEnabled(block: number): boolean

setBlurEnabled()#


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.setBlurEnabled

Signature#

setBlurEnabled(block: number, enabled: boolean): void

Block 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): boolean

setPlaceholderEnabled()#


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): void

supportsPlaceholderBehavior()#


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): boolean

isPlaceholderBehaviorEnabled()#


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): boolean

setPlaceholderBehaviorEnabled()#


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): void

supportsPlaceholderControls()#


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): boolean

isPlaceholderControlsOverlayEnabled()#


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): boolean

setPlaceholderControlsOverlayEnabled()#


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): void

isPlaceholderControlsButtonEnabled()#


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): boolean

setPlaceholderControlsButtonEnabled()#


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): void

Block 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): boolean

setScopeEnabled()#


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): void

isAllowedByScope()#


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): boolean

Block 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): number

isCombinable()#


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[]): boolean

Block 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): number

createCutoutFromPath()#


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): number

Block 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): number

getAudioInfoFromVideo()#


Gets information about all audio tracks from a video fill block.

// Get information about all audio tracks
const trackInfos = engine.block.getAudioInfoFromVideo(videoFillBlock);
console.log(`Video has ${trackInfos.length} audio tracks`);
// Display track information
trackInfos.forEach((track, index) => {
console.log(`Track ${index}: ${track.channels} channels, ${track.sampleRate}Hz, ${track.language}`);
});
// Use track info to create audio blocks selectively
const 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#

AudioTrackInfo[]

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 settings
const audioBlock = engine.block.createAudioFromVideo(videoFillBlock, 0);
// Extract full audio track without trim settings
const audioBlock = engine.block.createAudioFromVideo(videoFillBlock, 0, { keepTrimSettings: false });
// Extract a specific track, keep trim settings, and mute the original video
const 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): number

createAudiosFromVideo()#


Creates multiple audio blocks by extracting all audio tracks from a video fill block.

// Extract all audio tracks from a video with trim settings
const 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 video
const 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.supportsMasks

Signature#

supportsMasks(block: number): boolean

getMasks()#


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.getMasks

Signature#

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.appendMask

Signature#

appendMask(block: number, mask: number): void

insertMask()#


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.insertMask

Signature#

insertMask(block: number, mask: number, index: number): void

removeMask()#


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.removeMask

Signature#

removeMask(block: number, index: number): void

Block 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.hasMetadata

Signature#

hasMetadata(block: number, key: string): boolean

getMetadata()#


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.getMetadata

Signature#

getMetadata(block: number, key: string): string

setMetadata()#


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.setMetadata

Signature#

setMetadata(block: number, key: string, value: string): void

removeMetadata()#


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.removeMetadata

Signature#

removeMetadata(block: number, key: string): void

findAllMetadata()#


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.findAllMetadata

Signature#

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.supportsModifiers

Signature#

supportsModifiers(block: number): boolean

getModifiers()#


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.getModifiers

Signature#

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.appendModifier

Signature#

appendModifier(block: number, modifier: number): void

insertModifier()#


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.insertModifier

Signature#

insertModifier(block: number, modifier: number, index: number): void

removeModifier()#


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.removeModifier

Signature#

removeModifier(block: number, index: number): void

Block 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): number

supportsTransition()#


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): boolean

getTransition()#


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): number

setTransition()#


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): void

removeTransition()#


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): void

Helper#

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): void

getBackgroundTrack()#


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(): number

moveToBackgroundTrack()#


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): void

Other#

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.create

Signature#

create(type: DesignBlockType): number

createFill()#


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.createFill

Signature#

createFill(type: FillType): number

createShape()#


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.createShape

Signature#

createShape(type: ShapeType): number

createEffect()#


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.createEffect

Signature#

createEffect(type: EffectType): number

createMask()#


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.

Returns#

number

The ID of the newly created mask block.

Implementation of#

IBlockAPI.createMask

Signature#

createMask(): number

createBlur()#


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.createBlur

Signature#

createBlur(type: BlurType): number

createAnimation()#


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.createAnimation

Signature#

createAnimation(type: AnimationType): number

duplicate()#


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.duplicate

Signature#

duplicate(block: number, attachToParent?: boolean): number

destroy()#


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.destroy

Signature#

destroy(block: number): void

isValid()#


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.isValid

Signature#

isValid(block: number): boolean

findAll()#


Find all blocks in the scene.

Returns#

number[]

Array of all block IDs.

Implementation of#

IBlockAPI.findAll

Signature#

findAll(): number[]

findAllPlaceholders()#


Find all placeholder blocks in the scene.

Returns#

number[]

Array of placeholder block IDs.

Implementation of#

IBlockAPI.findAllPlaceholders

Signature#

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.

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.findByName

Signature#

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.findByType

Signature#

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.findByKind

Signature#

findByKind(kind: string): number[]

findAllSelected()#


Find all currently selected blocks.

Returns#

number[]

Array of selected block IDs.

Implementation of#

IBlockAPI.findAllSelected

Signature#

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.getParent

Signature#

getParent(block: number): number

setTransformParent()#


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.setTransformParent

Signature#

setTransformParent(block: number, parent: number): void

getTransformParent()#


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.getTransformParent

Signature#

getTransformParent(block: number): number

getOwningPageSlice()#


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.getOwningPageSlice

Signature#

getOwningPageSlice(block: number): number

getPageSlices()#


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.getPageSlices

Signature#

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.

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.hasTransformAnchor

Signature#

hasTransformAnchor(block: number): boolean

hasParent()#


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): boolean

getChildren()#


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.getChildren

Signature#

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.insertChild

Signature#

insertChild(parent: number, child: number, index: number): void

movePageSliceIntoPage()#


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): number

movePageSliceOutOfPage()#


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): number

appendChild()#


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.appendChild

Signature#

appendChild(parent: number, child: number): void

getType()#


Get the type of a block.

Parameters#

Parameter Type Description
block number The ID of the block.

Returns#

ObjectTypeLonghand

The block type string (e.g., ‘//ly.img.ubq/graphic’).

Implementation of#

IBlockAPI.getType

Signature#

getType(block: number): ObjectTypeLonghand

getKind()#


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.getKind

Signature#

getKind(block: number): string

setKind()#


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.setKind

Signature#

setKind(block: number, kind: string): void

getName()#


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.getName

Signature#

getName(block: number): string

setName()#


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.setName

Signature#

setName(block: number, name: string): void

getUUID()#


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.getUUID

Signature#

getUUID(block: number): string

setEnum()#


Setting 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.setEnum

Call 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.setEnum

Signatures#

setEnum(id: number, property: T, value: BlockEnumType[T]): void
setEnum(id: number, property: string, value: string): void

setPositionX()#


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.setPositionX

Signature#

setPositionX(block: number, value: number): void

setPositionY()#


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.setPositionY

Signature#

setPositionY(block: number, value: number): void

setWidth()#


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.setWidth

Signature#

setWidth(block: number, value: number, maintainCrop?: boolean): void

setWidthMode()#


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.setWidthMode

Signature#

setWidthMode(block: number, mode: "Auto" | "Absolute" | "Percent"): void

setHeight()#


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.setHeight

Signature#

setHeight(block: number, value: number, maintainCrop?: boolean): void

setHeightMode()#


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.setHeightMode

Signature#

setHeightMode(block: number, mode: "Auto" | "Absolute" | "Percent"): void

setSize()#


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): void

resizeContentAware()#


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): void

getGlobalBoundingBoxX()#


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.getGlobalBoundingBoxX

Signature#

getGlobalBoundingBoxX(block: number): number

getGlobalBoundingBoxY()#


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.getGlobalBoundingBoxY

Signature#

getGlobalBoundingBoxY(block: number): number

getGlobalBoundingBoxWidth()#


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.getGlobalBoundingBoxWidth

Signature#

getGlobalBoundingBoxWidth(block: number): number

getGlobalBoundingBoxHeight()#


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.getGlobalBoundingBoxHeight

Signature#

getGlobalBoundingBoxHeight(block: number): number

createTextAnimator()#


Create a new text animator block. Add it to a text block with appendTextAnimator.

Returns#

number

The ID of the newly created text animator block.

Implementation of#

IBlockAPI.createTextAnimator

Signature#

createTextAnimator(): number

createModifier()#


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.createModifier

Signature#

createModifier(type: ModifierType): number

convertToComponent()#


Makes a block a main component, so that instances can follow it.

Parameters#

Parameter Type
block number

Returns#

void

Signature#

convertToComponent(block: number): void

isComponent()#


Checks whether a block is a main component.

Parameters#

Parameter Type
block number

Returns#

boolean

Signature#

isComponent(block: number): boolean

createInstance()#


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.

Parameters#

Parameter Type
component number

Returns#

number

Signature#

createInstance(component: number): number

isInstance()#


Checks whether a block is the top block of an instance.

Parameters#

Parameter Type
block number

Returns#

boolean

Signature#

isInstance(block: number): boolean

getMainComponent()#


Gets the main component of an instance.

Parameters#

Parameter Type
instance number

Returns#

number

Signature#

getMainComponent(instance: number): number

detachInstance()#


Turns an instance into plain blocks that no longer follow the main component.

Parameters#

Parameter Type
instance number

Returns#

void

Signature#

detachInstance(instance: number): void

resetInstance()#


Removes all overrides of an instance.

Parameters#

Parameter Type
instance number

Returns#

void

Signature#

resetInstance(instance: number): void

combineAsVariants()#


Moves main components into a new container as variants of one component.

Parameters#

Parameter Type
components number[]

Returns#

number

Signature#

combineAsVariants(components: number[]): number

setVariantProperty()#


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): void

getVariantProperty()#


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): string

findAllVariantProperties()#


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): void

addComponentProperty()#


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): void

findAllComponentProperties()#


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): void

getComponentProperty()#


Gets a published property of an instance as text.

Parameters#

Parameter Type
instance number
name string

Returns#

string

Signature#

getComponentProperty(instance: number, name: string): string

setShape()#


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): void

insertSubshape()#


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): void

appendSubshape()#


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): void

getKeyframes()#


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.getKeyframes

Signature#

getKeyframes(block: number, property: string): Keyframe$1[]

getKeyframeMode()#


| Parameter | Type | | —— | —— | | block | number | | property | string |

Returns#

TrackMode

Throws#

BLOCK.KEYFRAMES_NO_TRACK when the property has no keyframes, or BLOCK.KEYFRAMES_PROPERTY_NOT_ANIMATABLE when isPropertyAnimatable also returns false.

Implementation of#

IBlockAPI.getKeyframeMode

Signature#

getKeyframeMode(block: number, property: string): TrackMode

getAnimatedValue()#


A property without keyframes gives its static value.

Parameters#

Parameter Type
block number
property string
time number

Returns#

KeyframeValue

Throws#

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.getAnimatedValue

Signature#

getAnimatedValue(block: number, property: string, time: number): KeyframeValue

removeKeyframes()#


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.removeKeyframes

Signature#

removeKeyframes(block: number, property: string): void

setMatte()#


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.setMatte

Signature#

setMatte(block: number, source: number, mode?: MatteMode): void

createFromSVG()#


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): number

setFontRequest()#


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.setFontRequest

Signature#

setFontRequest(block: number, request: FontRequest, from?: number, to?: number): void

getFontRequests()#


Gets unique requests in the source selection, or the entire text without a selection.

Parameters#

Parameter Type
block number
from? number
to? number

Returns#

FontRequest[]

Implementation of#

IBlockAPI.getFontRequests

Signature#

getFontRequests(block: number, from?: number, to?: number): FontRequest[]

setTypeface()#


| Parameter | Type | | —— | —— | | 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.setTypeface

Signature#

setTypeface(block: number, typeface: Typeface, from?: number, to?: number): void

setTextKerning()#


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.

Parameters#

Parameter Type
block number
kerning number
from? number
to? number

Returns#

void

Implementation of#

IBlockAPI.setTextKerning

Signature#

setTextKerning(block: number, kerning: number, from?: number, to?: number): void

getTextKernings()#


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.

Parameters#

Parameter Type
block number
from? number
to? number

Returns#

number[]

Implementation of#

IBlockAPI.getTextKernings

Signature#

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”

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.setTextOpenTypeFeatures

Signature#

setTextOpenTypeFeatures(block: number, features: OpenTypeFeature[], from?: number, to?: number): void

getTextOpenTypeFeatures()#


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.getTextOpenTypeFeatures

Signature#

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”

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.setTextVariationAxes

Signature#

setTextVariationAxes(block: number, axes: VariationAxisValue[], from?: number, to?: number): void

getTextVariationAxes()#


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#

VariationAxisValue[][]

Implementation of#

IBlockAPI.getTextVariationAxes

Signature#

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.

Parameters#

Parameter Type
block number
baselineShift number
from? number
to? number

Returns#

void

Implementation of#

IBlockAPI.setTextBaselineShift

Signature#

setTextBaselineShift(block: number, baselineShift: number, from?: number, to?: number): void

getTextBaselineShifts()#


Return the unique baseline shift values seen across the grapheme range, in design units. [0] for a clean block.

Parameters#

Parameter Type
block number
from? number
to? number

Returns#

number[]

Implementation of#

IBlockAPI.getTextBaselineShifts

Signature#

getTextBaselineShifts(block: number, from?: number, to?: number): number[]

setFont()#


| Parameter | Type | | —— | —— | | 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.setFont

Signature#

setFont(block: number, fontUri: string, typeface: Typeface): void

getTextCursorRange()#


Returns the current text cursor range as UTF-16 indices. When no block is currently being edited, returns { from: -1, to: -1 }.

Returns#

Range

Signature#

getTextCursorRange(): Range

setTextCursorRange()#


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).

Parameters#

Parameter Type
range Range

Returns#

void

Signature#

setTextCursorRange(range: Range): void

getTextCharacterInkBoxes()#


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#

CharacterInkBox[]

Implementation of#

IBlockAPI.getTextCharacterInkBoxes

Signature#

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.

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#

HorizontalTextAlignment

Signature#

getTextHorizontalAlignment(block: number, paragraphIndex?: number): TextHorizontalAlignment

setTextHorizontalAlignment()#


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.

Parameters#

Parameter Type
block number
alignment HorizontalTextAlignment
paragraphIndex? number

Returns#

void

Signature#

setTextHorizontalAlignment(block: number, alignment: TextHorizontalAlignment, paragraphIndex?: number): void

getTextDecorations()#


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.

Parameters#

Parameter Type
block number
from? number
to? number

Returns#

TextDecorationConfig[]

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.

Parameters#

Parameter Type
block number
config TextDecorationConfig
from? number
to? number

Returns#

void

Signature#

setTextDecoration(block: number, config: TextDecorationConfig, from?: number, to?: number): void

getTextParagraphIndices()#


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.

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).

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): number

getState()#


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.

Parameters#

Parameter Type
block number

Returns#

BlockState

Signature#

getState(block: number): BlockState

exportToStream()#


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.

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’.

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.saveToString

Signature#

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.saveToArchive

Signature#

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.

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.

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.

Parameters#

Parameter Type
block number
animation? AnimationOptions

Returns#

void

Signature#

applyAnimation(block: number, animation?: AnimationOptions): void

applyDropShadow()#


Apply a drop shadow effect to a block. Mirrors @cesdk/engine’s BlockAPI.applyDropShadow exactly.

Parameters#

Parameter Type
block number
options? DropShadowOptions

Returns#

void

Signature#

applyDropShadow(block: number, options?: DropShadowOptions): void

addImage()#


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.

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.

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.

Parameters#

Parameter Type
ids number[]
callback (ids) => void

Returns#

A function to unsubscribe.

() => void

Implementation of#

IBlockAPI.onStateChanged

onSelectionChanged#


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.

Parameters#

Parameter Type
callback () => void

Returns#

A function to unsubscribe.

() => void

Implementation of#

IBlockAPI.onSelectionChanged

onClicked#


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.

Parameters#

Parameter Type
callback (id) => void

Returns#

A function to unsubscribe.

() => void

Implementation of#

IBlockAPI.onClicked

createCutoutFromBlocks()#


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): number

unstable_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#

ImportedImageDefinitionInfo

The 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.

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.setVariableBinding

Signature#

setVariableBinding(id: number, property: string, key: string): void

getVariableBinding()#


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.getVariableBinding

Signature#

getVariableBinding(id: number, property: string): string

removeVariableBinding()#


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.removeVariableBinding

Signature#

removeVariableBinding(id: number, property: string): void

findAllVariableBindings()#


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.findAllVariableBindings

Signature#

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): void

generateVideoThumbnailSequence()#


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.

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): () => void

generateThumbnailAtTimeOffset()#


Generates a PNG thumbnail of the current page at a specific time, matching @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): void

generateAudioThumbnailSequence()#


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.

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