addElementAtPoint
Add element to fixed designs, which use a coordinate-based positioning system.
Parameters
element
object
RequiredAn element that's natively supported by the Canva editor.
An element that renders image content.
type
string
RequiredThe type of element.
This must be "image"
.
altText
AltText | undefined
RequiredA description of the image content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
dataUrl
string
OptionalA data URL that contains the image data.
ref
ImageRef
OptionalA unique identifier that points to an image asset in Canva's backend.
An element that renders video content.
type
string
RequiredThe type of element.
This must be "video"
.
ref
VideoRef
RequiredA unique identifier that points to a video asset in Canva's backend.
altText
AltText | undefined
RequiredA description of the video content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
An element that renders rich media, such as a YouTube video.
type
string
RequiredThe type of element.
This must be "embed"
.
url
string
RequiredThe URL of the rich media.
This URL must be supported by the Iframely API.
An element that renders text content.
type
string
RequiredThe type of element.
This must be "text"
.
children
string[]
RequiredThe text content.
Only the first element in this array is used.
fontSize
number
OptionalThe size of the text.
Minimum: 1
Maximum: 100
Default value: 16
textAlign
string
OptionalThe alignment of the text.
Default value: "start"
Available values:
"start"
"center"
"end"
"justify"
color
string
OptionalThe color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontRef
FontRef
OptionalA unique identifier that points to a font asset in Canva's backend.
fontWeight
FontWeight
OptionalThe weight (thickness) of the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the font.
Default value: "none"
Available values:
"none"
"underline"
An element that renders a vector shape.
type
string
RequiredThe type of element.
This must be "shape"
.
viewBox
ShapeViewBox
RequiredOptions for configuring the scale and cropping of the shape.
top
number
RequiredThe distance of the shape from the top edge of the element, in pixels.
left
number
RequiredThe distance of the shape from the left edge of the element, in pixels.
width
number
RequiredThe width of the view box, in pixels.
height
number
RequiredThe height of the view box, in pixels.
paths
ShapePath[]
RequiredThe paths that define the structure of the shape.
- There must be between 1 and 30 paths (inclusive).
- The maximum combined size of all paths must not exceed 2kb.
- The maximum number of unique fill colors across all paths is 6.
d
string
RequiredThe shape of the path.
This is similar to the d
attribute of an SVG's path
element, with some limitations:
- The path must start with an M command.
- The path must not have more than one M command.
- The path must not use the Q command.
- The path must be closed, either by:
- Using a Z command at the end of the path
- Having the last coordinate match the first coordinate
fill
Fill
RequiredThe appearance of the path's interior.
dropTarget
boolean
OptionalIf true
, users can replace a fill by dropping an image or video onto it.
color
string
OptionalThe color of the fill as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
asset
object
OptionalAn image or video to use as the fill.
An image asset that fills a path's interior.
type
string
RequiredThe type of fill.
This must be "image"
.
ref
ImageRef
RequiredA unique identifier that points to an image asset in Canva's backend.
altText
AltText
OptionalA description of the image content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
A video asset that fills a path's interior.
type
string
RequiredThe type of fill.
This must be "video"
.
ref
VideoRef
RequiredA unique identifier that points to a video asset in Canva's backend.
altText
AltText
OptionalA description of the image content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
stroke
PathStroke
OptionalThe outline of the path.
weight
number
RequiredThe weight (thickness) of the stroke.
Minimum: 0
Maximum: 100
color
string
RequiredThe color of the stroke as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
strokeAlign
string
RequiredThe alignment of the stroke.
This must be "inset"
.
An element that contains two or more elements.
type
string
RequiredThe type of element.
This must be "group"
.
children
GroupContentAtPoint[]
RequiredThe elements to render within the group.
- Each element within a group must have dimensions and a position.
- The dimensions and positions are relative to the dimensions and positions of the group.
An element that renders richtext content.
type
string
RequiredThe type of element.
This must be "richtext"
.
range
RichtextRange
RequiredThe richtext content.
formatParagraph
function
RequiredFormats 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
RequiredThe segment of the range on which to apply the formatting.
index
number
RequiredThe starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
RequiredThe number of characters in the segment, starting from the index.
formatting
RichtextFormatting
RequiredThe formatting to apply to the paragraph(s).
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
fontRef
FontRef
OptionalA unique identifier that points to a font asset in Canva's backend.
fontSize
number
OptionalThe 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
OptionalThe alignment of the text.
Default value: "start"
Available values:
"start"
"center"
"end"
"justify"
listLevel
number
OptionalThe list indentation level of the paragraph.
listMarker
string
OptionalThe appearance of list item markers.
This property only has an effect if listLevel
is greater than 0.
Default value: "none"
Available values:
"none"
"disc"
"circle"
"square"
"decimal"
"lower-alpha"
"lower-roman"
"checked"
"unchecked"
Returns
void
formatText
function
RequiredFormats a region of text with inline formatting properties.
Parameters
bounds
Bounds
RequiredThe segment of the range on which to apply the formatting.
index
number
RequiredThe starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
RequiredThe number of characters in the segment, starting from the index.
formatting
InlineFormatting
RequiredThe formatting to apply to the text.
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
Returns
void
appendText
function
RequiredAppends the specified characters to the end of the range.
Parameters
characters
string
RequiredThe characters to append to the richtext range.
formatting
InlineFormatting
OptionalOptions for formatting inline richtext.
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
Returns
bounds
Bounds
A segment of a richtext range.
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
RequiredReplaces a region of text with the specified characters.
Parameters
bounds
Bounds
RequiredThe segment of the range to replace.
index
number
RequiredThe starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
RequiredThe number of characters in the segment, starting from the index.
characters
string
RequiredThe replacement characters.
formatting
InlineFormatting
OptionalThe formatting to apply to the replaced text.
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
Returns
bounds
Bounds
The bounds of the replacement characters within the updated range.
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
RequiredReturns the current state of the richtext as plaintext.
Returns
string
readTextRegions
function
RequiredReturns 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>
OptionalThe formatting of the region.
An element that renders a table.
type
string
RequiredThe type of element.
This must be "table"
.
rows
object[]
RequiredThe rows of the table.
cells
Array<Cell | null | undefined>
RequiredThe cells (columns) of the row.
Each row must have the same number of cells.
This should be either the following object, null
, or undefined
.
attributes
CellAttributes
OptionalThe attributes of the cell.
backgroundColor
string
OptionalThe background color of the cell, as a hex code.
fontSize
number
OptionalThe size of the text.
Minimum: 1
Maximum: 100
Default value: 16
textAlign
string
OptionalThe alignment of the text.
Default value: "start"
Available values:
"start"
"center"
"end"
"justify"
color
string
OptionalThe color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontRef
FontRef
OptionalA unique identifier that points to a font asset in Canva's backend.
fontWeight
FontWeight
OptionalThe weight (thickness) of the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the font.
Default value: "none"
Available values:
"none"
"underline"
colSpan
number
OptionalThe number of columns that the cell occupies.
rowSpan
number
OptionalThe number of rows that the cell occupies.
type
string
RequiredAvailable values:
"empty"
"string"
value
string
The plaintext content of the cell.
If an empty string is provided, the type
will change to "empty"
.
An element that's natively supported by the Canva editor and has positional properties.
An element that renders image content and has positional properties.
type
string
RequiredThe type of element.
This must be "image"
.
altText
AltText | undefined
RequiredA description of the image content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
dataUrl
string
OptionalA data URL that contains the image data.
ref
ImageRef
OptionalA unique identifier that points to an image asset in Canva's backend.
An element that renders video content and has positional properties.
type
string
RequiredThe type of element.
This must be "video"
.
ref
VideoRef
RequiredA unique identifier that points to a video asset in Canva's backend.
altText
AltText | undefined
RequiredA description of the video content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
An element that renders rich media, such as a YouTube video, and has positional properties.
type
string
RequiredThe type of element.
This must be "embed"
.
url
string
RequiredThe URL of the rich media.
This URL must be supported by the Iframely API.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
An element that renders text content and has positional properties.
type
string
RequiredThe type of element.
This must be "text"
.
children
string[]
RequiredThe text content.
Only the first element in this array is used.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
fontSize
number
OptionalThe size of the text.
Minimum: 1
Maximum: 100
Default value: 16
textAlign
string
OptionalThe alignment of the text.
Default value: "start"
Available values:
"start"
"center"
"end"
"justify"
color
string
OptionalThe color of the text as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
fontRef
FontRef
OptionalA unique identifier that points to a font asset in Canva's backend.
fontWeight
FontWeight
OptionalThe weight (thickness) of the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the font.
Default value: "none"
Available values:
"none"
"underline"
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
width
number
OptionalThe width of the element, in pixels.
Minimum: 0
Maximum: 32767
An element that renders a vector shape and has positional properties.
type
string
RequiredThe type of element.
This must be "shape"
.
viewBox
ShapeViewBox
RequiredOptions for configuring the scale and cropping of the shape.
top
number
RequiredThe distance of the shape from the top edge of the element, in pixels.
left
number
RequiredThe distance of the shape from the left edge of the element, in pixels.
width
number
RequiredThe width of the view box, in pixels.
height
number
RequiredThe height of the view box, in pixels.
paths
ShapePath[]
RequiredThe paths that define the structure of the shape.
- There must be between 1 and 30 paths (inclusive).
- The maximum combined size of all paths must not exceed 2kb.
- The maximum number of unique fill colors across all paths is 6.
d
string
RequiredThe shape of the path.
This is similar to the d
attribute of an SVG's path
element, with some limitations:
- The path must start with an M command.
- The path must not have more than one M command.
- The path must not use the Q command.
- The path must be closed, either by:
- Using a Z command at the end of the path
- Having the last coordinate match the first coordinate
fill
Fill
RequiredThe appearance of the path's interior.
dropTarget
boolean
OptionalIf true
, users can replace a fill by dropping an image or video onto it.
color
string
OptionalThe color of the fill as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
asset
object
OptionalAn image or video to use as the fill.
An image asset that fills a path's interior.
type
string
RequiredThe type of fill.
This must be "image"
.
ref
ImageRef
RequiredA unique identifier that points to an image asset in Canva's backend.
altText
AltText
OptionalA description of the image content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
A video asset that fills a path's interior.
type
string
RequiredThe type of fill.
This must be "video"
.
ref
VideoRef
RequiredA unique identifier that points to a video asset in Canva's backend.
altText
AltText
OptionalA description of the image content.
Use undefined
for content with no description.
text
string
RequiredThe text content.
decorative
boolean | undefined
RequiredIndicates where the alternative text should be displayed.
- If
true
, the alternative text will only be displayed in the editor. - If
false
, the alternative text will be displayed in the editor and in view-only mode.
stroke
PathStroke
OptionalThe outline of the path.
weight
number
RequiredThe weight (thickness) of the stroke.
Minimum: 0
Maximum: 100
color
string
RequiredThe color of the stroke as a hex code.
The hex code must include all six characters and be prefixed with a #
symbol.
Example
"#ff0099"
strokeAlign
string
RequiredThe alignment of the stroke.
This must be "inset"
.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
An element that contains two or more elements and has positional properties.
type
string
RequiredThe type of element.
This must be "group"
.
children
GroupContentAtPoint[]
RequiredThe elements to render within the group.
- Each element within a group must have dimensions and a position.
- The dimensions and positions are relative to the dimensions and positions of the group.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
width
number
RequiredA width, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
height
number
RequiredA height, in pixels.
- The pixels are relative to their container.
Minimum: 0
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
An element that renders richtext content.
This type includes properties for controlling the position and dimensions of the element. It will be positioned and sized relative to its parent container. The parent container may be an app element, or the current page.
type
string
RequiredThe type of element.
This must be "richtext"
.
range
RichtextRange
RequiredThe richtext content.
formatParagraph
function
RequiredFormats 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
RequiredThe segment of the range on which to apply the formatting.
index
number
RequiredThe starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
RequiredThe number of characters in the segment, starting from the index.
formatting
RichtextFormatting
RequiredThe formatting to apply to the paragraph(s).
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
fontRef
FontRef
OptionalA unique identifier that points to a font asset in Canva's backend.
fontSize
number
OptionalThe 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
OptionalThe alignment of the text.
Default value: "start"
Available values:
"start"
"center"
"end"
"justify"
listLevel
number
OptionalThe list indentation level of the paragraph.
listMarker
string
OptionalThe appearance of list item markers.
This property only has an effect if listLevel
is greater than 0.
Default value: "none"
Available values:
"none"
"disc"
"circle"
"square"
"decimal"
"lower-alpha"
"lower-roman"
"checked"
"unchecked"
Returns
void
formatText
function
RequiredFormats a region of text with inline formatting properties.
Parameters
bounds
Bounds
RequiredThe segment of the range on which to apply the formatting.
index
number
RequiredThe starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
RequiredThe number of characters in the segment, starting from the index.
formatting
InlineFormatting
RequiredThe formatting to apply to the text.
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
Returns
void
appendText
function
RequiredAppends the specified characters to the end of the range.
Parameters
characters
string
RequiredThe characters to append to the richtext range.
formatting
InlineFormatting
OptionalOptions for formatting inline richtext.
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
Returns
bounds
Bounds
A segment of a richtext range.
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
RequiredReplaces a region of text with the specified characters.
Parameters
bounds
Bounds
RequiredThe segment of the range to replace.
index
number
RequiredThe starting position of the segment.
This is zero-based, meaning the first character of the range is at index 0.
length
number
RequiredThe number of characters in the segment, starting from the index.
characters
string
RequiredThe replacement characters.
formatting
InlineFormatting
OptionalThe formatting to apply to the replaced text.
color
string
OptionalThe 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
OptionalThe weight (thickness) of the font.
The available font weights depend on the font.
Default value: "normal"
Available values:
"normal"
"thin"
"extralight"
"light"
"medium"
"semibold"
"bold"
"ultrabold"
"heavy"
fontStyle
string
OptionalThe style of the font.
Default value: "normal"
Available values:
"normal"
"italic"
decoration
string
OptionalThe decoration of the text.
Default value: "none"
Available values:
"none"
"underline"
strikethrough
string
OptionalThe strikethrough of the text.
Default value: "none"
Available values:
"none"
"strikethrough"
link
string
OptionalAn external URL that the text links to.
Returns
bounds
Bounds
The bounds of the replacement characters within the updated range.
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
RequiredReturns the current state of the richtext as plaintext.
Returns
string
readTextRegions
function
RequiredReturns 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>
OptionalThe formatting of the region.
top
number
RequiredThe distance from the top edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
left
number
RequiredThe distance from the left edge of the container, in pixels.
- The pixels are relative to their container.
Minimum: -32768
Maximum: 32767
rotation
number
OptionalA rotation, in degrees.
Minimum: -180
Maximum: 180
width
number
OptionalThe width of the element, in pixels.
Minimum: 0
Maximum: 32767
Returns
Promise<void>