Word<T extends string | DynamicWord | Pausing = string | DynamicWord | Pausing>
⚠️
This page is under construction.
Word is a part of the Sentence. It is used to style the text.
Constructing a red word:
import { Word } from 'narraleaf-react';
const word = new Word("Hello", {color: "#f00"});
Constructing a word with ruby text:
const word = new Word("你好", {ruby: "nǐ hǎo"});
Constructing a dynamic word:
// This word will be executed when it is displayed
const word = new Word((ctx) =>
`Now it is ${new Date().toLocaleTimeString()}`
, {color: "#f00"});
Static Method
isWord
obj: any
- The object to check- Returns
true
if the object is an instance ofWord
, otherwisefalse
.
color
text: string | Word
- The text or Word instance to colorcolor: color
- The color to apply, see Color- Returns a new
Word
instance with the specified color.
bold
text: string | Word
- The text or Word instance to make bold- Returns a new
Word
instance with bold formatting.
italic
text: string | Word
- The text or Word instance to italicize- Returns a new
Word
instance with italic formatting.
Public Method
constructor
text: T
- The content of the wordconfig?: Partial<WordConfig>
- WordConfig
toString
If the word is a string, it will return the string. Otherwise, it will return an empty string.
- Returns
string