toRichText
See source codeConverts a plain text string into a TLRichText object. Each line of the input text becomes a separate paragraph in the rich text document. Empty lines are preserved as empty paragraphs to maintain the original text structure.
function toRichText(text: string): TLRichText
Example
const richText = toRichText('Hello\nWorld')
// Returns:
// {
// type: 'doc',
// content: [
// { type: 'paragraph', content: [{ type: 'text', text: 'Hello' }] },
// { type: 'paragraph', content: [{ type: 'text', text: 'World' }] }
// ]
// }
const emptyLine = toRichText('Line 1\n\nLine 3')
// Creates three paragraphs, with the middle one being empty
Parameters
Name | Description |
---|---|
|
The plain text string to convert to rich text |
Returns
A TLRichText object with the text content structured as paragraphs
Prev
isShapeId