import { ValidOptions, GetDynamic, AnyConstructor, GetPartialDynamic, CommandFunction, AnyFunction, EditorStateProps, Transaction, EditorState, GetFixedDynamic, RemoveAnnotations, PrimitiveSelection, GetCustomHandler, Dispose, GetHandler, LiteralUnion, Primitive, EmptyShape, Shape, GetFixed, IfNoRequiredProperties, GetStatic, GetConstructorProps, MakeUndefined, UndefinedFlipPartialAndRequired, StringKey, GetAcceptUndefined, EditorView, MarkType, ApplySchemaAttributes, MarkSpecOverride, MarkExtensionSpec, NodeType, NodeSpecOverride, NodeExtensionSpec, Replace, IfHasRequiredProperties, IfEmpty, StaticKeyList, HandlerKeyList, CustomHandlerKeyList, NonChainableCommandFunction, UnionToIntersection, ConditionalPick, Flavoring, ConditionalReturnPick, ProsemirrorAttributes, KeyBindingCommandFunction, Listable, CommandFunctionProps, MarkTypeProps, AttributesProps, FromToProps, Static, RemirrorContentType, ProsemirrorNode, Fragment, AcceptUndefined, Handler, MakeRequired, StateJSON, RemirrorJSON, ProsemirrorPlugin, CustomHandler, KeyBindingProps, KeyBindings, NodeViewMethod, SchemaAttributes, EditorSchema, UseDefault, GetStaticAndDynamic, ValueOf, Simplify, TransactionTransformer, EditorViewProps, TextProps, TransactionProps } from '@remirror/core-types'; export * from '@remirror/core-types'; import { ExtensionPriority, __INTERNAL_REMIRROR_IDENTIFIER_KEY__, RemirrorIdentifier, NamedShortcut, ExtensionTagType, ManagerPhase } from '@remirror/core-constants'; export * from '@remirror/core-constants'; import { PluginSpec, PluginKey, Plugin, EditorState as EditorState$1, Transaction as Transaction$1 } from '@remirror/pm/state'; import { I18n } from '@remirror/i18n'; import { CoreIcon } from '@remirror/icons'; export { CoreIcon } from '@remirror/icons'; import { ToggleBlockItemProps, RemoveMarkProps, ReplaceTextProps, ShouldSkipFunction, CustomDocumentProps, InvalidContentHandler, StringHandler, NamedStringHandlers, StringHandlerProps } from '@remirror/core-utils'; export * from '@remirror/core-utils'; import { Mark, NodeType as NodeType$1 } from '@remirror/pm/model'; import { EditorView as EditorView$1, DecorationSet, DirectEditorProps } from '@remirror/pm/view'; import { InputRule } from '@remirror/pm/inputrules'; import { PasteRule } from '@remirror/pm/paste-rules'; import { Suggester, SuggestState } from '@remirror/pm/suggest'; import { ProsemirrorPlugin as ProsemirrorPlugin$1 } from '@remirror/pm'; import { Unsubscribe } from 'nanoevents'; export * from '@remirror/core-helpers'; type Changes = { /** * 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; }; /** * Highlights all the properties that have changed. */ type ChangedOptions = { [Key in keyof GetDynamic]: Changes[Key]>; }; /** * Get the static extension settings. */ type GetOptions = Type['~O']; /** * Get the commands from a `RemirrorManager`, `Extension` or `Preset`. */ type GetCommands = Type['~C']; /** * Get the helpers provided by an from a `RemirrorManager`, `Extension` or * `Preset`. */ type GetHelpers = Type['~H']; /** * Get the constructor of an instance. */ type GetConstructor = Type['constructor']; /** * Get the options from any constructor. Can be used for both presets and * extensions. */ type OptionsOfConstructor = GetOptions>; /** * Get the options from any constructor. Can be used for both presets and * extensions. */ type DynamicOptionsOfConstructor = GetPartialDynamic>>; /** * The extension store which is shared across all extensions. It provides access * to methods and data that can be used throughout the extension lifecycle. */ interface ExtensionStore$1 extends Remirror.ExtensionStore { } type ExtensionCommandFunction = (...args: any[]) => CommandFunction; /** * The return signature for an extensions command method. */ interface ExtensionCommandReturn { [command: string]: ExtensionCommandFunction; } /** * The return signature for an extensions helper method. */ interface ExtensionHelperReturn { [helper: string]: AnyFunction; } /** * The type of a non chainable command. It is a function with an `isEnabled` * method to check whether the command can be run. */ interface CommandShape { /** * 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.isEnabled()` 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; /** * @deprecated use `enabled` instead. */ isEnabled: (...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; } interface ApplyStateLifecycleProps extends EditorStateProps { /** * The original transaction which caused this state update. */ tr: Transaction; /** * The previous state. */ previousState: EditorState; } 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[]; } 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[]; } interface BaseExtensionOptions extends Remirror.BaseExtensionOptions { /** * An object which excludes certain functionality from an extension. */ exclude?: ExcludeOptions$1; /** * 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; } interface ExcludeOptions$1 extends Partial { } /** * @internal */ type UpdateReason = 'set' | 'reset'; 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; } interface GetChangeOptionsReturn { /** * The next value of the properties after the update.This also includes values * which have not been changed. */ options: GetFixedDynamic; /** * 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>>; /** * Pick the changed values by their key. An object populated with only the * changed items will be returned to you. */ pickChanged: PickChanged; } type PickChanged = >(keys: Key[]) => Partial, Key>>; interface OnSetOptionsProps extends Pick, 'changes' | 'pickChanged'>, UpdateReasonProps { /** * The initial options for the extension. Falls back to default options. */ initialOptions: RemoveAnnotations>; /** * The next value of the properties after the update.This also includes values * which have not been changed. */ options: RemoveAnnotations>; } 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. */ interface CreateExtensionPlugin extends Pick, '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; } /** * A helper interface for creating strongly typed decorators. */ interface TypedPropertyDescriptor { configurable?: boolean; enumerable?: boolean; value?: Type; writable?: boolean; get?: () => Type; set?: (v: Type) => void; } /** * 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. */ type FocusType = PrimitiveSelection | boolean; declare const IGNORE = "__IGNORE__"; declare const GENERAL_OPTIONS: "__ALL__"; /** * @internal */ type CustomHandlerMethod = >(key: Key, value: Required>[Key]) => Dispose; type AddCustomHandler = (props: Partial>) => Dispose | undefined; type AddHandler = >(key: Key, method: GetHandler[Key]) => Dispose; interface HandlerKeyOptions { /** * When this value is encountered the handler will exit early. * * Set the value to `'__IGNORE__'` to ignore the early return value. */ earlyReturnValue?: LiteralUnion | ((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; }; } declare abstract class BaseClass { /** * 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 & { [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 & 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 & 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); /** * 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): BaseClass; /** * 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): 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) {} * * // BAD ❌ * onSetOptions = (props: OnSetOptionsProps) => {} * } * ``` * * @abstract */ protected onSetOptions?(props: OnSetOptionsProps): 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: Key, method: GetHandler[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: 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: Key, value: Required>[Key]): Dispose; /** * Override this method if you want to set custom handlers on your extension. * * This must return a dispose function. */ protected onAddCustomHandler?: AddCustomHandler; } interface BaseClass { constructor: BaseClassConstructor; } interface BaseClassConstructor extends Function { new (...args: ConstructorProps): 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; /** * 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 & { __ALL__?: HandlerKeyOptions; }>; /** * A list of the custom keys in the extension or preset options. */ readonly customHandlerKeys: string[]; } /** * 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. */ type ConstructorProps = IfNoRequiredProperties, [ options?: GetConstructorProps & DefaultStaticOptions ], [ options: GetConstructorProps & DefaultStaticOptions ]>; /** * 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. */ type DefaultOptions = MakeUndefined> & Partial & GetFixedDynamic, StringKey>>; interface AnyBaseClassOverrides { addCustomHandler: AnyFunction; addHandler: AnyFunction; clone: AnyFunction; } /** * 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. */ type ExtensionConstructorProps = ConstructorProps; /** * 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.isEnabled()`. * - 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; * id?: string; * } * * class AwesomeExtension extends PlainExtension { * static defaultOptions: DefaultExtensionOptions = { * isAwesome: true, * id: '', * } * * get name() { * return 'awesome' as const; * } * } * ``` */ declare abstract class Extension extends BaseClass { /** * 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; /** * 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); /** * 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[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 { * get name() { * return 'parent' as const; * } * * createExtensions() { * return [new BoldExtension()] * } * * onSetOptions(options: OnSetOptionsProps): void { * if (options.changes.weight.changed) { * // Update the value of the provided extension. * this.getExtension(BoldExtension).setOption({ weight: options.changes.weight.value }); * } * } * } * ``` */ getExtension(Constructor: Type): InstanceType; /** * Check if the type of this extension's constructor matches the type of the * provided constructor. */ isOfType(Constructor: Type): this is InstanceType; /** * 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): Extension; /** * 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. */ interface Extension extends Remirror.BaseExtension { /** * The type of the constructor for the extension. */ constructor: ExtensionConstructor; /** * 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[]; } /** * 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. */ type DefaultExtensionOptions = DefaultOptions; /** * 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 extends Extension { /** @internal */ static get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.PlainExtensionConstructor; /** @internal */ get [__INTERNAL_REMIRROR_IDENTIFIER_KEY__](): RemirrorIdentifier.PlainExtension; } /** * 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 extends Extension { /** @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); /** * 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; } interface MarkExtension extends Extension, Remirror.MarkExtension { } /** * 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 extends Extension { 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); /** * 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; } interface NodeExtension extends Extension, Remirror.NodeExtension { } /** * The type which is applicable to any extension instance. * * **NOTE** `& object` forces VSCode to use the name `AnyExtension` rather than * print out `Replace, Remirror.AnyExtensionOverrides>` */ type AnyExtension = Replace, Remirror.AnyExtensionOverrides> & object; /** * The type which is applicable to any extension instance. */ type AnyExtensionConstructor = Replace, { new (...args: any[]): AnyExtension; }>; /** * The type for any potential PlainExtension. */ type AnyPlainExtension = Replace, Remirror.AnyExtensionOverrides> & object; /** * The type for any potential NodeExtension. */ type AnyNodeExtension = Replace, Remirror.AnyExtensionOverrides> & object; /** * The type for any potential MarkExtension. */ type AnyMarkExtension = Replace, Remirror.AnyExtensionOverrides> & object; /** * 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; /** * Determines if the passed value is an extension. * * @param value - the value to test */ declare function isExtension(value: unknown): value is Type; /** * Determines if the passed value is an extension constructor. * * @param value - the value to test */ declare function isExtensionConstructor(value: unknown): value is Type; /** * Checks whether the provided value is a plain extension. * * @param value - the extension to check */ declare function isPlainExtension(value: unknown): value is Type; /** * 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(value: unknown): value is Type; /** * 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(value: unknown): value is Type; interface ExtensionConstructor extends BaseClassConstructor, Partial { new (...args: ExtensionConstructorProps): Extension; /** * The default priority level for all instance of this extension. * * @defaultValue ExtensionPriority.Default */ readonly defaultPriority: ExtensionPriority; } type AnyManagerStore = Remirror.ManagerStore; type ManagerStoreKeys = keyof Remirror.ManagerStore; 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; } } } interface DefaultOptionsProps { /** * 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; * } * ``` * * 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; } interface DefaultPriorityProps { /** * The default priority for this extension. * * @defaultValue {} */ defaultPriority?: ExtensionPriority; } interface StaticKeysProps { /** * The list of all keys which are static and can only be set at the start. */ staticKeys: StaticKeyList; } /** * 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. */ interface HandlerKeysProps { /** * The list of the option names which are event handlers. */ handlerKeys: HandlerKeyList; /** * 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; } type MappedHandlerKeyOptions = { [Key in keyof GetHandler]?: HandlerKeyOptions[Key]>, Parameters[Key]>>; } & { __ALL__?: HandlerKeyOptions; }; interface CustomHandlerKeysProps { customHandlerKeys: CustomHandlerKeyList; } type ExtensionDecoratorOptions = DefaultPriorityProps & IfHasRequiredProperties, DefaultOptionsProps, Partial>> & IfEmpty, Partial>, StaticKeysProps> & IfEmpty, Partial>, HandlerKeysProps> & IfEmpty, Partial>, CustomHandlerKeysProps> & Partial; /** * A decorator for the remirror extension. * * This adds static properties to the extension constructor. */ declare function extension(options: ExtensionDecoratorOptions): (ReadonlyConstructor: Type) => Type; /** * @deprecated use `extension` instead. */ declare const extensionDecorator: typeof extension; interface ExtensionListProps { /** * The extensions property. */ readonly extensions: readonly Extension[]; } /** * A utility type which maps the passed in extension command in an action that * is store in the `manager.store.actions.commandName()`. */ type MapToUnchainedCommand> = { [Command in keyof RawCommands]: CommandShape>; }; /** * A utility type which maps the chained commands. */ type MapToChainedCommand> = { [Command in keyof RawCommands]: ReturnType extends NonChainableCommandFunction ? void : (...args: Parameters) => any; }; /** * 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. */ type CommandsFromExtensions> = UnionToIntersection | GetDecoratedCommands>>; /** * 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 */ type GetDecoratedCommands = Type extends AnyExtension ? ConditionalPick> : never; interface UiAnnotation { __uiAnnotation?: never; } type UiCommandFunction = CommandFunction & UiAnnotation; type GetDecoratedUiCommands = Type extends AnyExtension ? ConditionalPick> : never; /** * Utility type for pulling all the command names from a list. * * TODO - why doesn't this work. */ type UiCommandNames = StringKey>]: keyof UnionToIntersection>[P] extends '__uiAnnotation' ? true : false; }, true>>; 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; } interface NewChainedCommandProps = ChainedIntersection> { /** * 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; } type ChainedIntersection = UnionToIntersection | GetDecoratedCommands>>; type ChainedFromExtensions = ChainedIntersection> = _ChainedFromExtensions & ((tr: Transaction) => _ChainedFromExtensions); type _ChainedFromExtensions = ChainedIntersection> = ChainedCommandProps & NewChainedCommandProps & { [Command in keyof Chained]: Chained[Command] extends (...args: any[]) => any ? (...args: Parameters) => ChainedFromExtensions : never; }; /** * Utility type for pulling all the command names from a list */ type CommandNames = StringKey>; /** * A utility type which maps the passed in extension helpers to a method called * with `manager.data.helpers.helperName()`. */ type MapHelpers> = { [Helper in keyof RawHelpers]: RawHelpers[Helper]; }; /** * 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. */ type HelpersFromExtensions> = UnionToIntersection | GetDecoratedHelpers>>; type HelperAnnotation = Flavoring<'HelperAnnotation'>; /** * An annotation which marks decorated helper methods for an extension. */ type Helper = Type extends null | undefined ? Type : Type & HelperAnnotation; /** * Remove the helper annotation. */ type RemoveHelper = Type extends Helper ? T : Type; type RemoveHelpers> = { [Key in keyof Type]: (...args: Parameters) => RemoveHelper>; }; /** * A function with a return signature annotated as a helper. */ type HelperFunction = AnyFunction; type GetDecoratedHelpers = Type extends object ? RemoveHelpers> : never; /** * Utility type for pulling all the action names from a list */ type HelperNames = StringKey>; /** * Removes [[`AnyExtension`]] from an extension union. This can be used to make * typechecking stricter. * * @typeParam Extension - The union of extensions to remove [[`AnyExtension`]] from. */ type RemoveAny = Extension extends Extension ? AnyExtension extends Extension ? never : Extension : never; /** * 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. */ type GetExtensions = AnyExtension extends Extension ? AnyExtension : Extension extends AnyExtension ? // Now create the union of the provided extension and it's recursively Extension | GetExtensions : AnyExtension; /** * Extract the function return type if the generic type is a function, otherwise * * @internal * * @example * * ```ts * type A = () => string * type B = UnpackedReturnType * // B = string * * type C = string * type D = UnpackedReturnType * // D = string * ``` */ type UnpackedReturnType = MaybeFunction extends (...args: any[]) => infer Returned ? Returned : MaybeFunction; /** * 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 * // Extension = BoldExtension | ItalicExtension * ``` * * @example * * ```ts * const extensions = () => [new BoldExtension(), new ItalicExtension()]; * type Extension = UnpackedExtension * // Extension = BoldExtension | ItalicExtension * ``` */ type UnpackedExtension AnyExtension[])> = UnpackedReturnType[number]; /** * The type which gets the active methods from the provided extensions. */ type ActiveFromExtensions = Record extends never ? string : GetNodeNameUnion, (attrs?: ProsemirrorAttributes) => boolean> & Record extends never ? string : GetMarkNameUnion, (attrs?: ProsemirrorAttributes) => boolean>; /** * The type which gets the attributes for the provided node or mark. It returns * undefined if the node / mark is not active. */ type AttrsFromExtensions = Record extends never ? string : GetNodeNameUnion, (attrs?: ProsemirrorAttributes) => ProsemirrorAttributes | undefined> & Record extends never ? string : GetMarkNameUnion, (attrs?: ProsemirrorAttributes) => ProsemirrorAttributes | undefined>; /** * Get the names of all available extensions. */ type GetNameUnion = GetExtensions['name']; /** * 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. */ type GetPlainNameUnion> = Expanded extends AnyPlainExtension ? Expanded['name'] : never; /** * 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. */ type GetMarkNameUnion> = Expanded extends AnyMarkExtension ? Expanded['name'] : never; /** * 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. */ type GetNodeNameUnion> = Expanded extends AnyNodeExtension ? Expanded['name'] : never; declare global { namespace Remirror { /** * A utility type for all the globally available extension names. This is * mainly used to provide autocompletion. */ type NameUnion = LiteralUnion, string>; /** * A utility type for all the globally available plain extension names. This * is mainly used to provide autocompletion. */ type PlainNameUnion = LiteralUnion, string>; /** * A utility type for all the globally available node extension names. This * is mainly used to provide autocompletion. */ type NodeNameUnion = LiteralUnion, string>; /** * A utility type for all the globally available mark extension names. This * is mainly used to provide autocompletion. */ type MarkNameUnion = LiteralUnion, string>; } } type ClassName = T | false | void | null | 0 | ''; declare function cx(...classes: ClassName[]): string; /** * 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; } declare global { namespace Remirror { interface ManagerStore { /** * 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; } } } /** * 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 { 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 { helper, Helper } from '@remirror/core'; * * class MyExtension { * get name() { * return 'my'; * } * * @helper() * alwaysTrue(): Helper { * 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() ? : null * } * ``` * * @category Method Decorator */ declare function helper(options?: HelperDecoratorOptions): (target: Extension, propertyKey: string, _descriptor: TypedPropertyDescriptor extends HelperAnnotation ? Type : never>>) => void; /** * 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 * } * ``` * * @category Method Decorator */ declare function command(options?: ChainableCommandDecoratorOptions>>): ExtensionDecorator; declare function command(options: NonChainableCommandDecoratorOptions>>): ExtensionDecorator; /** * 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(options: KeybindingDecoratorOptions>>): (target: Extension, propertyKey: string, _descriptor: TypedPropertyDescriptor) => void; interface HelperDecoratorOptions { } type KeyboardShortcutFunction = (options: Options, store: Remirror.ExtensionStore) => KeyboardShortcut; type KeyboardShortcutValue = Listable>; type KeyboardShortcut = KeyboardShortcutValue | KeyboardShortcutFunction; interface KeybindingDecoratorOptions { /** * 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; } type ExtensionDecorator = (target: Extension, propertyKey: string, _descriptor: TypedPropertyDescriptor>) => Return; 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; } type CommandDecoratorShortcut = string | { shortcut: string; attrs: ProsemirrorAttributes; } | string[] | Array<{ shortcut: string; attrs: ProsemirrorAttributes; }>; interface CommandUiDecoratorOptions { /** * The default command icon to use if this has a UI representation. */ icon?: CommandDecoratorValue; /** * 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; } 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: I18n['_']; } /** * @typeParam Value - the value which should be returned from the function or * used directly. */ type CommandDecoratorValue = ((props: CommandDecoratorMessageProps) => Value) | Value; type CommandDecoratorMessage = CommandDecoratorValue; interface ChainableCommandDecoratorOptions extends Remirror.CommandDecoratorOptions { /** * Set this to `true` to disable chaining of this command. This means it will * no longer be available when running ` * * @defaultValue false */ disableChaining?: false; } interface NonChainableCommandDecoratorOptions extends Remirror.CommandDecoratorOptions { /** * Set this to `true` to disable chaining of this command. This means it will * no longer be available when running ` * * @defaultValue false */ disableChaining: true; } type CommandDecoratorOptions = ChainableCommandDecoratorOptions | NonChainableCommandDecoratorOptions; declare global { namespace Remirror { /** * UX options for the command which can be extended. */ interface CommandDecoratorOptions 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; } } } /** * The parameter that is passed into `DelayedCommand`s. */ interface DelayedCommandProps { /** * 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; /** * 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; } type DelayedValue = Promise | (() => Promise); /** * Returns `true` when the provided value is a delayed value. */ declare function isDelayedValue(value: unknown): value is DelayedValue; /** * 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({ immediate, promise, onDone, onFail, }: DelayedCommandProps): CommandFunction; type DelayedPromiseCreator = (props: CommandFunctionProps) => Promise; declare class DelayedCommand { private readonly promiseCreator; private readonly failureHandlers; private readonly successHandlers; private readonly validateHandlers; constructor(promiseCreator: DelayedPromiseCreator); /** * 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; } interface ToggleMarkProps extends MarkTypeProps, Partial { /** * @deprecated use `selection` property instead. */ range?: FromToProps; /** * The selection point for toggling the chosen mark. */ selection?: PrimitiveSelection; } /** * 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; interface InsertTextOptions extends Partial { /** * Marks can be added to the inserted text. */ marks?: Record; } /** * 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; interface CommandOptions { /** * The className that is added to all tracker positions * * '@defaultValue 'remirror-tracker-position' */ trackerClassName?: Static; /** * The default element that is used for all trackers. * * @defaultValue 'span' */ trackerNodeName?: Static; } /** * 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 { 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$1): 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 * } * ``` * * 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 ; * }; * ``` */ 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), 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(pos: number, attrs: ProsemirrorAttributes): 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 * } * ``` */ 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>>; /** * Get the options that were passed into the provided command. */ getCommandOptions(name: string): Helper | undefined>; /** * A short hand way of getting the `view`, `state`, `tr` and `dispatch` * methods. */ getCommandProp(): Helper>; /** * 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>): 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; } interface InsertNodeOptions { attrs?: ProsemirrorAttributes; marks?: Array; /** * 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; } /** * Provides the list of Prosemirror EditorView props that should be updated/ */ type ForcedUpdateMeta = UpdatableViewProps[]; type UpdatableViewProps = 'attributes' | 'editable'; interface CommandExtensionMeta { forcedUpdates?: UpdatableViewProps[]; } /** * A type with a name property. */ type WithName = Type & { name: string; }; declare global { namespace Remirror { interface ManagerStore { /** * 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.isEnabled()) { * commands.toggleBold(); * } * ``` */ commands: CommandsFromExtensions; /** * 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; } interface BaseExtension { /** * `ExtensionCommands` * * This pseudo property makes it easier to infer Generic types of this * class. * * @internal */ ['~C']: this['createCommands'] extends AnyFunction ? ReturnType : 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; /** * 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; /** * 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; } interface AllExtensions { commands: CommandsExtension; } /** * The command names for all core extensions. */ type AllCommandNames = LiteralUnion, string>; /** * The command names for all core extensions. */ type AllUiCommandNames = LiteralUnion, string>; } } interface DecorationsOptions$1 { /** * 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; /** * 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>; /** * The className that is added to all placeholder positions * * '@defaultValue 'placeholder' */ placeholderClassName?: Static; /** * The default element that is used for all placeholders. * * @defaultValue 'span' */ placeholderNodeName?: Static; } /** * 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 { 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(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; /** * Find the positions of all the trackers in document. */ findAllPlaceholders(): Helper>; /** * Add some decorations based on the provided settings. */ createDecorations(state: EditorState): DecorationSet; /** * 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; } interface DecorationPlaceholderMeta { /** * The trackers to add. */ added?: Array>; /** * 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; } 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; } interface DataProps { /** * The data to store for this placeholder. */ data?: Data; } interface InlinePlaceholder extends BasePlaceholder, Partial, DataProps { type: 'inline'; } interface NodePlaceholder extends BasePlaceholder, DataProps { /** * 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; } interface WidgetPlaceholder extends BasePlaceholder, DataProps { /** * 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; } type WithBase = MakeRequired & { id: unknown; }; type DecorationPlaceholder = WidgetPlaceholder | NodePlaceholder | InlinePlaceholder; interface DelayedPlaceholderCommandProps { /** * A function that returns a promise. */ promise: DelayedPromiseCreator; /** * 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; }>; } 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(props: DelayedPlaceholderCommandProps): DelayedCommand; } 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; } } } interface DocChangedOptions { docChanged?: Handler<(props: StateUpdateLifecycleProps) => void>; } declare class DocChangedExtension extends PlainExtension { get name(): "docChanged"; onStateUpdate(props: StateUpdateLifecycleProps): void; } /** * 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; isViewEditable(state?: EditorState): Helper; /** * Get the full JSON output for the ProseMirror editor state object. */ getStateJSON(state?: EditorState): Helper; /** * 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; /** * @deprecated use `getJSON` instead. */ getRemirrorJSON(state?: EditorState): Helper; /** * 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; getTextBetween(from: number, to: number, doc?: ProsemirrorNode): Helper; /** * Get the html from the current state, or provide a custom state. */ getHTML(state?: EditorState): Helper; /** * Wrap the content in a pre tag to preserve whitespace and see what the * editor does with it. */ private textToProsemirrorNode; } interface GetTextHelperOptions extends Partial { /** * The divider used to separate text blocks. * * @defaultValue '\n\n' */ lineBreakDivider?: string; } declare global { namespace Remirror { interface ManagerStore { /** * The helpers provided by the extensions used. */ helpers: HelpersFromExtensions; /** * Check which nodes and marks are active under the current user * selection. * * ```ts * const { active } = manager.store; * * return active.bold() ? 'bold' : 'regular'; * ``` */ active: ActiveFromExtensions; /** * 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; } interface BaseExtension { /** * `ExtensionHelpers` * * This pseudo property makes it easier to infer Generic types of this * class. * * @internal */ ['~H']: this['createHelpers'] extends AnyFunction ? ReturnType : 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; /** * 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 * ? (😍) * : (😢); * }; * ``` */ createHelpers?(): ExtensionHelperReturn; } interface StringHandlers { /** * Register the plain `text` string handler which renders a text string * inside a `
`.
             */
            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;
            /**
             * Check which nodes and marks are active under the current user
             * selection.
             *
             * ```ts
             * const { active } = manager.store;
             *
             * return active.bold() ? 'bold' : 'regular';
             * ```
             */
            active: ActiveFromExtensions;
            /**
             * 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;
        }
        interface ListenerProperties {
            helpers: HelpersFromExtensions;
        }
        interface AllExtensions {
            helpers: HelpersExtension;
        }
    }
    /**
     * The helpers name for all extension defined in the current project.
     */
    type AllHelperNames = LiteralUnion, string>;
}

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;
}
/**
 * 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 {
    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;
}
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;
        }
    }
}

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;
}
/**
 * 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 {
    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;
    /**
     * @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;
    /**
     * Handle changes in the dynamic properties.
     */
    protected onSetOptions(props: OnSetOptionsProps): 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;
}
/**
 * A shortcut map which is used by the `KeymapExtension`.
 */
type ShortcutMap = Record;
/**
 * The default named shortcuts used within `remirror`.
 */
declare const DEFAULT_SHORTCUTS: ShortcutMap;
/**
 * Shortcuts used within google docs.
 */
declare const GOOGLE_DOC_SHORTCUTS: ShortcutMap;
declare const keyboardShortcuts: {
    default: ShortcutMap;
    googleDoc: ShortcutMap;
};
type KeyboardShortcuts = keyof typeof keyboardShortcuts | ShortcutMap;
/**
 * KeyBindings as a tuple with priority and the keymap.
 */
type KeyBindingsTuple = [priority: ExtensionPriority, bindings: KeyBindings];
/**
 * `KeyBindings` as an object or prioritized tuple.
 */
type PrioritizedKeyBindings = KeyBindings | KeyBindingsTuple;
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;
            /**
             * Add keymap bindings for this extension.
             *
             * @param parameter - schema parameter with type included
             */
            createKeymap?(extractShortcutNames: (shortcut: string) => string[]): PrioritizedKeyBindings;
        }
        interface AllExtensions {
            keymap: KeymapExtension;
        }
    }
}

/**
 * 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;
}
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;
        }
        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;
        }
        interface AllExtensions {
            nodeViews: NodeViewsExtension;
        }
    }
}

interface PasteRulesOptions {
}
/**
 * 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;
}
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;
        }
    }
}

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>;
}
/**
 * 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 {
    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;
    /**
     * 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;
}
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(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 {
            /**
             * 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: (name: GetNameUnion) => State;
            /**
             * All the plugin keys available to be used by plugins.
             */
            pluginKeys: Record;
        }
        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?: EditorState$1) => 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;
        }
    }
}

/**
 * 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;
}
/**
 * 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.
 */
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[];
}
/**
 * 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.
 */
type Identifiers = 'nodes' | 'marks' | 'all' | readonly string[] | IdentifiersObject;
/**
 * The interface for adding extra attributes to multiple node and mark
 * extensions.
 */
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;
}
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;
            /**
             * 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;
            /**
             * An override for the mark spec object. This only applies for
             * `MarkExtension`.
             */
            markOverride?: Static;
            /**
             * An override object for a node spec object. This only applies to the
             * `NodeExtension`.
             */
            nodeOverride?: Static;
        }
        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;
            /**
             * Overrides for the nodes.
             */
            nodeOverride?: Record;
            /**
             * 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 {
            /**
             * The nodes to place on the schema.
             */
            nodes: Record extends never ? string : GetNodeNameUnion, NodeExtensionSpec>;
            /**
             * The marks to be added to the schema.
             */
            marks: Record extends never ? string : GetMarkNameUnion, 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;
        }
    }
}

interface SuggestOptions {
    /**
     * The custom handler which enables adding `suggesters`.
     */
    suggester: CustomHandler;
}
/**
 * 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 {
    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;
    /**
     * Get the suggest plugin state.
     *
     * This may be removed at a later time.
     *
     * @experimental
     */
    getSuggestState(state?: EditorState): Helper;
    /**
     * Get some helpful methods from the SuggestPluginState.
     */
    getSuggestMethods(): Helper>;
    /**
     * 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;
}
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;
        }
    }
}

/**
 * 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;
}
/**
 * Check if the provided string is an extension tag.
 */
declare function isExtensionTag(value: string): value is ExtensionTagType;
/**
 * 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...
 */
type CombinedTags = Record;
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;
        }
        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;
        interface ManagerStore {
            /**
             * All the tags provided by the configured extensions.
             */
            tags: Readonly extends never ? string : GetNameUnion>>;
            /**
             * All the plain extension tags provided for the editor.
             */
            plainTags: Readonly extends never ? string : GetPlainNameUnion>>;
            /**
             * All the node extension tags provided for the editor.
             */
            nodeTags: Readonly extends never ? string : GetNodeNameUnion>>;
            /**
             * All the mark extension tags provided for the editor.
             */
            markTags: Readonly extends never ? string : GetMarkNameUnion>>;
        }
        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 enum ActionType {
    ADD_PLACEHOLDER = 0,
    REMOVE_PLACEHOLDER = 1
}
interface AddPlaceholderAction {
    type: ActionType.ADD_PLACEHOLDER;
    id: string;
    payload: any;
    pos: number;
}
interface RemovePlaceholderAction {
    type: ActionType.REMOVE_PLACEHOLDER;
    id: string;
}
type PlaceholderPluginAction = AddPlaceholderAction | RemovePlaceholderAction;

/**
 * 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$1, id: string): number | undefined;
declare function findUploadPlaceholderPayload(state: EditorState$1, id: string): any | undefined;
/**
 * 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$1): boolean;
declare function setUploadPlaceholderAction(tr: Transaction$1, action: PlaceholderPluginAction): Transaction$1;

interface UploadContext {
    set: (key: string, value: unknown) => void;
    get: (key: string) => unknown;
    addListener: (listener: UploadContextListener) => () => void;
}
type UploadContextListener = (values: Record) => void;

interface FileUploader {
    /**
     * 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;
    /**
     * Aborts the upload operation.
     */
    abort: () => void;
}

/**
 * Any `ProsemirrorNode` can use the `uploadFile` function in this file as long
 * as its attributes implement this interface.
 */
interface AbstractNodeAttributes {
    id?: any;
    error?: string | null;
}
type UploadFileHandler = () => FileUploader;
interface UploadPlaceholderPayload {
    context: UploadContext;
    fileUploader: FileUploader;
}
interface UploadFileProps {
    file: File;
    pos: number | undefined;
    view: EditorView$1;
    fileType: NodeType$1;
    uploadHandler: UploadFileHandler;
}
/**
 * Insert a file into the editor and upload it.
 */
declare function uploadFile({ file, pos, view, fileType, uploadHandler, }: UploadFileProps): void;

interface DecorationsOptions {
}
/**
 * `UploadExtension` handle the file upload process.
 */
declare class UploadExtension extends PlainExtension {
    get name(): "upload";
    /**
     * Create the extension plugin for inserting decorations into the editor.
     */
    createExternalPlugins(): ProsemirrorPlugin$1[];
}
declare global {
    namespace Remirror {
        interface AllExtensions {
            upload: UploadExtension;
        }
    }
}

interface BuiltinOptions extends SuggestOptions, KeymapOptions, DecorationsOptions$1, InputRulesOptions {
}
/**
 * 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): BuiltinPreset[];
type BuiltinPreset = TagsExtension | SchemaExtension | AttributesExtension | PluginsExtension | InputRulesExtension | PasteRulesExtension | NodeViewsExtension | SuggestExtension | CommandsExtension | HelpersExtension | KeymapExtension | DocChangedExtension | UploadExtension | DecorationsExtension;
declare global {
    namespace Remirror {
        interface ManagerSettings {
            /**
             * The options that can be passed into the built in options.
             */
            builtin?: GetStaticAndDynamic;
        }
        /**
         * The builtin preset.
         */
        type Builtin = BuiltinPreset;
        /**
         * The union of every extension available via the remirror codebase.
         */
        type Extensions = ValueOf;
    }
}

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;
}
/**
 * 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 {
    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;
}
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;
}
interface KeyBindingMetadata {
    type: 'keyBinding';
    /**
     * The name of the extension used.
     */
    extension: string;
    /**
     * The shortcut used to invoke this keybinding.
     */
    shortcut: string;
}
type Metadata = CommandMetadata | KeyBindingMetadata;
declare global {
    namespace Remirror {
        interface ManagerStore {
            /**
             * Get the command metadata for the transaction.
             * @internal
             */
            getCommandMeta(tr: Transaction): Metadata[];
        }
        interface AllExtensions {
            meta: MetaExtension;
        }
    }
}

/**
 * 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.
 */
type ExtensionTemplate = () => Extension[];
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;
}
type AnyRemirrorManager = Simplify, {
    clone: () => AnyRemirrorManager;
    store: Replace, {
        chain: any;
    }>;
    output: Replace, {
        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;
}>>;
/**
 * 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(value: unknown, mustIncludeList?: Array): value is RemirrorManager;
interface CreateEditorStateProps extends Omit {
    /**
     * 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;
}
interface RemirrorManagerConstructor extends Function {
    create(extension: Extension[], settings?: Remirror.ManagerSettings): RemirrorManager;
}
/**
 * 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 {
    #private;
    /**
     * Create the manager for your `Remirror` editor.
     */
    static create(extensions: Extension[] | ExtensionTemplate, settings?: Remirror.ManagerSettings): RemirrorManager;
    /**
     * 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 
     * }
     * ```
     */
    get output(): FrameworkOutput | 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>;
    /**
     * 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;
    /**
     * 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;
    /**
     * Returns the store marks.
     */
    get marks(): Record;
    /**
     * 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>>;
    /**
     * 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, 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$1;
    /**
     * Add a handler to the manager.
     *
     * Currently the only event that can be listened to is the `destroy` event.
     */
    addHandler(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): void;
    /**
     * Get the extension instance matching the provided constructor from the
     * manager.
     *
     * This will throw an error if non existent.
     */
    getExtension(Constructor: ExtensionConstructor): InstanceType;
    /**
     * 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(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;
    /**
     * Recreate the manager with new settings and extensions
     */
    recreate(extensions?: ExtraExtension[], settings?: Remirror.ManagerSettings): RemirrorManager;
    /**
     * 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): boolean;
}
interface RemirrorManager {
    /**
     * 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 extends never ? string : GetNameUnion;
    /**
     * `NodeNames`
     *
     * Type inference hack for node extension names. This is the only way I know
     * to store types on a class.
     *
     * @internal
     */
    ['~N']: GetNodeNameUnion extends never ? string : GetNodeNameUnion;
    /**
     * `MarkNames`
     *
     * Type inference hack for mark extension names. This is the only way I know
     * to store types on a class.
     *
     * @internal
     */
    ['~M']: GetMarkNameUnion extends never ? string : GetMarkNameUnion;
    /**
     * `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 extends never ? string : GetPlainNameUnion;
}
declare global {
    namespace Remirror {
        /**
         * Settings which can be passed into the manager.
         */
        interface ManagerSettings extends Partial {
            /**
             * Set the extension priority for extension's by their name.
             */
            priority?: Record;
            /**
             * 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 (
             *     
             *       
* * ); * }; * ``` */ 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 { /** * 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$1; /** * The previous state. Will be undefined when the view is first created. */ previousState?: EditorState$1; /** * 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$1; /** * 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$1) => void; /** * Get the extension instance matching the provided constructor from the * manager. * * This will throw an error if not defined. */ readonly getExtension: (Constructor: ExtensionConstructor) => InstanceType; /** * Get the value of a key from the manager store. */ getStoreKey: (key: Key) => AnyManagerStore[Key]; /** * Update the store with a specific key. */ setStoreKey: (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: 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; } } } interface BaseFramework { /** * 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; /** * Destroy the framework and cleanup all created listeners. */ destroy(): void; } interface FrameworkOptions> { /** * 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; } /** * The base options for an editor wrapper. This is used within the react and dom * implementations. */ interface FrameworkProps { /** * Pass in the extension manager. * * The manager is responsible for handling all Prosemirror related * functionality. */ manager: RemirrorManager; /** * 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 | AttributePropFunction; /** * 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, event: Event) => void; /** * An event listener which is called whenever the editor is blurred. */ onBlur?: (params: RemirrorEventListenerProps, event: Event) => void; /** * Called on every change to the Prosemirror state. */ onChange?: RemirrorEventListener; /** * 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; } type AddFrameworkHandler = >(event: Key, cb: FrameworkEvents[Key]) => Unsubscribe; /** * This is the base output that is created by a framework. */ interface FrameworkOutput extends Remirror.ManagerStore { /** * The manager which was used to create this editor. */ manager: RemirrorManager; /** * Add event handlers to the remirror editor at runtime. */ addHandler: AddFrameworkHandler; /** * 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: (Constructor: ExtensionConstructor) => InstanceType; /** * Assert if an extension is present by it's constructor. */ hasExtension: (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; } type CreateStateFromContent = (content: RemirrorContentType, selection?: PrimitiveSelection) => EditorState; interface RemirrorEventListenerProps extends EditorStateProps, Remirror.ListenerProperties, 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; } type RemirrorEventListener = (params: RemirrorEventListenerProps) => void; type AttributePropFunction = (params: RemirrorEventListenerProps) => Record; interface PlaceholderConfig extends TextProps { className: string; } interface UpdateStateProps extends Partial, 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[]; } interface TriggerChangeProps { /** * Whether or not to trigger this as a change and call any handlers. * * @defaultValue true */ triggerChange?: boolean; } interface ListenerProps extends Partial, Partial { /** * 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[]; } interface FrameworkEvents extends Pick { /** * An event listener which is called whenever the editor gains focus. */ focus: (params: RemirrorEventListenerProps, event: Event) => void; /** * An event listener which is called whenever the editor is blurred. */ blur: (params: RemirrorEventListenerProps, 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; } type UpdatableViewPropsObject = { [Key in UpdatableViewProps]: DirectEditorProps[Key]; }; declare global { namespace Remirror { interface ListenerProperties { } } } /** * 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 = FrameworkProps, Output extends FrameworkOutput = FrameworkOutput> implements BaseFramework { #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; /** * 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; /** * 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); /** * 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): 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; 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; 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; /** * Every framework implementation must provide it's own custom output. */ abstract get frameworkOutput(): Output; } export { ActiveFromExtensions, AddCustomHandler, AddHandler, AnyExtension, AnyExtensionConstructor, AnyManagerStore, AnyMarkExtension, AnyNodeExtension, AnyPlainExtension, AnyRemirrorManager, AppendLifecycleProps, ApplyStateLifecycleProps, AttributePropFunction, AttributesExtension, AttrsFromExtensions, BaseExtensionOptions, BaseFramework, BuiltinOptions, BuiltinPreset, ChainedCommandProps, ChainedFromExtensions, ChainedIntersection, ChangedOptions, ClassName, CombinedTags, CommandDecoratorMessage, CommandDecoratorMessageProps, CommandDecoratorOptions, CommandDecoratorShortcut, CommandDecoratorValue, CommandExtensionMeta, CommandNames, CommandOptions, CommandShape, CommandUiDecoratorOptions, CommandUiIcon, CommandsExtension, CommandsFromExtensions, CreateEditorStateProps, CreateExtensionPlugin, CreateStateFromContent, CustomHandlerMethod, DEFAULT_SHORTCUTS, DecorationPlaceholder, DecorationPlaceholderMeta, DecorationsExtension, DecorationsOptions$1 as DecorationsOptions, DefaultExtensionOptions, DelayedCommand, DelayedPlaceholderCommandProps, DelayedPromiseCreator, DelayedValue, DocChangedExtension, DocChangedOptions, DynamicOptionsOfConstructor, ExcludeOptions$1 as ExcludeOptions, Extension, ExtensionCommandFunction, ExtensionCommandReturn, ExtensionConstructor, ExtensionConstructorProps, ExtensionDecoratorOptions, ExtensionHelperReturn, ExtensionListProps, ExtensionStore$1 as ExtensionStore, FileUploader, FocusType, ForcedUpdateMeta, Framework, FrameworkOptions, FrameworkOutput, FrameworkProps, GOOGLE_DOC_SHORTCUTS, GetChangeOptionsReturn, GetCommands, GetConstructor, GetExtensions, GetHelpers, GetMarkNameUnion, GetNameUnion, GetNodeNameUnion, GetOptions, GetPlainNameUnion, HandlerKeyOptions, Helper, HelperAnnotation, HelperDecoratorOptions, HelperFunction, HelperNames, HelpersExtension, HelpersFromExtensions, IdentifierSchemaAttributes, Identifiers, IdentifiersObject, InputRulesExtension, InputRulesOptions, InsertNodeOptions, KeyBindingsTuple, KeybindingDecoratorOptions, KeyboardShortcut, KeyboardShortcutFunction, KeyboardShortcutValue, KeyboardShortcuts, KeymapExtension, KeymapOptions, ListenerProps, ManagerEvents, ManagerStoreKeys, MapHelpers, MapToChainedCommand, MapToUnchainedCommand, MarkExtension, MetaExtension, MetaOptions, Metadata, NewChainedCommandProps, NodeExtension, NodeViewsExtension, OnSetOptionsProps, OptionsOfConstructor, PasteRulesExtension, PasteRulesOptions, PickChanged, PlaceholderConfig, PlainExtension, PluginsExtension, PluginsOptions, PrioritizedKeyBindings, RemirrorEventListener, RemirrorEventListenerProps, RemirrorManager, RemoveAny, SchemaExtension, ShortcutMap, StateUpdateLifecycleProps, SuggestExtension, SuggestOptions, TagsExtension, TriggerChangeProps, TypedPropertyDescriptor, UiCommandFunction, UiCommandNames, UnpackedExtension, UpdatableViewProps, UpdateReason, UpdateReasonProps, UpdateStateProps, UploadContext, UploadExtension, UploadFileHandler, UploadPlaceholderPayload, WidgetPlaceholder, builtinPreset, command, cx, delayedCommand, extension, extensionDecorator, findUploadPlaceholderPayload, findUploadPlaceholderPos, hasUploadingFile, helper, insertText, isDelayedValue, isExtension, isExtensionConstructor, isExtensionTag, isMarkExtension, isNodeExtension, isPlainExtension, isRemirrorManager, keyBinding, keyboardShortcuts, mutateDefaultExtensionOptions, setUploadPlaceholderAction, toggleMark, uploadFile };