Skip to main content

extension-callout

package @remirror/extension-callout

class CalloutExtension

Adds a callout to the editor.

Signature:

export declare class CalloutExtension extends NodeExtension<CalloutOptions> 

Extends: NodeExtension<CalloutOptions>

(Some inherited members may not be shown because they are not represented in the documentation.)

property name

Signature:

get name(): "callout";

property tags

Signature:

readonly tags: "block"[];

method createInputRules

Create an input rule that listens for input of 3 colons followed by a valid callout type, to create a callout node If the callout type is invalid, the defaultType callout is created

Signature:

createInputRules(): InputRule[];

Returns:

InputRule[]

method createNodeSpec

Signature:

createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;

Parameters:

ParameterTypeDescription
extraApplySchemaAttributes
overrideNodeSpecOverride

Returns:

NodeExtensionSpec

method createNodeViews

Defines the callout html structure. Adds the returned DOM node form renderEmoji into it.

Signature:

createNodeViews(): NodeViewMethod;

Returns:

NodeViewMethod

method handleBackspace

Handle the backspace key when deleting content.

Signature:

handleBackspace({ dispatch, tr }: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
{ dispatch, tr }KeyBindingProps

Returns:

boolean

method handleEnterKey

Signature:

handleEnterKey({ dispatch, tr }: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
{ dispatch, tr }KeyBindingProps

Returns:

boolean

method toggleCallout

Toggle the callout at the current selection. If you don't provide the type it will use the options.defaultType.

If none exists one will be created or the existing callout content will be lifted out of the callout node.

if (commands.toggleCallout.enabled()) {
commands.toggleCallout({ type: 'success' });
}

Signature:

toggleCallout(attributes?: CalloutExtensionAttributes): CommandFunction;

Parameters:

ParameterTypeDescription
attributesCalloutExtensionAttributes(Optional)

Returns:

CommandFunction

method updateCallout

Update the callout at the current position. Primarily this is used to change the type.

if (commands.updateCallout.enabled()) {
commands.updateCallout({ type: 'error' });
}

Signature:

updateCallout(attributes: CalloutExtensionAttributes, pos?: number): CommandFunction;

Parameters:

ParameterTypeDescription
attributesCalloutExtensionAttributes
posnumber(Optional)

Returns:

CommandFunction

interface CalloutExtensionAttributes

Signature:

export interface CalloutExtensionAttributes extends ProsemirrorAttributes 

Extends: ProsemirrorAttributes

(Some inherited members may not be shown because they are not represented in the documentation.)

property emoji

The emoji information of callout.

Signature:

emoji?: string;

property type

The type of callout, for instance info, warning, error, success or blank.

Signature:

type?: LiteralUnion<'info' | 'warning' | 'error' | 'success' | 'blank', string>;

interface CalloutOptions

Options available to the [[CalloutExtension]].

Signature:

export interface CalloutOptions 

property defaultEmoji

The default emoji passed to attrsibute when none is provided.

Signature:

defaultEmoji?: Static<string>;

property defaultType

The default callout type to use when none is provided.

It is a property so it can change during the editor's life.

Signature:

defaultType?: Static<string>;

property renderEmoji

The function passed into calloutExtension to render the emoji at the front.

Signature:

renderEmoji?: (node: ProsemirrorNode, view: EditorView, getPos: () => number) => HTMLElement;

property validTypes

The valid types for the callout node.

Signature:

validTypes?: Static<string[]>;