@remirror/core
Version:
Where your quest to create a world class editing experience begins.
8,604 lines • 288 kB
TypeScript
import { __INTERNAL_REMIRROR_IDENTIFIER_KEY__ } from '@remirror/core-constants';
import { AcceptUndefined } from '@remirror/core-types';
import { AnchorHeadProps } from '@remirror/core-types';
import { And } from '@remirror/core-types';
import { AnyConstructor } from '@remirror/core-types';
import { AnyFunction } from '@remirror/core-types';
import { applyClonedTransaction } from '@remirror/core-utils';
import { ApplySchemaAttributes } from '@remirror/core-types';
import { areSchemasCompatible } from '@remirror/core-utils';
import { areStatesEqual } from '@remirror/core-utils';
import { Array1 } from '@remirror/core-types';
import { Array2 } from '@remirror/core-types';
import { Array3 } from '@remirror/core-types';
import { assert } from '@remirror/core-helpers';
import { assertGet } from '@remirror/core-helpers';
import { Asyncify } from '@remirror/core-types';
import { AsyncReturnType } from '@remirror/core-types';
import { atDocEnd } from '@remirror/core-utils';
import { atDocStart } from '@remirror/core-utils';
import { AttributesProps } from '@remirror/core-types';
import { Brand } from '@remirror/core-types';
import { callIfDefined } from '@remirror/core-helpers';
import { CamelCase } from '@remirror/core-types';
import { camelCase } from '@remirror/core-helpers';
import { canInsertNode } from '@remirror/core-utils';
import { capitalCase } from '@remirror/core-helpers';
import { capitalize } from '@remirror/core-helpers';
import { Cast } from '@remirror/core-helpers';
import { chainableEditorState } from '@remirror/core-utils';
import { chainCommands } from '@remirror/core-utils';
import { chainKeyBindingCommands } from '@remirror/core-utils';
import { clamp } from '@remirror/core-helpers';
import { Class } from '@remirror/core-types';
import { ClassName } from '@remirror/core-helpers';
import { cleanupOS } from '@remirror/core-helpers';
import { clone } from '@remirror/core-helpers';
import { cloneTransaction } from '@remirror/core-utils';
import { CommandFunction } from '@remirror/core-types';
import { CommandFunctionProps } from '@remirror/core-types';
import { composeTransactionSteps } from '@remirror/core-utils';
import { ConditionalExcept } from '@remirror/core-types';
import { ConditionalKeys } from '@remirror/core-types';
import { ConditionalPick } from '@remirror/core-types';
import { ConditionalReturnKeys } from '@remirror/core-types';
import { ConditionalReturnPick } from '@remirror/core-types';
import { constantCase } from '@remirror/core-helpers';
import { containsAttributes } from '@remirror/core-utils';
import { containsNodesOfType } from '@remirror/core-utils';
import { convertCommand } from '@remirror/core-utils';
import { convertPixelsToDomUnit } from '@remirror/core-utils';
import { Coords } from '@remirror/core-types';
import { CoreIcon } from '@remirror/icons';
import { createDocumentNode } from '@remirror/core-utils';
import { CreateDocumentNodeProps } from '@remirror/core-utils';
import { CustomDocumentProps } from '@remirror/core-utils';
import { CustomHandler } from '@remirror/core-types';
import { CustomHandlerKey } from '@remirror/core-types';
import { CustomHandlerKeyList } from '@remirror/core-types';
import { CustomHandlerShape } from '@remirror/core-types';
import { cx } from '@remirror/core-helpers';
import { debounce } from '@remirror/core-helpers';
import { DebouncedFunction } from '@remirror/core-helpers';
import { Decoration } from '@remirror/core-types';
import { DecorationSet } from '@remirror/core-types';
import { DecorationSet as DecorationSet_2 } from '@remirror/pm/view';
import { deepMerge } from '@remirror/core-helpers';
import { DeepPartial } from '@remirror/core-types';
import { DeepString } from '@remirror/core-types';
import { DefaultDocNodeOptions } from '@remirror/core-utils';
import { defaultImport } from '@remirror/core-helpers';
import { DelimiterCase } from '@remirror/core-types';
import { Diff } from '@remirror/core-types';
import type { DirectEditorProps } from '@remirror/pm/view';
import { DispatchFunction } from '@remirror/core-types';
import { Dispose } from '@remirror/core-types';
import { DOM_SIZE_UNITS } from '@remirror/core-utils';
import { DOMCompatibleAttributes } from '@remirror/core-types';
import { DOMOutputSpec } from '@remirror/core-types';
import { DomSizeUnit } from '@remirror/core-utils';
import { Dynamic } from '@remirror/core-types';
import { DynamicAttributeCreator } from '@remirror/core-types';
import { DynamicKey } from '@remirror/core-types';
import { DynamicKeyList } from '@remirror/core-types';
import { DynamicShape } from '@remirror/core-types';
import { EditorSchema } from '@remirror/core-types';
import { EditorState } from '@remirror/core-types';
import { EditorState as EditorState_2 } from '@remirror/pm/state';
import { EditorStateProps } from '@remirror/core-types';
import { EditorView } from '@remirror/core-types';
import { EditorView as EditorView_2 } from '@remirror/pm/view';
import { EditorViewProps } from '@remirror/core-types';
import { EMPTY_ARRAY } from '@remirror/core-constants';
import { EMPTY_NODE } from '@remirror/core-constants';
import { EMPTY_PARAGRAPH_NODE } from '@remirror/core-constants';
import { EmptyShape } from '@remirror/core-types';
import { endPositionOfParent } from '@remirror/core-utils';
import { Entries } from '@remirror/core-types';
import { entries } from '@remirror/core-helpers';
import { Entry } from '@remirror/core-types';
import { environment } from '@remirror/core-utils';
import { ErrorConstant } from '@remirror/core-constants';
import { Except } from '@remirror/core-types';
import { ExtensionPriority } from '@remirror/core-constants';
import { ExtensionTag } from '@remirror/core-constants';
import { ExtensionTagType } from '@remirror/core-constants';
import { extractPixelSize } from '@remirror/core-utils';
import { findBlockNodes } from '@remirror/core-utils';
import { findChildren } from '@remirror/core-utils';
import { findChildrenByAttribute } from '@remirror/core-utils';
import { findChildrenByMark } from '@remirror/core-utils';
import { findChildrenByNode } from '@remirror/core-utils';
import { findElementAtPosition } from '@remirror/core-utils';
import { findInlineNodes } from '@remirror/core-utils';
import { findMatches } from '@remirror/core-helpers';
import { findNodeAtPosition } from '@remirror/core-utils';
import { findNodeAtSelection } from '@remirror/core-utils';
import { findParentNode } from '@remirror/core-utils';
import { findParentNodeOfType } from '@remirror/core-utils';
import { findPositionOfNodeAfter } from '@remirror/core-utils';
import { findPositionOfNodeBefore } from '@remirror/core-utils';
import { FindProsemirrorNodeResult } from '@remirror/core-utils';
import { findSelectedNodeOfType } from '@remirror/core-utils';
import { findTextNodes } from '@remirror/core-utils';
import { FixedLengthArray } from '@remirror/core-types';
import { flattenArray } from '@remirror/core-helpers';
import { Flavor } from '@remirror/core-types';
import { Flavoring } from '@remirror/core-types';
import { FlipPartialAndRequired } from '@remirror/core-types';
import { format } from '@remirror/core-helpers';
import { Fragment } from '@remirror/core-types';
import { FragmentStringHandlerOptions } from '@remirror/core-utils';
import { freeze } from '@remirror/core-helpers';
import { FromToProps } from '@remirror/core-types';
import { Get } from '@remirror/core-types';
import { get } from '@remirror/core-helpers';
import { GetAcceptUndefined } from '@remirror/core-types';
import { getActiveNode } from '@remirror/core-utils';
import { GetAttributes } from '@remirror/core-types';
import { GetAttributesProps } from '@remirror/core-types';
import { getChangedNodeRanges } from '@remirror/core-utils';
import { getChangedNodes } from '@remirror/core-utils';
import { getChangedRanges } from '@remirror/core-utils';
import { GetConstructorProps } from '@remirror/core-types';
import { getCursor } from '@remirror/core-utils';
import { GetCustomHandler } from '@remirror/core-types';
import { getDefaultBlockNode } from '@remirror/core-utils';
import { getDefaultDocNode } from '@remirror/core-utils';
import { getDocRange } from '@remirror/core-utils';
import { getDocument } from '@remirror/core-utils';
import { GetDynamic } from '@remirror/core-types';
import { GetFixed } from '@remirror/core-types';
import { GetFixedCustomHandler } from '@remirror/core-types';
import { GetFixedDynamic } from '@remirror/core-types';
import { GetFixedProps } from '@remirror/core-types';
import { GetFixedStatic } from '@remirror/core-types';
import { GetFlippedStatic } from '@remirror/core-types';
import { getFontSize } from '@remirror/core-utils';
import { GetHandler } from '@remirror/core-types';
import { getInvalidContent } from '@remirror/core-utils';
import { getLazyArray } from '@remirror/core-helpers';
import { GetMappedCustomHandler } from '@remirror/core-types';
import { GetMappedHandler } from '@remirror/core-types';
import { getMarkAttributes } from '@remirror/core-utils';
import { GetMarkRange } from '@remirror/core-utils';
import { getMarkRange } from '@remirror/core-utils';
import { getMarkRanges } from '@remirror/core-utils';
import { getMarkType } from '@remirror/core-utils';
import { getMatchString } from '@remirror/core-utils';
import { getNodeType } from '@remirror/core-utils';
import { GetPartialDynamic } from '@remirror/core-types';
import { getRemirrorJSON } from '@remirror/core-utils';
import { GetRequiredKeys } from '@remirror/core-types';
import { getSelectedGroup } from '@remirror/core-utils';
import { getSelectedWord } from '@remirror/core-utils';
import { getShortcutSymbols } from '@remirror/core-utils';
import { GetStatic } from '@remirror/core-types';
import { GetStaticAndDynamic } from '@remirror/core-types';
import { getStyle } from '@remirror/core-utils';
import { getTextContentFromSlice } from '@remirror/core-utils';
import { getTextSelection } from '@remirror/core-utils';
import { Handler } from '@remirror/core-types';
import { HandlerKey } from '@remirror/core-types';
import { HandlerKeyList } from '@remirror/core-types';
import { HandlerShape } from '@remirror/core-types';
import { hasOwnProperty } from '@remirror/core-helpers';
import { hasTransactionChanged } from '@remirror/core-utils';
import { htmlToProsemirrorNode } from '@remirror/core-utils';
import { I18nFormatter } from '@remirror/core-types';
import { IfEmpty } from '@remirror/core-types';
import { IfHasRequiredProperties } from '@remirror/core-types';
import { IfMatches } from '@remirror/core-types';
import { IfNoRequiredProperties } from '@remirror/core-types';
import { includes } from '@remirror/core-helpers';
import { IndexUnionFromTuple } from '@remirror/core-types';
import { InputRule } from '@remirror/core-types';
import { InvalidContentBlock } from '@remirror/core-utils';
import { InvalidContentHandler } from '@remirror/core-utils';
import { InvalidContentHandlerProps } from '@remirror/core-utils';
import { invariant } from '@remirror/core-helpers';
import { isAllSelection } from '@remirror/core-utils';
import { isAndroidOS } from '@remirror/core-helpers';
import { isArray } from '@remirror/core-helpers';
import { isBoolean } from '@remirror/core-helpers';
import { isChrome } from '@remirror/core-utils';
import { isClass } from '@remirror/core-helpers';
import { isDate } from '@remirror/core-helpers';
import { isDefaultBlockNode } from '@remirror/core-utils';
import { isDefaultDocNode } from '@remirror/core-utils';
import { isDirectInstanceOf } from '@remirror/core-helpers';
import { isDocNode } from '@remirror/core-utils';
import { isDocNodeEmpty } from '@remirror/core-utils';
import { isDomNode } from '@remirror/core-utils';
import { isEditorSchema } from '@remirror/core-utils';
import { isEditorState } from '@remirror/core-utils';
import { isElementDomNode } from '@remirror/core-utils';
import { isEmptyArray } from '@remirror/core-helpers';
import { isEmptyBlockNode } from '@remirror/core-utils';
import { isEmptyObject } from '@remirror/core-helpers';
import { isEndOfTextBlock } from '@remirror/core-utils';
import { isEqual } from '@remirror/core-helpers';
import { isError } from '@remirror/core-helpers';
import { isFunction } from '@remirror/core-helpers';
import { isIdentifierOfType } from '@remirror/core-utils';
import { isInstanceOf } from '@remirror/core-helpers';
import { isInteger } from '@remirror/core-helpers';
import { isJSONPrimitive } from '@remirror/core-helpers';
import { isMap } from '@remirror/core-helpers';
import { isMarkActive } from '@remirror/core-utils';
import { isMarkType } from '@remirror/core-utils';
import { isNativePromise } from '@remirror/core-helpers';
import { isNodeActive } from '@remirror/core-utils';
import { isNodeOfType } from '@remirror/core-utils';
import { isNodeSelection } from '@remirror/core-utils';
import { isNodeType } from '@remirror/core-utils';
import { isNonEmptyArray } from '@remirror/core-helpers';
import { isNull } from '@remirror/core-helpers';
import { isNullOrUndefined } from '@remirror/core-helpers';
import { isNumber } from '@remirror/core-helpers';
import { isObject } from '@remirror/core-helpers';
import { isPlainObject } from '@remirror/core-helpers';
import { isPrimitive } from '@remirror/core-helpers';
import { isPromise } from '@remirror/core-helpers';
import { isProsemirrorFragment } from '@remirror/core-utils';
import { isProsemirrorMark } from '@remirror/core-utils';
import { isProsemirrorNode } from '@remirror/core-utils';
import { isRegExp } from '@remirror/core-helpers';
import { isRemirrorJSON } from '@remirror/core-utils';
import { isRemirrorType } from '@remirror/core-utils';
import { isResolvedPos } from '@remirror/core-utils';
import { isSafari } from '@remirror/core-utils';
import { isSafeInteger } from '@remirror/core-helpers';
import { isSelection } from '@remirror/core-utils';
import { isSelectionEmpty } from '@remirror/core-utils';
import { isSet } from '@remirror/core-helpers';
import { isStartOfDoc } from '@remirror/core-utils';
import { isStartOfTextBlock } from '@remirror/core-utils';
import { isString } from '@remirror/core-helpers';
import { isSymbol } from '@remirror/core-helpers';
import { isTextDomNode } from '@remirror/core-utils';
import { isTextSelection } from '@remirror/core-utils';
import { isTransaction } from '@remirror/core-utils';
import { isUndefined } from '@remirror/core-helpers';
import { IterableElement } from '@remirror/core-types';
import { joinStyles } from '@remirror/core-utils';
import { JsonArray } from '@remirror/core-types';
import { JsonObject } from '@remirror/core-types';
import { JsonPrimitive } from '@remirror/core-types';
import { JsonValue } from '@remirror/core-types';
import { KebabCase } from '@remirror/core-types';
import { kebabCase } from '@remirror/core-helpers';
import { KeepPartialProperties } from '@remirror/core-types';
import { KeyBindingCommandFunction } from '@remirror/core-types';
import { KeyBindingNames } from '@remirror/core-types';
import { KeyBindingProps } from '@remirror/core-types';
import { KeyBindings } from '@remirror/core-types';
import { keys } from '@remirror/core-helpers';
import { last } from '@remirror/core-helpers';
import { LEAF_NODE_REPLACING_CHARACTER } from '@remirror/core-constants';
import { lift } from '@remirror/core-utils';
import { Listable } from '@remirror/core-types';
import { Literal } from '@remirror/core-types';
import { LiteralUnion } from '@remirror/core-types';
import { MakeNullable } from '@remirror/core-types';
import { MakeOptional } from '@remirror/core-types';
import { MakeReadonly } from '@remirror/core-types';
import { MakeRequired } from '@remirror/core-types';
import { MakeUndefined } from '@remirror/core-types';
import { ManagerPhase } from '@remirror/core-constants';
import { Mapping } from '@remirror/core-types';
import { Mark } from '@remirror/core-types';
import { Mark as Mark_2 } from '@remirror/pm/model';
import { markEqualsType } from '@remirror/core-utils';
import { MarkExtensionSpec } from '@remirror/core-types';
import { markInputRule } from '@remirror/core-utils';
import { MarkSpecOverride } from '@remirror/core-types';
import { MarkType } from '@remirror/core-types';
import { MarkTypeProps } from '@remirror/core-types';
import { MarkTypesProps } from '@remirror/core-types';
import { MarkWithAttributes } from '@remirror/core-types';
import { MarkWithAttributesProps } from '@remirror/core-types';
import { Merge } from '@remirror/core-types';
import { mergeDOMRects } from '@remirror/core-utils';
import { MergeExclusive } from '@remirror/core-types';
import { mergeKeyBindings } from '@remirror/core-utils';
import { mergeProsemirrorKeyBindings } from '@remirror/core-utils';
import { MinArray } from '@remirror/core-types';
import { mutateTag } from '@remirror/core-constants';
import { NamedShortcut } from '@remirror/core-constants';
import { NamedStringHandlers } from '@remirror/core-utils';
import { NodeExtensionSpec } from '@remirror/core-types';
import { nodeInputRule } from '@remirror/core-utils';
import { NodeMarkOptions } from '@remirror/core-types';
import { NodeSpecOverride } from '@remirror/core-types';
import { NodeStringHandlerOptions } from '@remirror/core-utils';
import { NodeType } from '@remirror/core-types';
import { NodeType as NodeType_2 } from '@remirror/pm/model';
import { NodeTypeProps } from '@remirror/core-types';
import { NodeTypesProps } from '@remirror/core-types';
import { NodeView } from '@remirror/core-types';
import { NodeViewMethod } from '@remirror/core-types';
import { NodeWithAttributes } from '@remirror/core-types';
import { NodeWithAttributesProps } from '@remirror/core-types';
import { NodeWithPosition } from '@remirror/core-utils';
import { NON_BREAKING_SPACE_CHAR } from '@remirror/core-constants';
import { nonChainable } from '@remirror/core-utils';
import { NonChainableCommandFunction } from '@remirror/core-types';
import { NonNullableShape } from '@remirror/core-types';
import { noop } from '@remirror/core-helpers';
import { NULL_CHARACTER } from '@remirror/core-constants';
import { Nullable } from '@remirror/core-types';
import { object } from '@remirror/core-helpers';
import { ObjectMark } from '@remirror/core-types';
import { ObservableLike } from '@remirror/core-types';
import { omit } from '@remirror/core-helpers';
import { omitExtraAttributes } from '@remirror/core-utils';
import { omitUndefined } from '@remirror/core-helpers';
import { Opaque } from '@remirror/core-types';
import { OptionalMarkProps } from '@remirror/core-types';
import { OptionalProsemirrorNodeProps } from '@remirror/core-types';
import { PackageJson } from '@remirror/core-types';
import { ParsedDomSize } from '@remirror/core-utils';
import { parseSizeUnit } from '@remirror/core-utils';
import { PartialDeep } from '@remirror/core-types';
import { PartialWithRequiredKeys } from '@remirror/core-types';
import { PascalCase } from '@remirror/core-types';
import { pascalCase } from '@remirror/core-helpers';
import { pathCase } from '@remirror/core-helpers';
import { pick } from '@remirror/core-helpers';
import { PickPartial } from '@remirror/core-types';
import { PickRequired } from '@remirror/core-types';
import { plainInputRule } from '@remirror/core-utils';
import { Plugin as Plugin_2 } from '@remirror/pm/state';
import { PluginKey } from '@remirror/core-types';
import type { PluginSpec } from '@remirror/pm/state';
import { PosProps } from '@remirror/core-types';
import { Predicate } from '@remirror/core-types';
import { PredicateProps } from '@remirror/core-types';
import { preserveSelection } from '@remirror/core-utils';
import { Primitive } from '@remirror/core-types';
import { PrimitiveSelection } from '@remirror/core-types';
import { Promisable } from '@remirror/core-types';
import { ProsemirrorAttributes } from '@remirror/core-types';
import { ProsemirrorCommandFunction } from '@remirror/core-types';
import { ProsemirrorKeyBindings } from '@remirror/core-types';
import { ProsemirrorNode } from '@remirror/core-types';
import { ProsemirrorNodeProps } from '@remirror/core-types';
import { prosemirrorNodeToDom } from '@remirror/core-utils';
import { prosemirrorNodeToHtml } from '@remirror/core-utils';
import { ProsemirrorPlugin } from '@remirror/core-types';
import { ProsemirrorPlugin as ProsemirrorPlugin_2 } from '@remirror/pm';
import { randomFloat } from '@remirror/core-helpers';
import { randomInt } from '@remirror/core-helpers';
import { range } from '@remirror/core-helpers';
import { rangeHasMark } from '@remirror/core-utils';
import { RangeProps } from '@remirror/core-types';
import { ReadonlyDeep } from '@remirror/core-types';
import { RegExpProps } from '@remirror/core-types';
import { REMIRROR_WEBVIEW_NAME } from '@remirror/core-constants';
import { RemirrorContentType } from '@remirror/core-types';
import { RemirrorError } from '@remirror/core-helpers';
import { RemirrorErrorOptions } from '@remirror/core-helpers';
import { RemirrorIdentifier } from '@remirror/core-constants';
import { RemirrorIdentifierShape } from '@remirror/core-types';
import { RemirrorJSON } from '@remirror/core-types';
import { RemirrorMessage } from '@remirror/core-types';
import { RemoveAnnotation } from '@remirror/core-types';
import { RemoveAnnotations } from '@remirror/core-types';
import { RemoveFlavoring } from '@remirror/core-types';
import { removeMark } from '@remirror/core-utils';
import { RemoveMarkProps } from '@remirror/core-utils';
import { removeNodeAfter } from '@remirror/core-utils';
import { removeNodeAtPosition } from '@remirror/core-utils';
import { removeNodeBefore } from '@remirror/core-utils';
import { Replace } from '@remirror/core-types';
import { replaceNodeAtPosition } from '@remirror/core-utils';
import { replaceText } from '@remirror/core-utils';
import { ReplaceTextProps } from '@remirror/core-utils';
import { RequireAtLeastOne } from '@remirror/core-types';
import { RequireExactlyOne } from '@remirror/core-types';
import { ResolvedPos } from '@remirror/core-types';
import { ResolvedPosProps } from '@remirror/core-types';
import { SchemaAttributes } from '@remirror/core-types';
import { SchemaAttributesObject } from '@remirror/core-types';
import { SchemaJSON } from '@remirror/core-utils';
import { SchemaProps } from '@remirror/core-types';
import { schemaToJSON } from '@remirror/core-utils';
import { SELECTED_NODE_CLASS_NAME } from '@remirror/core-constants';
import { SELECTED_NODE_CLASS_SELECTOR } from '@remirror/core-constants';
import { Selection as Selection_2 } from '@remirror/core-types';
import { SelectionProps } from '@remirror/core-types';
import { set } from '@remirror/core-helpers';
import { setBlockType } from '@remirror/core-utils';
import { SetOptional } from '@remirror/core-types';
import { SetRequired } from '@remirror/core-types';
import { SetReturnType } from '@remirror/core-types';
import { setStyle } from '@remirror/core-utils';
import { shallowClone } from '@remirror/core-helpers';
import { Shape } from '@remirror/core-types';
import { ShouldSkipFunction } from '@remirror/core-utils';
import { ShouldSkipProps } from '@remirror/core-utils';
import { shouldUseDomEnvironment } from '@remirror/core-utils';
import { Simplify } from '@remirror/core-types';
import { SkippableInputRule } from '@remirror/core-utils';
import { Slice } from '@remirror/core-types';
import { SnakeCase } from '@remirror/core-types';
import { snakeCase } from '@remirror/core-helpers';
import { sort } from '@remirror/core-helpers';
import { spaceCase } from '@remirror/core-helpers';
import { startCase } from '@remirror/core-helpers';
import { startPositionOfParent } from '@remirror/core-utils';
import { STATE_OVERRIDE } from '@remirror/core-constants';
import { StateJSON } from '@remirror/core-types';
import { Static } from '@remirror/core-types';
import { StaticKey } from '@remirror/core-types';
import { StaticKeyList } from '@remirror/core-types';
import { StaticShape } from '@remirror/core-types';
import { StrictReplace } from '@remirror/core-types';
import { StringHandler } from '@remirror/core-utils';
import { StringHandlerOptions } from '@remirror/core-utils';
import { StringHandlerProps } from '@remirror/core-utils';
import { Stringified } from '@remirror/core-types';
import { StringKey } from '@remirror/core-types';
import { Suggester } from '@remirror/pm/suggest';
import { SuggestState } from '@remirror/pm/suggest';
import { take } from '@remirror/core-helpers';
import { textBetween } from '@remirror/core-utils';
import { TextProps } from '@remirror/core-types';
import { throttle } from '@remirror/core-helpers';
import { ThrottledFunction } from '@remirror/core-helpers';
import { toggleBlockItem } from '@remirror/core-utils';
import { ToggleBlockItemProps } from '@remirror/core-utils';
import { toggleWrap } from '@remirror/core-utils';
import { toString as toString_2 } from '@remirror/core-helpers';
import { Transaction } from '@remirror/core-types';
import { Transaction as Transaction_2 } from '@remirror/pm/state';
import { TransactionProps } from '@remirror/core-types';
import { TransactionTransformer } from '@remirror/core-types';
import { TrStateProps } from '@remirror/core-types';
import { TsConfigJson } from '@remirror/core-types';
import { TupleOf } from '@remirror/core-types';
import { TupleUnion } from '@remirror/core-types';
import { TupleValue } from '@remirror/core-types';
import { TypedArray } from '@remirror/core-types';
import { UndefinedFlipPartialAndRequired } from '@remirror/core-types';
import { UndefinedPickPartial } from '@remirror/core-types';
import { UnionToIntersection } from '@remirror/core-types';
import { uniqueArray } from '@remirror/core-helpers';
import { uniqueBy } from '@remirror/core-helpers';
import { uniqueId } from '@remirror/core-helpers';
import { UnknownShape } from '@remirror/core-types';
import { unset } from '@remirror/core-helpers';
import { Unsubscribe } from 'nanoevents';
import { updateMark } from '@remirror/core-utils';
import { UpdateMarkProps } from '@remirror/core-utils';
import { UseDefault } from '@remirror/core-types';
import { ValidOptions } from '@remirror/core-types';
import { Value } from '@remirror/core-types';
import { ValueOf } from '@remirror/core-types';
import { values } from '@remirror/core-helpers';
import { within } from '@remirror/core-helpers';
import { wrapIn } from '@remirror/core-utils';
import { Writable } from '@remirror/core-types';
import { Writeable } from '@remirror/core-types';
import { ZERO_WIDTH_SPACE_CHAR } from '@remirror/core-constants';
export { __INTERNAL_REMIRROR_IDENTIFIER_KEY__ }
/**
* Any `ProsemirrorNode` can use the `uploadFile` function in this file as long
* as its attributes implement this interface.
*/
declare interface AbstractNodeAttributes {
id?: any;
error?: string | null;
}
export { AcceptUndefined }
export declare enum ActionType {
ADD_PLACEHOLDER = 0,
REMOVE_PLACEHOLDER = 1
}
/**
* The type which gets the active methods from the provided extensions.
*/
declare type ActiveFromExtensions<Extension extends AnyExtension> = Record<GetNodeNameUnion<Extension> extends never ? string : GetNodeNameUnion<Extension>, (attrs?: ProsemirrorAttributes) => boolean> & Record<GetMarkNameUnion<Extension> extends never ? string : GetMarkNameUnion<Extension>, (attrs?: ProsemirrorAttributes) => boolean>;
export { ActiveFromExtensions }
export { ActiveFromExtensions as ActiveFromExtensions_alias_1 }
export { ActiveFromExtensions as ActiveFromExtensions_alias_2 }
declare type AddCustomHandler<Options extends ValidOptions> = (props: Partial<GetCustomHandler<Options>>) => Dispose | undefined;
export { AddCustomHandler }
export { AddCustomHandler as AddCustomHandler_alias_1 }
declare type AddFrameworkHandler<Extension extends AnyExtension> = <Key extends keyof FrameworkEvents<Extension>>(event: Key, cb: FrameworkEvents<Extension>[Key]) => Unsubscribe;
export { AddFrameworkHandler }
export { AddFrameworkHandler as AddFrameworkHandler_alias_1 }
declare type AddHandler<Options extends ValidOptions> = <Key extends keyof GetHandler<Options>>(key: Key, method: GetHandler<Options>[Key]) => Dispose;
export { AddHandler }
export { AddHandler as AddHandler_alias_1 }
/**
* TODO see if this is needed or remove.
*/
export declare type AddHandlers<Options extends ValidOptions> = (props: Partial<GetHandler<Options>>) => Dispose;
declare interface AddPlaceholderAction {
type: ActionType.ADD_PLACEHOLDER;
id: string;
payload: any;
pos: number;
}
export { AnchorHeadProps }
export { And }
export declare type AnyBaseClassConstructor = Replace<BaseClassConstructor<any, any>, {
new (...args: any[]): AnyFunction;
}>;
export declare interface AnyBaseClassOverrides {
addCustomHandler: AnyFunction;
addHandler: AnyFunction;
clone: AnyFunction;
}
export { AnyConstructor }
/**
* The type which is applicable to any extension instance.
*
* **NOTE** `& object` forces VSCode to use the name `AnyExtension` rather than
* print out `Replace<Extension<Shape>, Remirror.AnyExtensionOverrides>`
*/
declare type AnyExtension = Replace<Extension<Shape>, Remirror.AnyExtensionOverrides> & object;
export { AnyExtension }
export { AnyExtension as AnyExtension_alias_1 }
export { AnyExtension as AnyExtension_alias_2 }
/**
* The type which is applicable to any extension instance.
*/
declare type AnyExtensionConstructor = Replace<ExtensionConstructor<any>, {
new (...args: any[]): AnyExtension;
}>;
export { AnyExtensionConstructor }
export { AnyExtensionConstructor as AnyExtensionConstructor_alias_1 }
export { AnyExtensionConstructor as AnyExtensionConstructor_alias_2 }
export { AnyFunction }
declare type AnyManagerStore = Remirror.ManagerStore<any>;
export { AnyManagerStore }
export { AnyManagerStore as AnyManagerStore_alias_1 }
export { AnyManagerStore as AnyManagerStore_alias_2 }
/**
* The type for any potential MarkExtension.
*/
declare type AnyMarkExtension = Replace<MarkExtension<Shape>, Remirror.AnyExtensionOverrides> & object;
export { AnyMarkExtension }
export { AnyMarkExtension as AnyMarkExtension_alias_1 }
export { AnyMarkExtension as AnyMarkExtension_alias_2 }
/**
* The type for any potential NodeExtension.
*/
declare type AnyNodeExtension = Replace<NodeExtension<Shape>, Remirror.AnyExtensionOverrides> & object;
export { AnyNodeExtension }
export { AnyNodeExtension as AnyNodeExtension_alias_1 }
export { AnyNodeExtension as AnyNodeExtension_alias_2 }
/**
* The type for any potential PlainExtension.
*/
declare type AnyPlainExtension = Replace<PlainExtension<Shape>, Remirror.AnyExtensionOverrides> & object;
export { AnyPlainExtension }
export { AnyPlainExtension as AnyPlainExtension_alias_1 }
export { AnyPlainExtension as AnyPlainExtension_alias_2 }
declare type AnyRemirrorManager = Simplify<Replace<RemirrorManager<AnyExtension>, {
clone: () => AnyRemirrorManager;
store: Replace<Remirror.ManagerStore<AnyExtension>, {
chain: any;
}>;
output: Replace<FrameworkOutput<AnyExtension>, {
chain: any;
manager: AnyRemirrorManager;
}> | undefined;
view: EditorView;
addView: (view: EditorView) => void;
attachFramework: (framework: any, updateHandler: (props: StateUpdateLifecycleProps) => void) => void;
/** @internal */
['~E']: AnyExtension;
/** @internal */
['~AN']: string;
/** @internal */
['~N']: string;
/** @internal */
['~M']: string;
/** @internal */
['~P']: string;
}>>;
export { AnyRemirrorManager }
export { AnyRemirrorManager as AnyRemirrorManager_alias_1 }
export { AnyRemirrorManager as AnyRemirrorManager_alias_2 }
declare interface AppendLifecycleProps extends EditorStateProps {
/**
* Update this transaction in order to append.
*/
tr: Transaction;
/**
* The previous state.
*/
previousState: EditorState;
/**
* The transactions that have already been applied.
*/
transactions: readonly Transaction[];
}
export { AppendLifecycleProps }
export { AppendLifecycleProps as AppendLifecycleProps_alias_1 }
export { applyClonedTransaction }
/**
* Apply the provided mark type and attributes.
*
* @param markType - the mark to apply.
* @param attrs - the attributes to set on the applied mark.
* @param selectionPoint - optionally specify where the mark should be applied.
* Defaults to the current selection.
*/
export declare function applyMark(type: string | MarkType, attrs?: ProsemirrorAttributes, selectionPoint?: PrimitiveSelection): CommandFunction;
export { ApplySchemaAttributes }
declare interface ApplyStateLifecycleProps extends EditorStateProps {
/**
* The original transaction which caused this state update.
*/
tr: Transaction;
/**
* The previous state.
*/
previousState: EditorState;
}
export { ApplyStateLifecycleProps }
export { ApplyStateLifecycleProps as ApplyStateLifecycleProps_alias_1 }
export { areSchemasCompatible }
export { areStatesEqual }
export { Array1 }
export { Array2 }
export { Array3 }
export { assert }
export { assertGet }
export { Asyncify }
export { AsyncReturnType }
export { atDocEnd }
export { atDocStart }
declare type AttributePropFunction<Extension extends AnyExtension> = (params: RemirrorEventListenerProps<Extension>) => Record<string, string>;
export { AttributePropFunction }
export { AttributePropFunction as AttributePropFunction_alias_1 }
export { AttributePropFunction as AttributePropFunction_alias_2 }
/**
* This extension allows others extension to add the `createAttributes` method
* for adding attributes to the prosemirror dom element.
*
* @remarks
*
* Use this to include all the dynamically generated attributes provided by each
* extension. High priority extensions have preference over the lower priority
* extensions.
*
* @category Builtin Extension
*/
declare class AttributesExtension extends PlainExtension {
get name(): "attributes";
private attributeList;
private attributeObject;
/**
* Create the attributes object on initialization.
*
* @internal
*/
onCreate(): void;
private readonly updateAttributes;
private transformAttributes;
}
export { AttributesExtension }
export { AttributesExtension as AttributesExtension_alias_1 }
export { AttributesExtension as AttributesExtension_alias_2 }
export { AttributesProps }
/**
* The type which gets the attributes for the provided node or mark. It returns
* undefined if the node / mark is not active.
*/
declare type AttrsFromExtensions<Extension extends AnyExtension> = Record<GetNodeNameUnion<Extension> extends never ? string : GetNodeNameUnion<Extension>, (attrs?: ProsemirrorAttributes) => ProsemirrorAttributes | undefined> & Record<GetMarkNameUnion<Extension> extends never ? string : GetMarkNameUnion<Extension>, (attrs?: ProsemirrorAttributes) => ProsemirrorAttributes | undefined>;
export { AttrsFromExtensions }
export { AttrsFromExtensions as AttrsFromExtensions_alias_1 }
export { AttrsFromExtensions as AttrsFromExtensions_alias_2 }
export declare abstract class BaseClass<Options extends ValidOptions = EmptyShape, DefaultStaticOptions extends Shape = EmptyShape> {
/**
* The default options for this extension.
*
* TODO see if this can be cast to something other than any and allow
* composition.
*/
static readonly defaultOptions: any;
/**
* The static keys for this class.
*/
static readonly staticKeys: string[];
/**
* The event handler keys.
*/
static readonly handlerKeys: string[];
/**
* Customize the way the handler should behave.
*/
static handlerKeyOptions: Partial<Record<string, HandlerKeyOptions> & {
[GENERAL_OPTIONS]?: HandlerKeyOptions;
}>;
/**
* The custom keys.
*/
static readonly customHandlerKeys: string[];
/**
* This is not for external use. It is purely here for TypeScript inference of
* the generic `Options` type parameter.
*
* @internal
*/
['~O']: Options & DefaultStaticOptions;
/**
* This identifies this as a `Remirror` object. .
* @internal
*/
abstract readonly [__INTERNAL_REMIRROR_IDENTIFIER_KEY__]: RemirrorIdentifier;
/**
* The unique name of this extension.
*
* @remarks
*
* Every extension **must** have a name. The name should have a distinct type
* to allow for better type inference for end users. By convention the name
* should be `camelCased` and unique within your editor instance.
*
* ```ts
* class SimpleExtension extends Extension {
* get name() {
* return 'simple' as const;
* }
* }
* ```
*/
abstract get name(): string;
/**
* The options for this extension.
*
* @remarks
*
* Options are composed of Static, Dynamic, Handlers and ObjectHandlers.
*
* - `Static` - set at instantiation by the constructor.
* - `Dynamic` - optionally set at instantiation by the constructor and also
* set during the runtime.
* - `Handlers` - can only be set during the runtime.
* - `ObjectHandlers` - Can only be set during the runtime of the extension.
*/
get options(): RemoveAnnotations<GetFixed<Options> & DefaultStaticOptions>;
/**
* Get the dynamic keys for this extension.
*/
get dynamicKeys(): string[];
/**
* The options that this instance was created with, merged with all the
* default options.
*/
get initialOptions(): RemoveAnnotations<GetFixed<Options> & DefaultStaticOptions>;
/**
* The initial options at creation (used to reset).
*/
private readonly _initialOptions;
/**
* All the dynamic keys supported by this extension.
*/
private readonly _dynamicKeys;
/**
* Private instance of the extension options.
*/
private _options;
/**
* The mapped function handlers.
*/
private _mappedHandlers;
constructor(defaultOptions: DefaultStaticOptions, ...[options]: ConstructorProps<Options, DefaultStaticOptions>);
/**
* This method is called by the extension constructor. It is not strictly a
* lifecycle method since at this point the manager has not yet been
* instantiated.
*
* @remarks
*
* It should be used instead of overriding the constructor which is strongly
* advised against.
*
* There are some limitations when using this method.
*
* - Accessing `this.store` will throw an error since the manager hasn't been
* created and it hasn't yet been attached to the extensions.
* - `this.type` in `NodeExtension` and `MarkExtension` will also throw an
* error since the schema hasn't been created yet.
*
* You should use this to setup any instance properties with the options
* provided to the extension.
*/
protected init(): void;
/**
* Clone the current instance with the provided options. If nothing is
* provided it uses the same initial options as the current instance.
*/
abstract clone(...parameters: ConstructorProps<Options, DefaultStaticOptions>): BaseClass<Options, DefaultStaticOptions>;
/**
* Get the dynamic keys for this extension.
*/
private getDynamicKeys;
/**
* Throw an error if non dynamic keys are updated.
*/
private ensureAllKeysAreDynamic;
/**
* Update the properties with the provided partial value when changed.
*/
setOptions(update: GetPartialDynamic<Options>): void;
/**
* Reset the extension properties to their default values.
*
* @nonVirtual
*/
resetOptions(): void;
/**
* Override this to receive updates whenever the options have been updated on
* this instance. This method is called after the updates have already been
* applied to the instance. If you need more control over exactly how the
* option should be applied you should set the option to be `Custom`.
*
* **Please Note**:
*
* This must be defined as a instance method and not a property since it is
* called in the constructor.
*
* ```ts
* class ThisPreset extends Preset {
* // GOOD ✅
* onSetOptions(props: OnSetOptionsProps<Options>) {}
*
* // BAD ❌
* onSetOptions = (props: OnSetOptionsProps<Options>) => {}
* }
* ```
*
* @abstract
*/
protected onSetOptions?(props: OnSetOptionsProps<Options>): void;
/**
* Update the private options.
*/
private getDynamicOptions;
/**
* Update the dynamic options.
*/
private updateDynamicOptions;
/**
* Set up the mapped handlers object with default values (an empty array);
*/
private populateMappedHandlers;
/**
* This is currently fudged together, I'm not sure it will work.
*/
private createDefaultHandlerOptions;
/**
* Add a handler to the event handlers so that it is called along with all the
* other handler methods.
*
* This is helpful for integrating react hooks which can be used in multiple
* places. The original problem with fixed properties is that you can only
* assign to a method once and it overwrites any other methods. This pattern
* for adding handlers allows for multiple usages of the same handler in the
* most relevant part of the code.
*
* More to come on this pattern.
*
* @nonVirtual
*/
addHandler<Key extends keyof GetHandler<Options>>(key: Key, method: GetHandler<Options>[Key], priority?: ExtensionPriority): Dispose;
/**
* Determines if handlers exist for the given key.
*
* Checking the existence of a handler property directly gives wrong results.
* `this.options.onHandlerName` is always truthy because it is a reference to
* the wrapper function that calls each handler.
*
* ```ts
*
* // GOOD ✅
* if (!this.hasHandlers('onHandlerName')) {
* return;
* }
*
* // BAD ❌
* if (!this.options.onHandlerName) {
* return;
* }
* ```
*
* @param key The handler to test
*/
hasHandlers<Key extends keyof GetHandler<Options>>(key: Key): boolean;
private sortHandlers;
/**
* A method that can be used to add a custom handler. It is up to the
* extension creator to manage the handlers and dispose methods.
*/
addCustomHandler<Key extends keyof GetCustomHandler<Options>>(key: Key, value: Required<GetCustomHandler<Options>>[Key]): Dispose;
/**
* Override this method if you want to set custom handlers on your extension.
*
* This must return a dispose function.
*/
protected onAddCustomHandler?: AddCustomHandler<Options>;
}
export declare interface BaseClass<Options extends ValidOptions, DefaultStaticOptions extends Shape = EmptyShape> {
constructor: BaseClassConstructor<Options, DefaultStaticOptions>;
}
export declare interface BaseClassConstructor<Options extends ValidOptions = EmptyShape, DefaultStaticOptions extends Shape = EmptyShape> extends Function {
new (...args: ConstructorProps<Options, DefaultStaticOptions>): any;
/**
* The identifier for the constructor which can determine whether it is a node
* constructor, mark constructor or plain constructor.
* @internal
*/
readonly [__INTERNAL_REMIRROR_IDENTIFIER_KEY__]: RemirrorIdentifier;
/**
* Defines the `defaultOptions` for all extension instances.
*
* @remarks
*
* Once set it can't be updated during run time. Some of the settings are
* optional and some are not. Any non-required settings must be specified in
* the `defaultOptions`.
*
* **Please note**: There is a slight downside when setting up
* `defaultOptions`. `undefined` is not supported for partial settings at this
* point in time. As a workaround use `null` as the type and pass it as the
* value in the default settings.
*
* @defaultValue {}
*
* @internal
*/
readonly defaultOptions: DefaultOptions<Options, DefaultStaticOptions>;
/**
* An array of the keys that are static for this extension.
*
* This is actually currently unused, but might become useful in the future.
* An auto-fix lint rule will be added should that be the case.
*/
readonly staticKeys: string[];
/**
* An array of all the keys which correspond to the the event handler options.
*
* This **MUST** be present if you want to use event handlers in your
* extension.
*
* Every key here is automatically removed from the `setOptions` method and is
* added to the `addHandler` method for adding new handlers. The
* `this.options[key]` is automatically replaced with a method that combines
* all the handlers into one method that can be called effortlessly. All this
* work is done for you.
*/
readonly handlerKeys: string[];
/**
* Customize the way the handler should behave.
*/
readonly handlerKeyOptions: Partial<Record<string, HandlerKeyOptions> & {
__ALL__?: HandlerKeyOptions;
}>;
/**
* A list of the custom keys in the extension or preset options.
*/
readonly customHandlerKeys: string[];
}
declare interface BaseExtensionOptions extends Remirror.BaseExtensionOptions {
/**
* An object which excludes certain functionality from an extension.
*/
exclude?: ExcludeOptions;
/**
* The priority with which this extension should be loaded by the manager.
*
* @remarks
*
* Each priority level corresponds to a higher level of importance for the
* extension within the editor.
*
* When this is set to `null` the `defaultPriority` level for the extension
* will be used instead.
*/
priority?: ExtensionPriority;
}
export { BaseExtensionOptions }
export { BaseExtensionOptions as BaseExtensionOptions_alias_1 }
declare interface BaseFramework<Extension extends AnyExtension> {
/**
* The name of the framework being used.
*/
readonly name: string;
/**
* The state that is initially passed into the editor.
*/
initialEditorState: EditorState;
/**
* The minimum required output from the framework.
*/
readonly frameworkOutput: FrameworkOutput<Extension>;
/**
* Destroy the framework and cleanup all created listeners.
*/
destroy(): void;
}
export { BaseFramework }
export { BaseFramework as BaseFramework_alias_1 }
export { BaseFramework as BaseFramework_alias_2 }
declare interface BasePlaceholder {
/**
* A custom class name to use for the placeholder decoration. All the trackers
* will automatically be given the class name `remirror-tracker-position`
*
* @defaultValue ''
*/
className?: string;
/**
* A custom html element or string for a created element tag name.
*
* @defaultValue 'tracker'
*/
nodeName?: string;
}
export { Brand }
declare interface BuiltinOptions extends SuggestOptions, KeymapOptions, DecorationsOptions, InputRulesOptions {
}
export { BuiltinOptions }
export { BuiltinOptions as BuiltinOptions_alias_1 }
export { BuiltinOptions as BuiltinOptions_alias_2 }
declare type BuiltinPreset = TagsExtension | SchemaExtension | AttributesExtension | PluginsExtension | InputRulesExtension | PasteRulesExtension | NodeViewsExtension | SuggestExtension | CommandsExtension | HelpersExtension | KeymapExtension | DocChangedExtension | UploadExtension | DecorationsExtension;
export { BuiltinPreset }
export { BuiltinPreset as BuiltinPreset_alias_1 }
export { BuiltinPreset as BuiltinPreset_alias_2 }
/**
* Provides all the builtin extensions to the editor.
*
* @remarks
*
* This is used automatically and (at the time of writing) can't be removed from
* the editor. If you feel that there's a compelling reason to override these
* extensions feel free to create a [discussion
* here](https://github.com/remirror/remirror/discussions/category_choices) and
* it can be addressed.
*
* @category Builtin Extension
*
* The order of these extension are important.
*
* - [[`TagsExtension`]] is places first because it provides tagging which is
* used by the schema extension.
* - [[`SchemeExtension`]] goes next because it's super important to the editor
* functionality and needs to run before everything else which might depend
* on it.
*/
declare function builtinPreset(options?: GetStaticAndDynamic<BuiltinOptions>): BuiltinPreset[];
export { builtinPreset }
export { builtinPreset as builtinPreset_alias_1 }
export { builtinPreset as builtinPreset_alias_2 }
export { callIfDefined }
export { CamelCase }
export { camelCase }
export { canInsertNode }
export { capitalCase }
export { capitalize }
export { Cast }
declare interface ChainableCommandDecoratorOptions<Options extends Shape> extends Remirror.CommandDecoratorOptions<Options> {
/**
* Set this to `true` to disable chaining of this command. This means it will
* no longer be available when running `
*
* @defaultValue false
*/
disableChaining?: false;
}
export { chainableEditorState }
export { chainCommands }
declare interface ChainedCommandProps {
/**
* Dispatches the chained commands.
*
* ```ts
* chain.insertText('hello').run();
* ```
*
* This will run all commands in the chain regardless of whether a previous
* command was not able to be run.
*
* If `exitEarly` is set to true the commands will stop running at the first
* chainable command which doesn't return true.
*/
run: (options?: {
exitEarly?: boolean;
}) => void;
/**
* Applies the updates to the transaction without dispatching the transaction.
*
* This can be used to update a transaction without applying the update.
*/
tr: () => Transaction;
/**
* Check to see whether the command chain can be run. Returns true when the
* command can be run.
*
* ```ts
* if (chain.insertText('hello').enabled()) {
* doSomething();
* }
* ```
*/
enabled: () => boolean;
}
export { ChainedCommandProps }
export { ChainedCommandProps as ChainedCommandProps_alias_1 }
export { ChainedCommandProps as ChainedCommandProps_alias_2 }
declare type ChainedFromExtensions<Extension extends AnyExtension, Chained extends ChainedIntersection<Extension> = ChainedIntersection<Extension>> = _ChainedFromExtensions<Extension, Chained> & ((tr: Transaction) => _ChainedFromExtensions<Extension, Chained>);
export { ChainedFromExtensions }
export { ChainedFromExtensions as ChainedFromExtensions_alias_1 }
export { ChainedFromExtensions as ChainedFromExtensions_alias_2 }
declare type _ChainedFromExtensions<Extension extends AnyExtension, Chained extends ChainedIntersection<Extension> = ChainedIntersection<Extension>> = ChainedCommandProps & NewChainedCommandProps<Extension, Chained> & {
[Command in keyof Chained]: Chained[Command] extends (...args: any[]) => any ? (...args: Parameters<Chained[Command]>) => ChainedFromExtensions<Extension> : never;
};
declare type ChainedIntersection<Extension extends AnyExtension> = UnionToIntersection<MapToChainedCommand<GetCommands<Extension> | GetDecoratedCommands<Extension>>>;
export { ChainedIntersection }
export { ChainedIntersection as ChainedIntersection_alias_1 }
export { ChainedIntersection as ChainedIntersection_alias_2 }
export { chainKeyBindingCommands }
/**
* Highlights all the properties that have changed.
*/
declare type ChangedOptions<Options extends ValidOptions> = {
[Key in keyof GetDynamic<Options>]: Changes<GetDynamic<Options>[Key]>;
};
export { ChangedOptions }
export { ChangedOptions as ChangedOptions_alias_1 }
declare type Changes<Type> = {
/**
* Whether or not the value has changed.
*
* - `false` when no change occurred.
*/
changed: false;
} | {
/**
* - `true` when a change occurred.
*/
changed: true;
/**
* The previous value before the changed. This is only accessible when
* `changed` is `true`.
*/
previousValue: Type;
/**
* The latest value after the change. This is only accessible when
* `changed` is `true`.
*/
value: Type;
};
export { clamp }
export { Class }
export { ClassName }
export { cleanupOS }
export { clone }
export { cloneTransaction }
/**
* The shape of the tag data stored by the extension manager.
*
* This data can be used by other extensions to dynamically determine which
* nodes should affected by commands / plugins / keys etc...
*/
declare type CombinedTags<Name extends string = string> = Record<ExtensionTagType, Name[]>;
export { CombinedTags }
export { CombinedTags as CombinedTags_alias_1 }
export { CombinedTags as CombinedTags_alias_2 }
/**
* A decorator which can be applied to top level methods on an extension to
* identify them as commands. This can be used as a replacement for the
* `createCommands` method.
*
* If you prefer not to use decorators, then you can continue using
* `createCommands`. Internally the decorators are being used as they are better
* for documentation purposes.
*
* For automated type inference methods that use this decorator must implement
* the following type signature.
*
* ```ts
* import { CommandFunction } from '@remirror/core';
*
* type Signature = (...args: any[]) => CommandFunction;
* ```
*
* The following is an example of how this can be used within your extension.
*
* ```ts
* import { command, CommandFunction } from '@remirror/core';
*
* class MyExtension {
* get name() {
* return 'my';
* }
*
* @command()
* myCommand(text: string): CommandFunction {
* return ({ tr, dispatch }) => {
* dispatch?.(tr.insertText('my command ' + text));
* return true;
* }
* }
* }
* ```
*
* The above command can now be used within your editor instance.
*
* ```tsx
* import { useRemirrorContext } from '@remirror/react';
*
* const MyEditorButton = () => {
* const { commands } = useRemirrorContext();
*
* return <button onClick={() => commands.myCommand('hello')}>My Button</button>
* }
* ```
*
* @category Method Decorator
*/
declare function command<Extension extends AnyExtension>(options?: ChainableCommandDecoratorOptions<Required<GetOptions<Extension>>>): ExtensionDecorator<Extension, CommandFunction, void>;
declare function command<Extension extends AnyExtension>(options: NonChainableCommandDecoratorOptions<Required<GetOptions<Extension>>>): ExtensionDecorator<Extension, NonChainableCommandFunction, void>;
export { command }
export { command as command_alias_1 }
export { command as command_alias_2 }
declare type CommandDecoratorMessage = CommandDecoratorValue<string>;
export { CommandDecoratorMessage }
export { CommandDecoratorMessage as CommandDecoratorMessage_alias_1 }
export { CommandDecoratorMessage as CommandDecoratorMessage_alias_2 }
declare interface CommandDecoratorMessageProps {
/**
* True when the command is enabled.
*/
enabled: boolean;
/**
* True when the extension is active.
*/
active: boolean;
/**
* Predefined attributes which can influence the returned value.
*/
attrs: ProsemirrorAttributes | undefined;
/**
* A translation utility for translating a predefined string / or message
* descriptor.
*/
t: I18nFormatter;
}
export { CommandDecoratorMessageProps }
export { CommandDecoratorMessageProps as CommandDecoratorMessageProps_alias_1 }
export { CommandDecoratorMessageProps as CommandDecoratorMessageProps_alias_2 }
declare type CommandDecoratorOptions<Options extends Shape = Shape> = ChainableCommandDecoratorOptions<Options> | NonChainableCommandDecoratorOptions<Options>;
export { CommandDecoratorOptions }
export { CommandDecoratorOptions as CommandDecoratorOptions_alias_1 }
export { CommandDecoratorOptions as CommandDecoratorOptions_alias_2 }
declare type CommandDecoratorShortcut = string | {
shortcut: string;
attrs: ProsemirrorAttributes;
} | string[] | Array<{
shortcut: string;
attrs: ProsemirrorAttributes;
}>;
export { CommandDecoratorShortcut }
export { CommandDecoratorShortcut as CommandDecoratorShortcut_alias_1 }
export { CommandDecoratorShortcut as CommandDecoratorShortcut_alias_2 }
/**
* @typeParam Value - the value which should be returned from the function or
* used directly.
*/
declare type CommandDecoratorValue<Value> = ((props: CommandDecoratorMessageProps) => Value) | Value;
export { CommandDecoratorValue }
export { CommandDecoratorValue as CommandDecoratorValue_alias_1 }
export { CommandDecoratorValue as CommandDecoratorValue_alias_2 }
declare interface CommandExtensionMeta {
forcedUpdates?: UpdatableViewProps[];
}
export { CommandExtensionMeta }
export { CommandExtensionMeta as CommandExtensionMeta_alias_1 }
export { CommandExtensionMeta as CommandExtensionMeta_alias_2 }
export { CommandFunction }
export { CommandFunctionProps }
declare interface CommandMetadata {
type: 'command';
/**
* Was this called as part of a chain?
*/
chain: boolean;
/**
* Is this a decorated command?
*/
decorated: boolean;
/**
* The name of the extension.
*/
extension: string;
/**
* The name of the command that was called.
*/
name: string;
}
/**
* Utility type for pulling all the command names from a list
*/
declare type CommandNames<Extension extends AnyExtension> = StringKey<CommandsFromExtensions<Extension>>;
export { CommandNames }
export { CommandNames as CommandNames_alias_1 }
export { CommandNames as CommandNames_alias_2 }
declare interface CommandOptions {
/**
* The className that is added to all tracker positions
*
* '@defaultValue 'remirror-tracker-position'
*/
trackerClassName?: Static<string>;
/**
* The default element that is used for all trackers.
*
* @defaultValue 'span'
*/
trackerNodeName?: Static<string>;
}
export { CommandOptions }
export { CommandOptions as CommandOptions_alias_1 }
export { CommandOptions as CommandOptions_alias_2 }
/**
* Generate chained and unchained commands for making changes to the editor.
*
* @remarks
*
* Typically actions are used to create interactive menus. For example a menu
* can use a command to toggle bold formatting or to undo the last action.
*
* @category Builtin Extension
*/
declare class CommandsExtension extends PlainExtension<CommandOptions> {
get name(): "commands";
/**
* The current transaction which allows for making commands chainable.
*
* It is shared by all the commands helpers and can even be used in the
* [[`KeymapExtension`]].
*
* @internal
*/
get transaction(): Transaction;
/**
* This is the holder for the shared transaction which is shared by commands
* in order to support chaining.
*
* @internal
*/
private _transaction?;
/**
* Track the decorated command data.
*/
private readonly decorated;
onCreate(): void;
/**
* Attach commands once the view is attached.
*/
onView(view: EditorView_2): void;
/**
* Update the cached transaction whenever the state is updated.
*/
onStateUpdate({ state }: StateUpdateLifecycleProps): void;
/**
* Create a plugin that solely exists to track forced updates via the
* generated plugin key.
*/
createPlugin(): CreateExtensionPlugin;
/**
* Enable custom commands to be used within the editor by users.
*
* This is preferred to the initial idea of setting commands on the
* manager or even as a prop. The problem is that there's no typechecking
* and it should be just fine to add your custom commands here to see the
* dispatched immediately.
*
* To use it, firstly define the command.
*
* ```ts
* import { CommandFunction } from 'remirror';
*
* const myCustomCommand: CommandFunction = ({ tr, dispatch }) => {
* dispatch?.(tr.insertText('My Custom Command'));
*
* return true;
* }
* ```
*
* And then use it within the component.
*
* ```ts
* import React, { useCallback } from 'react';
* import { useRemirror } from '@remirror/react';
*
* const MyEditorButton = () => {
* const { commands } = useRemirror();
* const onClick = useCallback(() => {
* commands.customDispatch(myCustomCommand);
* }, [commands])
*
* return <button onClick={onClick}>Custom Command</button>
* }
* ```
*
* An alternative is to use a custom command directly from a
* `prosemirror-*` library. This can be accomplished in the following way.
*
*
* ```ts
* import { joinDown } from 'prosemirror-commands';
* import { convertCommand } from 'remirror';
*
* const MyEditorButton = () => {
* const { commands } = useRemirror();
* const onClick = useCallback(() => {
* commands.customDispatch(convertCommand(joinDown));
* }, [commands]);
*
* return <button onClick={onClick}>Custom Command</button>;
* };
* ```
*/
customDispatch(command: CommandFunction): CommandFunction;
/**
* Insert text into the dom at the current location by default. If a
* promise is provided instead of text the resolved value will be inserted
* at the tracked position.
*/
insertText(text: string | (() => Promise<string>), options?: InsertTextOptions): CommandFunction;
/**
* Select the text within the provided range.
*
* Here are some ways it can be used.
*
* ```ts
* // Set to the end of the document.
* commands.selectText('end');
*
* // Set the selection to the start of the document.
* commands.selectText('start');
*
* // Select all the text in the document.
* commands.selectText('all')
*
* // Select a range of text. It's up to you to make sure the selected
* // range is valid.
* commands.selectText({ from: 10, to: 15 });
*
* // Specify the anchor and range in the selection.
* commands.selectText({ anchor: 10, head: 15 });
*
* // Set to a specific position.
* commands.selectText(10);
*
* // Use a ProseMirror selection
* commands.selectText(TextSelection.near(state.doc.resolve(10)))
* ```
*
* Although this is called `selectText` you can provide your own selection
* option which can be any type of selection.
*/
selectText(selection: PrimitiveSelection, options?: {
forceUpdate?: boolean;
}): CommandFunction;
/**
* Select the link at the current location.
*/
selectMark(type: string | MarkType): CommandFunction;
/**
* Delete the provided range or current selection.
*/
delete(range?: FromToProps): CommandFunction;
/**
* Fire an empty update to trigger an update to all decorations, and state
* that may not yet have run.
*
* This can be used in extensions to trigger updates when certain options that
* affect the editor state have changed.
*
* @param action - provide an action which is called just before the empty
* update is dispatched (only when dispatch is available). This can be used in
* chainable editor scenarios when you want to lazily invoke an action at the
* point the update is about to be applied.
*/
emptyUpdate(action?: () => void): CommandFunction;
/**
* Force an update of the specific updatable ProseMirror props.
*
* This command is always available as a builtin command.
*
* @category Builtin Command
*/
forceUpdate(...keys: UpdatableViewProps[]): CommandFunction;
/**
* Update the attributes for the node at the specified `pos` in the
* editor.
*
* @category Builtin Command
*/
updateNodeAttributes<Type extends object>(pos: number, attrs: ProsemirrorAttributes<Type>): CommandFunction;
/**
* Set the content of the editor while preserving history.
*
* Under the hood this is replacing the content in the document with the new
* state.doc of the provided content.
*
* If the content is a string you will need to ensure you have the proper
* string handler set up in the editor.
*/
setContent(content: RemirrorContentType, selection?: PrimitiveSelection): CommandFunction;
/**
* Reset the content of the editor while preserving the history.
*
* This means that undo and redo will still be active since the doc is replaced with a new doc.
*/
resetContent(): CommandFunction;
/**
* Fire an update to remove the current range selection. The cursor will
* be placed at the anchor of the current range selection.
*
* A range selection is a non-empty text selection.
*
* @category Builtin Command
*/
emptySelection(): CommandFunction;
/**
* Insert a new line into the editor.
*
* Depending on editor setup and where the cursor is placed this may have
* differing impacts.
*
* @category Builtin Command
*/
insertNewLine(): CommandFunction;
/**
* Insert a node into the editor with the provided content.
*
* @category Builtin Command
*/
insertNode(node: string | NodeType | ProsemirrorNode | Fragment, options?: InsertNodeOptions): CommandFunction;
/**
* Set the focus for the editor.
*
* If using this with chaining this should only be placed at the end of
* the chain. It can cause hard to debug issues when used in the middle of
* a chain.
*
* ```tsx
* import { useCallback } from 'react';
* import { useRemirrorContext } from '@remirror/react';
*
* const MenuButton = () => {
* const { chain } = useRemirrorContext();
* const onClick = useCallback(() => {
* chain
* .toggleBold()
* .focus('end')
* .run();
* }, [chain])
*
* return <button onClick={onClick}>Bold</button>
* }
* ```
*/
focus(position?: FocusType): CommandFunction;
/**
* Blur focus from the editor and also update the selection at the same
* time.
*/
blur(position?: PrimitiveSelection): CommandFunction;
/**
* Set the block type of the current selection or the provided range.
*
* @param nodeType - the node type to create
* @param attrs - the attributes to add to the node type
* @param selection - the position in the document to set the block node
* @param preserveAttrs - when true preserve the attributes at the provided selection
*/
setBlockNodeType(nodeType: string | NodeType, attrs?: ProsemirrorAttributes, selection?: PrimitiveSelection, preserveAttrs?: boolean): CommandFunction;
/**
* Toggle between wrapping an inactive node with the provided node type, and
* lifting it up into it's parent.
*
* @param nodeType - the node type to toggle
* @param attrs - the attrs to use for the node
* @param selection - the selection point in the editor to perform the action
*/
toggleWrappingNode(nodeType: string | NodeType, attrs?: ProsemirrorAttributes, selection?: PrimitiveSelection): CommandFunction;
/**
* Toggle a block between the provided type and toggleType.
*/
toggleBlockNodeItem(toggleProps: ToggleBlockItemProps): CommandFunction;
/**
* Wrap the selection or the provided text in a node of the given type with the
* given attributes.
*/
wrapInNode(nodeType: string | NodeType, attrs?: ProsemirrorAttributes, range?: FromToProps | undefined): CommandFunction;
/**
* Removes a mark from the current selection or provided range.
*/
applyMark(markType: string | MarkType, attrs?: ProsemirrorAttributes, selection?: PrimitiveSelection): CommandFunction;
/**
* Removes a mark from the current selection or provided range.
*/
toggleMark(props: ToggleMarkProps): CommandFunction;
/**
* Removes a mark from the current selection or provided range.
*/
removeMark(props: RemoveMarkProps): CommandFunction;
/**
* Set the meta data to attach to the editor on the next update.
*/
setMeta(name: string, value: unknown): CommandFunction;
/**
* Select all text in the editor.
*/
selectAll(): CommandFunction;
/**
* Copy the selected content for non empty selections.
*/
copy(): CommandFunction;
/**
* Select all text in the editor.
*/
paste(): CommandFunction;
/**
* Cut the selected content.
*/
cut(): CommandFunction;
/**
* Replaces text with an optional appended string at the end. The replacement
* can be text, or a custom node.
*
* @param props - see [[`ReplaceTextProps`]]
*/
replaceText(props: ReplaceTextProps): CommandFunction;
/**
* Get the all the decorated commands available on the editor instance.
*/
getAllCommandOptions(): Helper<Record<string, WithName<CommandDecoratorOptions>>>;
/**
* Get the options that were passed into the provided command.
*/
getCommandOptions(name: string): Helper<WithName<CommandDecoratorOptions> | undefined>;
/**
* A short hand way of getting the `view`, `state`, `tr` and `dispatch`
* methods.
*/
getCommandProp(): Helper<Required<CommandFunctionProps>>;
/**
* Update the command options via a shallow merge of the provided options. If
* no options are provided the entry is deleted.
*
* @internal
*/
updateDecorated(name: string, options?: Partial<WithName<CommandDecoratorOptions>>): void;
/**
* Needed on iOS since `requestAnimationFrame` doesn't breaks the focus
* implementation.
*/
private handleIosFocus;
/**
* Focus the editor after a slight delay.
*/
private delayedFocus;
/**
* A helper for forcing through updates in the view layer. The view layer can
* check for the meta data of the transaction with
* `manager.store.getForcedUpdate(tr)`. If that has a value then it should use
* the unique symbol to update the key.
*/
private readonly forceUpdateTransaction;
/**
* Check for a forced update in the transaction. This pulls the meta data
* from the transaction and if it is true then it was a forced update.
*
* ```ts
* import { CommandsExtension } from 'remirror/extensions';
*
* const commandsExtension = manager.getExtension(CommandsExtension);
* log(commandsExtension.getForcedUpdates(tr))
* ```
*
* This can be used for updating:
*
* - `nodeViews`
* - `editable` status of the editor
* - `attributes` - for the top level node
*
* @internal
*/
private getForcedUpdates;
/**
* Get the command metadata.
*/
private getCommandMeta;
private setCommandMeta;
/**
* Add the commands from the provided `commands` property to the `chained`,
* `original` and `unchained` objects.
*/
private addCommands;
/**
* Create an unchained command method.
*/
private unchainedFactory;
/**
* Create the unchained command.
*/
private createUnchainedCommand;
/**
* Create a chained command method.
*/
private chainedFactory;
}
export { CommandsExtension }
export { CommandsExtension as CommandsExtension_alias_1 }
export { CommandsExtension as CommandsExtension_alias_2 }
/**
* Utility type which receives an extension and provides the type of actions it
* makes available.
*
* @typeParam Extension - the extensions being used within the editor
* @typeParam Expanded - auto generated from `Extension`. These are the
* fully expanded extensions with all sub extensions automatically provided. You
* never need to provide this type as it is automatically calculated.
*/
declare type CommandsFromExtensions<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> = UnionToIntersection<MapToUnchainedCommand<GetCommands<Expanded> | GetDecoratedCommands<Expanded>>>;
export { CommandsFromExtensions }
export { CommandsFromExtensions as CommandsFromExtensions_alias_1 }
export { CommandsFromExtensions as CommandsFromExtensions_alias_2 }
/**
* The type of a non chainable command. It is a function with an `enabled`
* method to check whether the command can be run.
*/
declare interface CommandShape<Parameter extends any[] = []> {
/**
* Returns true when the command can be run and false when it can't be run. It
* basically runs the command without dispatching it to see whether it returns
* true or false.
*
* @remarks
*
* Some commands can have rules and restrictions. For example, formatting like
*`bold` is disabled within a `codeBlock`. In this case
*`commands.toggleBold.enabled()` returns `false` when within a `codeBlock`
*and `true` when outside.
*
* @param args - The same arguments that are applied to the command function.
*/
enabled: (...args: Parameter) => boolean;
/**
* This function gives you access to the original command defined by the
* extension in your editor exactly as it was defined.
*
* The function returns a function that takes the CommandFunctionProps of
* `{ state, dispatch?, tr, view? }` object.
*
* ```ts
* function command(...args: any[]) => CommandFunction;
* ```
*/
original: (...args: Parameter) => CommandFunction;
/**
* Commands which are not attached to a node extension or a mark extension can
* optionally define custom `isActive` checker.
*
* This is used for checking if `centerAlign` is active from the
* `@remirror/extension-node-formatting`.
*/
active?: () => boolean;
(...args: Parameter): void;
}
export { CommandShape }
export { CommandShape as CommandShape_alias_1 }
declare interface CommandUiDecoratorOptions {
/**
* The default command icon to use if this has a UI representation.
*/
icon?: CommandDecoratorValue<CoreIcon | CommandUiIcon>;
/**
* A label for the command with support for i18n. This makes use of
* `babel-plugin-macros` to generate the message.
*/
label?: CommandDecoratorMessage;
/**
* An i18n compatible description which can be used to provide extra context
* for the command.
*/
description?: CommandDecoratorMessage;
/**
* A keyboard shortcut which can be used to run the specified command.
*
* Rather than defining this here, you should create a decorated `keyBinding`
* and set the `command` name option. This way the shortcut will dynamically
* be added at runtime.
*/
shortcut?: CommandDecoratorShortcut;
}
export { CommandUiDecoratorOptions }
export { CommandUiDecoratorOptions as CommandUiDecoratorOptions_alias_1 }
export { CommandUiDecoratorOptions as CommandUiDecoratorOptions_alias_2 }
declare interface CommandUiIcon {
/**
* The icon name.
*/
name: CoreIcon;
/**
* Text placed in a superscript position. For `ltr` this is in the top right
* hand corner of the icon.
*/
sup?: string;
/**
* Text placed in a subscript position. For `ltr` this is in the bottom right
* hand corner.
*/
sub?: string;
}
export { CommandUiIcon }
export { CommandUiIcon as CommandUiIcon_alias_1 }
export { CommandUiIcon as CommandUiIcon_alias_2 }
export { composeTransactionSteps }
export { ConditionalExcept }
export { ConditionalKeys }
export { ConditionalPick }
export { ConditionalReturnKeys }
export { ConditionalReturnPick }
export { constantCase }
/**
* Auto infers the parameter for the constructor. If there is a required static
* option then the TypeScript compiler will error if nothing is passed in.
*/
export declare type ConstructorProps<Options extends ValidOptions, DefaultStaticOptions extends Shape> = IfNoRequiredProperties<GetStatic<Options>, [
options?: GetConstructorProps<Options> & DefaultStaticOptions
], [
options: GetConstructorProps<Options> & DefaultStaticOptions
]>;
export { containsAttributes }
export { containsNodesOfType }
export { convertCommand }
export { convertPixelsToDomUnit }
export { Coords }
export { CoreIcon }
export { createDocumentNode }
export { CreateDocumentNodeProps }
declare interface CreateEditorStateProps extends Omit<StringHandlerProps, 'stringHandler'> {
/**
* This is where content can be supplied to the Editor.
*
* @remarks
*
* Content can either be
* - a string (which will be parsed by the stringHandler)
* - JSON object matching Prosemirror expected shape
* - A top level ProsemirrorNode
*
* If this is left undefined then the editor will use the default empty `doc`.
*/
content?: RemirrorContentType;
/**
* The selection that the user should have in the created node.
*
* @defaultValue 'end'
*/
selection?: PrimitiveSelection;
/**
* A function which transforms a string into a prosemirror node.
*
* @remarks
*
* Can be used to transform markdown / html or any other string format into a
* prosemirror node.
*
* See [[`fromHTML`]] for an example of how this could work.
*/
stringHandler?: keyof Remirror.StringHandlers | StringHandler;
}
export { CreateEditorStateProps }
export { CreateEditorStateProps as CreateEditorStateProps_alias_1 }
export { CreateEditorStateProps as CreateEditorStateProps_alias_2 }
/**
* An interface for creating custom plugins in your `remirror` editor.
*/
declare interface CreateExtensionPlugin<PluginState = any> extends Pick<PluginSpec<PluginState>, 'props' | 'state' | 'key' | 'view' | 'filterTransaction' | 'appendTransaction'> {
/**
Additional properties are allowed on plugin specs, which can be
read via [`Plugin.spec`](https://prosemirror.net/docs/ref/#state.Plugin.spec).
*/
[key: string]: any;
}
export { CreateExtensionPlugin }
export { CreateExtensionPlugin as CreateExtensionPlugin_alias_1 }
declare type CreateStateFromContent = (content: RemirrorContentType, selection?: PrimitiveSelection) => EditorState;
export { CreateStateFromContent }
export { CreateStateFromContent as CreateStateFromContent_alias_1 }
export { CreateStateFromContent as CreateStateFromContent_alias_2 }
export declare function createUploadContext(): UploadContext;
export declare function createUploadPlaceholderPlugin(): Plugin_2<UploadPlaceholderPluginData>;
export { CustomDocumentProps }
export { CustomHandler }
export { CustomHandlerKey }
export { CustomHandlerKeyList }
declare interface CustomHandlerKeysProps<Options extends Shape = EmptyShape> {
customHandlerKeys: CustomHandlerKeyList<Options>;
}
/**
* @internal
*/
declare type CustomHandlerMethod<Options extends ValidOptions> = <Key extends keyof GetCustomHandler<Options>>(key: Key, value: Required<GetCustomHandler<Options>>[Key]) => Dispose;
export { CustomHandlerMethod }
export { CustomHandlerMethod as CustomHandlerMethod_alias_1 }
export { CustomHandlerShape }
export { cx }
declare interface DataProps<Data = any> {
/**
* The data to store for this placeholder.
*/
data?: Data;
}
export { debounce }
export { DebouncedFunction }
export { Decoration }
declare type DecorationPlaceholder = WidgetPlaceholder | NodePlaceholder | InlinePlaceholder;
export { DecorationPlaceholder }
export { DecorationPlaceholder as DecorationPlaceholder_alias_1 }
export { DecorationPlaceholder as DecorationPlaceholder_alias_2 }
declare interface DecorationPlaceholderMeta {
/**
* The trackers to add.
*/
added?: Array<WithBase<DecorationPlaceholder>>;
/**
* The trackers to update with new data. Data is an object and is used to
* include properties like `progress` for progress indicators. Only `widget`
* decorations can be updated in this way.
*/
updated?: Array<{
id: unknown;
data: any;
}>;
/**
* The trackers to remove.
*/
removed?: unknown[];
/**
* When set to true will delete all the active trackers.
*/
clearTrackers?: boolean;
}
export { DecorationPlaceholderMeta }
export { DecorationPlaceholderMeta as DecorationPlaceholderMeta_alias_1 }
export { DecorationPlaceholderMeta as DecorationPlaceholderMeta_alias_2 }
export { DecorationSet }
/**
* Simplify the process of adding decorations to the editor. All the decorations
* added to the document this way are automatically tracked which allows for
* custom components to be nested inside decorations.
*
* @category Builtin Extension
*/
declare class DecorationsExtension extends PlainExtension<DecorationsOptions> {
get name(): "decorations";
/**
* The placeholder decorations.
*/
private placeholders;
/**
* A map of the html elements to their decorations.
*/
private readonly placeholderWidgets;
onCreate(): void;
/**
* Create the extension plugin for inserting decorations into the editor.
*/
createPlugin(): CreateExtensionPlugin;
updateDecorations(): CommandFunction;
/**
* Command to dispatch a transaction adding the placeholder decoration to
* be tracked.
*
* @param id - the value that is used to identify this tracker. This can
* be any value. A promise, a function call, a string.
* @param options - the options to call the tracked position with. You can
* specify the range `{ from: number; to: number }` as well as the class
* name.
*/
addPlaceholder(id: unknown, placeholder: DecorationPlaceholder, deleteSelection?: boolean): CommandFunction;
/**
* A command to updated the placeholder decoration.
*
* To update multiple placeholders you can use chained commands.
*
* ```ts
* let idsWithData: Array<{id: unknown, data: number}>;
*
* for (const { id, data } of idsWithData) {
* chain.updatePlaceholder(id, data);
* }
*
* chain.run();
* ```
*/
updatePlaceholder<Data = any>(id: unknown, data: Data): CommandFunction;
/**
* A command to remove the specified placeholder decoration.
*/
removePlaceholder(id: unknown): CommandFunction;
/**
* A command to remove all active placeholder decorations.
*/
clearPlaceholders(): CommandFunction;
/**
* Find the position for the tracker with the ID specified.
*
* @param id - the unique position id which can be any type
*/
findPlaceholder(id: unknown): Helper<FromToProps | undefined>;
/**
* Find the positions of all the trackers in document.
*/
findAllPlaceholders(): Helper<Map<unknown, FromToProps>>;
/**
* Add some decorations based on the provided settings.
*/
createDecorations(state: EditorState): DecorationSet_2;
/**
* This stores all tracked positions in the editor and maps them via the
* transaction updates.
*/
onApplyState(): void;
/**
* Add a widget placeholder and track it as a widget placeholder.
*/
private addWidgetPlaceholder;
/**
* Add an inline placeholder.
*/
private addInlinePlaceholder;
/**
* Add a placeholder for nodes.
*/
private addNodePlaceholder;
/**
* Add the node and class name to the placeholder object.
*/
private withRequiredBase;
/**
* Get the command metadata.
*/
private getMeta;
/**
* Set the metadata for the command.
*/
private setMeta;
/**
* Add a placeholder decoration with the specified params to the transaction
* and return the transaction.
*
* It is up to you to dispatch the transaction or you can just use the
* commands.
*/
private addPlaceholderTransaction;
/**
* Update the data stored by a placeholder.
*
* This replaces the whole data value.
*/
private updatePlaceholderTransaction;
/**
* Discards a previously defined tracker once not needed.
*
* This should be used to cleanup once the position is no longer needed.
*/
private removePlaceholderTransaction;
/**
* This helper returns a transaction that clears all position trackers when
* any exist.
*
* Otherwise it returns undefined.
*/
private clearPlaceholdersTransaction;
/**
* Handles delayed commands which rely on the
*/
private readonly createPlaceholderCommand;
}
export { DecorationsExtension }
export { DecorationsExtension as DecorationsExtension_alias_1 }
export { DecorationsExtension as DecorationsExtension_alias_2 }
declare interface DecorationsOptions {
/**
* This setting is for adding a decoration to the selected text and can be
* used to preserve the marker for the selection when the editor loses focus.
*
* You can set it as `'selection'` to match the default styles provided by
* `@remirror/styles`.
*
* @defaultValue undefined
*/
persistentSelectionClass?: AcceptUndefined<string | boolean>;
/**
* Add custom decorations to the editor via `extension.addHandler`. This can
* be used via the `useDecorations` hook available from `remirror/react`.
*/
decorations: Handler<(state: EditorState) => DecorationSet_2>;
/**
* The className that is added to all placeholder positions
*
* '@defaultValue 'placeholder'
*/
placeholderClassName?: Static<string>;
/**
* The default element that is used for all placeholders.
*
* @defaultValue 'span'
*/
placeholderNodeName?: Static<string>;
}
export { DecorationsOptions }
export { DecorationsOptions as DecorationsOptions_alias_1 }
export { DecorationsOptions as DecorationsOptions_alias_2 }
declare interface DecorationsOptions_2 {
}
export { deepMerge }
export { DeepPartial }
export { DeepString }
/**
* The default named shortcuts used within `remirror`.
*/
declare const DEFAULT_SHORTCUTS: ShortcutMap;
export { DEFAULT_SHORTCUTS }
export { DEFAULT_SHORTCUTS as DEFAULT_SHORTCUTS_alias_1 }
export { DEFAULT_SHORTCUTS as DEFAULT_SHORTCUTS_alias_2 }
export { DefaultDocNodeOptions }
/**
* Get the expected type signature for the `defaultOptions`. Requires that every
* optional setting key (except for keys which are defined on the
* `BaseExtensionOptions`) has a value assigned.
*/
declare type DefaultExtensionOptions<Options extends ValidOptions> = DefaultOptions<Options, BaseExtensionOptions>;
export { DefaultExtensionOptions }
export { DefaultExtensionOptions as DefaultExtensionOptions_alias_1 }
export { DefaultExtensionOptions as DefaultExtensionOptions_alias_2 }
export { defaultImport }
/**
* Get the expected type signature for the `defaultOptions`. Requires that every
* optional setting key (except for keys which are defined on the
* `BaseExtensionOptions`) has a value assigned.
*/
export declare type DefaultOptions<Options extends ValidOptions, DefaultStaticOptions extends Shape> = MakeUndefined<UndefinedFlipPartialAndRequired<GetStatic<Options>> & Partial<DefaultStaticOptions> & GetFixedDynamic<Options>, StringKey<GetAcceptUndefined<Options>>>;
declare interface DefaultOptionsProps<Options extends Shape = EmptyShape> {
/**
* The default options.
*
* All non required options must have a default value provided.
*
* Please note that as mentioned in this issue
* [#624](https://github.com/remirror/remirror/issues/624), partial options
* can cause trouble when setting a default.
*
* If you need to accept `undefined `as an acceptable default option there are
* two possible ways to resolve this.
*
* #### Use `AcceptUndefined`
*
* This is the preferred solution and should be used instead of the following
* `null` union.
*
* ```ts
* import { AcceptUndefined } from 'remirror';
*
* interface Options {
* optional?: AcceptUndefined<string>;
* }
* ```
*
* Now when the options are consumed by this decorator there should be no
* errors when setting the value to `undefined`.
*
* #### `null` union
*
* If you don't mind using nulls in your code then this might appeal to you.
*
* ```ts
* interface Options {
* optional?: string | null;
* }
* ```
*
* @defaultValue {}
*/
defaultOptions: DefaultExtensionOptions<Options>;
}
declare interface DefaultPriorityProps {
/**
* The default priority for this extension.
*
* @defaultValue {}
*/
defaultPriority?: ExtensionPriority;
}
declare class DelayedCommand<Value> {
private readonly promiseCreator;
private readonly failureHandlers;
private readonly successHandlers;
private readonly validateHandlers;
constructor(promiseCreator: DelayedPromiseCreator<Value>);
/**
* The commands that will immediately be run and used to evaluate whether to
* proceed.
*/
validate(handler: CommandFunction, method?: 'push' | 'unshift'): this;
/**
* Add a success callback to the handler.
*/
success(handler: CommandFunction<{
value: Value;
}>, method?: 'push' | 'unshift'): this;
/**
* Add a failure callback to the handler.
*/
failure(handler: CommandFunction<{
error: any;
}>, method?: 'push' | 'unshift'): this;
private runHandlers;
/**
* Generate the `remirror` command.
*/
readonly generateCommand: () => CommandFunction;
}
export { DelayedCommand }
export { DelayedCommand as DelayedCommand_alias_1 }
/**
* Add tentative support for delayed commands in the editor.
*
* Delayed commands are commands that run an immediate action, like adding a
* tracker to a position in the document. Once the promise that is provided is
* returned the `onDone` parameter is run with the document in the current
* state. The tracker that was added can now be used to insert content, delete
* content or replace content.
*
* @experimental This is still being worked on and the API is subject to changes
* in structure going forward.
*
* @deprecated use [[`DelayedCommand`]] instead.
*
*/
declare function delayedCommand<Value>({ immediate, promise, onDone, onFail, }: DelayedCommandProps<Value>): CommandFunction;
export { delayedCommand }
export { delayedCommand as delayedCommand_alias_1 }
/**
* The parameter that is passed into `DelayedCommand`s.
*/
declare interface DelayedCommandProps<Value> {
/**
* Runs as soon as the command is triggered. For most delayed commands within
* the `remirror` codebase this is used to add a position tracker to the
* document.
*/
immediate?: CommandFunction;
/**
* The promise that provides the value that the `onDone` callback uses to
* complete the delayed command.
*/
promise: DelayedValue<Value>;
/**
* Called when the provided promise resolves.
*/
onDone: CommandFunction<{
value: Value;
}>;
/**
* Called when the promise fails. This could be used to cleanup the active
* position trackers when the delayed command fails.
*/
onFail?: CommandFunction;
}
declare interface DelayedPlaceholderCommandProps<Value> {
/**
* A function that returns a promise.
*/
promise: DelayedPromiseCreator<Value>;
/**
* The placeholder configuration.
*/
placeholder: DecorationPlaceholder;
/**
* Called when the promise succeeds and the placeholder still exists. If no
* placeholder can be found (for example, the user has deleted the entire
* document) then the failure handler is called instead.
*/
onSuccess: (value: Value, range: FromToProps, commandProps: CommandFunctionProps) => boolean;
/**
* Called when a failure is encountered.
*/
onFailure?: CommandFunction<{
error: any;
}>;
}
export { DelayedPlaceholderCommandProps }
export { DelayedPlaceholderCommandProps as DelayedPlaceholderCommandProps_alias_1 }
export { DelayedPlaceholderCommandProps as DelayedPlaceholderCommandProps_alias_2 }
declare type DelayedPromiseCreator<Value> = (props: CommandFunctionProps) => Promise<Value>;
export { DelayedPromiseCreator }
export { DelayedPromiseCreator as DelayedPromiseCreator_alias_1 }
declare type DelayedValue<Type> = Promise<Type> | (() => Promise<Type>);
export { DelayedValue }
export { DelayedValue as DelayedValue_alias_1 }
export { DelimiterCase }
export { Diff }
export { DispatchFunction }
export { Dispose }
declare class DocChangedExtension extends PlainExtension<DocChangedOptions> {
get name(): "docChanged";
onStateUpdate(props: StateUpdateLifecycleProps): void;
}
export { DocChangedExtension }
export { DocChangedExtension as DocChangedExtension_alias_1 }
export { DocChangedExtension as DocChangedExtension_alias_2 }
declare interface DocChangedOptions {
docChanged?: Handler<(props: StateUpdateLifecycleProps) => void>;
}
export { DocChangedOptions }
export { DocChangedOptions as DocChangedOptions_alias_1 }
export { DocChangedOptions as DocChangedOptions_alias_2 }
export { DOM_SIZE_UNITS }
export { DOMCompatibleAttributes }
export { DOMOutputSpec }
export { DomSizeUnit }
export { Dynamic }
export { DynamicAttributeCreator }
export { DynamicKey }
export { DynamicKeyList }
/**
* Get the options from any constructor. Can be used for both presets and
* extensions.
*/
declare type DynamicOptionsOfConstructor<Constructor extends AnyConstructor> = GetPartialDynamic<GetOptions<InstanceType<Constructor>>>;
export { DynamicOptionsOfConstructor }
export { DynamicOptionsOfConstructor as DynamicOptionsOfConstructor_alias_1 }
export { DynamicShape }
export { EditorSchema }
export { EditorState }
export { EditorStateProps }
export { EditorView }
export { EditorViewProps }
export { EMPTY_ARRAY }
export { EMPTY_NODE }
export { EMPTY_PARAGRAPH_NODE }
export { EmptyShape }
export { endPositionOfParent }
export { Entries }
export { entries }
export { Entry }
export { environment }
export { ErrorConstant }
export { Except }
declare interface ExcludeOptions extends Partial<Remirror.ExcludeOptions> {
}
export { ExcludeOptions }
export { ExcludeOptions as ExcludeOptions_alias_1 }
/**
* Extensions are fundamental to the way that Remirror works by grouping
* together the functionality and handling the management of similar concerns.
*
* @remarks
*
* Extension can adjust editor functionality in any way. Here are some
* examples.
*
* - How the editor displays certain content, i.e. **bold**, _italic_,
* **underline**.
* - Which commands should be made available e.g. `commands.toggleBold()` to
* toggle the weight of the selected text.
* - Check if a command is currently enabled (i.e a successful dry run) e.g.
* `commands.toggleBold.enabled()`.
* - Register Prosemirror `Plugin`s, `keymap`s, `InputRule`s `PasteRule`s,
* `Suggestions`, and custom `nodeViews` which affect the behavior of the
* editor.
*
* There are three types of `Extension`.
*
* - `NodeExtension` - For creating Prosemirror nodes in the editor. See
* {@link NodeExtension}
* - `MarkExtension` - For creating Prosemirror marks in the editor. See
* {@link MarkExtension}
* - `PlainExtension` - For behavior which doesn't map to a `ProsemirrorNode` or
* `Mark` and as a result doesn't directly affect the Prosemirror `Schema` or
* content. See {@link PlainExtension}.
*
* This `Extension` is an abstract class that should not be used directly but
* rather extended to add the intended functionality.
*
* ```ts
* import { PlainExtension, Static } from 'remirror';
*
* interface AwesomeExtensionOptions {
* isAwesome?: Static<boolean>;
* id?: string;
* }
*
* class AwesomeExtension extends PlainExtension<AwesomeExtensionOptions> {
* static defaultOptions: DefaultExtensionOptions<AwesomeExtensionOptions> = {
* isAwesome: true,
* id: '',
* }
*
* get name() {
* return 'awesome' as const;
* }
* }
* ```
*/
declare abstract class Extension<Options extends ValidOptions = EmptyShape> extends BaseClass<Options, BaseExtensionOptions> {
/**
* The default priority for this family of extensions.
*/
static readonly defaultPriority: ExtensionPriority;
/**
* Allows for the `RemirrorManager` or `Preset`'s to override the priority of
* an extension.
*/
private priorityOverride?;
/**
* The priority level for this instance of the extension. A higher value
* corresponds to a higher priority extension
*/
get priority(): ExtensionPriority;
/**
* The name that the constructor should have, which doesn't get mangled in
* production.
*/
get constructorName(): string;
/**
* The store is a shared object that's internal to each extension. It includes
* often used items like the `view` and `schema` that are added by the
* extension manager and also the lifecycle extension methods.
*
* **NOTE** - The store is not available until the manager has been created
* and received the extension. As a result trying to access the store during
* `init` and `constructor` will result in a runtime error.
*
* Some properties of the store are available at different phases. You should
* check the inline documentation to know when a certain property is useable
* in your extension.
*/
protected get store(): Remirror.ExtensionStore;
/**
* The list of extensions added to the editor by this `Preset`.
*/
get extensions(): Array<this['~E']>;
/**
* Private list of extension stored within this [[`Preset`]].
*/
private _extensions;
/**
* An extension mapping of the extensions and their constructors.
*/
private readonly extensionMap;
/**
* This store is can be modified by the extension manager with and lifecycle
* extension methods.
*
* Different properties are added at different times so it's important to
* check the documentation for each property to know what phase is being
* added.
*/
private _store?;
constructor(...args: ExtensionConstructorProps<Options>);
/**
* When there are duplicate extensions used within the editor the extension
* manager will call this method and make sure all extension holders are using
* the same instance of the `ExtensionConstructor`.
*
* @internal
*/
replaceChildExtension(constructor: AnyExtensionConstructor, extension: this['~E']): void;
/**
* Not for usage. This is purely for types to make it easier to infer
* available sub extension types.
*
* @internal
*/
['~E']: ReturnType<this['createExtensions']>[number];
/**
* Create the extensions which will be consumed by the preset. Override this
* if you would like to make your extension a parent to other (holder)
* extensions which don't make sense existing outside of the context of this
* extension.
*
* @remarks
*
* Since this method is called in the constructor it should always be created
* as an instance method and not a property. Properties aren't available for
* the call to the parent class.
*
* ```ts
* class HolderExtension extends PlainExtension {
* get name() {
* return 'holder'
* }
*
* // GOOD ✅
* createExtensions() {
* return [];
* }
*
* // BAD ❌
* createExtensions = () => {
* return [];
* }
* }
* ```
*/
createExtensions(): AnyExtension[];
/**
* Get an extension from this holder extension by providing the desired
* `Constructor`.
*
* @param Constructor - the extension constructor to find in the editor.
*
* @remarks
*
* This method will throw an error if the constructor doesn't exist within the
* extension created by this extension.
*
* It can be used to forward options and attach handlers to the children
* extensions. It is the spiritual replacement of the `Preset` extension.
*
* ```ts
* import { PlainExtension, OnSetOptionsProps } from 'remirror';
*
* interface ParentOptions { weight?: string }
*
* class ParentExtension extends PlainExtension<ParentOptions> {
* get name() {
* return 'parent' as const;
* }
*
* createExtensions() {
* return [new BoldExtension()]
* }
*
* onSetOptions(options: OnSetOptionsProps<ParentOptions>): void {
* if (options.changes.weight.changed) {
* // Update the value of the provided extension.
* this.getExtension(BoldExtension).setOption({ weight: options.changes.weight.value });
* }
* }
* }
* ```
*/
getExtension<Type extends this['~E']['constructor']>(Constructor: Type): InstanceType<Type>;
/**
* Check if the type of this extension's constructor matches the type of the
* provided constructor.
*/
isOfType<Type extends AnyExtensionConstructor>(Constructor: Type): this is InstanceType<Type>;
/**
* Pass a reference to the globally shared `ExtensionStore` for this
* extension.
*
* @remarks
*
* The extension store allows extensions to access important variables without
* complicating their creator methods.
*
* ```ts
* import { PlainExtension } from 'remirror';
*
* class Awesome extends PlainExtension {
* customMethod() {
* if (this.store.view.hasFocus()) {
* log('dance dance dance');
* }
* }
* }
* ```
*
* This should only be called by the `RemirrorManager`.
*
* @internal
* @nonVirtual
*/
setStore(store: Remirror.ExtensionStore): void;
/**
* Clone an extension.
*/
clone(...args: ExtensionConstructorProps<Options>): Extension<Options>;
/**
* Set the priority override for this extension. This is used in the
* `RemirrorManager` in order to override the priority of an extension.
*
* If you set the first parameter to `undefined` it will remove the priority
* override.
*
* @internal
*/
setPriority(priority: undefined | ExtensionPriority): void;
/**
* This handler is called when the `RemirrorManager` is first created.
*
* @remarks
*
* Since it is called as soon as the manager is some methods may not be
* available in the extension store. When accessing methods on `this.store` be
* shore to check when they become available in the lifecycle.
*
* You can return a `Dispose` function which will automatically be called when
* the extension is destroyed.
*
* This handler is called before the `onView` handler.
*
* @category Lifecycle Methods
*/
onCreate?(): Dispose | void;
/**
* This event happens when the view is first received from the view layer
* (e.g. React).
*
* Return a dispose function which will be called when the extension is
* destroyed.
*
* This handler is called after the `onCreate` handler.
*
* @category Lifecycle Methods
*/
onView?(view: EditorView): Dispose | void;
/**
* This can be used by the `Extension` to append a transaction to the latest
* update.
*
* This is shorthand for the `ProsemirrorPlugin.spec.appendTransaction`.
*
* @category Lifecycle Methods
*/
onAppendTransaction?(props: AppendLifecycleProps): void;
/**
* This is called when the prosemirror editor state is first attached to the
* editor. It can be useful for doing some preparation work.
*
* This is a shorthand for creating a plugin and adding the
* [[`Plugin.spec.state.init`]].
*
* @category Lifecycle Methods
*/
onInitState?(state: EditorState): void;
/**
* This is called when the state is being applied to the editor. This can be
* used as a shorthand for the [[`Plugin.spec.state.apply`]] method.
*
* For example, when using [[`createDecorations`]] you can respond to editor
* updates within this callback.
*
* @category Lifecycle Methods
*/
onApplyState?(props: ApplyStateLifecycleProps): void;
/**
* This handler is called after a transaction successfully updates the editor
* state. It is called asynchronously after the [[`onApplyState`]] hook has
* been run run.
*
* @category Lifecycle Methods
*/
onStateUpdate?(props: StateUpdateLifecycleProps): void;
/**
* Called when the extension is being destroyed.
*
* @category Lifecycle Methods
*/
onDestroy?(): void;
}
/**
* Declaration merging since the constructor property can't be defined on the
* actual class.
*/
declare interface Extension<Options extends ValidOptions = EmptyShape> extends Remirror.BaseExtension {
/**
* The type of the constructor for the extension.
*/
constructor: ExtensionConstructor<Options>;
/**
* An extension can declare the extensions it requires.
*
* @remarks
*
* When creating the extension manager the extension will be checked for
* required extension as well as a quick check to see if the required
* extension is already included. If not present a descriptive error will be
* thrown.
*/
requiredExtensions?: AnyExtensionConstructor[];
}
export { Extension }
export { Extension as Extension_alias_1 }
export { Extension as Extension_alias_2 }
/**
* A decorator for the remirror extension.
*
* This adds static properties to the extension constructor.
*/
declare function extension<Options extends Shape = EmptyShape>(options: ExtensionDecoratorOptions<Options>): <Type extends AnyExtensionConstructor>(ReadonlyConstructor: Type, context?: ClassDecoratorContext<Type> | undefined) => Type;
export { extension }
export { extension as extension_alias_1 }
export { extension as extension_alias_2 }
declare type ExtensionCommandFunction = (...args: any[]) => CommandFunction;
export { ExtensionCommandFunction }
export { ExtensionCommandFunction as ExtensionCommandFunction_alias_1 }
/**
* The return signature for an extensions command method.
*/
declare interface ExtensionCommandReturn {
[command: string]: ExtensionCommandFunction;
}
export { ExtensionCommandReturn }
export { ExtensionCommandReturn as ExtensionCommandReturn_alias_1 }
declare interface ExtensionConstructor<Options extends ValidOptions = EmptyShape> extends BaseClassConstructor<Options, BaseExtensionOptions>, Partial<Remirror.StaticExtensionOptions> {
new (...args: ExtensionConstructorProps<Options>): Extension<Options>;
/**
* The default priority level for all instance of this extension.
*
* @defaultValue ExtensionPriority.Default
*/
readonly defaultPriority: ExtensionPriority;
}
export { ExtensionConstructor }
export { ExtensionConstructor as ExtensionConstructor_alias_1 }
export { ExtensionConstructor as ExtensionConstructor_alias_2 }
/**
* Auto infers the parameter for the constructor. If there is a required static
* option then the TypeScript compiler will error if nothing is passed in.
*/
declare type ExtensionConstructorProps<Options extends ValidOptions> = ConstructorProps<Options, BaseExtensionOptions>;
export { ExtensionConstructorProps }
export { ExtensionConstructorProps as ExtensionConstructorProps_alias_1 }
export { ExtensionConstructorProps as ExtensionConstructorProps_alias_2 }
declare type ExtensionDecorator<Extension extends AnyExtension, Fn, Return> = (method: AnyFunction<Fn>, context: ClassMethodDecoratorContext<Extension, AnyFunction<Fn>>) => Return;
declare type ExtensionDecoratorOptions<Options extends Shape = EmptyShape> = DefaultPriorityProps & IfHasRequiredProperties<DefaultExtensionOptions<Options>, DefaultOptionsProps<Options>, Partial<DefaultOptionsProps<Options>>> & IfEmpty<GetStatic<Options>, Partial<StaticKeysProps<Options>>, StaticKeysProps<Options>> & IfEmpty<GetHandler<Options>, Partial<HandlerKeysProps<Options>>, HandlerKeysProps<Options>> & IfEmpty<GetCustomHandler<Options>, Partial<CustomHandlerKeysProps<Options>>, CustomHandlerKeysProps<Options>> & Partial<Remirror.StaticExtensionOptions>;
export { ExtensionDecoratorOptions }
export { ExtensionDecoratorOptions as ExtensionDecoratorOptions_alias_1 }
export { ExtensionDecoratorOptions as ExtensionDecoratorOptions_alias_2 }
/**
* The return signature for an extensions helper method.
*/
declare interface ExtensionHelperReturn {
[helper: string]: AnyFunction;
}
export { ExtensionHelperReturn }
export { ExtensionHelperReturn as ExtensionHelperReturn_alias_1 }
declare interface ExtensionListProps<Extension extends AnyExtension = AnyExtension> {
/**
* The extensions property.
*/
readonly extensions: readonly Extension[];
}
export { ExtensionListProps }
export { ExtensionListProps as ExtensionListProps_alias_1 }
export { ExtensionListProps as ExtensionListProps_alias_2 }
export { ExtensionPriority }
/**
* The extension store which is shared across all extensions. It provides access
* to methods and data that can be used throughout the extension lifecycle.
*/
declare interface ExtensionStore extends Remirror.ExtensionStore {
}
export { ExtensionStore }
export { ExtensionStore as ExtensionStore_alias_1 }
export { ExtensionTag }
export { ExtensionTagType }
/**
* A function that returns the extension to be used in the RemirrorManager. This
* is similar to a preset function except that it takes no arguments.
*
* ```ts
* import { RemirrorManager } from 'remirror';
* import { BoldExtension, ItalicExtension } from 'remirror/extensions';
*
* const template = () => [new BoldExtension(), new ItalicExtension()]
* const manager = RemirrorManager.create(template);
* ```
*
* If the template is mixed in with other manager creators it will add the
* relevant extension provided.
*/
declare type ExtensionTemplate<Extension extends AnyExtension> = () => Extension[];
export { ExtensionTemplate }
export { ExtensionTemplate as ExtensionTemplate_alias_1 }
/**
* This is the object shape that is returned from the combined transformation.
*/
export declare interface ExtensionTransformation<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> {
/**
* The list of extensions sorted by priority and original extension. Every
* extension passed in and those contained by presets are placed here.
*/
extensions: Expanded[];
/**
* A map where the key is the [[`ExtensionConstructor`]] and the value is the
* [[`Extension`]] instance. This is used to lookup extensions contained
* within a manager. It is a weak map so that values can be garbage collected
* when references to the constructor are lost.
*/
extensionMap: WeakMap<GetConstructor<Expanded>, Expanded>;
}
/**
* This helper function extracts all the lifecycle methods from the provided
* extension and adds them to the provided `handler` container.
*/
export declare function extractLifecycleMethods(props: SetupExtensionProps): void;
export { extractPixelSize }
declare interface FileUploader<NodeAttributes> {
/**
* Inserts the file (but doesn't start the upload operation) and returns an
* object with this to be uploaded file's attributes.
*/
insert: (file: File) => NodeAttributes;
/**
* Starts the upload operation and returns a promise. The promise will be
* resolved by a successful upload with uploaded file's attributes, or rejected
* because of an error.
*
* `upload` can update the object `context` to update information during
* the upload process. `context` will be passed to the render function. The
* render function can add a listener to `context` by using `context.addListener`
* to get the updated values. The default render function will try to find the
* keys `loaded` and `total` in `context`, which are two numbers that
* represent the progress of the upload.
*/
upload: (context: UploadContext) => Promise<NodeAttributes>;
/**
* Aborts the upload operation.
*/
abort: () => void;
}
export { FileUploader }
export { FileUploader as FileUploader_alias_1 }
export { FileUploader as FileUploader_alias_2 }
export { FileUploader as FileUploader_alias_3 }
export { findBlockNodes }
export { findChildren }
export { findChildrenByAttribute }
export { findChildrenByMark }
export { findChildrenByNode }
export { findElementAtPosition }
export { findInlineNodes }
export { findMatches }
export { findNodeAtPosition }
export { findNodeAtSelection }
export { findParentNode }
export { findParentNodeOfType }
export { findPositionOfNodeAfter }
export { findPositionOfNodeBefore }
export { FindProsemirrorNodeResult }
export { findSelectedNodeOfType }
export { findTextNodes }
declare function findUploadPlaceholderPayload(state: EditorState_2, id: string): any | undefined;
export { findUploadPlaceholderPayload }
export { findUploadPlaceholderPayload as findUploadPlaceholderPayload_alias_1 }
export { findUploadPlaceholderPayload as findUploadPlaceholderPayload_alias_2 }
export { findUploadPlaceholderPayload as findUploadPlaceholderPayload_alias_3 }
/**
* Try to find the position of the placeholder in the document based on the
* upload placeholder id
*
* @remarks
*
* This function will first try to find the position based on the decoration set.
* However, in some cases (e.g. `ReplaceStep`) the decoration will not be
* available. In that case, it will then try to find every node in the document
* recursively, which is much slower than the decoration set way in a large
* document.
*/
declare function findUploadPlaceholderPos(state: EditorState_2, id: string): number | undefined;
export { findUploadPlaceholderPos }
export { findUploadPlaceholderPos as findUploadPlaceholderPos_alias_1 }
export { findUploadPlaceholderPos as findUploadPlaceholderPos_alias_2 }
export { findUploadPlaceholderPos as findUploadPlaceholderPos_alias_3 }
export { FixedLengthArray }
export { flattenArray }
export { Flavor }
export { Flavoring }
export { FlipPartialAndRequired }
/**
* The type of arguments acceptable for the focus parameter.
*
* - Can be a prosemirror selection
* - A range of `{ from: number; to: number }`
* - A single position with a `number`
* - A string of `'start' | 'end'`
* - `true` which sets the focus to the current position or start.
*/
declare type FocusType = PrimitiveSelection | boolean;
export { FocusType }
export { FocusType as FocusType_alias_1 }
/**
* Provides the list of Prosemirror EditorView props that should be updated/
*/
declare type ForcedUpdateMeta = UpdatableViewProps[];
export { ForcedUpdateMeta }
export { ForcedUpdateMeta as ForcedUpdateMeta_alias_1 }
export { ForcedUpdateMeta as ForcedUpdateMeta_alias_2 }
export { format }
export { Fragment }
export { FragmentStringHandlerOptions }
/**
* This is the `Framework` class which is used to create an abstract class for
* implementing `Remirror` into the framework of your choice.
*
* The best way to learn how to use it is to take a look at the [[`DomFramework`]]
* and [[`ReactFramework`]] implementations.
*
* @remarks
*
* There are two methods and one getter property which must be implemented for this
*/
declare abstract class Framework<Extension extends AnyExtension = BuiltinPreset, Props extends FrameworkProps<Extension> = FrameworkProps<Extension>, Output extends FrameworkOutput<Extension> = FrameworkOutput<Extension>> implements BaseFramework<Extension> {
#private;
/**
* A previous state that can be overridden by the framework implementation.
*/
protected previousStateOverride?: EditorState;
/**
* The event listener which allows consumers to subscribe to the different
* events taking place in the editor. Events currently supported are:
*
* - `destroy`
* - `focus`
* - `blur`
* - `updated`
*/
protected get addHandler(): AddFrameworkHandler<Extension>;
/**
* The updatable view props.
*/
protected get updatableViewProps(): UpdatableViewPropsObject;
/**
* True when this is the first render of the editor.
*/
protected get firstRender(): boolean;
/**
* Store the name of the framework.
*/
abstract get name(): string;
/**
* The props passed in when creating or updating the `Framework` instance.
*/
get props(): Props;
/**
* Returns the previous editor state. On the first render it defaults to
* returning the current state. For the first render the previous state and
* current state will always be equal.
*/
protected get previousState(): EditorState;
/**
* The instance of the [[`RemirrorManager`]].
*/
protected get manager(): RemirrorManager<Extension>;
/**
* The ProseMirror [[`EditorView`]].
*/
protected get view(): EditorView;
/**
* A unique id for the editor. Can be used to differentiate between editors.
*
* Please note that this ID is only locally unique, it should not be used as a
* database key.
*/
protected get uid(): string;
/**
* The initial editor state from when the editor was first created.
*/
get initialEditorState(): EditorState;
constructor(options: FrameworkOptions<Extension, Props>);
/**
* Setup the manager event listeners which are disposed of when the manager is
* destroyed.
*/
private updateListener;
/**
* Update the constructor props passed in. Useful for frameworks like react
* where props are constantly changing and when using hooks function closures
* can become stale.
*
* You can call the update method with the new `props` to update the internal
* state of this instance.
*/
update(options: FrameworkOptions<Extension, Props>): this;
/**
* Retrieve the editor state.
*/
protected readonly getState: () => EditorState;
/**
* Retrieve the previous editor state.
*/
protected readonly getPreviousState: () => EditorState;
/**
* This method must be implement by the extending framework class. It returns
* an [[`EditorView`]] which is added to the [[`RemirrorManager`]].
*/
protected abstract createView(state: EditorState, element?: Element): EditorView;
/**
* This is used to implement how the state updates are used within your
* application instance.
*
* It must be implemented.
*/
protected abstract updateState(props: UpdateStateProps): void;
/**
* Update the view props.
*/
protected updateViewProps(...keys: UpdatableViewProps[]): void;
/**
* This sets the attributes for the ProseMirror Dom node.
*/
protected getAttributes(ssr?: false): Record<string, string>;
protected getAttributes(ssr: true): Shape;
/**
* Part of the Prosemirror API and is called whenever there is state change in
* the editor.
*
* @internalremarks
* How does it work when transactions are dispatched one after the other.
*/
protected readonly dispatchTransaction: (tr: Transaction) => void;
/**
* Adds `onBlur` and `onFocus` listeners.
*
* When extending this class make sure to call this method once
* `ProsemirrorView` has been added to the dom.
*/
protected addFocusListeners(): void;
/**
* Remove `onBlur` and `onFocus` listeners.
*
* When extending this class in your framework, make sure to call this just
* before the view is destroyed.
*/
protected removeFocusListeners(): void;
/**
* Called when the component unmounts and is responsible for cleanup.
*
* @remarks
*
* - Removes listeners for the editor `blur` and `focus` events
*/
destroy(): void;
/**
* Use this method in the `onUpdate` event to run all change handlers.
*/
readonly onChange: (props?: ListenerProps) => void;
/**
* Listener for editor 'blur' events
*/
private readonly onBlur;
/**
* Listener for editor 'focus' events
*/
private readonly onFocus;
/**
* Sets the content of the editor. This bypasses the update function.
*
* @param content
* @param triggerChange
*/
private readonly setContent;
/**
* Clear the content of the editor (reset to the default empty node).
*
* @param triggerChange - whether to notify the onChange handler that the
* content has been reset
*/
private readonly clearContent;
/**
* Creates the props passed into all event listener handlers. e.g.
* `onChange`
*/
protected eventListenerProps(props?: ListenerProps): RemirrorEventListenerProps<Extension>;
protected readonly createStateFromContent: CreateStateFromContent;
/**
* Focus the editor.
*/
protected readonly focus: (position?: FocusType) => void;
/**
* Blur the editor.
*/
protected readonly blur: (position?: PrimitiveSelection) => void;
/**
* Methods and properties which are made available to all consumers of the
* `Framework` class.
*/
protected get baseOutput(): FrameworkOutput<Extension>;
/**
* Every framework implementation must provide it's own custom output.
*/
abstract get frameworkOutput(): Output;
}
export { Framework }
export { Framework as Framework_alias_1 }
export { Framework as Framework_alias_2 }
declare interface FrameworkEvents<Extension extends AnyExtension> extends Pick<ManagerEvents, 'destroy'> {
/**
* An event listener which is called whenever the editor gains focus.
*/
focus: (params: RemirrorEventListenerProps<Extension>, event: Event) => void;
/**
* An event listener which is called whenever the editor is blurred.
*/
blur: (params: RemirrorEventListenerProps<Extension>, event: Event) => void;
/**
* Called on every state update after the state has been applied to the editor.
*
* This should be used to track the current editor state and check if commands
* are enabled.
*/
updated: RemirrorEventListener<Extension>;
}
export { FrameworkEvents }
export { FrameworkEvents as FrameworkEvents_alias_1 }
declare interface FrameworkOptions<Extension extends AnyExtension, Props extends FrameworkProps<Extension>> {
/**
* The initial editor state
*/
initialEditorState: EditorState;
/**
* A method for getting the passed in props.
*/
getProps: () => Props;
/**
* When provided the view will immediately be inserted into the dom within
* this element.
*/
element?: Element;
}
export { FrameworkOptions }
export { FrameworkOptions as FrameworkOptions_alias_1 }
export { FrameworkOptions as FrameworkOptions_alias_2 }
/**
* This is the base output that is created by a framework.
*/
declare interface FrameworkOutput<Extension extends AnyExtension> extends Remirror.ManagerStore<Extension> {
/**
* The manager which was used to create this editor.
*/
manager: RemirrorManager<Extension>;
/**
* Add event handlers to the remirror editor at runtime.
*/
addHandler: AddFrameworkHandler<Extension>;
/**
* The unique id for the editor instance.
*/
uid: string;
/**
* Clears all editor content.
*
* @param options - includes a `triggerChange` handler which should be
* triggered by the update.
*
* To use this in a controlled editor, you must set `triggerChange` to `true`.
*/
clearContent: (options?: TriggerChangeProps) => void;
/**
* Replace all editor content with the new content.
*
* @remarks
*
* Allows for the editor content to be overridden by force.
*
* @param triggerOnChange - whether the `onChange` handler should be triggered
* by the update. Defaults to `false`.
*
* To use this in a controlled editor, you must set `triggerChange` to `true`.
*/
setContent: (content: RemirrorContentType, options?: TriggerChangeProps) => void;
/**
* A getter function for the current editor state. It's a wrapper around
* `view.state`.
*/
getState: () => EditorState;
/**
* A getter function for the previous prosemirror editor state. It can be used
* to check what's changed between states.
*/
getPreviousState: () => EditorState;
/**
* Get an extension by it's constructor.
*/
getExtension: <ExtensionConstructor extends AnyExtensionConstructor>(Constructor: ExtensionConstructor) => InstanceType<ExtensionConstructor>;
/**
* Assert if an extension is present by it's constructor.
*/
hasExtension: <ExtensionConstructor extends AnyExtensionConstructor>(Constructor: ExtensionConstructor) => boolean;
/**
* Focus the editor at the `start` | `end` a specific position or at a valid
* range between `{ from, to }`.
*
* @deprecated This method may be removed in the future and it is advisable to
* use `commands.focus()`.
*/
focus: (position?: FocusType) => void;
/**
* Blur the editor.
*
* @deprecated This method may be removed in the future and it is advisable to
* use `commands.blur()`.
*/
blur: (position?: PrimitiveSelection) => void;
}
export { FrameworkOutput }
export { FrameworkOutput as FrameworkOutput_alias_1 }
export { FrameworkOutput as FrameworkOutput_alias_2 }
/**
* The base options for an editor wrapper. This is used within the react and dom
* implementations.
*/
declare interface FrameworkProps<Extension extends AnyExtension> {
/**
* Pass in the extension manager.
*
* The manager is responsible for handling all Prosemirror related
* functionality.
*/
manager: RemirrorManager<Extension>;
/**
* Set the starting value for the editor.
*
* Without setting the value prop `onChange` remirror renders as an uncontrolled
* component. Value changes are passed back out of the editor and there is now
* way to set the value via props. As a result this is the only opportunity to
* directly control the rendered text.
*
* @defaultValue `{ type: 'doc', content: [{ type: 'paragraph' }] }`
*/
initialContent?: RemirrorContentType | [RemirrorContentType, PrimitiveSelection];
/**
* Adds attributes directly to the prosemirror element.
*
* @defaultValue {}
*/
attributes?: Record<string, string> | AttributePropFunction<Extension>;
/**
* Additional classes which can be passed into the the editor wrapper. These
* are placed on root `Prosemirror` element and can be used to effect styling
* within the editor.
*/
classNames?: ClassName[];
/**
* Determines whether this editor is editable or not.
*
* @defaultValue true
*/
editable?: boolean;
/**
* When set to true focus will be place on the editor as soon as it first
* loads.
*
* @defaultValue false
*/
autoFocus?: FocusType;
/**
* An event listener which is called whenever the editor gains focus.
*/
onFocus?: (params: RemirrorEventListenerProps<Extension>, event: Event) => void;
/**
* An event listener which is called whenever the editor is blurred.
*/
onBlur?: (params: RemirrorEventListenerProps<Extension>, event: Event) => void;
/**
* Called on every change to the Prosemirror state.
*/
onChange?: RemirrorEventListener<Extension>;
/**
* A method called when the editor is dispatching the transaction.
*
* @remarks
* Use this to update the transaction which will be used to update the editor
* state.
*/
onDispatchTransaction?: TransactionTransformer;
/**
* Sets the accessibility label for the editor instance.
*
* @defaultValue ''
*/
label?: string;
}
export { FrameworkProps }
export { FrameworkProps as FrameworkProps_alias_1 }
export { FrameworkProps as FrameworkProps_alias_2 }
export { freeze }
export { FromToProps }
declare const GENERAL_OPTIONS: "__ALL__";
export { Get }
export { get }
export { GetAcceptUndefined }
export { getActiveNode }
export { GetAttributes }
export { GetAttributesProps }
export { getChangedNodeRanges }
export { getChangedNodes }
/**
* Get the property changes and the next value from an update.
*/
export declare function getChangedOptions<Options extends ValidOptions>(props: GetChangedOptionsProps<Options>): GetChangeOptionsReturn<Options>;
export declare interface GetChangedOptionsProps<Options extends ValidOptions> {
/**
* The previous readonly properties object.
*/
previousOptions: GetFixedDynamic<Options>;
/**
* The partial update object that was passed through.
*/
update: GetPartialDynamic<Options>;
/**
* A method to check whether two values are equal.
*/
equals?: (valueA: unknown, valueB: unknown) => boolean;
}
export { getChangedRanges }
declare interface GetChangeOptionsReturn<Options extends ValidOptions> {
/**
* The next value of the properties after the update.This also includes values
* which have not been changed.
*/
options: GetFixedDynamic<Options>;
/**
* An object with all the keys showing what's been changed. This should be
* used to determine the children extensions which should be updated.
*
* @remarks
*
* Using this can prevent unnecessary updates. It's possible for new
* properties to be passed that are identical to the previous, by checking if
* the object was changed this can be avoided.
*
* This uses a discriminated union. When the `changed` property is true then
* the object has a value as well.
*
* ```ts
* if (changes.myProperty.changed) {
* doSomething(changes.myProperty.value);
* }
* ```
*/
changes: Readonly<Required<ChangedOptions<Options>>>;
/**
* Pick the changed values by their key. An object populated with only the
* changed items will be returned to you.
*/
pickChanged: PickChanged<Options>;
}
export { GetChangeOptionsReturn }
export { GetChangeOptionsReturn as GetChangeOptionsReturn_alias_1 }
/**
* Get the commands from a `RemirrorManager`, `Extension` or `Preset`.
*/
declare type GetCommands<Type extends {
['~C']: unknown;
}> = Type['~C'];
export { GetCommands }
export { GetCommands as GetCommands_alias_1 }
/**
* Get the constructor of an instance.
*/
declare type GetConstructor<Type extends {
constructor: unknown;
}> = Type['constructor'];
export { GetConstructor }
export { GetConstructor as GetConstructor_alias_1 }
export { GetConstructorProps }
export { getCursor }
export { GetCustomHandler }
/**
* This uses a hack available via conditional types and `Distributive
* conditional types`. When a conditional is used on a union it distributes the
* types so that the union can avoid the case where:
*
* > access is restricted to members that are common to all types in the union
*
* A better explanation is available here
* https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types
*/
declare type GetDecoratedCommands<Type> = Type extends AnyExtension ? ConditionalPick<Type, AnyFunction<CommandFunction>> : never;
declare type GetDecoratedHelpers<Type> = Type extends object ? RemoveHelpers<ConditionalReturnPick<Type, HelperAnnotation>> : never;
declare type GetDecoratedUiCommands<Type> = Type extends AnyExtension ? ConditionalPick<Type, AnyFunction<UiCommandFunction>> : never;
export { getDefaultBlockNode }
export { getDefaultDocNode }
export { getDocRange }
export { getDocument }
export { GetDynamic }
/**
* Get the extension type and the extension type of all sub extensions.
*
* This uses recursive conditional types which are only available in
* `typescript@4.1` https://github.com/microsoft/TypeScript/pull/40002
*
* @typeParam Extension - The union of extensions.
*/
declare type GetExtensions<Extension> = AnyExtension extends Extension ? AnyExtension : Extension extends AnyExtension ? // Now create the union of the provided extension and it's recursively
Extension | GetExtensions<Extension['~E']> : AnyExtension;
export { GetExtensions }
export { GetExtensions as GetExtensions_alias_1 }
export { GetExtensions as GetExtensions_alias_2 }
export { GetFixed }
export { GetFixedCustomHandler }
export { GetFixedDynamic }
export { GetFixedProps }
export { GetFixedStatic }
export { GetFlippedStatic }
export { getFontSize }
export { GetHandler }
/**
* Get the helpers provided by an from a `RemirrorManager`, `Extension` or
* `Preset`.
*/
declare type GetHelpers<Type extends {
['~H']: unknown;
}> = Type['~H'];
export { GetHelpers }
export { GetHelpers as GetHelpers_alias_1 }
export { getInvalidContent }
export { getLazyArray }
export { GetMappedCustomHandler }
export { GetMappedHandler }
export { getMarkAttributes }
/**
* A utility type for retrieving the name of an extension only when it's a mark
* extension.
*
* @typeParam Extension - the extensions being used within the editor
* @typeParam Expanded - auto generated from `Extension`. These are the
* fully expanded extensions with all sub extensions automatically provided. You
* never need to provide this type as it is automatically calculated.
*/
declare type GetMarkNameUnion<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> = Expanded extends AnyMarkExtension ? Expanded['name'] : never;
export { GetMarkNameUnion }
export { GetMarkNameUnion as GetMarkNameUnion_alias_1 }
export { GetMarkNameUnion as GetMarkNameUnion_alias_2 }
export { GetMarkRange }
export { getMarkRange }
export { getMarkRanges }
export { getMarkType }
export { getMatchString }
/**
* Get the names of all available extensions.
*/
declare type GetNameUnion<Extension extends AnyExtension> = GetExtensions<Extension>['name'];
export { GetNameUnion }
export { GetNameUnion as GetNameUnion_alias_1 }
export { GetNameUnion as GetNameUnion_alias_2 }
/**
* A utility type for retrieving the name of an extension only when it's a node
* extension.
*
* @typeParam Extension - the extensions being used within the editor
* @typeParam Expanded - auto generated from `Extension`. These are the
* fully expanded extensions with all sub extensions automatically provided. You
* never need to provide this type as it is automatically calculated.
*/
declare type GetNodeNameUnion<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> = Expanded extends AnyNodeExtension ? Expanded['name'] : never;
export { GetNodeNameUnion }
export { GetNodeNameUnion as GetNodeNameUnion_alias_1 }
export { GetNodeNameUnion as GetNodeNameUnion_alias_2 }
export { getNodeType }
/**
* Get the static extension settings.
*/
declare type GetOptions<Type extends {
['~O']: unknown;
}> = Type['~O'];
export { GetOptions }
export { GetOptions as GetOptions_alias_1 }
export { GetPartialDynamic }
/**
* A utility type for retrieving the name of an extension only when it's a plain
* extension.
*
* @typeParam Extension - the extensions being used within the editor
* @typeParam Expanded - auto generated from `Extension`. These are the
* fully expanded extensions with all sub extensions automatically provided. You
* never need to provide this type as it is automatically calculated.
*/
declare type GetPlainNameUnion<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> = Expanded extends AnyPlainExtension ? Expanded['name'] : never;
export { GetPlainNameUnion }
export { GetPlainNameUnion as GetPlainNameUnion_alias_1 }
export { GetPlainNameUnion as GetPlainNameUnion_alias_2 }
export { getRemirrorJSON }
export { GetRequiredKeys }
export { getSelectedGroup }
export { getSelectedWord }
export { getShortcutSymbols }
export { GetStatic }
export { GetStaticAndDynamic }
export { getStyle }
export { getTextContentFromSlice }
declare interface GetTextHelperOptions extends Partial<EditorStateProps> {
/**
* The divider used to separate text blocks.
*
* @defaultValue '\n\n'
*/
lineBreakDivider?: string;
}
export { getTextSelection }
/**
* Shortcuts used within google docs.
*/
declare const GOOGLE_DOC_SHORTCUTS: ShortcutMap;
export { GOOGLE_DOC_SHORTCUTS }
export { GOOGLE_DOC_SHORTCUTS as GOOGLE_DOC_SHORTCUTS_alias_1 }
export { GOOGLE_DOC_SHORTCUTS as GOOGLE_DOC_SHORTCUTS_alias_2 }
export { Handler }
export { HandlerKey }
export { HandlerKeyList }
declare interface HandlerKeyOptions<ReturnType = any, Args extends any[] = any[]> {
/**
* When this value is encountered the handler will exit early.
*
* Set the value to `'__IGNORE__'` to ignore the early return value.
*/
earlyReturnValue?: LiteralUnion<typeof IGNORE, Primitive> | ((value: unknown) => boolean);
/**
* Allows combining the values from the handlers together to produce a single
* reduced output value.
*/
reducer?: {
/**
* Combine the value with the the previous value
*/
accumulator: (accumulated: ReturnType, latestValue: ReturnType, ...args: Args) => ReturnType;
/**
* The a function that returns the default value for combined handler
* values. This is required for setting up a default value.
*/
getDefault: (...args: Args) => ReturnType;
};
}
export { HandlerKeyOptions }
export { HandlerKeyOptions as HandlerKeyOptions_alias_1 }
/**
* This notifies the extension which options are handlers. Handlers typically
* represent event handlers that are called in response to something happening.
*
* An `onChange` option could be a handler. When designing the API I had to
* consider that often times, you might want to listen to a handler in several
* places.
*
* A limitation of the static and dynamic options is that there is only one
* value per extension. So if there is a `minValue` option and that min value
* option is set in the extension then it becomes the value for all consumers of
* the extension. Handlers don't have the same expected behaviour. It is
* generally expected that you should be able to subscribe to an event in
* multiple places.
*
* In order to make this possible with `remirror` the handlers are automatically
* created based on the handler keys you provide. Each handler is an array and
* when the handler is called with `this.options.onChange`, each item in the
* array is called based on the rules provided.
*/
declare interface HandlerKeysProps<Options extends Shape = EmptyShape> {
/**
* The list of the option names which are event handlers.
*/
handlerKeys: HandlerKeyList<Options>;
/**
* Customize how the handler should work.
*
* This allows you to decide how the handlers will be composed together.
* Currently it only support function handlers, but you can tell the extension
* to exit early when a certain return value is received.
*
* ```ts
* const handlerOptions = { onChange: { earlyReturnValue: true }};
* ```
*
* The above setting means that onChange will exit early as soon as one of the
* methods returns true.
*/
handlerKeyOptions?: MappedHandlerKeyOptions<Options>;
}
export { HandlerShape }
export { hasOwnProperty }
export { hasTransactionChanged }
/**
* Determine if there are active file uploads in the given state
*
* @remarks
* This utility is useful to warn users there are still active uploads before
* exiting or saving a document.
*
* @see https://remirror.vercel.app/?path=/story/extensions-file--with-upload-incomplete-warning
*
* @param state - the editor state
*/
declare function hasUploadingFile(state: EditorState_2): boolean;
export { hasUploadingFile }
export { hasUploadingFile as hasUploadingFile_alias_1 }
export { hasUploadingFile as hasUploadingFile_alias_2 }
export { hasUploadingFile as hasUploadingFile_alias_3 }
/**
* An annotation which marks decorated helper methods for an extension.
*/
declare type Helper<Type> = Type extends null | undefined ? Type : Type & HelperAnnotation;
export { Helper }
export { Helper as Helper_alias_1 }
export { Helper as Helper_alias_2 }
/**
* A decorator which can be applied to top level methods on an extension to
* identify them as helpers. This can be used as a replacement for the
* `createHelpers` method.
*
* To allow the TypeScript compiler to automatically infer types, please create
* your methods with the following type signature.
*
* ```ts
* import { Helper } from '@remirror/core';
*
* type Signature = (...args: any[]) => Helper<SomeReturnType>;
* ```
*
* The following is an example of how this can be used within your extension.
*
* ```ts
* import { helper, Helper } from '@remirror/core';
*
* class MyExtension {
* get name() {
* return 'my';
* }
*
* @helper()
* alwaysTrue(): Helper<boolean> {
* return true;
* }
* }
* ```
*
* The above helper can now be used within your editor instance.
*
* ```tsx
* import { useRemirrorContext } from '@remirror/react';
*
* const MyEditorButton = () => {
* const { helpers } = useRemirrorContext();
*
* return helpers.alwaysTrue() ? <button>My Button</button> : null
* }
* ```
*
* @category Method Decorator
*/
declare function helper(options?: HelperDecoratorOptions): <Extension extends AnyExtension, Type>(method: AnyFunction<NonNullable<Type> extends HelperAnnotation ? Type : never>, context: ClassMethodDecoratorContext<Extension, (this: Extension, ...args: any) => any>) => AnyFunction<NonNullable<Type> extends HelperAnnotation ? Type : never>;
export { helper }
export { helper as helper_alias_1 }
export { helper as helper_alias_2 }
declare type HelperAnnotation = Flavoring<'HelperAnnotation'>;
export { HelperAnnotation }
export { HelperAnnotation as HelperAnnotation_alias_1 }
export { HelperAnnotation as HelperAnnotation_alias_2 }
declare interface HelperDecoratorOptions {
}
export { HelperDecoratorOptions }
export { HelperDecoratorOptions as HelperDecoratorOptions_alias_1 }
export { HelperDecoratorOptions as HelperDecoratorOptions_alias_2 }
/**
* A function with a return signature annotated as a helper.
*/
declare type HelperFunction<Type extends HelperAnnotation = HelperAnnotation> = AnyFunction<Type>;
export { HelperFunction }
export { HelperFunction as HelperFunction_alias_1 }
export { HelperFunction as HelperFunction_alias_2 }
/**
* Utility type for pulling all the action names from a list
*/
declare type HelperNames<Extension extends AnyExtension> = StringKey<HelpersFromExtensions<Extension>>;
export { HelperNames }
export { HelperNames as HelperNames_alias_1 }
export { HelperNames as HelperNames_alias_2 }
/**
* Helpers are custom methods that can provide extra functionality to the
* editor.
*
* @remarks
*
* They can be used for pulling information from the editor or performing custom
* async commands.
*
* Also provides the default helpers used within the extension.
*
* @category Builtin Extension
*/
declare class HelpersExtension extends PlainExtension {
get name(): "helpers";
/**
* Add the `html` and `text` string handlers to the editor.
*/
onCreate(): void;
/**
* Check whether the selection is empty.
*/
isSelectionEmpty(state?: EditorState): Helper<boolean>;
isViewEditable(state?: EditorState): Helper<boolean>;
/**
* Get the full JSON output for the ProseMirror editor state object.
*/
getStateJSON(state?: EditorState): Helper<StateJSON>;
/**
* Get the JSON output for the main ProseMirror `doc` node.
*
* This can be used to persist data between sessions and can be passed as
* content to the `initialContent` prop.
*/
getJSON(state?: EditorState): Helper<RemirrorJSON>;
/**
* Insert a html string as a ProseMirror Node.
*
* @category Builtin Command
*/
insertHtml(html: string, options?: InsertNodeOptions): CommandFunction;
/**
* A method to get all the content in the editor as text. Depending on the
* content in your editor, it is not guaranteed to preserve it 100%, so it's
* best to test that it meets your needs before consuming.
*/
getText({ lineBreakDivider, state, }?: GetTextHelperOptions): Helper<string>;
getTextBetween(from: number, to: number, doc?: ProsemirrorNode): Helper<string>;
/**
* Get the html from the current state, or provide a custom state.
*/
getHTML(state?: EditorState): Helper<string>;
/**
* Wrap the content in a pre tag to preserve whitespace and see what the
* editor does with it.
*/
private textToProsemirrorNode;
}
export { HelpersExtension }
export { HelpersExtension as HelpersExtension_alias_1 }
export { HelpersExtension as HelpersExtension_alias_2 }
/**
* Utility type which receives an extension and provides the type of helpers it
* makes available.
*
* @typeParam Extension - the extensions being used within the editor
* @typeParam Expanded - auto generated from `Extension`. These are the
* fully expanded extensions with all sub extensions automatically provided. You
* never need to provide this type as it is automatically calculated.
*/
declare type HelpersFromExtensions<Extension extends AnyExtension, Expanded extends AnyExtension = GetExtensions<Extension>> = UnionToIntersection<MapHelpers<GetHelpers<Expanded> | GetDecoratedHelpers<Expanded>>>;
export { HelpersFromExtensions }
export { HelpersFromExtensions as HelpersFromExtensions_alias_1 }
export { HelpersFromExtensions as HelpersFromExtensions_alias_2 }
export { htmlToProsemirrorNode }
export { I18nFormatter }
/**
* The extra identifiers that can be used.
*
* - `nodes` - match all nodes
* - `marks` - match all marks
* - `all` - match everything in the editor
* - `string[]` - match the selected node and mark names
* - [[`IdentifiersObject`]] - match by `ExtensionTag` and type name.
*/
declare type Identifiers = 'nodes' | 'marks' | 'all' | readonly string[] | IdentifiersObject;
export { Identifiers }
export { Identifiers as Identifiers_alias_1 }
export { Identifiers as Identifiers_alias_2 }
/**
* The interface for adding extra attributes to multiple node and mark
* extensions.
*/
declare interface IdentifierSchemaAttributes {
/**
* The nodes or marks to add extra attributes to.
*
* This can either be an array of the strings or the following specific
* identifiers:
*
* - 'nodes' for all nodes
* - 'marks' for all marks
* - 'all' for all extensions which touch the schema.
*/
identifiers: Identifiers;
/**
* The attributes to be added.
*/
attributes: SchemaAttributes;
}
export { IdentifierSchemaAttributes }
export { IdentifierSchemaAttributes as IdentifierSchemaAttributes_alias_1 }
export { IdentifierSchemaAttributes as IdentifierSchemaAttributes_alias_2 }
/**
* With tags, you can select a specific sub selection of marks and nodes. This
* will be the basis for adding advanced formatting to remirror.
*
* ```ts
* import { ExtensionTag } from 'remirror';
* import { createCoreManager, CorePreset } from 'remirror/extensions';
* import { WysiwygPreset } from 'remirror/extensions';
*
* const manager = createCoreManager(() => [new WysiwygPreset(), new CorePreset()], {
* extraAttributes: [
* {
* identifiers: {
* tags: [ExtensionTag.NodeBlock],
* type: 'node',
* },
* attributes: { role: 'presentation' },
* },
* ],
* });
* ```
*
* Each item in the tags array should be read as an `OR` so the following would
* match `Tag1` OR `Tag2` OR `Tag3`.
*
* ```json
* { tags: ["Tag1", "Tag2", "Tag3"] }
* ```
*
* The `type` property (`mark | node`) is exclusive and limits the type of
* extension names that will be matched. When `mark` is set it only matches with
* marks.
*/
declare interface IdentifiersObject {
/**
* Determines how the array of tags are combined:
*
* - `all` - the extension only matches when all tags are present.
* - `any` - the extension will match if it includes any of the specified
* tags.
*
* This only affects the `tags` property.
*
* The saddest part about this property is that, as a UK resident, I've
* succumbed to using the Americanized spelling instead of the Oxford
* Dictionary defined spelling of `behaviour` 😢
*
* @defaultValue 'any'
*/
behavior?: 'all' | 'any';
/**
* Will find relevant names based on the defined `behaviour`.
*/
tags?: ExtensionTagType[];
/**
* Additional names to include. These will still be added even if the
* extension name matches with `excludeTags` member.
*/
names?: string[];
/**
* Whether to restrict by whether this is a [[`ProsemirrorNode`]] or a
* [[`Mark`]]. Leave blank to accept all types.
*/
type?: 'node' | 'mark';
/**
* Exclude these names from being matched.
*/
excludeNames?: string[];
/**
* Exclude these tags from being matched. Will always exclude if any of the
* tags
*/
excludeTags?: string[];
}
export { IdentifiersObject }
export { IdentifiersObject as IdentifiersObject_alias_1 }
export { IdentifiersObject as IdentifiersObject_alias_2 }
export { IfEmpty }
export { IfHasRequiredProperties }
export { IfMatches }
export { IfNoRequiredProperties }
declare const IGNORE = "__IGNORE__";
export { includes }
export { IndexUnionFromTuple }
declare interface InlinePlaceholder<Data = any> extends BasePlaceholder, Partial<FromToProps>, DataProps<Data> {
type: 'inline';
}
export { InputRule }
/**
* This extension allows others extension to add the `createInputRules` method
* for automatically transforming text when a certain regex pattern is typed.
*
* @remarks
*
* This is an example of adding custom functionality to an extension via the
* `ExtensionParameterMethods`.
*
* @category Builtin Extension
*/
declare class InputRulesExtension extends PlainExtension<InputRulesOptions> {
get name(): "inputRules";
/**
* Add the extension store method for rebuilding all input rules.
*/
onCreate(): void;
/**
* Add the `inputRules` plugin to the editor.
*/
createExternalPlugins(): ProsemirrorPlugin[];
private generateInputRulesPlugin;
/**
* The method for rebuilding all the input rules.
*
* 1. Rebuild inputRules.
* 2. Replace the old input rules plugin.
* 3. Update the plugins used in the state (triggers an editor update).
*/
private rebuildInputRules;
}
export { InputRulesExtension }
export { InputRulesExtension as InputRulesExtension_alias_1 }
export { InputRulesExtension as InputRulesExtension_alias_2 }
declare interface InputRulesOptions {
/**
* Handlers which can be registered to check whether an input rule should be
* active at this time.
*
* The handlers are given a parameter with the current `state`, the `fullMatch`
* and the `captureGroup` and can determine whether the input rule should
* still be run.
*
* Return `true` to prevent any active input rules from being triggered.
*/
shouldSkipInputRule?: Handler<ShouldSkipFunction>;
}
export { InputRulesOptions }
export { InputRulesOptions as InputRulesOptions_alias_1 }
export { InputRulesOptions as InputRulesOptions_alias_2 }
declare interface InsertNodeOptions {
attrs?: ProsemirrorAttributes;
marks?: Array<Mark_2 | string | MarkType>;
/**
* The content to insert.
*/
content?: Fragment | ProsemirrorNode | ProsemirrorNode[] | string;
/**
* @deprecated use selection property instead.
*/
range?: FromToProps;
/**
* Set the selection where the command should occur.
*/
selection?: PrimitiveSelection;
/**
* Set this to true to replace an empty parent block with this content (if the
* content is a block node).
*/
replaceEmptyParentBlock?: boolean;
}
export { InsertNodeOptions }
export { InsertNodeOptions as InsertNodeOptions_alias_1 }
export { InsertNodeOptions as InsertNodeOptions_alias_2 }
/**
* Insert text into the dom at the current location by default. If a promise is
* provided then the text will be inserted at the tracked position when the
* promise is resolved.
*/
declare function insertText(text: string, options?: InsertTextOptions): CommandFunction;
export { insertText }
export { insertText as insertText_alias_1 }
export declare interface InsertTextOptions extends Partial<FromToProps> {
/**
* Marks can be added to the inserted text.
*/
marks?: Record<string, ProsemirrorAttributes>;
}
export { InvalidContentBlock }
export { InvalidContentHandler }
export { InvalidContentHandlerProps }
export { invariant }
export { isAllSelection }
export { isAndroidOS }
export { isArray }
export { isBoolean }
export { isChrome }
export { isClass }
export { isDate }
export { isDefaultBlockNode }
export { isDefaultDocNode }
/**
* Returns `true` when the provided value is a delayed value.
*/
declare function isDelayedValue<Type>(value: unknown): value is DelayedValue<Type>;
export { isDelayedValue }
export { isDelayedValue as isDelayedValue_alias_1 }
export { isDirectInstanceOf }
export { isDocNode }
export { isDocNodeEmpty }
export { isDomNode }
export { isEditorSchema }
export { isEditorState }
export { isElementDomNode }
export { isEmptyArray }
export { isEmptyBlockNode }
export { isEmptyObject }
export { isEndOfTextBlock }
export { isEqual }
export { isError }
/**
* Determines if the passed value is an extension.
*
* @param value - the value to test
*/
declare function isExtension<Type extends AnyExtension = AnyExtension>(value: unknown): value is Type;
export { isExtension }
export { isExtension as isExtension_alias_1 }
export { isExtension as isExtension_alias_2 }
/**
* Determines if the passed value is an extension constructor.
*
* @param value - the value to test
*/
declare function isExtensionConstructor<Type extends AnyExtensionConstructor = AnyExtensionConstructor>(value: unknown): value is Type;
export { isExtensionConstructor }
export { isExtensionConstructor as isExtensionConstructor_alias_1 }
export { isExtensionConstructor as isExtensionConstructor_alias_2 }
/**
* Check if the provided string is an extension tag.
*/
declare function isExtensionTag(value: string): value is ExtensionTagType;
export { isExtensionTag }
export { isExtensionTag as isExtensionTag_alias_1 }
export { isExtensionTag as isExtensionTag_alias_2 }
export { isFunction }
export { isIdentifierOfType }
export { isInstanceOf }
export { isInteger }
export { isJSONPrimitive }
export { isMap }
export { isMarkActive }
/**
* Determines if the passed in extension is a mark extension. Useful as a type
* guard where a particular type of extension is needed.
*
* @param value - the extension to check
*/
declare function isMarkExtension<Type extends AnyMarkExtension = AnyMarkExtension>(value: unknown): value is Type;
export { isMarkExtension }
export { isMarkExtension as isMarkExtension_alias_1 }
export { isMarkExtension as isMarkExtension_alias_2 }
export { isMarkType }
export declare interface IsNameUniqueProps {
/**
* The name to check against
*/
name: string;
/**
* The set to check within
*/
set: Set<string>;
/**
* The error code to use
*
* @defaultValue 'extension'
*/
code: ErrorConstant.DUPLICATE_HELPER_NAMES | ErrorConstant.DUPLICATE_COMMAND_NAMES;
}
export { isNativePromise }
export { isNodeActive }
/**
* Determines if the passed in extension is a node extension. Useful as a type
* guard where a particular type of extension is needed.
*
* @param value - the extension to check
*/
declare function isNodeExtension<Type extends AnyNodeExtension = AnyNodeExtension>(value: unknown): value is Type;
export { isNodeExtension }
export { isNodeExtension as isNodeExtension_alias_1 }
export { isNodeExtension as isNodeExtension_alias_2 }
export { isNodeOfType }
export { isNodeSelection }
export { isNodeType }
export { isNonEmptyArray }
export { isNull }
export { isNullOrUndefined }
export { isNumber }
export { isObject }
/**
* Checks whether the provided value is a plain extension.
*
* @param value - the extension to check
*/
declare function isPlainExtension<Type extends AnyPlainExtension = AnyPlainExtension>(value: unknown): value is Type;
export { isPlainExtension }
export { isPlainExtension as isPlainExtension_alias_1 }
export { isPlainExtension as isPlainExtension_alias_2 }
export { isPlainObject }
export { isPrimitive }
export { isPromise }
export { isProsemirrorFragment }
export { isProsemirrorMark }
export { isProsemirrorNode }
export { isRegExp }
export { isRemirrorJSON }
/**
* Checks to see whether the provided value is a `RemirrorManager` instance.
*
* An optional parameter `mustIncludeList` is available if you want to check
* that the manager includes all the listed extensions.
*
* @param value - the value to check
* @param mustIncludeList - an array of presets and extension the manager must
* include to pass the test. The identifier can either be the Extension / Preset
* name e.g. `bold`, or the Extension / Preset constructor `BoldExtension`
*/
declare function isRemirrorManager<Extension extends AnyExtension = AnyExtension>(value: unknown, mustIncludeList?: Array<AnyExtensionConstructor | string>): value is RemirrorManager<Extension>;
export { isRemirrorManager }
export { isRemirrorManager as isRemirrorManager_alias_1 }
export { isRemirrorManager as isRemirrorManager_alias_2 }
export { isRemirrorType }
export { isResolvedPos }
export { isSafari }
export { isSafeInteger }
export { isSelection }
export { isSelectionEmpty }
export { isSet }
export { isStartOfDoc }
export { isStartOfTextBlock }
export { isString }
export { isSymbol }
export { isTextDomNode }
export { isTextSelection }
export { isTransaction }
export { isUndefined }
export { IterableElement }
export { joinStyles }
export { JsonArray }
export { JsonObject }
export { JsonPrimitive }
export { JsonValue }
export { KebabCase }
export { kebabCase }
export { KeepPartialProperties }
/**
* A decorator which can be applied to an extension method to
* identify as a key binding method. This can be used as a replacement for
* the `createKeymap` method depending on your preference.
*
* If you prefer not to use decorators, then you can continue using
* `createKeymap`.
*
* @category Method Decorator
*/
declare function keyBinding<Extension extends AnyExtension>(options: KeybindingDecoratorOptions<Required<GetOptions<Extension>>>): (method: KeyBindingCommandFunction, context: ClassMethodDecoratorContext<Extension>) => KeyBindingCommandFunction;
export { keyBinding }
export { keyBinding as keyBinding_alias_1 }
export { keyBinding as keyBinding_alias_2 }
export { KeyBindingCommandFunction }
declare interface KeybindingDecoratorOptions<Options extends Shape = Shape> {
/**
* The keypress sequence to intercept.
*
* - `Enter`
* - `Shift-Enter`
*/
shortcut: KeyboardShortcut;
/**
* This can be used to set a keybinding as inactive based on the provided
* options.
*/
isActive?: (options: Options, store: Remirror.ExtensionStore) => boolean;
/**
* The priority for this keybinding.
*/
priority?: ExtensionPriority | ((options: Options, store: Remirror.ExtensionStore) => ExtensionPriority);
/**
* The name of the command that the keybinding should be attached to.
*/
command?: Remirror.AllUiCommandNames;
}
export { KeybindingDecoratorOptions }
export { KeybindingDecoratorOptions as KeybindingDecoratorOptions_alias_1 }
export { KeybindingDecoratorOptions as KeybindingDecoratorOptions_alias_2 }
declare interface KeyBindingMetadata {
type: 'keyBinding';
/**
* The name of the extension used.
*/
extension: string;
/**
* The shortcut used to invoke this keybinding.
*/
shortcut: string;
}
export { KeyBindingNames }
export { KeyBindingProps }
export { KeyBindings }
/**
* KeyBindings as a tuple with priority and the keymap.
*/
declare type KeyBindingsTuple = [priority: ExtensionPriority, bindings: KeyBindings];
export { KeyBindingsTuple }
export { KeyBindingsTuple as KeyBindingsTuple_alias_1 }
export { KeyBindingsTuple as KeyBindingsTuple_alias_2 }
declare type KeyboardShortcut = KeyboardShortcutValue | KeyboardShortcutFunction;
export { KeyboardShortcut }
export { KeyboardShortcut as KeyboardShortcut_alias_1 }
export { KeyboardShortcut as KeyboardShortcut_alias_2 }
declare type KeyboardShortcutFunction<Options extends Shape = Shape> = (options: Options, store: Remirror.ExtensionStore) => KeyboardShortcut;
export { KeyboardShortcutFunction }
export { KeyboardShortcutFunction as KeyboardShortcutFunction_alias_1 }
export { KeyboardShortcutFunction as KeyboardShortcutFunction_alias_2 }
declare type KeyboardShortcuts = keyof typeof keyboardShortcuts | ShortcutMap;
export { KeyboardShortcuts }
export { KeyboardShortcuts as KeyboardShortcuts_alias_1 }
export { KeyboardShortcuts as KeyboardShortcuts_alias_2 }
declare const keyboardShortcuts: {
default: ShortcutMap;
googleDoc: ShortcutMap;
};
export { keyboardShortcuts }
export { keyboardShortcuts as keyboardShortcuts_alias_1 }
export { keyboardShortcuts as keyboardShortcuts_alias_2 }
declare type KeyboardShortcutValue = Listable<LiteralUnion<'Enter' | 'ArrowDown' | 'ArrowUp' | 'ArrowLeft' | 'ArrowRight' | 'Escape' | 'Delete' | 'Backspace', string>>;
export { KeyboardShortcutValue }
export { KeyboardShortcutValue as KeyboardShortcutValue_alias_1 }
export { KeyboardShortcutValue as KeyboardShortcutValue_alias_2 }
/**
* This extension allows others extension to use the `createKeymaps` method.
*
* @remarks
*
* Keymaps are the way of controlling how the editor responds to a keypress and
* different key combinations.
*
* Without this extension most of the shortcuts and behaviors we have come to
* expect from text editors would not be provided.
*
* @category Builtin Extension
*/
declare class KeymapExtension extends PlainExtension<KeymapOptions> {
get name(): "keymap";
/**
* The custom keybindings added by the handlers. In react these can be added
* via `hooks`.
*/
private extraKeyBindings;
/**
* Track the backward exits from a mark to allow double tapping the left arrow
* to move to the previous block node.
*/
private readonly backwardMarkExitTracker;
/**
* The underlying keydown handler.
*/
private keydownHandler;
/**
* Get the shortcut map.
*/
private get shortcutMap();
/**
* This adds the `createKeymap` method functionality to all extensions.
*/
onCreate(): void;
/** Add the created keymap to the available plugins. */
createExternalPlugins(): ProsemirrorPlugin[];
private setupKeydownHandler;
/**
* Updates the stored keymap bindings on this extension.
*/
private generateKeymapBindings;
/**
* Handle exiting the mark forwards.
*/
arrowRightShortcut(props: KeyBindingProps): boolean;
/**
* Handle the arrow left key to exit the mark.
*/
arrowLeftShortcut(props: KeyBindingProps): boolean;
/**
* Handle exiting the mark forwards.
*/
backspace(props: KeyBindingProps): boolean;
/**
* Create the base keymap and give it a low priority so that all other keymaps
* override it.
*/
createKeymap(): PrioritizedKeyBindings;
/**
* Get the real shortcut name from the named shortcut.
*/
getNamedShortcut(shortcut: string, options?: Shape): Helper<string[]>;
/**
* @internalremarks
*
* Think about the case where bindings are disposed of and then added in a
* different position in the `extraKeyBindings` array. This is especially
* pertinent when using hooks.
*/
protected onAddCustomHandler: AddCustomHandler<KeymapOptions>;
/**
* Handle changes in the dynamic properties.
*/
protected onSetOptions(props: OnSetOptionsProps<KeymapOptions>): void;
private sortKeymaps;
/**
* The method for rebuilding all the extension keymaps.
*
* 1. Rebuild keymaps.
* 2. Replace `this.keydownHandler` with the new keydown handler.
*/
private readonly rebuildKeymap;
/**
* Exits the mark forwards when at the end of a block node.
*/
private exitMarkForwards;
private exitNodeBackwards;
/**
* Exit a mark when at the beginning of a block node.
*/
private exitMarkBackwards;
}
export { KeymapExtension }
export { KeymapExtension as KeymapExtension_alias_1 }
export { KeymapExtension as KeymapExtension_alias_2 }
declare interface KeymapOptions {
/**
* The shortcuts to use for named keybindings in the editor.
*
* @defaultValue 'default'
*/
shortcuts?: KeyboardShortcuts;
/**
* Determines whether a backspace after an input rule has been applied should
* reverse the effect of the input rule.
*
* @defaultValue true
*/
undoInputRuleOnBackspace?: boolean;
/**
* Determines whether the escape key selects the current node.
*
* @defaultValue false
*/
selectParentNodeOnEscape?: boolean;
/**
* When true will exclude the default prosemirror keymap.
*
* @remarks
*
* You might want to set this to true if you want to fully customise the
* keyboard mappings for your editor. Otherwise it is advisable to leave it
* unchanged.
*
* @defaultValue false
*/
excludeBaseKeymap?: boolean;
/**
* Whether to support exiting marks when the left and right array keys are
* pressed.
*
* Can be set to
*
* - `true` - enables exits from both the entrance and the end of the mark
*/
exitMarksOnArrowPress?: boolean;
/**
* The implementation for the extra keybindings added to the settings.
*
* @remarks
*
* This allows for you to add extra key mappings which will be checked before
* the default keymaps, if they return false then the default keymaps are
* still checked.
*
* No key mappings are removed in this process.
*
* ```ts
* const extension = BaseKeymapExtension.create({ keymap: {
* Enter({ state, dispatch }) {
* //... Logic
* return true;
* },
* }});
* ```
*/
keymap?: CustomHandler<PrioritizedKeyBindings>;
}
export { KeymapOptions }
export { KeymapOptions as KeymapOptions_alias_1 }
export { KeymapOptions as KeymapOptions_alias_2 }
export { keys }
export { last }
export { LEAF_NODE_REPLACING_CHARACTER }
/**
* A legacy decorator (pre Stage 3) which can be applied to top level methods
* on an extension to identify them as commands. This can be used as a
* replacement for the `createCommands` method.
*
* If you prefer not to use decorators, then you can continue using
* `createCommands`. Internally the decorators are being used as they are better
* for documentation purposes.
*
* For automated type inference methods that use this decorator must implement
* the following type signature.
*
* ```ts
* import { CommandFunction } from '@remirror/core';
*
* type Signature = (...args: any[]) => CommandFunction;
* ```
*
* The following is an example of how this can be used within your extension.
*
* ```ts
* import { legacyCommand, CommandFunction } from '@remirror/core';
*
* class MyExtension {
* get name() {
* return 'my';
* }
*
* @legacyCommand()
* myCommand(text: string): CommandFunction {
* return ({ tr, dispatch }) => {
* dispatch?.(tr.insertText('my command ' + text));
* return true;
* }
* }
* }
* ```
*
* The above command can now be used within your editor instance.
*
* ```tsx
* import { useRemirrorContext } from '@remirror/react';
*
* const MyEditorButton = () => {
* const { commands } = useRemirrorContext();
*
* return <button onClick={() => commands.myCommand('hello')}>My Button</button>
* }
* ```
*
* @category Method Decorator
* @deprecated legacy - please use the ES2023 decorator `@command`
*/
declare function legacyCommand<Extension extends AnyExtension>(options?: ChainableCommandDecoratorOptions<Required<GetOptions<Extension>>>): LegacyExtensionDecorator<Extension, CommandFunction, void>;
declare function legacyCommand<Extension extends AnyExtension>(options: NonChainableCommandDecoratorOptions<Required<GetOptions<Extension>>>): LegacyExtensionDecorator<Extension, NonChainableCommandFunction, void>;
export { legacyCommand }
export { legacyCommand as legacyCommand_alias_1 }
export { legacyCommand as legacyCommand_alias_2 }
declare type LegacyExtensionDecorator<Extension extends AnyExtension, Fn, Return> = (target: Extension, propertyKey: string, _descriptor: TypedPropertyDescriptor<AnyFunction<Fn>>) => Return;
export { LegacyExtensionDecorator }
export { LegacyExtensionDecorator as LegacyExtensionDecorator_alias_1 }
export { LegacyExtensionDecorator as LegacyExtensionDecorator_alias_2 }
/**
* A legacy decorator (pre Stage 3) which can be applied to top level methods
* on an extension to identify them as helpers. This can be used as a
* replacement for the `createHelpers` method.
*
* To allow the TypeScript compiler to automatically infer types, please create
* your methods with the following type signature.
*
* ```ts
* import { Helper } from '@remirror/core';
*
* type Signature = (...args: any[]) => Helper<SomeReturnType>;
* ```
*
* The following is an example of how this can be used within your extension.
*
* ```ts
* import { legacyHelper, Helper } from '@remirror/core';
*
* class MyExtension {
* get name() {
* return 'my';
* }
*
* @legacyHelper()
* alwaysTrue(): Helper<boolean> {
* return true;
* }
* }
* ```
*
* The above helper can now be used within your editor instance.
*
* ```tsx
* import { useRemirrorContext } from '@remirror/react';
*
* const MyEditorButton = () => {
* const { helpers } = useRemirrorContext();
*
* return helpers.alwaysTrue() ? <button>My Button</button> : null
* }
* ```
*
* @category Method Decorator
* @deprecated legacy - please use the ES2023 decorator `@helper`
*/
declare function legacyHelper(options?: HelperDecoratorOptions): <Extension extends AnyExtension, Type>(target: Extension, propertyKey: string, _descriptor: TypedPropertyDescriptor<AnyFunction<NonNullable<Type> extends HelperAnnotation ? Type : never>>) => void;
export { legacyHelper }
export { legacyHelper as legacyHelper_alias_1 }
export { legacyHelper as legacyHelper_alias_2 }
/**
* A legacy decorator (pre Stage 3) which can be applied to an extension
* method to identify as a key binding method. This can be used as a
* replacement for the `createKeymap` method depending on your
* preference.
*
* If you prefer not to use decorators, then you can continue using
* `createKeymap`.
*
* @category Method Decorator
* @deprecated legacy - please use the ES2023 decorator `@keyBinding`
*/
declare function legacyKeyBinding<Extension extends AnyExtension>(options: KeybindingDecoratorOptions<Required<GetOptions<Extension>>>): (target: Extension, propertyKey: string, _descriptor: TypedPropertyDescriptor<KeyBindingCommandFunction>) => void;
export { legacyKeyBinding }
export { legacyKeyBinding as legacyKeyBinding_alias_1 }
export { legacyKeyBinding as legacyKeyBinding_alias_2 }
export { lift }
export { Listable }
declare interface ListenerProps extends Partial<EditorStateProps>, Partial<TransactionProps> {
/**
* When the state updates are not controlled and it was a transaction that
* caused the state to be updated this value captures all the transaction
* updates caused by prosemirror plugins hook state methods like
* `filterTransactions` and `appendTransactions`.
*
* This is for advanced users only.
*/
transactions?: readonly Transaction[];
}
export { ListenerProps }
export { ListenerProps as ListenerProps_alias_1 }
export { ListenerProps as ListenerProps_alias_2 }
export { Literal }
export { LiteralUnion }
export { MakeNullable }
export { MakeOptional }
export { MakeReadonly }
export { MakeRequired }
export { MakeUndefined }
declare interface ManagerEvents {
/**
* Called when the state is updated.
*/
stateUpdate: (props: StateUpdateLifecycleProps) => void;
/**
* Called whenever the manager is cloned with the newly created manager
* instance.
*
* This is mainly used for testing so that the RemirrorTester can always
* reference the latest manager.
*/
clone: (manager: AnyRemirrorManager) => void;
/**
* Called whenever the manager is recreated with the newly created manager
* instance.
*
* This is mainly used for testing so that the RemirrorTester can always
* reference the latest manager.
*/
recreate: (manager: AnyRemirrorManager) => void;
/**
* An event listener which is called whenever the manager is destroyed.
*/
destroy: () => void;
}
export { ManagerEvents }
export { ManagerEvents as ManagerEvents_alias_1 }
export { ManagerEvents as ManagerEvents_alias_2 }
export declare interface ManagerLifecycleHandlers {
/**
* Contains the methods run when the manager is first created.
*/
create: Array<() => Dispose | void>;
/**
* Holds the methods to run once the Editor has received the view from the
* attached.
*/
view: Array<(view: EditorView) => Dispose | void>;
/**
* The update method is called every time the state updates. This allows
* extensions to listen to updates.
*/
update: Array<(props: StateUpdateLifecycleProps) => void>;
/**
* Called when the manager is being destroyed.
*/
destroy: Array<() => void>;
}
export { ManagerPhase }
declare type ManagerStoreKeys = keyof Remirror.ManagerStore<any>;
export { ManagerStoreKeys }
export { ManagerStoreKeys as ManagerStoreKeys_alias_1 }
export { ManagerStoreKeys as ManagerStoreKeys_alias_2 }
/**
* A utility type which maps the passed in extension helpers to a method called
* with `manager.data.helpers.helperName()`.
*/
declare type MapHelpers<RawHelpers extends Record<string, AnyFunction>> = {
[Helper in keyof RawHelpers]: RawHelpers[Helper];
};
export { MapHelpers }
export { MapHelpers as MapHelpers_alias_1 }
export { MapHelpers as MapHelpers_alias_2 }
declare type MappedHandlerKeyOptions<Options extends Shape = EmptyShape> = {
[Key in keyof GetHandler<Options>]?: HandlerKeyOptions<ReturnType<GetHandler<Options>[Key]>, Parameters<GetHandler<Options>[Key]>>;
} & {
__ALL__?: HandlerKeyOptions;
};
export { Mapping }
/**
* A utility type which maps the chained commands.
*/
declare type MapToChainedCommand<RawCommands extends Record<string, AnyFunction>> = {
[Command in keyof RawCommands]: ReturnType<RawCommands[Command]> extends NonChainableCommandFunction ? void : (...args: Parameters<RawCommands[Command]>) => any;
};
export { MapToChainedCommand }
export { MapToChainedCommand as MapToChainedCommand_alias_1 }
export { MapToChainedCommand as MapToChainedCommand_alias_2 }
/**
* A utility type which maps the passed in extension command in an action that
* is store in the `manager.store.actions.commandName()`.
*/
declare type MapToUnchainedCommand<RawCommands extends Record<string, AnyFunction>> = {
[Command in keyof RawCommands]: CommandShape<Parameters<RawCommands[Command]>>;
};
export { MapToUnchainedCommand }
export { MapToUnchainedCommand as MapToUnchainedCommand_alias_1 }
export { MapToUnchainedCommand as MapToUnchainedCommand_alias_2 }
export { Mark }
export { markEqualsType }
/**
* A mark extension is based on the `Mark` concept from from within prosemirror
* {@link https://prosemirror.net/docs/guide/#schema.marks}
*
* @remarks
*
* Marks are used to add extra styling or other information to inline content.
* Mark types are objects much like node types, used to tag mark objects and
* provide additional information about them.
*/
declare abstract class MarkExtension<Options extends ValidOptions = EmptyShape> extends Extension<Options> {
/** @internal */
static get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.MarkExtensionConstructor;
/**
* Whether to disable extra attributes for this extension.
*/
static readonly disableExtraAttributes: boolean;
/** @internal */
get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.MarkExtension;
/**
* Provides access to the mark type from the schema.
*
* @remarks
*
* The type is available as soon as the schema is created by the
* `SchemaExtension` which has the priority `Highest`. It should be safe to
* access in any of the lifecycle methods.
*/
get type(): MarkType;
constructor(...args: ExtensionConstructorProps<Options>);
/**
* Provide a method for creating the schema. This is required in order to
* create a `MarkExtension`.
*
* @remarks
*
* The main difference between the return value of this method and Prosemirror
* `MarkSpec` is that that the `toDOM` method doesn't allow dom manipulation.
* You can only return an array or string.
*
* For more advanced requirements, it may be possible to create a `nodeView`
* to manage the dom interactions.
*/
abstract createMarkSpec(extra: ApplySchemaAttributes, override: MarkSpecOverride): MarkExtensionSpec;
}
declare interface MarkExtension<Options extends ValidOptions = EmptyShape> extends Extension<Options>, Remirror.MarkExtension {
}
export { MarkExtension }
export { MarkExtension as MarkExtension_alias_1 }
export { MarkExtension as MarkExtension_alias_2 }
export { MarkExtensionSpec }
export { markInputRule }
export { MarkSpecOverride }
export { MarkType }
export { MarkTypeProps }
export { MarkTypesProps }
export { MarkWithAttributes }
export { MarkWithAttributesProps }
export { Merge }
export { mergeDOMRects }
export { MergeExclusive }
export { mergeKeyBindings }
export { mergeProsemirrorKeyBindings }
declare type Metadata = CommandMetadata | KeyBindingMetadata;
export { Metadata }
export { Metadata as Metadata_alias_1 }
export { Metadata as Metadata_alias_2 }
/**
* Support meta data for commands and key bindings.
*
* Metadata is dded to all commands and keybindings and that information is
* provided to the `onChange` handle whenever the state is updated.
*
* @internalremarks
*
* TODO capture keybindings as well. This will be more difficult since
* keybindings can dynamically be added to the editor.
*/
declare class MetaExtension extends PlainExtension<MetaOptions> {
get name(): "meta";
onCreate(): void;
/**
* This is here to provide a
*/
createPlugin(): CreateExtensionPlugin;
/**
* Intercept command names and attributes.
*/
private captureCommands;
/**
* Intercept command name and attributes.
*/
private captureKeybindings;
/**
* Get the command metadata.
*/
private getCommandMeta;
private setCommandMeta;
}
export { MetaExtension }
export { MetaExtension as MetaExtension_alias_1 }
export { MetaExtension as MetaExtension_alias_2 }
declare interface MetaOptions {
/**
* Set to true to capture meta data on commands and keybindings. This creates
* a wrapper around every command and keybinding and as a result it may lead
* to a performance penalty.
*/
capture?: Static<boolean>;
}
export { MetaOptions }
export { MetaOptions as MetaOptions_alias_1 }
export { MetaOptions as MetaOptions_alias_2 }
export { MinArray }
/**
* Mutate the default extension options.
*
* @remarks
*
* This is a dangerous method since it allows you to mutate the received object.
* Don't use it unless you absolutely have to.
*
* A potential use case is for adding a new default option to all extensions. It
* shows an example of how to accomplish this in a typesafe way.
*
* ```ts
* import { mutateDefaultExtensionOptions } from 'remirror';
*
* mutateDefaultExtensionOptions((settings) => {
* // Set the default value of all extensions to have a property `customSetting` with value `false`.
* settings.customSetting = false;
* })
*
* declare global {
* namespace Remirror {
* interface BaseExtensionOptions {
* customSetting?: boolean;
* }
* }
* }
*```
*
* The mutation must happen before any extension have been instantiated.
*/
declare function mutateDefaultExtensionOptions(mutatorMethod: (defaultOptions: BaseExtensionOptions) => void): void;
export { mutateDefaultExtensionOptions }
export { mutateDefaultExtensionOptions as mutateDefaultExtensionOptions_alias_1 }
export { mutateDefaultExtensionOptions as mutateDefaultExtensionOptions_alias_2 }
export { mutateTag }
export { NamedShortcut }
export { NamedStringHandlers }
declare interface NewChainedCommandProps<Extension extends AnyExtension, Chained extends ChainedIntersection<Extension> = ChainedIntersection<Extension>> {
/**
* Returns a new chain, with an empty command set.
*
* ```ts
* chain.toggleBold();
* chain.new().toggleItalic().run(); // Only toggleItalic would be run
* ```
*/
new: (tr?: Transaction) => ChainedFromExtensions<Extension, Chained>;
}
export { NewChainedCommandProps }
export { NewChainedCommandProps as NewChainedCommandProps_alias_1 }
export { NewChainedCommandProps as NewChainedCommandProps_alias_2 }
/**
* Defines the abstract class for extensions which can place nodes into the
* prosemirror state.
*
* @remarks
*
* For more information see {@link https://prosemirror.net/docs/ref/#model.Node}
*/
declare abstract class NodeExtension<Options extends ValidOptions = EmptyShape> extends Extension<Options> {
static get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.NodeExtensionConstructor;
/**
* Whether to disable extra attributes for this extension.
*/
static readonly disableExtraAttributes: boolean;
/** @internal */
get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.NodeExtension;
/**
* Provides access to the node type from the schema.
*/
get type(): NodeType;
constructor(...args: ExtensionConstructorProps<Options>);
/**
* Provide a method for creating the schema. This is required in order to
* create a `NodeExtension`.
*
* @remarks
*
* A node schema defines the behavior of the content within the editor. This
* is very tied to the prosemirror implementation and the best place to learn
* more about it is in the
* {@link https://prosemirror.net/docs/guide/#schema docs}.
*
* @params hole - a method that is meant to indicate where extra attributes
* should be placed (if they exist).
*
* The `hole` is a function that augments the passed object adding a special
* `secret` key which is used to insert the extra attributes setter.
*
* ```ts
* import { NodeExtension, SpecHole } from 'remirror';
*
* class AwesomeExtension extends NodeExtension {
* get name() { return 'awesome' as const'; }
*
* createNodeSpec() {
* return {
* toDOM: (node) => {
* return ['p', hole(), 0]
* }
* }
* }
* }
* ```
*
* The above example will have the `hole()` method call replaced with the
* extra attributes.
*/
abstract createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
}
declare interface NodeExtension<Options extends ValidOptions = EmptyShape> extends Extension<Options>, Remirror.NodeExtension {
}
export { NodeExtension }
export { NodeExtension as NodeExtension_alias_1 }
export { NodeExtension as NodeExtension_alias_2 }
export { NodeExtensionSpec }
export { nodeInputRule }
export { NodeMarkOptions }
declare interface NodePlaceholder<Data = any> extends BasePlaceholder, DataProps<Data> {
/**
* Set this as a node tracker.
*/
type: 'node';
/**
* If provided the The `pos` must be directly before the node in order to be
* valid. If not provided it will select the parent node of the current
* selection.
*/
pos: number | null;
}
export { NodeSpecOverride }
export { NodeStringHandlerOptions }
export { NodeType }
export { NodeTypeProps }
export { NodeTypesProps }
export { NodeView }
export { NodeViewMethod }
/**
* This extension allows others extension to add the `createNodeView` method
* for creating nodeViews which alter how the dom is rendered for the node.
*
* @remarks
*
* This is an example of adding custom functionality to an extension via the
* `ExtensionParameterMethods`.
*
* @category Builtin Extension
*/
declare class NodeViewsExtension extends PlainExtension {
get name(): "nodeViews";
createPlugin(): CreateExtensionPlugin;
}
export { NodeViewsExtension }
export { NodeViewsExtension as NodeViewsExtension_alias_1 }
export { NodeViewsExtension as NodeViewsExtension_alias_2 }
export { NodeWithAttributes }
export { NodeWithAttributesProps }
export { NodeWithPosition }
export { NON_BREAKING_SPACE_CHAR }
export { nonChainable }
declare interface NonChainableCommandDecoratorOptions<Options extends Shape> extends Remirror.CommandDecoratorOptions<Options> {
/**
* Set this to `true` to disable chaining of this command. This means it will
* no longer be available when running `
*
* @defaultValue false
*/
disableChaining: true;
}
export { NonChainableCommandFunction }
export { NonNullableShape }
export { noop }
export { NULL_CHARACTER }
export { Nullable }
export { object }
export { ObjectMark }
export { ObservableLike }
export { omit }
export { omitExtraAttributes }
export { omitUndefined }
declare interface OnSetOptionsProps<Options extends ValidOptions> extends Pick<GetChangeOptionsReturn<Options>, 'changes' | 'pickChanged'>, UpdateReasonProps {
/**
* The initial options for the extension. Falls back to default options.
*/
initialOptions: RemoveAnnotations<GetFixedDynamic<Options>>;
/**
* The next value of the properties after the update.This also includes values
* which have not been changed.
*/
options: RemoveAnnotations<GetFixedDynamic<Options>>;
}
export { OnSetOptionsProps }
export { OnSetOptionsProps as OnSetOptionsProps_alias_1 }
export { Opaque }
export { OptionalMarkProps }
export { OptionalProsemirrorNodeProps }
/**
* Get the options from any constructor. Can be used for both presets and
* extensions.
*/
declare type OptionsOfConstructor<Constructor extends AnyConstructor> = GetOptions<InstanceType<Constructor>>;
export { OptionsOfConstructor }
export { OptionsOfConstructor as OptionsOfConstructor_alias_1 }
export { PackageJson }
export { ParsedDomSize }
export { parseSizeUnit }
export { PartialDeep }
export { PartialWithRequiredKeys }
export { PascalCase }
export { pascalCase }
/**
* This extension allows others extension to add the `createPasteRules` method
* for automatically transforming pasted text which matches a certain regex
* pattern in the dom.
*
* @category Builtin Extension
*/
declare class PasteRulesExtension extends PlainExtension {
get name(): "pasteRules";
createExternalPlugins(): ProsemirrorPlugin[];
private generatePasteRulesPlugin;
}
export { PasteRulesExtension }
export { PasteRulesExtension as PasteRulesExtension_alias_1 }
export { PasteRulesExtension as PasteRulesExtension_alias_2 }
declare interface PasteRulesOptions {
}
export { PasteRulesOptions }
export { PasteRulesOptions as PasteRulesOptions_alias_1 }
export { PasteRulesOptions as PasteRulesOptions_alias_2 }
export { pathCase }
export { pick }
declare type PickChanged<Options extends ValidOptions> = <Key extends keyof GetFixedDynamic<Options>>(keys: Key[]) => Partial<Pick<GetFixedDynamic<Options>, Key>>;
export { PickChanged }
export { PickChanged as PickChanged_alias_1 }
export { PickPartial }
export { PickRequired }
declare interface PlaceholderConfig extends TextProps {
className: string;
}
export { PlaceholderConfig }
export { PlaceholderConfig as PlaceholderConfig_alias_1 }
export { PlaceholderConfig as PlaceholderConfig_alias_2 }
export declare type PlaceholderPluginAction = AddPlaceholderAction | RemovePlaceholderAction;
/**
* Create a plain extension which doesn't directly map to Prosemirror nodes or
* marks.
*
* Plain extensions are a great way to add custom behavior to your editor.
*/
declare abstract class PlainExtension<Options extends ValidOptions = EmptyShape> extends Extension<Options> {
/** @internal */
static get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.PlainExtensionConstructor;
/** @internal */
get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.PlainExtension;
}
export { PlainExtension }
export { PlainExtension as PlainExtension_alias_1 }
export { PlainExtension as PlainExtension_alias_2 }
export { plainInputRule }
export { PluginKey }
/**
* This extension allows others extension to add the `createPlugin` method using
* Prosemirror Plugins.
*
* @remarks
*
* This is an example of adding custom functionality to an extension via the
* `ExtensionParameterMethods`.
*
* @category Builtin Extension
*/
declare class PluginsExtension extends PlainExtension<PluginsOptions> {
get name(): "plugins";
/**
* All plugins created by other extension as well.
*/
private plugins;
/**
* The plugins added via the manager (for reference only).
*/
private managerPlugins;
/**
* Called when the state is is being applied after an update.
*/
private readonly applyStateHandlers;
/**
* Called when the state is first initialized.
*/
private readonly initStateHandlers;
/**
* Handlers for the `onAppendTransaction` lifecycle method.
*/
private readonly appendTransactionHandlers;
/**
* Store the plugin keys.
*/
private readonly pluginKeys;
/**
* Store state getters for the extension.
*/
private readonly stateGetters;
/**
* This extension is responsible for adding state to the editor.
*/
onCreate(): void;
/**
* Create a plugin which adds the [[`onInitState`]] and [[`onApplyState`]]
* lifecycle methods.
*/
createPlugin(): CreateExtensionPlugin<void>;
/**
* Get all the plugins from the extension.
*/
private extractExtensionPlugins;
private readonly getPluginStateCreator;
/**
* Add or replace a plugin.
*/
private updatePlugins;
private readonly getStateByName;
/**
* Add the plugin specific properties and methods to the manager and extension
* store.
*/
private updateExtensionStore;
/**
* Reruns the `createPlugin` and `createExternalPlugins` methods of the
* provided extension.
*
* ```ts
* // From within an extension
* this.store.updateExtensionPlugins(this);
* ```
*/
private updateExtensionPlugins;
/**
* Applies the store plugins to the state. If any have changed then it will be
* updated.
*/
private dispatchPluginUpdate;
}
export { PluginsExtension }
export { PluginsExtension as PluginsExtension_alias_1 }
export { PluginsExtension as PluginsExtension_alias_2 }
declare interface PluginsOptions {
/**
* The event handler which can be used by hooks to listen to state updates
* when they are being applied to the editor.
*/
applyState?: Handler<(props: ApplyStateLifecycleProps) => void>;
/**
* The event handler which can be used by hooks to listen to intercept updates
* to the transaction.
*/
appendTransaction?: Handler<(props: AppendLifecycleProps) => void>;
}
export { PluginsOptions }
export { PluginsOptions as PluginsOptions_alias_1 }
export { PluginsOptions as PluginsOptions_alias_2 }
export { PosProps }
export { Predicate }
export { PredicateProps }
export { preserveSelection }
export { Primitive }
export { PrimitiveSelection }
/**
* `KeyBindings` as an object or prioritized tuple.
*/
declare type PrioritizedKeyBindings = KeyBindings | KeyBindingsTuple;
export { PrioritizedKeyBindings }
export { PrioritizedKeyBindings as PrioritizedKeyBindings_alias_1 }
export { PrioritizedKeyBindings as PrioritizedKeyBindings_alias_2 }
export { Promisable }
export { ProsemirrorAttributes }
export { ProsemirrorCommandFunction }
export { ProsemirrorKeyBindings }
export { ProsemirrorNode }
export { ProsemirrorNodeProps }
export { prosemirrorNodeToDom }
export { prosemirrorNodeToHtml }
export { ProsemirrorPlugin }
export { randomFloat }
export { randomInt }
export { range }
export { rangeHasMark }
export { RangeProps }
export { ReadonlyDeep }
export { RegExpProps }
export { REMIRROR_WEBVIEW_NAME }
export { RemirrorContentType }
export { RemirrorError }
export { RemirrorErrorOptions }
declare type RemirrorEventListener<Extension extends AnyExtension> = (params: RemirrorEventListenerProps<Extension>) => void;
export { RemirrorEventListener }
export { RemirrorEventListener as RemirrorEventListener_alias_1 }
export { RemirrorEventListener as RemirrorEventListener_alias_2 }
declare interface RemirrorEventListenerProps<Extension extends AnyExtension> extends EditorStateProps, Remirror.ListenerProperties<Extension>, EditorViewProps {
/**
* The original transaction which caused this state update.
*
* This allows for inspecting the reason behind the state change. When
* undefined this means that the state was updated externally.
*
* If available:
* - Metadata on the transaction can be inspected. `tr.getMeta`
* - Was the change caused by added / removed content? `tr.docChanged`
* - Was ths change caused by an updated selection? `tr.selectionSet`
* - `tr.steps` can be inspected for further granularity.
*/
tr?: Transaction;
/**
* When the state updates are not controlled and it was a transaction that
* caused the state to be updated this value captures all the transaction
* updates caused by prosemirror plugins hook state methods like
* `filterTransactions` and `appendTransactions`.
*
* This is for advanced users only.
*/
transactions?: readonly Transaction[];
/**
* A shorthand way of checking whether the update was triggered by editor
* usage (internal) or overwriting the state.
*
* - `true` The update was triggered by a change in the prosemirror doc or an
* update to the selection. In these cases `tr` will have a value.
* - `false` The update was caused by a call to `setContent` or `resetContent`
*/
internalUpdate: boolean;
/**
* True when this is the first render of the editor. This applies when the
* editor is first attached to the DOM.
*/
firstRender: boolean;
/**
* The previous state.
*/
previousState: EditorState;
/**
* Manually create a new state object with the desired content.
*/
createStateFromContent: CreateStateFromContent;
}
export { RemirrorEventListenerProps }
export { RemirrorEventListenerProps as RemirrorEventListenerProps_alias_1 }
export { RemirrorEventListenerProps as RemirrorEventListenerProps_alias_2 }
export { RemirrorIdentifier }
export { RemirrorIdentifierShape }
export { RemirrorJSON }
/**
* The `Manager` has multiple hook phases which are able to hook into the
* extension manager flow and add new functionality to the editor.
*
* The `ExtensionEventMethod`s
*
* - onCreate - when the extension manager is created and after the schema is
* made available.
* - onView - when the view has been received from the dom ref.
*/
/**
* A class to manage the extensions and prosemirror interactions within the
* editor.
*
* @remarks
*
* The RemirrorManager enables the lifecycle methods of the extensions by
* calling each method in the distinct phases of the lifecycle.
*
* - `onCreate` - This happens when the manager is constructed. It calls on the
* extension which have an `onCreate` method and allows them to do their work.
*
* For the built in methods, this is when the `SchemaExtension` creates the
* Schema and when the `TagsExtension` combines the tags for the editor
* instance.
*
* ```ts
* const manager = Manager.create(() => [
* new DocExtension(),
* new TextExtension(),
* new ParagraphExtension(),
* ])
* ```
*
* At this point all the `onCreate` methods have been called. Including the
* `onCreate` for the `Schema`.
*
* - `onView` - This is called the framework instance connects the
* `RemirrorManager` to the ProseMirror EditorView.
*
* ```ts
* manager.addView(new EditorView(...))
* manager.store.commands.insertText('Hello world');.
* ```
*
* - [[`onStateUpdate`]] - This is the method called every time the ProseMirror
* state changes. Both the extensions and the `Framework` listen to this event
* and can provide updates in response.
*/
declare class RemirrorManager<Extension extends AnyExtension> {
#private;
/**
* Create the manager for your `Remirror` editor.
*/
static create<Extension extends AnyExtension>(extensions: Extension[] | ExtensionTemplate<Extension>, settings?: Remirror.ManagerSettings): RemirrorManager<Extension | BuiltinPreset>;
/**
* Identifies this as a `Manager`.
*
* @internal
*/
get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.Manager;
/**
* Returns `true` if the manager has been destroyed.
*/
get destroyed(): boolean;
/**
* `true` when the view has been added to the UI layer and the editor is
* running.
*/
get mounted(): boolean;
/**
* Retrieve the framework output.
*
* This be undefined if the manager hasn't been provided to a framework yet
* the manager.
*
* With synchronous frameworks this means that it should only be accessed
* after the manager has been applied to the editor creation function.
*
* For frameworks like React it is only available when the manager is provided
* to the `Remirror` component and after the very first render. This means it
* is available within the `onRef` callback.
*
* ```tsx
* import React, { useEffect } from 'react';
* import { useRemirror, Remirror } from '@remirror/react';
*
* const Editor = () => {
* const { manager } = useRemirror();
*
* const callback = () => {
* return manager.output; // ✅ This is fine.
* }
*
* useEffect(() => {
* log(manager.output); // ✅ This is also fine.
* }, []);
*
* log(manager.output); // ❌ This will be undefined on the first render.
*
* return <Remirror manager={manager} />
* }
* ```
*/
get output(): FrameworkOutput<Extension> | undefined;
/**
* Returns true when a framework is attached to the manager.
*
* This can be used to check if it is safe to call `manager.output`.
*/
get frameworkAttached(): boolean;
/**
* The extensions stored by this manager
*/
get extensions(): ReadonlyArray<GetExtensions<Extension>>;
/**
* The registered string handlers provided by the extensions.
*
* By default this includes `html` and `plainText`
*/
get stringHandlers(): NamedStringHandlers;
/**
* Get the extension manager store which is accessible at initialization.
*/
get store(): Remirror.ManagerStore<Extension>;
/**
* Provides access to the extension store.
*/
get extensionStore(): Remirror.ExtensionStore;
/**
* Shorthand access to the active transaction from the manager. This is the
* shared transaction available to all commands and should be used when you
* need to make your commands chainable.
*
* If working with react and setting up your editor as a controlled component
* then this is the preferred way to run custom commands, otherwise your
* commands will end up being non-chainable and be overwritten by anything
* that comes after.
*/
get tr(): Transaction;
/**
* Returns the stored nodes
*/
get nodes(): Record<this['~N'], NodeExtensionSpec>;
/**
* Returns the store marks.
*/
get marks(): Record<this['~M'], MarkExtensionSpec>;
/**
* A shorthand method for retrieving the schema for this extension manager
* from the data.
*/
get schema(): EditorSchema;
/**
* A shorthand getter for retrieving the tags from the extension manager.
*/
get extensionTags(): Readonly<CombinedTags<GetNameUnion<Extension>>>;
/**
* A shorthand way of retrieving the editor view.
*/
get view(): EditorView;
/**
* Retrieve the settings used when creating the manager.
*/
get settings(): Remirror.ManagerSettings;
/**
* The document to use for rendering and outputting HTML.
*/
get document(): Document;
/**
* Creates the extension manager which is used to simplify the management of
* the prosemirror editor.
*
* This is set to private to encourage using `RemirrorManager.create`
* instead of the `new` keyword.
*/
private constructor();
/**
* Loops through all extensions to set up the lifecycle handlers.
*/
private setupLifecycleHandlers;
/**
* Set the string handler to use for a given name.
*
* This allows users to set the string handler
*/
private setStringHandler;
/**
* Set the manager value for the provided key. This is used by extensions to
* add data to the manager.
*/
private setStoreKey;
/**
* Get the manager value for the provided key. This is used by extensions to
* get data from the manager.
*/
private getStoreKey;
/**
* A method to set values in the extension store which is made available to
* extension.
*
* **NOTE** This method should only be used in the `onCreate` extension method
* or it will throw an error.
*/
private setExtensionStore;
/**
* Create the initial store.
*/
private createExtensionStore;
/**
* A state getter method which is passed into the params.
*/
private readonly getState;
/**
* Stores the editor view on the manager
*
* @param view - the editor view
*/
addView(view: EditorView): this;
/**
* Attach a framework to the manager.
*/
attachFramework(framework: BaseFramework<Extension>, updateHandler: (props: StateUpdateLifecycleProps) => void): void;
/**
* Create an empty document for the editor based on the current schema.
*
* This automatically looks at the supported content for the doc and the
* available nodes which fulfil that content in order to create a document
* with only the minimal required content.
*
* This can be used in conjunction with the create state to reset the current
* value of the editor.
*/
createEmptyDoc(): ProsemirrorNode;
/**
* Create the editor state from content passed to this extension manager.
*/
createState(props?: CreateEditorStateProps): EditorState_2;
/**
* Add a handler to the manager.
*
* Currently the only event that can be listened to is the `destroy` event.
*/
addHandler<Key extends keyof ManagerEvents>(event: Key, cb: ManagerEvents[Key]): Unsubscribe;
/**
* Update the state of the view and trigger the `onStateUpdate` lifecycle
* method as well.
*/
private readonly updateState;
/**
* This method should be called by the view layer every time the state is
* updated.
*
* An example usage of this is within the collaboration extension.
*/
onStateUpdate(props: Omit<StateUpdateLifecycleProps, 'firstUpdate'>): void;
/**
* Get the extension instance matching the provided constructor from the
* manager.
*
* This will throw an error if non existent.
*/
getExtension<ExtensionConstructor extends AnyExtensionConstructor>(Constructor: ExtensionConstructor): InstanceType<ExtensionConstructor>;
/**
* Determines in an extension is present by providing the desired
* `Constructor`.
*
* This method can be used as a safer alternative to getExtension which
* will throw an error if the constructor doesn't exist within the
* extension created by this extension.
*/
hasExtension<ExtensionConstructor extends AnyExtensionConstructor>(Constructor: ExtensionConstructor): boolean;
/**
* Make a clone of the manager.
*
* @internalremarks What about the state stored in the extensions and presets,
* does this need to be recreated as well?
*/
clone(): RemirrorManager<Extension>;
/**
* Recreate the manager with new settings and extensions
*/
recreate<ExtraExtension extends AnyExtension>(extensions?: ExtraExtension[], settings?: Remirror.ManagerSettings): RemirrorManager<Extension | ExtraExtension>;
/**
* This method should be called to destroy the manager and remove the view.
*/
destroy(): void;
/**
* Check whether the manager includes the names or constructors provided for
* the preset and extensions.
*
* Returns true if all are included, returns false otherwise.
*/
includes(mustIncludeList: Array<AnyExtensionConstructor | string>): boolean;
}
declare interface RemirrorManager<Extension extends AnyExtension> {
/**
* The constructor for the [[`RemirrorManager`]].
*/
constructor: RemirrorManagerConstructor;
/**
* Pseudo type property which contains the recursively extracted `Extension`
* stored by this manager.
*
* @internal
*/
['~E']: Extension;
/**
* `AllNames`
*
* Get all the names of the extensions within this editor.
*
* @internal
*/
['~AN']: GetNameUnion<Extension> extends never ? string : GetNameUnion<Extension>;
/**
* `NodeNames`
*
* Type inference hack for node extension names. This is the only way I know
* to store types on a class.
*
* @internal
*/
['~N']: GetNodeNameUnion<Extension> extends never ? string : GetNodeNameUnion<Extension>;
/**
* `MarkNames`
*
* Type inference hack for mark extension names. This is the only way I know
* to store types on a class.
*
* @internal
*/
['~M']: GetMarkNameUnion<Extension> extends never ? string : GetMarkNameUnion<Extension>;
/**
* `PlainNames`
*
* Type inference hack for all the plain extension names. This is the only way
* I know to store types on a class.
*
* @internal
*/
['~P']: GetPlainNameUnion<Extension> extends never ? string : GetPlainNameUnion<Extension>;
}
export { RemirrorManager }
export { RemirrorManager as RemirrorManager_alias_1 }
export { RemirrorManager as RemirrorManager_alias_2 }
declare interface RemirrorManagerConstructor extends Function {
create<Extension extends AnyExtension>(extension: Extension[], settings?: Remirror.ManagerSettings): RemirrorManager<Extension | BuiltinPreset>;
}
export { RemirrorMessage }
export { RemoveAnnotation }
export { RemoveAnnotations }
/**
* Removes [[`AnyExtension`]] from an extension union. This can be used to make
* typechecking stricter.
*
* @typeParam Extension - The union of extensions to remove [[`AnyExtension`]] from.
*/
declare type RemoveAny<Extension> = Extension extends Extension ? AnyExtension extends Extension ? never : Extension : never;
export { RemoveAny }
export { RemoveAny as RemoveAny_alias_1 }
export { RemoveAny as RemoveAny_alias_2 }
export { RemoveFlavoring }
/**
* Remove the helper annotation.
*/
declare type RemoveHelper<Type> = Type extends Helper<infer T> ? T : Type;
declare type RemoveHelpers<Type extends Record<string, AnyFunction>> = {
[Key in keyof Type]: (...args: Parameters<Type[Key]>) => RemoveHelper<ReturnType<Type[Key]>>;
};
export { removeMark }
export { RemoveMarkProps }
export { removeNodeAfter }
export { removeNodeAtPosition }
export { removeNodeBefore }
declare interface RemovePlaceholderAction {
type: ActionType.REMOVE_PLACEHOLDER;
id: string;
}
export { Replace }
export { replaceNodeAtPosition }
export { replaceText }
export { ReplaceTextProps }
export { RequireAtLeastOne }
export { RequireExactlyOne }
export { ResolvedPos }
export { ResolvedPosProps }
export { SchemaAttributes }
export { SchemaAttributesObject }
/**
* This is the schema extension which creates the schema and provides extra
* attributes as defined in the manager or the extension settings.
*
* @remarks
*
* The schema is the most important part of the remirror editor. This is the
* extension responsible for creating it, injecting extra attributes and
* managing the plugin which is responsible for making sure dynamically created
* attributes are updated.
*
* In order to add extra attributes the following would work.
*
* ```ts
* import { RemirrorManager } from 'remirror';
* import uuid from 'uuid';
* import hash from 'made-up-hasher';
*
* const manager = RemirrorManager.create([], {
* extraAttributes: [
* {
* identifiers: 'nodes',
* attributes: {
* awesome: {
* default: 'awesome',
* parseDOM: (domNode) => domNode.getAttribute('data-awesome'),
* toDOM: (attrs) => ([ 'data-awesome', attrs.awesome ])
* },
* },
* },
* { identifiers: ['paragraph'], attributes: { id: { default: () => uuid() } } },
* { identifiers: ['bold'], attributes: { hash: (mark) => hash(JSON.stringify(mark.attrs)) } },
* ],
* })
* ```
*
* It is an array of identifiers and attributes. Setting the default to a
* function allows you to set up a dynamic attribute which is updated with the
* synchronous function that you provide to it.
*
* @category Builtin Extension
*/
declare class SchemaExtension extends PlainExtension {
get name(): "schema";
/**
* The dynamic attributes for each node and mark extension.
*
* The structure will look like the following.
*
* ```ts
* {
* paragraph: { id: () => uid(), hash: (node) => hash(node) },
* bold: { random: () => Math.random(), created: () => Date.now() },
* };
* ```
*
* This object is used by the created plugin to listen for changes to the doc,
* and check for new nodes and marks which haven't yet applied the dynamic
* attribute and add the attribute.
*/
private readonly dynamicAttributes;
/**
* This method is responsible for creating, configuring and adding the
* `schema` to the editor. `Schema` is a special type in ProseMirror editors
* and with `remirror` it's all just handled for you.
*/
onCreate(): void;
/**
* This creates the plugin that is used to automatically create the dynamic
* attributes defined in the extra attributes object.
*/
createPlugin(): CreateExtensionPlugin;
/**
* Add the schema and nodes to the manager and extension store.
*/
private addSchema;
/**
* Check the dynamic nodes to see if the provided node:
*
* - a) is dynamic and therefore can be updated.
* - b) has just been created and does not yet have a value for the dynamic
* node.
*
* @param node - the node
* @param pos - the node's position
* @param tr - the mutable ProseMirror transaction which is applied to create
* the next editor state
*/
private checkAndUpdateDynamicNodes;
/**
* Loop through the dynamic marks to see if the provided node:
*
* - a) is wrapped by a matching mark.
* - b) has just been added and doesn't yet have the dynamic attribute
* applied.
*
* @param node - the node
* @param pos - the node's position
* @param tr - the mutable ProseMirror transaction which is applied to create
* the next editor state.
*/
private checkAndUpdateDynamicMarks;
/**
* Gather all the extra attributes that have been added by extensions.
*/
private gatherExtraAttributes;
}
export { SchemaExtension }
export { SchemaExtension as SchemaExtension_alias_1 }
export { SchemaExtension as SchemaExtension_alias_2 }
export { SchemaJSON }
export { SchemaProps }
export { schemaToJSON }
export { SELECTED_NODE_CLASS_NAME }
export { SELECTED_NODE_CLASS_SELECTOR }
export { Selection_2 as Selection }
export { SelectionProps }
export { set }
export { setBlockType }
export { SetOptional }
export { SetRequired }
export { SetReturnType }
export { setStyle }
declare interface SetupExtensionProps {
extension: AnyExtension;
nodeNames: string[];
markNames: string[];
plainNames: string[];
store: Remirror.ExtensionStore;
handlers: ManagerLifecycleHandlers;
}
declare function setUploadPlaceholderAction(tr: Transaction_2, action: PlaceholderPluginAction): Transaction_2;
export { setUploadPlaceholderAction }
export { setUploadPlaceholderAction as setUploadPlaceholderAction_alias_1 }
export { setUploadPlaceholderAction as setUploadPlaceholderAction_alias_2 }
export { setUploadPlaceholderAction as setUploadPlaceholderAction_alias_3 }
export { shallowClone }
export { Shape }
/**
* A shortcut map which is used by the `KeymapExtension`.
*/
declare type ShortcutMap = Record<NamedShortcut, string>;
export { ShortcutMap }
export { ShortcutMap as ShortcutMap_alias_1 }
export { ShortcutMap as ShortcutMap_alias_2 }
export { ShouldSkipFunction }
export { ShouldSkipProps }
export { shouldUseDomEnvironment }
export { Simplify }
export { SkippableInputRule }
export { Slice }
export { SnakeCase }
export { snakeCase }
export { sort }
export { spaceCase }
export { startCase }
export { startPositionOfParent }
export { STATE_OVERRIDE }
export { StateJSON }
declare interface StateUpdateLifecycleProps extends EditorStateProps {
/**
* The previous state.
*/
previousState: EditorState;
/**
* When true, this lets you know that it is the first state update to happen.
* This can be used to run an action that should only be run when the state is
* first available.
*/
firstUpdate: boolean;
/**
* The original transaction which caused this state update.
*
* This allows for inspecting the reason behind the state change.
* When undefined this means that the state was updated externally.
*
* If available:
* - Metadata on the transaction can be inspected. `tr.getMeta`
* - Was the change caused by added / removed content? `tr.docChanged`
* - Was ths change caused by an updated selection? `tr.selectionSet`
* - `tr.steps` can be inspected for further granularity.
*/
tr?: Transaction;
/**
* When the state updates are not controlled and it was a transaction that
* caused the state to be updated this value captures all the transaction
* updates caused by prosemirror plugins hook state methods like
* `filterTransactions` and `appendTransactions`.
*
* This is for advanced users only, and I personally have never needed it.
*/
transactions?: readonly Transaction[];
}
export { StateUpdateLifecycleProps }
export { StateUpdateLifecycleProps as StateUpdateLifecycleProps_alias_1 }
export { Static }
export { StaticKey }
export { StaticKeyList }
declare interface StaticKeysProps<Options extends Shape = EmptyShape> {
/**
* The list of all keys which are static and can only be set at the start.
*/
staticKeys: StaticKeyList<Options>;
}
export { StaticShape }
export { StrictReplace }
export { StringHandler }
export { StringHandlerOptions }
export { StringHandlerProps }
export { Stringified }
export { StringKey }
/**
* This extension allows others extension to add the `createSuggesters` method
* for adding the prosemirror-suggest functionality to your editor.
*
* @remarks
*
* This is an example of adding custom functionality to an extension via the
* `ExtensionParameterMethods`.
*
* @category Builtin Extension
*/
declare class SuggestExtension extends PlainExtension<SuggestOptions> {
get name(): "suggest";
/**
* Create the `addSuggester` method and `removeSuggester` methods to the
* extension store.
*
* This can be used by extensions to conditionally add suggestion support.
*/
onCreate(): void;
/**
* Add the `prosemirror-suggest` plugin to the editor.
*/
createExternalPlugins(): ProsemirrorPlugin[];
/**
* Allow additional `Suggesters` to be added to the editor. This can be used
* by `React` to create hooks.
*/
onAddCustomHandler: AddCustomHandler<SuggestOptions>;
/**
* Get the suggest plugin state.
*
* This may be removed at a later time.
*
* @experimental
*/
getSuggestState(state?: EditorState): Helper<SuggestState>;
/**
* Get some helpful methods from the SuggestPluginState.
*/
getSuggestMethods(): Helper<Pick<SuggestState, 'addIgnored' | 'clearIgnored' | 'removeIgnored' | 'ignoreNextExit' | 'setMarkRemoved' | 'findMatchAtPosition' | 'findNextTextSelection' | 'setLastChangeFromAppend'>>;
/**
* Check to see whether the provided name is the currently active
* suggester.
*
* @param name - the name of the suggester to include
*/
isSuggesterActive(name: string | string[]): Helper<boolean>;
}
export { SuggestExtension }
export { SuggestExtension as SuggestExtension_alias_1 }
export { SuggestExtension as SuggestExtension_alias_2 }
declare interface SuggestOptions {
/**
* The custom handler which enables adding `suggesters`.
*/
suggester: CustomHandler<Suggester>;
}
export { SuggestOptions }
export { SuggestOptions as SuggestOptions_alias_1 }
export { SuggestOptions as SuggestOptions_alias_2 }
/**
* Create the extension tags which are passed into each extensions method to
* enable dynamically generated rules and commands.
*
* Tags on nodes and marks are automatically added to the schema as groups.
*
* @category Builtin Extension
*/
declare class TagsExtension extends PlainExtension {
get name(): "tags";
/**
* Track the tags which have been applied to the extensions in this editor.
*/
private allTags;
/**
* The tags for plain extensions.
*/
private plainTags;
/**
* The tags for mark extensions.
*/
private markTags;
/**
* The tags for node extensions.
*/
private nodeTags;
/**
* Create the tags which are used to identify extension with particular
* behavioral traits.
*/
onCreate(): void;
/**
* Reset the tags to the empty object with empty arrays.
*/
private resetTags;
/**
* Update the tags object for each extension.
*/
private updateTagForExtension;
}
export { TagsExtension }
export { TagsExtension as TagsExtension_alias_1 }
export { TagsExtension as TagsExtension_alias_2 }
export { take }
export { textBetween }
export { TextProps }
export { throttle }
export { ThrottledFunction }
/**
* Checks whether a given string is unique to the set. Add the name if it
* doesn't already exist, or throw an error when `shouldThrow` is true.
*
* @param props - destructured params
*/
export declare function throwIfNameNotUnique(props: IsNameUniqueProps): void;
export { toggleBlockItem }
export { ToggleBlockItemProps }
/**
* A custom `toggleMark` function that works for the `remirror` codebase.
*
* Create a command function that toggles the given mark with the given
* attributes. Will return `false` when the current selection doesn't support
* that mark. This will remove the mark if any marks of that type exist in the
* selection, or add it otherwise. If the selection is empty, this applies to
* the [stored marks](#state.EditorState.storedMarks) instead of a range of the
* document.
*
* The differences from the `prosemirror-commands` version.
* - Acts on the transaction rather than the state to allow for commands to be
* chained together.
* - Uses the ONE parameter function signature for compatibility with remirror.
* - Supports passing a custom range.
*/
declare function toggleMark(props: ToggleMarkProps): CommandFunction;
export { toggleMark }
export { toggleMark as toggleMark_alias_1 }
export declare interface ToggleMarkProps extends MarkTypeProps, Partial<AttributesProps> {
/**
* @deprecated use `selection` property instead.
*/
range?: FromToProps;
/**
* The selection point for toggling the chosen mark.
*/
selection?: PrimitiveSelection;
}
export { toggleWrap }
export { toString_2 as toString }
export { Transaction }
export { TransactionProps }
export { TransactionTransformer }
/**
* Transforms the unsorted array of presets and extension into presets and
* sorted extensions. Handles uniqueness of extensions and automatically throws
* an error when required extensions are missing.
*
* @internalremarks Currently matching by constructor - what if different
* versions exist in the same app
*
* @param initialExtensions - the extensions to be transformed. This includes
* the extension that are parents to other extensions.
*
* @returns the list of extension instances sorted by priority
*/
export declare function transformExtensions<RawExtensions extends AnyExtension>(initialExtensions: readonly RawExtensions[], settings: Remirror.ManagerSettings): ExtensionTransformation<RawExtensions>;
declare interface TriggerChangeProps {
/**
* Whether or not to trigger this as a change and call any handlers.
*
* @defaultValue true
*/
triggerChange?: boolean;
}
export { TriggerChangeProps }
export { TriggerChangeProps as TriggerChangeProps_alias_1 }
export { TriggerChangeProps as TriggerChangeProps_alias_2 }
export { TrStateProps }
export { TsConfigJson }
export { TupleOf }
export { TupleUnion }
export { TupleValue }
export { TypedArray }
declare interface UiAnnotation {
__uiAnnotation?: never;
}
declare type UiCommandFunction = CommandFunction & UiAnnotation;
export { UiCommandFunction }
export { UiCommandFunction as UiCommandFunction_alias_1 }
export { UiCommandFunction as UiCommandFunction_alias_2 }
/**
* Utility type for pulling all the command names from a list.
*
* TODO - why doesn't this work.
*/
declare type UiCommandNames<Extension extends AnyExtension> = StringKey<ConditionalPick<{
[P in keyof UnionToIntersection<GetDecoratedUiCommands<Extension>>]: keyof UnionToIntersection<GetDecoratedUiCommands<Extension>>[P] extends '__uiAnnotation' ? true : false;
}, true>>;
export { UiCommandNames }
export { UiCommandNames as UiCommandNames_alias_1 }
export { UiCommandNames as UiCommandNames_alias_2 }
export { UndefinedFlipPartialAndRequired }
export { UndefinedPickPartial }
export { UnionToIntersection }
export { uniqueArray }
export { uniqueBy }
export { uniqueId }
export { UnknownShape }
/**
* Get the union extension type from an array of extensions or from a function that returns an array of extension.
*
* @example
*
* ```ts
* const extensions = [new BoldExtension(), new ItalicExtension()];
* type Extension = UnpackedExtension<typeof extensions>
* // Extension = BoldExtension | ItalicExtension
* ```
*
* @example
*
* ```ts
* const extensions = () => [new BoldExtension(), new ItalicExtension()];
* type Extension = UnpackedExtension<typeof extensions>
* // Extension = BoldExtension | ItalicExtension
* ```
*/
declare type UnpackedExtension<Extension extends AnyExtension[] | (() => AnyExtension[])> = UnpackedReturnType<Extension>[number];
export { UnpackedExtension }
export { UnpackedExtension as UnpackedExtension_alias_1 }
export { UnpackedExtension as UnpackedExtension_alias_2 }
/**
* Extract the function return type if the generic type is a function, otherwise
*
* @internal
*
* @example
*
* ```ts
* type A = () => string
* type B = UnpackedReturnType<A>
* // B = string
*
* type C = string
* type D = UnpackedReturnType<A>
* // D = string
* ```
*/
declare type UnpackedReturnType<MaybeFunction> = MaybeFunction extends (...args: any[]) => infer Returned ? Returned : MaybeFunction;
export { unset }
declare type UpdatableViewProps = 'attributes' | 'editable';
export { UpdatableViewProps }
export { UpdatableViewProps as UpdatableViewProps_alias_1 }
export { UpdatableViewProps as UpdatableViewProps_alias_2 }
declare type UpdatableViewPropsObject = {
[Key in UpdatableViewProps]: DirectEditorProps[Key];
};
export { UpdatableViewPropsObject }
export { UpdatableViewPropsObject as UpdatableViewPropsObject_alias_1 }
export { updateMark }
export { UpdateMarkProps }
/**
* @internal
*/
declare type UpdateReason = 'set' | 'reset';
export { UpdateReason }
export { UpdateReason as UpdateReason_alias_1 }
declare interface UpdateReasonProps {
/**
* Describes what triggered an update.
*
* - `set` - the change was triggered by an update in some properties
* - `reset` - the user has specifically requested to reset all properties to
* their initial defaults
* - `init` - the update is happening when the preset is being It will receive
* all the items as changes.
*/
reason: UpdateReason;
}
export { UpdateReasonProps }
export { UpdateReasonProps as UpdateReasonProps_alias_1 }
declare interface UpdateStateProps extends Partial<TransactionProps>, EditorStateProps, TriggerChangeProps {
/**
* When the state updates are not controlled and it was a transaction that
* caused the state to be updated this value captures all the transaction
* updates caused by prosemirror plugins hook state methods like
* `filterTransactions` and `appendTransactions`.
*
* This is for advanced users only.
*/
transactions?: readonly Transaction[];
}
export { UpdateStateProps }
export { UpdateStateProps as UpdateStateProps_alias_1 }
export { UpdateStateProps as UpdateStateProps_alias_2 }
declare interface UploadContext {
set: (key: string, value: unknown) => void;
get: (key: string) => unknown;
addListener: (listener: UploadContextListener) => () => void;
}
export { UploadContext }
export { UploadContext as UploadContext_alias_1 }
export { UploadContext as UploadContext_alias_2 }
export { UploadContext as UploadContext_alias_3 }
declare type UploadContextListener = (values: Record<string, unknown>) => void;
/**
* `UploadExtension` handle the file upload process.
*/
declare class UploadExtension extends PlainExtension<DecorationsOptions_2> {
get name(): "upload";
/**
* Create the extension plugin for inserting decorations into the editor.
*/
createExternalPlugins(): ProsemirrorPlugin_2[];
}
export { UploadExtension }
export { UploadExtension as UploadExtension_alias_1 }
export { UploadExtension as UploadExtension_alias_2 }
export { UploadExtension as UploadExtension_alias_3 }
/**
* Insert a file into the editor and upload it.
*/
declare function uploadFile<NodeAttributes extends AbstractNodeAttributes>({ file, pos, view, fileType, uploadHandler, }: UploadFileProps<NodeAttributes>): void;
export { uploadFile }
export { uploadFile as uploadFile_alias_1 }
export { uploadFile as uploadFile_alias_2 }
export { uploadFile as uploadFile_alias_3 }
declare type UploadFileHandler<NodeAttributes> = () => FileUploader<NodeAttributes>;
export { UploadFileHandler }
export { UploadFileHandler as UploadFileHandler_alias_1 }
export { UploadFileHandler as UploadFileHandler_alias_2 }
export { UploadFileHandler as UploadFileHandler_alias_3 }
export declare interface UploadFileProps<NodeAttributes extends AbstractNodeAttributes = object> {
file: File;
pos: number | undefined;
view: EditorView_2;
fileType: NodeType_2;
uploadHandler: UploadFileHandler<NodeAttributes>;
}
declare interface UploadPlaceholderPayload<NodeAttributes extends AbstractNodeAttributes> {
context: UploadContext;
fileUploader: FileUploader<NodeAttributes>;
}
export { UploadPlaceholderPayload }
export { UploadPlaceholderPayload as UploadPlaceholderPayload_alias_1 }
export { UploadPlaceholderPayload as UploadPlaceholderPayload_alias_2 }
export { UploadPlaceholderPayload as UploadPlaceholderPayload_alias_3 }
declare interface UploadPlaceholderPluginData {
set: DecorationSet_2;
payloads: Map<string, any>;
}
export { UseDefault }
export { ValidOptions }
export { Value }
export { ValueOf }
export { values }
declare interface WidgetPlaceholder<Data = any> extends BasePlaceholder, DataProps<Data> {
/**
* Declare this as a widget tracker.
*
* Widget trackers support adding custom components to the created dom
* element.
*/
type: 'widget';
/**
* Widget trackers only support fixed positions.
*/
pos: number;
/**
* Called the first time this widget decoration is added to the dom.
*/
createElement?(view: EditorView, pos: number): HTMLElement;
/**
* Called whenever the position tracker updates with the new position.
*/
onUpdate?(view: EditorView, pos: number, element: HTMLElement, data: any): void;
/**
* Called when the widget decoration is removed from the dom.
*/
onDestroy?(view: EditorView, element: HTMLElement): void;
}
export { WidgetPlaceholder }
export { WidgetPlaceholder as WidgetPlaceholder_alias_1 }
export { WidgetPlaceholder as WidgetPlaceholder_alias_2 }
declare type WithBase<Type extends BasePlaceholder> = MakeRequired<Type, keyof BasePlaceholder> & {
id: unknown;
};
export { within }
/**
* A type with a name property.
*/
declare type WithName<Type> = Type & {
name: string;
};
export { wrapIn }
export { Writable }
export { Writeable }
export { ZERO_WIDTH_SPACE_CHAR }
export { }
declare global {
namespace Remirror {
/**
* A global type which allows setting additional options on the exclude.
*/
interface ExcludeOptions {}
/**
* A global type which allows additional default settings to be added to the
* editor.
*/
interface BaseExtensionOptions {}
}
}
/**
* An interface for creating custom plugins in your `remirror` editor.
*/
export interface CreateExtensionPlugin<PluginState = any>
extends Pick<
PluginSpec<PluginState>,
'props' | 'state' | 'key' | 'view' | 'filterTransaction' | 'appendTransaction'
> {
/**
Additional properties are allowed on plugin specs, which can be
read via [`Plugin.spec`](https://prosemirror.net/docs/ref/#state.Plugin.spec).
*/
[key: string]: any;
}
/**
* The type of arguments acceptable for the focus parameter.
*
* - Can be a prosemirror selection
* - A range of `{ from: number; to: number }`
* - A single position with a `number`
* - A string of `'start' | 'end'`
* - `true` which sets the focus to the current position or start.
*/
export type FocusType = PrimitiveSelection | boolean;
declare global {
namespace Remirror {
/**
* A utility type for all the globally available extension names. This is
* mainly used to provide autocompletion.
*/
type NameUnion = LiteralUnion<GetNameUnion<Extensions>, string>;
/**
* A utility type for all the globally available plain extension names. This
* is mainly used to provide autocompletion.
*/
type PlainNameUnion = LiteralUnion<GetPlainNameUnion<Extensions>, string>;
/**
* A utility type for all the globally available node extension names. This
* is mainly used to provide autocompletion.
*/
type NodeNameUnion = LiteralUnion<GetNodeNameUnion<Extensions>, string>;
/**
* A utility type for all the globally available mark extension names. This
* is mainly used to provide autocompletion.
*/
type MarkNameUnion = LiteralUnion<GetMarkNameUnion<Extensions>, string>;
}
}
declare global {
/**
* This namespace is global and you can use declaration merging to extend and
* create new types used by the `remirror` project.
*
* @remarks
*
* The following would add `MyCustomType` to the `Remirror` namespace. Please
* note that this can only be used for types and interfaces.
*
* ```ts
* declare global {
* namespace Remirror {
* type MyCustomType = 'look-at-me';
* }
* }
* ```
*/
namespace Remirror {
/**
* This interface stores all the currently installed extensions. As a result
* it can be used to set the default loaded extensions to include all
* available within `node_modules`. By extending this extension in the
* global `Remirror` namespace the key is ignored but the value is used to
* form the union type in the `chain`, `commands`, `helpers` properties on
* the `Remirror.ExtensionStore` interface.
*
* This is useful for extensions being able to reuse the work of other
* extension.
*/
interface AllExtensions {}
/**
* This is the global interface for adding extra methods and properties to
* all [[`Extension`]]s using declaration merging.
*
* @remarks
*
* The following will add `newOption` to the expected options. This is the
* way that extensions which add new functionality to the editor can request
* configuration options.
*
* ```ts
* declare global {
* namespace Remirror {
* interface ExtensionFactoryProps {
* newOption?: string;
* }
* }
* }
* ```
*/
interface BaseExtension {}
interface NodeExtension {}
interface MarkExtension {}
/**
* An override to for the `AnyExtension` type. If you're extension adds a
* new property to the `Extension` that is deeply nested or very complex it
* can break the `AnyExtension` implementation from being compatible with
* all valid extensions.
*
* The keys you provide on this override replace the default `AnyExtension`
* types include unsafe properties that need to be simplified.
*
* An example is the `constructor` property which makes it impossible to
* find a common interface between extensions with different settings and
* properties. By setting the `constructor` to a much simpler override all
* `Extension`'s are now assignable to the `AnyExtension type again.`
*/
interface AnyExtensionOverrides extends AnyBaseClassOverrides {
constructor: AnyExtensionConstructor;
['~C']: ExtensionCommandReturn;
['~H']: ExtensionHelperReturn;
['~E']: AnyExtension;
}
}
}
/* eslint-enable @typescript-eslint/member-ordering */
// Make the abstract extension available but only as a type.
export type { Extension };
declare global {
namespace Remirror {
interface ManagerStore<Extension extends AnyExtension> {
/**
* The attributes to be added to the prosemirror editor.
*/
attributes: ProsemirrorAttributes;
}
interface ExtensionStore {
/**
* Triggers a recalculation of the `view.dom` attributes for each
* extension and notifies the parent UI once done.
*
* This will also dispatch an update to the state automatically. However
* you can disable this by setting `triggerUpdate` to `false`.
*
* By not triggering an update the new value may not be capture by the view layer, e.g. `React`.
*
* @param triggerUpdate - defaults to true
*/
updateAttributes: (triggerUpdate?: boolean) => void;
}
interface ExcludeOptions {
/**
* Whether to use the attributes provided by this extension
*
* @defaultValue undefined
*/
attributes?: boolean;
}
interface BaseExtension {
/**
* A list of class names to add to the main editor element.
*/
classNames?: ClassName[];
/**
* Allows the extension to modify the attributes for the Prosemirror editor
* dom element.
*
* @remarks
*
* Sometimes an extension will need to make a change to the attributes of the
* editor itself. For example a placeholder may need to do some work to make
* the editor more accessible by setting the `aria-placeholder` value to match
* the value of the placeholder.
*
* @alpha
*/
createAttributes?(): ProsemirrorAttributes;
}
interface AllExtensions {
attributes: AttributesExtension;
}
}
}
declare global {
namespace Remirror {
/**
* UX options for the command which can be extended.
*/
interface CommandDecoratorOptions<Options extends Shape = Shape>
extends CommandUiDecoratorOptions {
/**
* A function which can be used to override whether a command is already
* active for the current selection.
*/
active?: (options: Options, store: ExtensionStore) => boolean;
}
}
}
declare global {
namespace Remirror {
interface ManagerSettings {
/**
* The options that can be passed into the built in options.
*/
builtin?: GetStaticAndDynamic<BuiltinOptions>;
}
/**
* The builtin preset.
*/
type Builtin = BuiltinPreset;
/**
* The union of every extension available via the remirror codebase.
*/
type Extensions = ValueOf<AllExtensions>;
}
}
declare global {
namespace Remirror {
interface ManagerStore<Extension extends AnyExtension> {
/**
* Get the forced updates from the provided transaction.
*/
getForcedUpdates: (tr: Transaction) => ForcedUpdateMeta;
/**
* Enables the use of custom commands created by extensions which extend
* the functionality of your editor in an expressive way.
*
* @remarks
*
* Commands are synchronous and immediately dispatched. This means that
* they can be used to create menu items when the functionality you need
* is already available by the commands.
*
* ```ts
* if (commands.toggleBold.enabled()) {
* commands.toggleBold();
* }
* ```
*/
commands: CommandsFromExtensions<Extension>;
/**
* Chainable commands for composing functionality together in quaint and
* beautiful ways
*
* @remarks
*
* You can use this property to create expressive and complex commands
* that build up the transaction until it can be run.
*
* The way chainable commands work is by adding multiple steps to a shared
* transaction which is then dispatched when the `run` command is called.
* This requires making sure that commands within your code use the `tr`
* that is provided rather than the `state.tr` property. `state.tr`
* creates a new transaction which is not shared by the other steps in a
* chainable command.
*
* The aim is to make as many commands as possible chainable as explained
* [here](https://github.com/remirror/remirror/issues/418#issuecomment-666922209).
*
* There are certain commands that can't be made chainable.
*
* - undo
* - redo
*
* ```ts
* chain
* .toggleBold()
* .insertText('Hi')
* .setSelection('all')
* .run();
* ```
*
* The `run()` method ends the chain and dispatches the command.
*/
chain: ChainedFromExtensions<Extension>;
}
interface BaseExtension {
/**
* `ExtensionCommands`
*
* This pseudo property makes it easier to infer Generic types of this
* class.
*
* @internal
*/
['~C']: this['createCommands'] extends AnyFunction
? ReturnType<this['createCommands']>
: EmptyShape;
/**
* @experimental
*
* Stores all the command names for this decoration that have been added
* as decorators to the extension instance. This is used by the
* `CommandsExtension` to pick the commands and store meta data attached
* to each command.
*
* @internal
*/
decoratedCommands?: Record<string, CommandDecoratorOptions>;
/**
* Create and register commands for that can be called within the editor.
*
* These are typically used to create menu's actions and as a direct
* response to user actions.
*
* @remarks
*
* The `createCommands` method should return an object with each key being
* unique within the editor. To ensure that this is the case it is
* recommended that the keys of the command are namespaced with the name
* of the extension.
*
* ```ts
* import { ExtensionFactory } from '@remirror/core';
*
* const MyExtension = ExtensionFactory.plain({
* name: 'myExtension',
* version: '1.0.0',
* createCommands() {
* return {
* haveFun() {
* return ({ state, dispatch }) => {
* if (dispatch) {
* dispatch(tr.insertText('Have fun!'));
* }
*
* return true; // True return signifies that this command is enabled.
* }
* },
* }
* }
* })
* ```
*
* The actions available in this case would be `undoHistory` and
* `redoHistory`. It is unlikely that any other extension would override
* these commands.
*
* Another benefit of commands is that they are picked up by typescript
* and can provide code completion for consumers of the extension.
*/
createCommands?(): ExtensionCommandReturn;
}
interface ExtensionStore {
/**
* A property containing all the available commands in the editor.
*
* This should only be accessed after the `onView` lifecycle method
* otherwise it will throw an error. If you want to use it in the
* `createCommands` function then make sure it is used within the returned
* function scope and not in the outer scope.
*/
commands: CommandsFromExtensions<Extensions | (AnyExtension & { _T: false })>;
/**
* A method that returns an object with all the chainable commands
* available to be run.
*
* @remarks
*
* Each chainable command mutates the states transaction so after running
* all your commands. you should dispatch the desired transaction.
*
* This should only be called when the view has been initialized (i.e.)
* within the `createCommands` method calls.
*
* ```ts
* import { ExtensionFactory } from '@remirror/core';
*
* const MyExtension = ExtensionFactory.plain({
* name: 'myExtension',
* version: '1.0.0',
* createCommands: () => {
* // This will throw since it can only be called within the returned
* methods.
* const chain = this.store.chain; // ❌
*
* return {
* // This is good 😋
* haveFun() {
* return ({ state, dispatch }) =>
* this.store.chain.insertText('fun!').run(); ✅
* },
* }
* }
* })
* ```
*
* This should only be accessed after the `EditorView` has been fully
* attached to the `RemirrorManager`.
*
* The chain can also be called as a function with a custom `tr`
* parameter. This allows you to provide a custom transaction to use
* within the chainable commands.
*
* Use the command at the beginning of the command chain to override the
* shared transaction.
*
* There are times when you want to be sure of the transaction which is
* being updated.
*
* To restore the previous transaction call the `restore` chained method.
*
* @param tr - the transaction to set
*/
chain: ChainedFromExtensions<Extensions | (AnyExtension & { _T: false })>;
}
interface AllExtensions {
commands: CommandsExtension;
}
/**
* The command names for all core extensions.
*/
type AllCommandNames = LiteralUnion<CommandNames<Remirror.Extensions>, string>;
/**
* The command names for all core extensions.
*/
type AllUiCommandNames = LiteralUnion<UiCommandNames<Remirror.Extensions>, string>;
}
}
declare global {
namespace Remirror {
interface ExtensionStore {
/**
* Create delayed command which automatically adds a placeholder to the
* document while the delayed command is being run and also automatically
* removes it once it has completed.
*/
createPlaceholderCommand<Value = any>(
props: DelayedPlaceholderCommandProps<Value>,
): DelayedCommand<Value>;
}
interface BaseExtension {
/**
* Create a decoration set which adds decorations to your editor. The
* first parameter is the `EditorState`.
*
* This can be used in combination with the `onApplyState` handler which
* can map the decoration.
*
* @param state - the editor state which was passed in.
*/
createDecorations?(state: EditorState): DecorationSet;
}
interface AllExtensions {
decorations: DecorationsExtension;
}
}
}
declare global {
namespace Remirror {
interface ManagerStore<Extension extends AnyExtension> {
/**
* The helpers provided by the extensions used.
*/
helpers: HelpersFromExtensions<Extension>;
/**
* Check which nodes and marks are active under the current user
* selection.
*
* ```ts
* const { active } = manager.store;
*
* return active.bold() ? 'bold' : 'regular';
* ```
*/
active: ActiveFromExtensions<Extension>;
/**
* Get the attributes for the named node or mark from the current user
* selection.
*
* ```ts
* const { attrs } = manager.store;
*
* attrs.heading(); // => { id: 'i1238ha', level: 1 }
* ```
*/
attrs: AttrsFromExtensions<Extension>;
}
interface BaseExtension {
/**
* `ExtensionHelpers`
*
* This pseudo property makes it easier to infer Generic types of this
* class.
*
* @internal
*/
['~H']: this['createHelpers'] extends AnyFunction
? ReturnType<this['createHelpers']>
: EmptyShape;
/**
* @experimental
*
* Stores all the helpers that have been added via decorators to the
* extension instance. This is used by the `HelpersExtension` to pick the
* helpers.
*
* @internal
*/
decoratedHelpers?: Record<string, HelperDecoratorOptions>;
/**
* A helper method is a function that takes in arguments and returns a
* value depicting the state of the editor specific to this extension.
*
* @remarks
*
* Unlike commands they can return anything and may not effect the
* behavior of the editor.
*
* Below is an example which should provide some idea on how to add
* helpers to the app.
*
* ```tsx
* // extension.ts
* import { ExtensionFactory } from '@remirror/core';
*
* const MyBeautifulExtension = ExtensionFactory.plain({
* name: 'beautiful',
* createHelpers: () => ({
* checkBeautyLevel: () => 100
* }),
* })
* ```
*
* ```
* // app.tsx
* import { useRemirrorContext } from '@remirror/react';
*
* const MyEditor = () => {
* const { helpers } = useRemirrorContext({ autoUpdate: true });
*
* return helpers.beautiful.checkBeautyLevel() > 50
* ? (<span>😍</span>)
* : (<span>😢</span>);
* };
* ```
*/
createHelpers?(): ExtensionHelperReturn;
}
interface StringHandlers {
/**
* Register the plain `text` string handler which renders a text string
* inside a `<pre />`.
*/
text: HelpersExtension;
/**
* Register the html string handler, which converts a html string to a
* prosemirror node.
*/
html: HelpersExtension;
}
interface ExtensionStore {
/**
* Helper method to provide information about the content of the editor.
* Each extension can register its own helpers.
*
* This should only be accessed after the `onView` lifecycle method
* otherwise it will throw an error.
*/
helpers: HelpersFromExtensions<Extensions>;
/**
* Check which nodes and marks are active under the current user
* selection.
*
* ```ts
* const { active } = manager.store;
*
* return active.bold() ? 'bold' : 'regular';
* ```
*/
active: ActiveFromExtensions<Extensions>;
/**
* Get the attributes for the named node or mark from the current user
* selection.
*
* ```ts
* const { attrs } = manager.store;
*
* attrs.heading(); // => { id: 'i1238ha', level: 1 }
* ```
*/
attrs: AttrsFromExtensions<Extensions>;
}
interface ListenerProperties<Extension extends AnyExtension> {
helpers: HelpersFromExtensions<Extension>;
}
interface AllExtensions {
helpers: HelpersExtension;
}
}
/**
* The helpers name for all extension defined in the current project.
*/
type AllHelperNames = LiteralUnion<HelperNames<Remirror.Extensions>, string>;
}
declare global {
namespace Remirror {
interface ExcludeOptions {
/**
* Whether to use the inputRules for this particular extension.
*
* @defaultValue undefined
*/
inputRules?: boolean;
}
interface ExtensionStore {
/**
* When called this will run through every `createInputRules` method on every
* extension to recreate input rules.
*
* @remarks
*
* Under the hood it updates the plugin which is used to insert the
* input rules into the editor. This causes the state to be updated and
* will cause a rerender in your ui framework.
*/
rebuildInputRules: () => void;
}
interface BaseExtension {
/**
* Register input rules which are activated if the regex matches as a user is
* typing.
*
* @param parameter - schema parameter with type included
*/
createInputRules?(): InputRule[];
}
interface AllExtensions {
inputRules: InputRulesExtension;
}
}
}
declare global {
namespace Remirror {
interface ExcludeOptions {
/**
* Whether to exclude keybindings support. This is not a recommended
* action and can break functionality.
*
* @defaultValue undefined
*/
keymap?: boolean;
}
interface ExtensionStore {
/**
* When called this will run through every `createKeymap` method on every
* extension to recreate the keyboard bindings.
*
* @remarks
*
* **NOTE** - This will not update keybinding for extensions that
* implement their own keybinding functionality (e.g. any plugin using
* Suggestions)
*/
rebuildKeymap: () => void;
}
interface BaseExtension {
/**
* Stores all the keybinding names and options for this decoration that
* have been added as decorators to the extension instance. This is used
* by the `KeymapExtension` to pick the commands and store metadata
* attached to each command.
*
* @internal
*/
decoratedKeybindings?: Record<string, KeybindingDecoratorOptions>;
/**
* Add keymap bindings for this extension.
*
* @param parameter - schema parameter with type included
*/
createKeymap?(extractShortcutNames: (shortcut: string) => string[]): PrioritizedKeyBindings;
}
interface AllExtensions {
keymap: KeymapExtension;
}
}
}
declare global {
namespace Remirror {
interface ManagerStore<Extension extends AnyExtension> {
/**
* Get the command metadata for the transaction.
* @internal
*/
getCommandMeta(tr: Transaction): Metadata[];
}
interface AllExtensions {
meta: MetaExtension;
}
}
}
declare global {
namespace Remirror {
interface ManagerSettings {
/**
* Add custom node views to the manager which will take priority over the
* nodeViews provided by the extensions and plugins.
*/
nodeViews?: Record<string, NodeViewMethod>;
}
interface BaseExtension {
/**
* Registers one or multiple nodeViews for the extension.
*
* This is a shorthand way of registering a nodeView without the need to
* create a prosemirror plugin. It allows for the registration of one nodeView
* which has the same name as the extension.
*
* To register more than one you would need to use a custom plugin returned
* from the `plugin` method.
*
* @param parameter - schema parameter with type included
*/
createNodeViews?(): NodeViewMethod | Record<string, NodeViewMethod>;
}
interface AllExtensions {
nodeViews: NodeViewsExtension;
}
}
}
declare global {
namespace Remirror {
interface ExcludeOptions {
/**
* Whether to exclude the extension's pasteRules
*
* @defaultValue undefined
*/
pasteRules?: boolean;
}
interface BaseExtension {
/**
* Register paste rules for this extension.
*
* Paste rules are activated when text, images, or html is pasted into the
* editor.
*/
createPasteRules?(): PasteRule[] | PasteRule;
}
interface AllExtensions {
pasteRules: PasteRulesExtension;
}
}
}
declare global {
namespace Remirror {
interface ManagerSettings {
/**
* Add custom plugins to the manager while creating it.
*
* Plugins created via the manager are given priority over all extension
* based plugins. There's scope for adding a priority based model for
* inserting plugins, but it seems like a sane default until that's
* available.
*/
plugins?: ProsemirrorPlugin[];
}
interface ExtensionStore {
/**
* Retrieve the state for any given extension name. This will throw an
* error if the extension identified by that name doesn't implement the
* `createPlugin` method.
*
* @param name - the name of the extension
*
* @remarks
*
* ```ts
* const pluginState = getPluginState(extension.name);
* ```
*/
getPluginState<State>(name: string): State;
/**
* Add the new plugins. If previous plugins are provided then also remove
* the previous plugins.
*
* ```ts
* this.store.updatePlugins(this.createExternalPlugins(), this.externalPlugins);
* ```
*
* @param plugins - the plugins to add
* @param previousPlugins - the plugins to remove
*/
updatePlugins(plugins: ProsemirrorPlugin[], previousPlugins?: ProsemirrorPlugin[]): void;
/**
* Reruns the `createPlugin` and `createExternalPlugins` methods of the
* provided extension.
*
* This will also automatically update the state with the newly generated
* plugins by dispatching an update.
*
* ```ts
* // From within an extension
* this.store.updateExtensionPlugins(this);
* this.store.dispatchPluginUpdate();
* ```
*
* @param extension - the extension instance, constructor or name.
*/
updateExtensionPlugins(extension: AnyExtension | AnyExtensionConstructor | string): void;
/**
* Applies the store plugins to the state. If any have changed then it
* will be updated.
*/
dispatchPluginUpdate(): void;
}
interface ManagerStore<Extension extends AnyExtension> {
/**
* All of the plugins combined together from all sources
*/
plugins: ProsemirrorPlugin[];
/**
* Retrieve the state for a given extension name. This will throw an error
* if the extension doesn't exist.
*
* @param name - the name of the extension
*/
getPluginState: <State>(name: GetNameUnion<Extension>) => State;
/**
* All the plugin keys available to be used by plugins.
*/
pluginKeys: Record<string, PluginKey>;
}
interface ExcludeOptions {
/**
* Whether to exclude the extension's plugin
*
* @defaultValue undefined
*/
plugins?: boolean;
}
interface BaseExtension {
/**
* The plugin key for custom plugin created by this extension. This only
* exists when there is a valid `createPlugin` method on the extension.
*
* This can be used to set and retrieve metadata.
*
* ```ts
* const meta = tr.getMeta(this.pluginKey);
* ```
*/
pluginKey: PluginKey;
/**
* The plugin that was created by the `createPlugin` method. This only
* exists for extension which implement that method.
*/
plugin: Plugin;
/**
* The external plugins created by the `createExternalPlugins` method.
*/
externalPlugins: Plugin[];
/**
* Retrieve the state of the custom plugin for this extension. This will
* throw an error if the extension doesn't have a valid `createPlugin`
* method.
*
* @remarks
*
* ```ts
* const pluginState = this.getPluginState();
* ```
*
* This is only available after the initialize stage of the editor manager
* lifecycle.
*
* If you would like to use it before that e.g. in the decorations prop of
* the `createPlugin` method, you can call it with a current state which
* will be used to retrieve the plugin state.
*
* Please note that when using this in the decorations callback it is
* advisable to pass in the `state` argument in case the callback is
* called before the framework, or the view have been initialized.
*/
getPluginState: <State>(state?: EditorState) => State;
/**
* Create a custom plugin directly in the editor.
*
* @remarks
*
* A unique `key` is automatically applied to enable easier retrieval of
* the plugin state.
*
* ```ts
* import { CreateExtensionPlugin } from 'remirror';
*
* class MyExtension extends PlainExtension {
* get name() {
* return 'me' as const;
* }
*
* createPlugin(): CreateExtensionPlugin {
* return {
* props: {
* handleKeyDown: keydownHandler({
* Backspace: handler,
* 'Mod-Backspace': handler,
* Delete: handler,
* 'Mod-Delete': handler,
* 'Ctrl-h': handler,
* 'Alt-Backspace': handler,
* 'Ctrl-d': handler,
* 'Ctrl-Alt-Backspace': handler,
* 'Alt-Delete': handler,
* 'Alt-d': handler,
* }),
* decorations: state => {
* const pluginState = this.getPluginState(state);
* pluginState.setDeleted(false);
* return pluginState.decorationSet;
* },
* },
* }
* }
* }
* ```
*/
createPlugin?(): CreateExtensionPlugin;
/**
* Register third party plugins when this extension is placed into the
* editor.
*
* @remarks
*
* Some plugins (like the table plugin) consume several different plugins,
* creator method allows you to return a list of plugins you'd like to
* support.
*/
createExternalPlugins?(): ProsemirrorPlugin[];
}
interface AllExtensions {
plugins: PluginsExtension;
}
}
}
declare global {
namespace Remirror {
interface BaseExtension {
/**
* Allows the extension to create an extra attributes array that will be
* added to the extra attributes.
*
* For example the `@remirror/extension-bidi` adds a `dir` attribute to
* all node extensions which allows them to automatically infer whether
* the text direction should be right-to-left, or left-to-right.
*/
createSchemaAttributes?(): IdentifierSchemaAttributes[];
}
interface BaseExtensionOptions {
/**
* Inject additional attributes into the defined mark / node schema. This
* can only be used for `NodeExtensions` and `MarkExtensions`.
*
* @remarks
*
* Sometimes you need to add additional attributes to a node or mark. This
* property enables this without needing to create a new extension.
*
* This is only applied to the `MarkExtension` and `NodeExtension`.
*
* @defaultValue {}
*/
extraAttributes?: Static<SchemaAttributes>;
/**
* When true will disable extra attributes for this instance of the
* extension.
*
* @remarks
*
* This is only applied to the `MarkExtension` and `NodeExtension`.
*
* @defaultValue undefined
*/
disableExtraAttributes?: Static<boolean>;
/**
* An override for the mark spec object. This only applies for
* `MarkExtension`.
*/
markOverride?: Static<MarkSpecOverride>;
/**
* An override object for a node spec object. This only applies to the
* `NodeExtension`.
*/
nodeOverride?: Static<NodeSpecOverride>;
}
interface ManagerSettings {
/**
* Allows for setting extra attributes on multiple nodes and marks by
* their name or constructor. These attributes are automatically added and
* retrieved from from the dom by prosemirror.
*
* @remarks
*
* An example is shown below.
*
* ```ts
* import { RemirrorManager } from 'remirror';
*
* const managerSettings = {
* extraAttributes: [
* {
* identifiers: ['blockquote', 'heading'],
* attributes: { id: 'id', alignment: '0', },
* }, {
* identifiers: ['mention', 'codeBlock'],
* attributes: { 'userId': { default: null } },
* },
* ]
* };
*
* const manager = RemirrorManager.create([], { extraAttributes })
* ```
*/
extraAttributes?: IdentifierSchemaAttributes[];
/**
* Overrides for the mark.
*/
markOverride?: Record<string, MarkSpecOverride>;
/**
* Overrides for the nodes.
*/
nodeOverride?: Record<string, NodeSpecOverride>;
/**
* Perhaps you don't need extra attributes at all in the editor. This
* allows you to disable extra attributes when set to true.
*
* @defaultValue undefined
*/
disableExtraAttributes?: boolean;
/**
* Setting this to a value will override the default behaviour of the
* `RemirrorManager`. It overrides the created schema and ignores the
* specs created by all extensions within your editor.
*
* @remarks
*
* This is an advanced option and should only be used in cases where there
* is a deeper understanding of `Prosemirror`. By setting this, please
* note that a lot of functionality just won't work which is powered by
* the `extraAttributes`.
*/
schema?: EditorSchema;
/**
* The name of the default block node. This node will be given a higher
* priority when being added to the schema.
*
* By default this is undefined and the default block node is assigned
* based on the extension priorities.
*
* @defaultValue undefined
*/
defaultBlockNode?: string;
}
interface ManagerStore<Extension extends AnyExtension> {
/**
* The nodes to place on the schema.
*/
nodes: Record<
GetNodeNameUnion<Extension> extends never ? string : GetNodeNameUnion<Extension>,
NodeExtensionSpec
>;
/**
* The marks to be added to the schema.
*/
marks: Record<
GetMarkNameUnion<Extension> extends never ? string : GetMarkNameUnion<Extension>,
MarkExtensionSpec
>;
/**
* The schema created by this extension manager.
*/
schema: EditorSchema;
/**
* The name of the default block node. This is used by all internal
* extension when toggling block nodes. It can also be used in other
* cases.
*
* This can be updated via the manager settings when first creating the
* editor.
*
* @defaultValue 'paragraph'
*/
defaultBlockNode: string;
}
interface MarkExtension {
/**
* Provides access to the `MarkExtensionSpec`.
*/
spec: MarkExtensionSpec;
}
interface NodeExtension {
/**
* Provides access to the `NodeExtensionSpec`.
*/
spec: NodeExtensionSpec;
}
interface ExtensionStore {
/**
* The Prosemirror schema being used for the current editor.
*
* @remarks
*
* The value is created when the manager initializes. So it can be used in
* `createCommands`, `createHelpers`, `createKeymap` and most of the
* creator methods.
*/
schema: EditorSchema;
}
interface StaticExtensionOptions {
/**
* When true will disable extra attributes for all instances of this
* extension.
*
* @defaultValue false
*/
readonly disableExtraAttributes?: boolean;
}
interface AllExtensions {
schema: SchemaExtension;
}
}
}
declare global {
namespace Remirror {
interface ExcludeOptions {
/**
* Whether to exclude the suggesters plugin configuration for the
* extension.
*
* @defaultValue undefined
*/
suggesters?: boolean;
}
interface BaseExtension {
/**
* Create suggesters which respond to an activation `char` or regex
* pattern within the editor instance. The onChange handler provided is
* called with the data around the matching text.
*
* @remarks
*
* Suggesters are a powerful way of building up the editors
* functionality. They can support `@` mentions, `#` tagging, `/` special
* command keys which trigger action menus and much more.
*/
createSuggesters?(): Suggester[] | Suggester;
}
interface AllExtensions {
suggest: SuggestExtension;
}
interface ExtensionStore {
/**
* Add a suggester.
*/
addSuggester(suggester: Suggester): void;
/**
* Remove a suggester.
*/
removeSuggester(suggester: Suggester | string): void;
}
interface AllExtensions {
suggest: SuggestExtension;
}
}
}
declare global {
namespace Remirror {
interface ManagerSettings {
/**
* Add extra tags to the extensions by name. This can be used to add
* behavior traits to certain extensions.
*
* Please note this will change the schema since the tags are added to the
* node and mark groups.
*
* ```ts
* RemirrorManager.create(
* [],
* { extraTags: { bold: [ExtensionTag.Awesome] } }
* );
* ```
*/
extraTags?: Record<string, ExtensionTagType[]>;
}
interface BaseExtension {
/**
* The generated tags for this extension are added here. Do not add this
* property to your extensions as it will be overridden.
*/
tags: ExtensionTagType[];
/**
* Dynamically create tags for the extension.
*
* Tags are a helpful tool for categorizing the behavior of an extension.
* This behavior is later grouped in the `Manager` and passed to the
* `extensionStore`. Tags can be used by commands that need to remove all
* formatting and use the tag to identify which registered extensions are
* formatters.
*
* @remarks
*
* Tags are also automatically added to the node and mark extensions as a
* group when they are found there.
*
* There are internally defined tags but it's also possible to define any
* custom string as a tag. See [[`ExtensionTag`]].
*/
createTags?(): ExtensionTagType[];
}
type A = UseDefault<never, string>;
interface ManagerStore<Extension extends AnyExtension> {
/**
* All the tags provided by the configured extensions.
*/
tags: Readonly<
CombinedTags<GetNameUnion<Extension> extends never ? string : GetNameUnion<Extension>>
>;
/**
* All the plain extension tags provided for the editor.
*/
plainTags: Readonly<
CombinedTags<
GetPlainNameUnion<Extension> extends never ? string : GetPlainNameUnion<Extension>
>
>;
/**
* All the node extension tags provided for the editor.
*/
nodeTags: Readonly<
CombinedTags<
GetNodeNameUnion<Extension> extends never ? string : GetNodeNameUnion<Extension>
>
>;
/**
* All the mark extension tags provided for the editor.
*/
markTags: Readonly<
CombinedTags<
GetMarkNameUnion<Extension> extends never ? string : GetMarkNameUnion<Extension>
>
>;
}
interface ExtensionStore {
/**
* All the tags provided by the configured extensions.
*/
tags: CombinedTags;
/**
* All the plain extension tags provided for the editor.
*/
plainTags: CombinedTags;
/**
* All the node extension tags provided for the editor.
*/
nodeTags: CombinedTags;
/**
* All the mark extension tags provided for the editor.
*/
markTags: CombinedTags;
}
interface BaseExtensionOptions {
/**
* Add extra tags to the extension.
*
* Tags can be used to unlock certain behavioural traits for nodes and
* marks.
*
* Please note this will change the schema since the tags are added to the
* node and mark groups.
*/
extraTags?: ExtensionTagType[];
}
interface AllExtensions {
tags: TagsExtension;
}
}
}
declare global {
namespace Remirror {
/**
* Settings which can be passed into the manager.
*/
interface ManagerSettings extends Partial<CustomDocumentProps> {
/**
* Set the extension priority for extension's by their name.
*/
priority?: Record<string, ExtensionPriority>;
/**
* An object which excludes certain functionality from all extensions
* within the manager.
*/
exclude?: ExcludeOptions;
/**
* The error handler which is called when the JSON passed is invalid.
*
* @remarks
*
* The following can be used to setup the `onError` handler on the the
* manager.
*
* ```tsx
* import React from 'react';
* import { Remirror, InvalidContentHandler } from 'remirror';
* import { Remirror, useManager } from '@remirror/react';
* import { WysiwygPreset } from 'remirror/extensions';
*
* const Editor = () => {
* const onError: InvalidContentHandler = useCallback(({ json, invalidContent, transformers }) => {
* // Automatically remove all invalid nodes and marks.
* return transformers.remove(json, invalidContent);
* }, []);
*
* const manager = useManager(() => [new WysiwygPreset()], { onError });
*
* return (
* <Remirror manager={manager}>
* <div />
* </Remirror>
* );
* };
* ```
*/
onError?: InvalidContentHandler;
/**
* A function which transforms a string into a prosemirror node.
*
* @remarks
*
* Can be used to transform markdown / html or any other string format into a
* prosemirror node.
*
* See [[`fromHTML`]] for an example of how this could work.
*/
stringHandler?: keyof Remirror.StringHandlers | StringHandler;
/**
* The default named selection. This is used when `manager.createState` is
* called without providing a selection.
*
* @defaultValue 'end'
*/
defaultSelection?: 'start' | 'end' | 'all';
}
/**
* Describes the object where the extension manager stores it's data.
*
* @remarks
*
* Since this is a global namespace, you can extend the store if your
* extension is modifying the shape of the `Manager.store` property.
*/
interface ManagerStore<Extension extends AnyExtension> {
/**
* The editor view stored by this instance.
*/
view: EditorView;
}
interface ExtensionStore {
/**
* Make the remirror manager available to the editor.
*/
manager: AnyRemirrorManager;
/**
* The list of all extensions included in the editor.
*/
readonly extensions: AnyExtension[];
/**
* The stage the manager is currently at.
*/
readonly phase: ManagerPhase;
/**
* The view available to extensions once `addView` has been called on the
* `RemirrorManager` instance.
*/
readonly view: EditorView;
/**
* The latest state.
*/
currentState: EditorState;
/**
* The previous state. Will be undefined when the view is first created.
*/
previousState?: EditorState;
/**
* The root document to be used for the editor. This is mainly used for
* non-browser environment.
*/
readonly document: Document;
/**
* The settings passed to the manager.
*/
readonly managerSettings: ManagerSettings;
/**
* The names of every node extension.
*/
nodeNames: readonly string[];
/**
* The names of every mark extension.
*/
markNames: readonly string[];
/**
* The names of every plain extension.
*/
plainNames: readonly string[];
/**
* The named string handlers which are supported by the current editor
* implementation.
*/
readonly stringHandlers: NamedStringHandlers;
/**
* Return true when the editor view has been created.
*/
readonly isMounted: () => boolean;
/**
* A helper method for retrieving the state of the editor
*/
readonly getState: () => EditorState;
/**
* Allow extensions to trigger an update in the prosemirror state. This
* should not be used often. It's here in case you need it in an
* emergency.
*
* Internally it's used by the [[`PluginsExtension`]] to create a new
* state when the plugins are updated at runtime.
*/
readonly updateState: (state: EditorState) => void;
/**
* Get the extension instance matching the provided constructor from the
* manager.
*
* This will throw an error if not defined.
*/
readonly getExtension: <ExtensionConstructor extends AnyExtensionConstructor>(
Constructor: ExtensionConstructor,
) => InstanceType<ExtensionConstructor>;
/**
* Get the value of a key from the manager store.
*/
getStoreKey: <Key extends ManagerStoreKeys>(key: Key) => AnyManagerStore[Key];
/**
* Update the store with a specific key.
*/
setStoreKey: <Key extends ManagerStoreKeys>(key: Key, value: AnyManagerStore[Key]) => void;
/**
* Set a value on the extension store. One of the design decisions in this `1.0.0`
* version of `remirror` was to move away from passing elaborate arguments to each extension
* method and allow extensions to interact with a store shared by all
* extensions.
*
* The extension store object is immutable and will throw an error if updated directly.
*
* ```ts
* class MyExtension extends PlainExtension {
* get name() {}
* }
* ```
*/
setExtensionStore: <Key extends keyof ExtensionStore>(
key: Key,
value: ExtensionStore[Key],
) => void;
/**
* Set the string handler to use for a given name.
*
* This allows users to set the string handler
*/
setStringHandler: (name: keyof StringHandlers, handler: StringHandler) => void;
}
}
}
declare global {
namespace Remirror {
interface ListenerProperties<Extension extends AnyExtension> {}
}
}
declare global {
namespace Remirror {
interface AllExtensions {
upload: UploadExtension;
}
}
}