Content Builder
This doc focuses on various API types, and not the exhaustive list of APIs. Examples based on Image demonstrate the “block” plugin related APIs like Image, Divider, etc -- all the plugins that require a separate block (unlike “inline” plugins). Examples based on Paragraph demonstrate text related APIs.
The Content Builder is stateless and immutable. This means, each API accepts RichContent to process, and returns a new copy of RichContent.
All the building blocks (e.g. ImageData objects) are defined in ricos-schema
package.
#
InstantiationThe ContentBuilder depends on key generation utility () => string
which provides unique node keys. The wix-rich-content-common
package exports such utility.
#
Append / insert new contentThe add methods add new content nodes. The node position is defined either by index (i.e. sequential number inside nodes collection), or by before/after key (adds the content relatively to a given existing node addressed by key). If no index/before/after keys provided, the new content appended to the end.
#
Adding bullet/ordered listThe list addition API is a bit different. It accepts items parameter which contains textual data, and an optional data parameter.
This parameter determines the default data for paragraph that contains text. At the moment, lists support only paragraphs as list item containers.
#
Examples#
Imagereturns the following content:
#
Listresults in: