Content Converters
#
Draft.jsRicos is in the preparation phase of migrating from a draft-js based content to our new Ricos schema. To support this we provide conversion functions to & from draft.
#
FromDraftOptionsBy default, the fromDraft
API throws error when it encounters invalid DraftContent
. Sometimes, this behavior is not desired.
The opts: FromDraftOptions
parameter allows to alter it, by setting { ignoreUnsupportedValues: true }
. In this case, any invalid values are gracefully ignored.
#
Example#
Plain TextRicos is a rich text & rich content editor. The following functions allow converting between plain text and rich content.
#
Plain text to rich content#
Example#
Rich content to plain text#
urlShortenerThis function will be called on image source URLs and can be used with URL shortener services.
#
getVideoUrlUsed to resolve a VideoSource
object into an absolute URL.
Defaults to src => https://video.wixstatic.com/${src.pathname}
#
Example#
HTMLThe following functions allow converting rich content to and from HTML.
Supporting:
- Headings
- Bold
- Italic
- Links
- Lists
- Line break
- Emojis