openDesign
Reads a specified part of the user's design and returns all elements in that part.
Parameters
options
DesignContextOptions
Options for configuring which part of a design to read.
Properties of options
type
string
The type of context.
This must be "current_page"
.
callback
function
Parameters
draft
CurrentPageResult
The result of reading part of a design when the context is the current page.
Properties of draft
save
function
- Any changes to the draft are only reflected in the design after this method is called.
- Once this method is called, further changes to the draft are not possible.
Returns
Promise<void>
page
FixedPage
The current page of the design.
Properties of page
type
string
The type of page.
This must be "fixed"
.
locked
boolean
If true
, the page is locked and cannot be modified.
dimensions
undefined | Dimensions
The dimensions of the page. dimensions
is undefined for whiteboard pages.
Properties of dimensions
width
number
A width, in pixels.
height
number
A height, in pixels.
background
undefined | Fill
The background of the page. background
is undefined for whiteboard pages.
Properties of background
media
undefined | MediaFill
The media fill for the path, if any.
An image that fills the interior of a path.
type
string
The type of media.
This must be "image"
.
imageRef
ImageRef
A unique identifier that points to an image asset in Canva's backend.
flipX
boolean
If true
, the image is flipped horizontally.
flipY
boolean
If true
, the image is flipped vertically.
A video that fills the interior of a path.
type
string
The type of media.
This must be "video"
.
videoRef
VideoRef
A unique identifier that points to a video asset in Canva's backend.
flipX
boolean
If true
, the video is flipped horizontally.
flipY
boolean
If true
, the video is flipped vertically.
color
undefined | ColorFill
The color fill for the path, if any.
A solid color that fills the interior of a path.
type
string
The type of color.
This must be "solid"
.
color
string
The color of the fill, as a hex code.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Represents an element that's not supported by the Apps SDK.
type
string
The type of element.
This must be "unsupported"
.
elements
List<FixedElement>
The elements on the page.
Elements are rendered in the order they appear in the list. Later elements appear on top of earlier ones.
Properties of elements
count
function
Returns
The number of items.
number
toArray
function
Returns
An array containing all items. The items are the same as in the list.
readonly T
[]
forEach
function
Parameters
callback
ForEachCallback<T>
The function to run for each item.
Parameters
item
T
The current item in the list.
index
number
The index of the current item.
Returns
void
Returns
void
filter
function
Parameters
filter
FilterPredicate<T>
A function that tests each item. Returns true
to keep the item.
Parameters
item
T
The item to test.
Returns
true
if the item should be included, otherwise false
.
boolean
Returns
An array of items that passed the test.
readonly T
[]
insertBefore
function
Parameters
ref
undefined | T
The 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.
item
T
The item to add. A copy of this item will be inserted.
Returns
The added item, or undefined
if the operation failed.
undefined | T
insertAfter
function
Parameters
ref
undefined | T
The 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.
item
T
The item to add. A copy of this item will be inserted.
Returns
The added item, or undefined
if the operation failed.
undefined | T
moveBefore
function
Parameters
ref
undefined | T
The 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.
item
T
The item to move. The operation fails if the item is not already in the list.
Returns
void
moveAfter
function
Parameters
ref
undefined | T
The 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.
item
T
The item to move. The operation fails if the item is not already in the list.
Returns
void
delete
function
Parameters
item
T
The item to remove from the list.
Returns
void
helpers
object
Properties of helpers
elementBuilder
ElementBuilder
Provides methods for creating elements.
These methods don't add the elements to the design. They only return elements that can
be added to a design, such as with the insertAfter
method.
Properties of elementBuilder
createRectElement
function
Parameters
opts
CreateRectElementOpts
Options for creating the rect element.
Properties of opts
fill
FillOpts
color
ColorFillOpts
media
MediaFillOpts
Options for creating an image fill in the element builder
Options for creating a video fill in the element builder
media
MediaFillOpts
Options for creating an image fill in the element builder
Options for creating a video fill in the element builder
color
ColorFillOpts
stroke
StrokeOpts
Properties of stroke
color
ColorFillOpts
weight
number
The weight (thickness) of the stroke.
- Minimum: 0
- Maximum: 100
Returns
An element that renders a rectangle.
The rectangle can be filled with image content, video content, or a solid color.
width
number
A width, in pixels.
height
number
A height, in pixels.
locked
boolean
If true
, the element is locked and cannot be modified.
top
number
The distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
left
number
The distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
rotation
number
A rotation, in degrees.
- Minimum: -180
- Maximum: 180
transparency
number
Transparency as a percentage.
- Minimum: 0
- Maximum: 1
type
string
The type of content.
This must be "rect"
.
fill
Fill
The appearance of the rectangle's interior.
Properties of fill
media
undefined | MediaFill
The media fill for the path, if any.
An image that fills the interior of a path.
type
string
The type of media.
This must be "image"
.
imageRef
ImageRef
A unique identifier that points to an image asset in Canva's backend.
flipX
boolean
If true
, the image is flipped horizontally.
flipY
boolean
If true
, the image is flipped vertically.
A video that fills the interior of a path.
type
string
The type of media.
This must be "video"
.
videoRef
VideoRef
A unique identifier that points to a video asset in Canva's backend.
flipX
boolean
If true
, the video is flipped horizontally.
flipY
boolean
If true
, the video is flipped vertically.
color
undefined | ColorFill
The color fill for the path, if any.
A solid color that fills the interior of a path.
type
string
The type of color.
This must be "solid"
.
color
string
The color of the fill, as a hex code.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Represents an element that's not supported by the Apps SDK.
type
string
The type of element.
This must be "unsupported"
.
stroke
Stroke
The outline of the rectangle.
Properties of stroke
weight
number
The weight (thickness) of the stroke.
- Minimum: 0
- Maximum: 100
color
ColorFill
The color of the stroke.
A solid color that fills the interior of a path.
type
string
The type of color.
This must be "solid"
.
color
string
The color of the fill, as a hex code.
- Must be six characters long.
- Must start with a
#
. - Must use lowercase letters.
Represents an element that's not supported by the Apps SDK.
type
string
The type of element.
This must be "unsupported"
.
createShapeElement
function
Parameters
opts
CreateShapeElementOpts
Options for creating the shape element.
Properties of opts
paths
ShapePathOpts[]
Properties of paths
fill
FillOpts
color
ColorFillOpts
media
MediaFillOpts
Options for creating an image fill in the element builder
Options for creating a video fill in the element builder
media
MediaFillOpts
Options for creating an image fill in the element builder
Options for creating a video fill in the element builder
color
ColorFillOpts
stroke
StrokeOpts
Properties of stroke
color
ColorFillOpts
weight
number
The weight (thickness) of the stroke.
- Minimum: 0
- Maximum: 100
d
string
The shape of the path.
This is similar to the d
attribute of an SVG's path
element, with some limitations:
- Must start with an
M
command. - Only one
M
command is allowed. Q
andT
commands are not permitted.- The path must be closed using a
Z
command or matching start and end coordinates.
Returns
An element that renders a vector shape.
width
number
A width, in pixels.
height
number
A height, in pixels.
locked
boolean
If true
, the element is locked and cannot be modified.
top
number
The distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
left
number
The distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
rotation
number
A rotation, in degrees.
- Minimum: -180
- Maximum: 180
transparency
number
Transparency as a percentage.
- Minimum: 0
- Maximum: 1
type
string
The type of content.
This must be "shape"
.
viewBox
AlignedBox
The scale and cropping of the shape.
Properties of viewBox
top
number
The distance of the shape from the top edge of the element, in pixels.
left
number
The distance of the shape from the left edge of the element, in pixels.
width
number
The width of the view box, in pixels.
height
number
The height of the view box, in pixels.
paths
ReadableList<Path>
The 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.
Properties of paths
count
function
Returns
The number of items.
number
toArray
function
Returns
An array containing all items. The items are the same as in the list.
readonly T
[]
forEach
function
Parameters
callback
ForEachCallback<T>
The function to run for each item.
Parameters
item
T
The current item in the list.
index
number
The index of the current item.
Returns
void
Returns
void
filter
function
Parameters
filter
FilterPredicate<T>
A function that tests each item. Returns true
to keep the item.
Parameters
item
T
The item to test.
Returns
true
if the item should be included, otherwise false
.
boolean
Returns
An array of items that passed the test.
readonly T
[]
createEmbedElement
function
Parameters
opts
CreateEmbedElementOpts
Options for creating the embed element.
Returns
An element that embeds rich media, such as a YouTube video.
width
number
A width, in pixels.
height
number
A height, in pixels.
locked
boolean
If true
, the element is locked and cannot be modified.
top
number
The distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
left
number
The distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
rotation
number
A rotation, in degrees.
- Minimum: -180
- Maximum: 180
transparency
number
Transparency as a percentage.
- Minimum: 0
- Maximum: 1
type
string
The type of content.
This must be "embed"
.
url
string
The URL of the rich media.
This URL must be supported by the Iframely API.
createTextElement
function
Parameters
opts
CreateTextElementOpts
Options for creating the text element.
Returns
An element that renders text content.
width
number
A width, in pixels.
height
number
A height, in pixels.
locked
boolean
If true
, the element is locked and cannot be modified.
top
number
The distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
left
number
The distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
- Minimum: -32768
- Maximum: 32767
rotation
number
A rotation, in degrees.
- Minimum: -180
- Maximum: 180
transparency
number
Transparency as a percentage.
- Minimum: 0
- Maximum: 1
type
string
The type of content.
This must be "text"
.
text
RichtextRange
The text content.
Properties of text
formatParagraph
function
Formats all of the paragraphs that overlap the given bounds.
- The
\n
character indicates the end of a paragraph. - All paragraphs that overlap the provided bounds will be formatted in their entirety.
Parameters
bounds
Bounds
The segment of the range on which to apply the formatting.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
formatting
RichtextFormatting
The formatting to apply to the paragraph(s).
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
fontRef
FontRef
A unique identifier that points to a font asset in Canva's backend.
fontSize
number
The size of the text, in pixels.
- In the Canva editor, this number is shown as points (pts), not pixels.
- Minimum: 1
- Maximum: 100
textAlign
string
The alignment of the text.
Default Value: "start"
The available options include:
"start"
"center"
"end"
"justify"
listLevel
number
The list indentation level of the paragraph.
listMarker
string
The appearance of list item markers.
This property only has an effect if listLevel
is greater than 0.
Default Value: "none"
The available options include:
"none"
"disc"
"circle"
"square"
"decimal"
"lower-alpha"
"lower-roman"
"checked"
"unchecked"
Returns
void
formatText
function
Formats a region of text with inline formatting properties.
Parameters
bounds
Bounds
The segment of the range on which to apply the formatting.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
formatting
InlineFormatting
The formatting to apply to the text.
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
Returns
void
appendText
function
Appends the specified characters to the end of the range.
Parameters
characters
string
The characters to append to the richtext range.
formatting
InlineFormatting
Options for formatting inline richtext.
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
Returns
bounds
Bounds
A segment of a richtext range.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
replaceText
function
Replaces a region of text with the specified characters.
Parameters
bounds
Bounds
The segment of the range to replace.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
characters
string
The replacement characters.
formatting
InlineFormatting
The formatting to apply to the replaced text.
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
Returns
bounds
Bounds
The bounds of the replacement characters within the updated range.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
readPlaintext
function
Returns the current state of the richtext as plaintext.
Returns
string
readTextRegions
function
Returns the current state of the richtext as one or more text regions. Each region is an object that contains the text content and its formatting.
Returns
text
string
The plaintext content of the region.
formatting
Partial<RichtextFormatting>
The formatting of the region.
createRichtextRange
function
Returns
Provides methods for interacting with a range of formatted text.
formatParagraph
function
Formats all of the paragraphs that overlap the given bounds.
- The
\n
character indicates the end of a paragraph. - All paragraphs that overlap the provided bounds will be formatted in their entirety.
Parameters
bounds
Bounds
The segment of the range on which to apply the formatting.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
formatting
RichtextFormatting
The formatting to apply to the paragraph(s).
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
fontRef
FontRef
A unique identifier that points to a font asset in Canva's backend.
fontSize
number
The size of the text, in pixels.
- In the Canva editor, this number is shown as points (pts), not pixels.
- Minimum: 1
- Maximum: 100
textAlign
string
The alignment of the text.
Default Value: "start"
The available options include:
"start"
"center"
"end"
"justify"
listLevel
number
The list indentation level of the paragraph.
listMarker
string
The appearance of list item markers.
This property only has an effect if listLevel
is greater than 0.
Default Value: "none"
The available options include:
"none"
"disc"
"circle"
"square"
"decimal"
"lower-alpha"
"lower-roman"
"checked"
"unchecked"
Returns
void
formatText
function
Formats a region of text with inline formatting properties.
Parameters
bounds
Bounds
The segment of the range on which to apply the formatting.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
formatting
InlineFormatting
The formatting to apply to the text.
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
Returns
void
appendText
function
Appends the specified characters to the end of the range.
Parameters
characters
string
The characters to append to the richtext range.
formatting
InlineFormatting
Options for formatting inline richtext.
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
Returns
bounds
Bounds
A segment of a richtext range.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
replaceText
function
Replaces a region of text with the specified characters.
Parameters
bounds
Bounds
The segment of the range to replace.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
characters
string
The replacement characters.
formatting
InlineFormatting
The formatting to apply to the replaced text.
Properties of formatting
color
string
The color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontWeight
FontWeight
The weight (thickness) of the font.
The available font weights depend on the font.
Default Value: "normal"
The available options include:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
The style of the font.
Default Value: "normal"
The available options include:
"normal"
"italic"
decoration
string
The decoration of the text.
Default Value: "none"
The available options include:
"none"
"underline"
strikethrough
string
The strikethrough of the text.
Default Value: "none"
The available options include:
"none"
"strikethrough"
link
string
An external URL that the text links to.
Returns
bounds
Bounds
The bounds of the replacement characters within the updated range.
Properties of bounds
index
number
The starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
The number of characters in the segment, starting from the index.
readPlaintext
function
Returns the current state of the richtext as plaintext.
Returns
string
readTextRegions
function
Returns the current state of the richtext as one or more text regions. Each region is an object that contains the text content and its formatting.
Returns
text
string
The plaintext content of the region.
formatting
Partial<RichtextFormatting>
The formatting of the region.
Returns
void
or Promise<void>
Returns
Promise<void>