Skip to content

BlockSuite API Documentation / @blocksuite/affine-rich-text

@blocksuite/affine-rich-text ​

Classes ​

RichText ​

Extends ​

Constructors ​

Other ​

styles ​

static styles: CSSResult

Overrides ​

WithDisposable(ShadowlessElement).styles

attributeRenderer ​
attributesSchema ​
embedChecker ​
enableAutoScrollHorizontally ​
enableClipboard ​
enableFormat ​
enableUndoRedo ​
inlineEditor ​
Get Signature ​

get inlineEditor(): AffineInlineEditor | null

Returns ​

AffineInlineEditor | null

inlineEditorContainer ​
Get Signature ​

get inlineEditorContainer(): HTMLDivElement

Returns ​

HTMLDivElement

inlineEventSource ​
inlineRangeProvider ​
markdownMatches ​
readonly ​
undoManager ​
verticalScrollContainerGetter ​
vLineRenderer ​
wrapText ​
yText ​
connectedCallback() ​

connectedCallback(): void

Returns ​

void

Overrides ​

WithDisposable(ShadowlessElement).connectedCallback

attributes ​

controllers ​

dev-mode ​

lifecycle ​

properties ​

rendering ​

render() ​

render(): TemplateResult<1>

Invoked on each update to perform rendering tasks. This method may return any value renderable by lit-html's ChildPart - typically a TemplateResult. Setting properties inside this method will not trigger the element to update.

Returns ​

TemplateResult<1>

Overrides ​

WithDisposable(ShadowlessElement).render

styles ​

updates ​

getUpdateComplete() ​

getUpdateComplete(): Promise<boolean>

Override point for the updateComplete promise.

It is not safe to override the updateComplete getter directly due to a limitation in TypeScript which means it is not possible to call a superclass getter (e.g. super.updateComplete.then(...)) when the target language is ES5 (https://github.com/microsoft/TypeScript/issues/338). This method should be overridden instead. For example:

ts
class MyElement extends LitElement {
  override async getUpdateComplete() {
    const result = await super.getUpdateComplete();
    await this._myChild.updateComplete;
    return result;
  }
}
Returns ​

Promise<boolean>

A promise of a boolean that resolves to true if the update completed without triggering another update.

Overrides ​

WithDisposable(ShadowlessElement).getUpdateComplete

updated() ​

updated(changedProperties): void

Invoked whenever the element is updated. Implement to perform post-updating tasks via DOM APIs, for example, focusing an element.

Setting properties inside this method will trigger the element to update again after this update cycle completes.

Parameters ​
changedProperties ​

Map<string | number | symbol, unknown>

Returns ​

void

Overrides ​

WithDisposable(ShadowlessElement).updated

Interfaces ​

TextAlignConfig ​

Properties ​

hotkey ​

hotkey: string[] | null

icon ​

icon: TemplateResult<1>

name ​

name: string

textAlign ​

textAlign: TextAlign


TextConversionConfig ​

Text primitive entries used in slash menu and format bar, which are also used for registering hotkeys for converting block flavours.

Properties ​

description? ​

optional description?: string

flavour ​

flavour: string

hotkey ​

hotkey: string[] | null

icon ​

icon: TemplateResult<1>

name ​

name: string

searchAlias? ​

optional searchAlias?: string[]

type? ​

optional type?: string

Variables ​

textAlignConfigs ​

const textAlignConfigs: TextAlignConfig[]


textConversionConfigs ​

const textConversionConfigs: TextConversionConfig[]

Functions ​

asyncGetRichText() ​

asyncGetRichText(std, id): Promise<RichText | null>

Parameters ​

std ​

BlockStdScope

id ​

string

Returns ​

Promise<RichText | null>


asyncSetInlineRange() ​

asyncSetInlineRange(std, model, inlineRange): Promise<void>

Parameters ​

std ​

BlockStdScope

model ​

BlockModel

inlineRange ​

InlineRange

Returns ​

Promise<void>


cleanSpecifiedTail() ​

cleanSpecifiedTail(std, inlineEditorOrModel, str): void

Remove specified text from the current range.

Parameters ​

std ​

BlockStdScope

inlineEditorOrModel ​

BlockModel<object> | InlineEditor<{ bold?: true | null; code?: true | null; italic?: true | null; link?: string | null; strike?: true | null; underline?: true | null; }>

str ​

string

Returns ​

void


clearMarksOnDiscontinuousInput() ​

clearMarksOnDiscontinuousInput(inlineEditor): void

Parameters ​

inlineEditor ​

InlineEditor

Returns ​

void


focusTextModel() ​

focusTextModel(std, id, offset?): void

Parameters ​

std ​

BlockStdScope

id ​

string

offset? ​

number = 0

Returns ​

void


getInlineEditorByModel() ​

getInlineEditorByModel(std, model): AffineInlineEditor | null

Parameters ​

std ​

BlockStdScope

model ​

string | BlockModel<object>

Returns ​

AffineInlineEditor | null


getPrefixText() ​

getPrefixText(inlineEditor): string

Parameters ​

inlineEditor ​

InlineEditor

Returns ​

string


getRichTextByModel() ​

getRichTextByModel(std, id): RichText | null

In most cases, you not need RichText, you can use getInlineEditorByModel instead.

Parameters ​

std ​

BlockStdScope

id ​

string

Returns ​

RichText | null


getTextContentFromInlineRange() ​

getTextContentFromInlineRange(inlineEditor, startRange): string | null

Parameters ​

inlineEditor ​

InlineEditor

startRange ​

InlineRange | null

Returns ​

string | null


insertContent() ​

insertContent(std, model, text, attributes?): void

Parameters ​

std ​

BlockStdScope

model ​

BlockModel

text ​

string

attributes? ​

AffineTextAttributes

Returns ​

void


onModelTextUpdated() ​

onModelTextUpdated(std, model, callback?): Promise<void>

Parameters ​

std ​

BlockStdScope

model ​

BlockModel

callback? ​

(text) => void

Returns ​

Promise<void>


selectTextModel() ​

selectTextModel(std, id, index?, length?): void

Parameters ​

std ​

BlockStdScope

id ​

string

index? ​

number = 0

length? ​

number = 0

Returns ​

void