Skip to main content

extension-codemirror6

package @remirror/extension-codemirror6

class CodeMirrorExtension

Signature:

export declare class CodeMirrorExtension extends NodeExtension<CodeMirrorExtensionOptions> 

Extends: NodeExtension<CodeMirrorExtensionOptions>

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

property name

Signature:

get name(): "codeMirror";

method createCodeMirror

Creates a CodeMirror block at the current position.

commands.createCodeMirror({ language: 'js' });

Signature:

createCodeMirror(attributes: CodeMirrorExtensionAttributes): CommandFunction;

Parameters:

ParameterTypeDescription
attributesCodeMirrorExtensionAttributes

Returns:

CommandFunction

method createInputRules

Create an input rule that listens converts the code fence into a code block when typing triple back tick followed by a space.

Signature:

createInputRules(): InputRule[];

Returns:

InputRule[]

method createKeymap

Signature:

createKeymap(): PrioritizedKeyBindings;

Returns:

PrioritizedKeyBindings

method createNodeSpec

Signature:

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

Parameters:

ParameterTypeDescription
extraApplySchemaAttributes
overrideNodeSpecOverride

Returns:

NodeExtensionSpec

method createNodeViews

Signature:

createNodeViews(): NodeViewMethod;

Returns:

NodeViewMethod

method enterKey

Signature:

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

Parameters:

ParameterTypeDescription
{ dispatch, tr }KeyBindingProps

Returns:

boolean

method updateCodeMirror

Update the code block at the current position. Primarily this is used to change the language.

if (commands.updateCodeMirror.isEnabled()) {
commands.updateCodeMirror({ language: 'markdown' });
}

Signature:

updateCodeMirror(attributes: CodeMirrorExtensionAttributes): CommandFunction;

Parameters:

ParameterTypeDescription
attributesCodeMirrorExtensionAttributes

Returns:

CommandFunction

interface CodeMirrorExtensionAttributes

Signature:

export interface CodeMirrorExtensionAttributes extends ProsemirrorAttributes 

Extends: ProsemirrorAttributes

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

property language

A string to represent the language matching the language name or alias in [LanguageDescription](https://codemirror.net/docs/ref/\#language.LanguageDescription)

Signature:

language?: string;

interface CodeMirrorExtensionOptions

Signature:

export interface CodeMirrorExtensionOptions 

property extensions

The CodeMirror extensions to use.

Signature:

extensions?: CodeMirrorExtension[] | null;

Remarks:

For package size reasons, no CodeMirror extensions are included by default. You might want to install and add the following two extensions:

property languages

The CodeMirror languages to use.

Signature:

languages?: LanguageDescription[] | null;

Remarks:

You can install [@codemirror/language-data](https://codemirror.net/6/docs/ref/\#language-data) and import languages from there.

property toggleName

The name of the node that the codeMirror block should toggle back and forth from.

Signature:

toggleName?: string;