Skip to main content

core-constants

package @remirror/core-constants

enum ErrorConstant

The error codes for errors used throughout the codebase.

Signature:

export declare enum ErrorConstant 

Enumeration Members:

MemberValueDescription
CORE_HELPERS"RMR0004"An error occurred in a function called from the @remirror/core-helpers library.
CUSTOM"RMR0003"This is a custom error possibly thrown by an external library.
DUPLICATE_COMMAND_NAMES"RMR0016"Command method names must be unique within the editor.
DUPLICATE_HELPER_NAMES"RMR0017"Helper method names must be unique within the editor.
EXTENSION"RMR0100"An error occurred within an extension.
EXTENSION_EXTRA_ATTRIBUTES"RMR0102"Extra attributes must either be a string or an object.
EXTENSION_SPEC"RMR0101"The spec was defined without calling the defaults, parse or dom methods.
HELPERS_CALLED_IN_OUTER_SCOPE"RMR0013"The helpers method which is passed into the ``create*` method should only be called within returned method since it relies on an active view (not present in the outer scope).
I18N_CONTEXT"RMR0300"There is something wrong with your i18n setup.
INTERNAL"RMR0006"This is an error which should not occur and is internal to the remirror codebase.
INVALID_COMMAND_ARGUMENTS"RMR0002"The arguments passed to the command method were invalid.
INVALID_CONTENT"RMR0021"The content provided to the editor is not supported.
INVALID_EXTENSION"RMR0019"The provided extension is invalid.
INVALID_GET_EXTENSION"RMR0010"The user requested an invalid extension from the getExtensions method. Please check the createExtensions return method is returning an extension with the defined constructor.
INVALID_MANAGER_ARGUMENTS"RMR0011"Invalid value passed into Manager constructor. Only and Extensions are supported.
INVALID_MANAGER_EXTENSION"RMR0014"The user requested an invalid extension from the manager.
INVALID_NAME"RMR0050"An invalid name was used for the extension.
INVALID_SET_EXTENSION_OPTIONS"RMR0103"A call to extension.setOptions was made with invalid keys.
MANAGER_PHASE_ERROR"RMR0008"Called a method event at the wrong time. Please make sure getter functions are only called with within the scope of the returned functions. They should not be called in the outer scope of your method.
MISSING_REQUIRED_EXTENSION"RMR0007"You're editor is missing a required extension.
MUTATION"RMR0005"You have attempted to change a value that shouldn't be changed.
NON_CHAINABLE_COMMAND"RMR0018"Attempted to chain a non chainable command.
PROD"RMR0000"An error occurred in production. Details shall be hidden.
REACT_COMPONENTS"RMR0206"An error occurred when rendering the react components.
REACT_CONTROLLED"RMR0203"There is a problem with your controlled editor setup.
REACT_EDITOR_VIEW"RMR0202"A problem occurred adding the editor view to the dom.
REACT_GET_CONTEXT"RMR0205"You attempted to call getContext provided by the useRemirror prop during the first render of the editor. This is not possible and should only be after the editor first mounts.
REACT_GET_ROOT_PROPS"RMR0201"getRootProps has been called MULTIPLE times. It should only be called ONCE during render.
REACT_HOOKS"RMR0207"An error occurred within a remirror hook.
REACT_NODE_VIEW"RMR0204"Something went wrong with your custom ReactNodeView Component.
REACT_PROVIDER_CONTEXT"RMR0200"useRemirror was called outside of the remirror context. It can only be used within an active remirror context created by the <Remirror />.
SCHEMA"RMR0012"There is a problem with the schema or you are trying to access a node / mark that doesn't exists.
UNKNOWN"RMR0001"An error happened but we're not quite sure why.

Remarks:

They can be removed but should never be changed since they are also used to reference the errors within search engines.

enum ExtensionPriority

The priority of extension which determines what order it is loaded into the editor.

Signature:

export declare enum ExtensionPriority 

Enumeration Members:

MemberValueDescription
Critical1000000Use this **never** 😉
Default100This is the **default** priority for most extensions.
High10000The highest priority level that should be used in a publicly shared extension (to allow some wiggle room for downstream users overriding priorities).
Highest100000A, like super duper, high priority.
Low10This is the **default** priority for builtin behavior changing extensions.
Lowest0This is useful for extensions that exist to be overridden.
Medium1000A medium priority extension. This is typically all you need to take priority over built in extensions.

Remarks:

Higher priority extension (higher numberic value) will ensure the extension has a higher preference in your editor. In the case where you load two identical extensions into your editor (same name, or same constructor), the extension with the higher priority is the one that will be loaded.

The higher the numeric value the higher the priority. The priority can also be passed a number but naming things in this enum should help provide some context to the numbers.

By default all extensions are created with a ExtensionPriority.Default.

enum ManagerPhase

Identifies the stage the extension manager is at.

Signature:

export declare enum ManagerPhase 

Enumeration Members:

MemberValueDescription
Create1

When the extension manager is being created and the onCreate methods are being called.

This happens within the RemirrorManager constructor.

Destroy4The manager is being destroyed.
EditorView2When the view is being added and all onView lifecycle methods are being called. The view is typically added before the dom is ready for it.
None0The initial value for the manager phase.
Runtime3The phases of creating this manager are completed and onTransaction is called every time the state updates.

enum NamedShortcut

The named shortcuts that can be used to update multiple commands.

Signature:

export declare enum NamedShortcut 

Enumeration Members:

MemberValueDescription
AddComment"|comment|"
AddFootnote"|footnote|"
Bold"|bold|"
BulletList"|bullet|"
CenterAlignment"|center-align|"
ClearFormatting"|clear|"
Code"|code|"
Codeblock"|codeblock|"
ContextMenu"|context-menu|"
Copy"|copy|"
Cut"|cut|"
DecreaseFontSize"|dec-font-size|"
DecreaseIndent"|dedent|"
Divider"|divider|"
Find"|find|"
FindBackwards"|find-backwards|"
FindReplace"|find-replace|"
Format"|format|"A keyboard shortcut to trigger formatting the current block.
H1"|h1|"
H2"|h2|"
H3"|h3|"
H4"|h4|"
H5"|h5|"
H6"|h6|"
IncreaseFontSize"|inc-font-size|"
IncreaseIndent"|indent|"
InsertLink"|link|"
Italic"|italic|"
JustifyAlignment"|justify-align|"
LeftAlignment"|left-align|"
OrderedList"|number|"
Paragraph"|paragraph|"
Paste"|paste|"
PastePlain"|paste-plain|"
Quote"|quote|"
Redo"|redo|"
RightAlignment"|right-align|"
SelectAll"|select-all|"
Shortcuts"|shortcuts|"
Strike"|strike|"
Subscript"|sub|"
Superscript"|sup|"
TaskList"|task|"
Underline"|underline|"
Undo"|undo|"

function mutateTag()

A method for updating the extension tags.

import { ExtensionTag, mutateTag } from 'remirror';

mutateTag((tag) => {
tag.SuperCustom = 'superCustom';
});

declare global {
namespace Remirror {
interface ExtensionTag {
SuperCustom: 'superCustom';
}
}
}


log(ExtensionTag.SuperCustom); // This is fine ✅
log(ExtensionTag.NotDefined); // This will throw ❌

Signature:

export declare function mutateTag(mutator: (Tag: ExtensionTag) => void): void;

Parameters:

ParameterTypeDescription
mutator(Tag: ExtensionTag) => void

Returns:

void

variable EMPTY_ARRAY

Helpful empty array for use when a default array value is needed.

DO NOT MUTATE!

Signature:

EMPTY_ARRAY: never[]

variable EMPTY_NODE

Signature:

EMPTY_NODE: {
type: string;
content: never[];
}

variable EMPTY_PARAGRAPH_NODE

A default empty object node. Useful for resetting the content of a prosemirror document.

Signature:

EMPTY_PARAGRAPH_NODE: {
type: string;
content: {
type: string;
}[];
}

variable ExtensionTag

These are the default supported tag strings which help categorize different behaviors that extensions can exhibit.

Signature:

ExtensionTag: ExtensionTag

Remarks:

Any extension can register itself with multiple such behaviors and these categorizations can be used by other extensions when running commands and updating the document.

variable LEAF_NODE_REPLACING_CHARACTER

ProseMirror uses the Unicode Character 'OBJECT REPLACEMENT CHARACTER' (U+FFFC) as text representation for leaf nodes, i.e. nodes that don't have any content or text property (e.g. hardBreak, emoji, mention, rule) It was introduced because of https://github.com/ProseMirror/prosemirror/issues/262 This can be used in an input rule regex to be able to include or exclude such nodes.

Signature:

LEAF_NODE_REPLACING_CHARACTER = "\uFFFC"

variable NON_BREAKING_SPACE_CHAR

The non breaking space character.

Signature:

NON_BREAKING_SPACE_CHAR = "\u00A0"

variable NULL_CHARACTER

The null character.

See https://stackoverflow.com/a/6380172

Signature:

NULL_CHARACTER = "\0"

variable REMIRROR_WEBVIEW_NAME

The global name for the module exported by the remirror webview bundle.

Signature:

REMIRROR_WEBVIEW_NAME = "$$__REMIRROR_WEBVIEW_BUNDLE__$$"

variable SELECTED_NODE_CLASS_NAME

The css class added to a node that is selected.

Signature:

SELECTED_NODE_CLASS_NAME = "ProseMirror-selectednode"

variable SELECTED_NODE_CLASS_SELECTOR

The css selector for a selected node.

Signature:

SELECTED_NODE_CLASS_SELECTOR: string

variable STATE_OVERRIDE

Indicates that a state update was caused by an override and not via transactions or user commands.

This is the case when setContent is called and for all controlled updates within a react editor instance.

Signature:

STATE_OVERRIDE = "__state_override__"

variable ZERO_WIDTH_SPACE_CHAR

A character useful for separating inline nodes.

Signature:

ZERO_WIDTH_SPACE_CHAR = "\u200B"

Remarks:

Typically used in decorations as follows.

document.createTextNode(ZERO_WIDTH_SPACE_CHAR);

This produces the html entity '8203'

type ExtensionTag

The type for the extension tags..

Signature:

export declare type ExtensionTag = Remirror.ExtensionTags & typeof BaseExtensionTag;

type ExtensionTagType

The string values which can be used as extension tags.

Signature:

export declare type ExtensionTagType = ExtensionTag[keyof ExtensionTag];

References: ExtensionTag