ElementList
A list of elements.
Methods
count
function
RequiredGets the number of items in the list.
Returns
The number of items.
number
toArray
function
RequiredConverts the list to an array.
Returns
An array containing all items. The items are the same as in the list.
For more information, see AbsoluteElement.
forEach
function
RequiredExecutes a function for each item in the list.
Parameters
callback
ForEachCallback<AbsoluteElement>
RequiredThe function to run for each item.
For more information, see AbsoluteElement.
Parameters
item
AbsoluteElement
RequiredThe current item in the list.
For more information, see AbsoluteElement.
index
number
RequiredThe index of the current item.
Returns
void
Returns
void
filter
function
RequiredCreates a new array with items that pass a test.
Parameters
filter
FilterPredicate<AbsoluteElement>
RequiredA function that tests each item. Returns true
to keep the item.
For more information, see AbsoluteElement.
Parameters
item
AbsoluteElement
RequiredThe item to test.
For more information, see AbsoluteElement.
Returns
true
if the item should be included, otherwise false
.
boolean
Returns
An array of items that passed the test.
For more information, see AbsoluteElement.
moveBefore
function
RequiredMoves an existing item to a new position right before another item.
Parameters
ref
undefined | AbsoluteElement
RequiredThe existing item to move the item before.
If ref
is undefined
, the item is moved to the end of the list.
If ref
does not exist in the list, the operation fails.
For more information, see AbsoluteElement.
item
AbsoluteElement
RequiredThe item to move. The operation fails if the item is not already in the list.
For more information, see AbsoluteElement.
Returns
void
moveAfter
function
RequiredMoves an existing item to a new position right after another item.
Parameters
ref
undefined | AbsoluteElement
RequiredThe existing item to move the item after.
If ref
is undefined
, the item is moved to the end of the list.
If ref
does not exist in the list, the operation fails.
For more information, see AbsoluteElement.
item
AbsoluteElement
RequiredThe item to move. The operation fails if the item is not already in the list.
For more information, see AbsoluteElement.
Returns
void
delete
function
RequiredRemoves an item from the list.
Parameters
item
AbsoluteElement
RequiredThe item to remove from the list.
For more information, see AbsoluteElement.
Returns
void
insertBefore
function
RequiredAdds a copy of an item to the list and places it right before another item.
Parameters
ref
undefined | AbsoluteElement
RequiredThe existing item to place the new item before.
If ref
is undefined
, the new item is added at the end of the list.
If ref
does not exist in the list, the operation fails.
For more information, see AbsoluteElement.
state
InsertableElementState
RequiredAn element state that can be inserted into a page.
A state that creates a rectangle element.
The rectangle can be filled with image content, video content, or a solid color.
type
string
Read-onlyRequiredThe type of content.
This must be "rect"
.
fill
FillState
Read-onlyRequiredThe appearance of the rectangle's interior.
mediaContainer
undefined | MediaFillState
RequiredThe media fill for the path, if any.
A state that creates an image fill.
type
string
Read-onlyRequiredThe type of media.
This must be "image"
.
imageRef
ImageRef
Read-onlyRequiredA unique identifier that points to an image asset in Canva's backend.
flipX
boolean
RequiredIf true
, the image is flipped horizontally.
flipY
boolean
RequiredIf true
, the image is flipped vertically.
A state that creates a video fill.
type
string
Read-onlyRequiredThe type of media.
This must be "video"
.
videoRef
VideoRef
Read-onlyRequiredA unique identifier that points to a video asset in Canva's backend.
flipX
boolean
RequiredIf true
, the video is flipped horizontally.
flipY
boolean
RequiredIf true
, the video is flipped vertically.
colorContainer
undefined | ColorFillState
RequiredThe color fill for the path, if any.
A state that creates a solid color fill.
type
string
Read-onlyRequiredThe type of color.
This must be "solid"
.
color
string
RequiredThe color of the fill.
This must be a valid, six-digit hex code, prefixed with a #
symbol.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Example
"#ff0099"
Represents something that's not supported by the Apps SDK.
type
string
Read-onlyRequiredThis must be "unsupported"
.
stroke
StrokeState
Read-onlyRequiredThe outline of the rectangle.
weight
number
RequiredThe weight (thickness) of the stroke.
Minimum: 0
Maximum: 100
colorContainer
ColorFillState
RequiredThe color of the stroke.
A state that creates a solid color fill.
type
string
Read-onlyRequiredThe type of color.
This must be "solid"
.
color
string
RequiredThe color of the fill.
This must be a valid, six-digit hex code, prefixed with a #
symbol.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Example
"#ff0099"
Represents something that's not supported by the Apps SDK.
type
string
Read-onlyRequiredThis must be "unsupported"
.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
A state that creates a vector shape element.
type
string
Read-onlyRequiredThe type of content.
This must be "shape"
.
viewBox
AlignedBoxState
Read-onlyRequiredThe scale and cropping of the shape.
top
number
Read-onlyRequiredThe distance of the shape from the top edge of the element, in pixels.
left
number
Read-onlyRequiredThe distance of the shape from the left edge of the element, in pixels.
width
number
Read-onlyRequiredThe width of the view box, in pixels.
height
number
Read-onlyRequiredThe height of the view box, in pixels.
paths
ListState<PathState>
Read-onlyRequiredThe paths that define the structure of the shape.
- Must have between 1 and 30 paths.
- Total size of all paths must not exceed 2kb.
- Maximum of 6 unique fill colors across all paths.
For more information, see ListState.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
A state that creates an embed element, such as a YouTube video.
type
string
Read-onlyRequiredThe type of content.
This must be "embed"
.
url
string
Read-onlyRequiredThe URL of the rich media.
This URL must be supported by the Iframely API.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
A state that creates a text element.
type
string
Read-onlyRequiredThe type of content.
This must be "text"
.
text
object
Read-onlyRequiredThe text content.
regions
ListState<TextRegion>
RequiredA list of items that can be read.
For more information, see ListState.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
Returns
The added item, or undefined
if the operation failed.
For more information, see AbsoluteElement.
insertAfter
function
RequiredAdds a copy of an item to the list and places it right after another item.
Parameters
ref
undefined | AbsoluteElement
RequiredThe existing item to place the new item after.
If ref
is undefined
, the new item is added at the end of the list.
If ref
does not exist in the list, the operation fails.
For more information, see AbsoluteElement.
state
InsertableElementState
RequiredAn element state that can be inserted into a page.
A state that creates a rectangle element.
The rectangle can be filled with image content, video content, or a solid color.
type
string
Read-onlyRequiredThe type of content.
This must be "rect"
.
fill
FillState
Read-onlyRequiredThe appearance of the rectangle's interior.
mediaContainer
undefined | MediaFillState
RequiredThe media fill for the path, if any.
A state that creates an image fill.
type
string
Read-onlyRequiredThe type of media.
This must be "image"
.
imageRef
ImageRef
Read-onlyRequiredA unique identifier that points to an image asset in Canva's backend.
flipX
boolean
RequiredIf true
, the image is flipped horizontally.
flipY
boolean
RequiredIf true
, the image is flipped vertically.
A state that creates a video fill.
type
string
Read-onlyRequiredThe type of media.
This must be "video"
.
videoRef
VideoRef
Read-onlyRequiredA unique identifier that points to a video asset in Canva's backend.
flipX
boolean
RequiredIf true
, the video is flipped horizontally.
flipY
boolean
RequiredIf true
, the video is flipped vertically.
colorContainer
undefined | ColorFillState
RequiredThe color fill for the path, if any.
A state that creates a solid color fill.
type
string
Read-onlyRequiredThe type of color.
This must be "solid"
.
color
string
RequiredThe color of the fill.
This must be a valid, six-digit hex code, prefixed with a #
symbol.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Example
"#ff0099"
Represents something that's not supported by the Apps SDK.
type
string
Read-onlyRequiredThis must be "unsupported"
.
stroke
StrokeState
Read-onlyRequiredThe outline of the rectangle.
weight
number
RequiredThe weight (thickness) of the stroke.
Minimum: 0
Maximum: 100
colorContainer
ColorFillState
RequiredThe color of the stroke.
A state that creates a solid color fill.
type
string
Read-onlyRequiredThe type of color.
This must be "solid"
.
color
string
RequiredThe color of the fill.
This must be a valid, six-digit hex code, prefixed with a #
symbol.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Example
"#ff0099"
Represents something that's not supported by the Apps SDK.
type
string
Read-onlyRequiredThis must be "unsupported"
.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
A state that creates a vector shape element.
type
string
Read-onlyRequiredThe type of content.
This must be "shape"
.
viewBox
AlignedBoxState
Read-onlyRequiredThe scale and cropping of the shape.
top
number
Read-onlyRequiredThe distance of the shape from the top edge of the element, in pixels.
left
number
Read-onlyRequiredThe distance of the shape from the left edge of the element, in pixels.
width
number
Read-onlyRequiredThe width of the view box, in pixels.
height
number
Read-onlyRequiredThe height of the view box, in pixels.
paths
ListState<PathState>
Read-onlyRequiredThe paths that define the structure of the shape.
- Must have between 1 and 30 paths.
- Total size of all paths must not exceed 2kb.
- Maximum of 6 unique fill colors across all paths.
For more information, see ListState.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
A state that creates an embed element, such as a YouTube video.
type
string
Read-onlyRequiredThe type of content.
This must be "embed"
.
url
string
Read-onlyRequiredThe URL of the rich media.
This URL must be supported by the Iframely API.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
A state that creates a text element.
type
string
Read-onlyRequiredThe type of content.
This must be "text"
.
text
object
Read-onlyRequiredThe text content.
regions
ListState<TextRegion>
RequiredA list of items that can be read.
For more information, see ListState.
width
number
Read-onlyRequiredA width, in pixels.
height
number
Read-onlyRequiredA height, in pixels.
locked
boolean
Read-onlyRequiredIf true
, the element is locked and cannot be modified.
top
number
Read-onlyRequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
Read-onlyRequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
Read-onlyRequiredA rotation, in degrees.
Minimum: -180
Maximum: 180
transparency
number
Read-onlyRequiredTransparency as a percentage.
Minimum: 0
Maximum: 1
Returns
The added item, or undefined
if the operation failed.
For more information, see AbsoluteElement.