API reference: @salmonui/rich-text
RichTextCommandsinterface
import type { RichTextCommands } from '@salmonui/rich-text';interface RichTextCommands {
bold(): boolean;
italic(): boolean;
underline(): boolean;
strike(): boolean;
subscript(): boolean;
superscript(): boolean;
code(): boolean;
uppercase(): boolean;
lowercase(): boolean;
fontFamily(value: string | null): boolean;
fontSize(value: string | null): boolean;
color(value: string | null): boolean;
backgroundColor(value: string | null): boolean;
paragraph(): boolean;
heading(level: 1 | 2 | 3 | 4 | 5 | 6): boolean;
blockquote(): boolean;
codeBlock(language?: string | null): boolean;
setCodeLanguage(language: string | null): boolean;
textAlign(align: RichTextTextAlign | null): boolean;
lineHeight(value: string | null): boolean;
indent(): boolean;
outdent(): boolean;
bulletList(style?: RichTextBulletStyle | null): boolean;
orderedList(style?: RichTextOrderedStyle | null): boolean;
taskList(): boolean;
toggleTask(): boolean;
horizontalRule(): boolean;
clearFormat(): boolean;
setLink(link: RichTextLinkInput): boolean;
unsetLink(): boolean;
insertImage(image: RichTextImageInput): boolean;
updateImage(image: Partial<RichTextImageInput>): boolean;
insertAudio(media: RichTextMediaInput): boolean;
insertVideo(media: RichTextMediaInput): boolean;
insertEmbed(media: RichTextMediaInput): boolean;
deleteNode(): boolean;
insertTable(size: {
readonly rows: number;
readonly cols: number;
readonly headerRow?: boolean | undefined;
}): boolean;
addRowBefore(): boolean;
addRowAfter(): boolean;
deleteRow(): boolean;
addColumnBefore(): boolean;
addColumnAfter(): boolean;
deleteColumn(): boolean;
mergeCells(): boolean;
splitCell(): boolean;
toggleHeaderRow(): boolean;
setTableStyle(style: RichTextTableStyle | null): boolean;
deleteTable(): boolean;
insertText(text: string): boolean;
insertHtml(html: string, options?: {
readonly blocks?: boolean;
}): boolean;
selectAll(): boolean;
undo(): boolean;
redo(): boolean;
find(query: string, options?: RichTextFindOptions): number;
findNext(): boolean;
findPrevious(): boolean;
replace(text: string): boolean;
replaceAll(text: string): number;
clearFind(): boolean;
copyFormat(sticky?: boolean): boolean;
applyFormat(): boolean;
cancelFormatPainter(): boolean;
}
Typed commands (actionsRef.current.commands); each returns whether it applied.
| Name | Signature | Description |
|---|---|---|
bold | bold(): boolean; | |
italic | italic(): boolean; | |
underline | underline(): boolean; | |
strike | strike(): boolean; | |
subscript | subscript(): boolean; | |
superscript | superscript(): boolean; | |
code | code(): boolean; | |
uppercase | uppercase(): boolean; | |
lowercase | lowercase(): boolean; | |
fontFamily | fontFamily(value: string | null): boolean; | |
fontSize | fontSize(value: string | null): boolean; | |
color | color(value: string | null): boolean; | |
backgroundColor | backgroundColor(value: string | null): boolean; | |
paragraph | paragraph(): boolean; | |
heading | heading(level: 1 | 2 | 3 | 4 | 5 | 6): boolean; | |
blockquote | blockquote(): boolean; | |
codeBlock | codeBlock(language?: string | null): boolean; | |
setCodeLanguage | setCodeLanguage(language: string | null): boolean; | |
textAlign | textAlign(align: RichTextTextAlign | null): boolean; | |
lineHeight | lineHeight(value: string | null): boolean; | |
indent | indent(): boolean; | |
outdent | outdent(): boolean; | |
bulletList | bulletList(style?: RichTextBulletStyle | null): boolean; | |
orderedList | orderedList(style?: RichTextOrderedStyle | null): boolean; | |
taskList | taskList(): boolean; | |
toggleTask | toggleTask(): boolean; | |
horizontalRule | horizontalRule(): boolean; | |
clearFormat | clearFormat(): boolean; | |
setLink | setLink(link: RichTextLinkInput): boolean; | |
unsetLink | unsetLink(): boolean; | |
insertImage | insertImage(image: RichTextImageInput): boolean; | |
updateImage | updateImage(image: Partial<RichTextImageInput>): boolean; | |
insertAudio | insertAudio(media: RichTextMediaInput): boolean; | |
insertVideo | insertVideo(media: RichTextMediaInput): boolean; | |
insertEmbed | insertEmbed(media: RichTextMediaInput): boolean; | |
deleteNode | deleteNode(): boolean; | |
insertTable | insertTable(size: {
readonly rows: number;
readonly cols: number;
readonly headerRow?: boolean | undefined;
}): boolean; | |
addRowBefore | addRowBefore(): boolean; | |
addRowAfter | addRowAfter(): boolean; | |
deleteRow | deleteRow(): boolean; | |
addColumnBefore | addColumnBefore(): boolean; | |
addColumnAfter | addColumnAfter(): boolean; | |
deleteColumn | deleteColumn(): boolean; | |
mergeCells | mergeCells(): boolean; | |
splitCell | splitCell(): boolean; | |
toggleHeaderRow | toggleHeaderRow(): boolean; | |
setTableStyle | setTableStyle(style: RichTextTableStyle | null): boolean; | |
deleteTable | deleteTable(): boolean; | |
insertText | insertText(text: string): boolean; | |
insertHtml | insertHtml(html: string, options?: {
readonly blocks?: boolean;
}): boolean; | Sanitized and parsed through the schema, replacing the selection like a
paste; |
selectAll | selectAll(): boolean; | |
undo | undo(): boolean; | |
redo | redo(): boolean; | |
find | find(query: string, options?: RichTextFindOptions): number; | Highlights matches and selects the first; returns the match count. |
findNext | findNext(): boolean; | |
findPrevious | findPrevious(): boolean; | |
replace | replace(text: string): boolean; | Replaces the current match and moves to the next. |
replaceAll | replaceAll(text: string): number; | Returns the number of replaced matches. |
clearFind | clearFind(): boolean; | |
copyFormat | copyFormat(sticky?: boolean): boolean; | Format painter: copy the format at the selection ( |
applyFormat | applyFormat(): boolean; | |
cancelFormatPainter | cancelFormatPainter(): boolean; |