UNPKG

@remirror/core

Version:

Where your quest to create a world class editing experience begins.

1,132 lines (1,079 loc) 287 kB
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 bu