@remirror/pm

  • Version 2.0.8
  • Published
  • 98.4 kB
  • 19 dependencies
  • MIT license

Install

npm i @remirror/pm
yarn add @remirror/pm
pnpm add @remirror/pm

Overview

A bundled library containing all the core prosemirror libraries required for using remirror

Index

Functions

function chainableEditorState

chainableEditorState: (tr: Transaction$1, state: EditorState$1) => EditorState$1;
  • Creates a fake state that can be used on ProseMirror library commands to make them chainable. The provided Transaction tr can be a shared one.

    Parameter tr

    the chainable transaction that should be amended.

    Parameter state

    the state of the editor (available via view.state).

    This should not be used other than for passing to prosemirror-* library commands.

function chainCommands

chainCommands: <Extra extends object = object>(
...commands: Array<CommandFunction<Extra>>
) => CommandFunction<Extra>;
  • Similar to the chainCommands from the prosemirror-commands library. Allows multiple commands to be chained together and runs until one of them returns true.

function convertCommand

convertCommand: <Extra extends object = object>(
commandFunction: ProsemirrorCommandFunction
) => CommandFunction<Extra>;
  • Wraps the default [[ProsemirrorCommandFunction]] and makes it compatible with the default **remirror** [[CommandFunction]] call signature.

    It extracts all the public APIs of the state object and assigns the chainable transaction to the state.tr property to support chaining.

function nonChainable

nonChainable: <Extra extends object = object>(
commandFunction: CommandFunction<Extra>
) => NonChainableCommandFunction<Extra>;
  • Marks a command function as non chainable. It will throw an error when chaining is attempted.

    Remarks

    const command = nonChainable(({ state, dispatch }) => {...});

Interfaces

interface CommandFunctionProps

interface CommandFunctionProps {}
  • A parameter builder interface for the remirror CommandFunction.

property dispatch

dispatch?: DispatchFunction;
  • The dispatch function which causes the command to be performed.

    Remarks

    dispatch can be undefined. When no dispatch callback is provided the command should perform a 'dry run', determining whether the command is applicable (return true), but not actually performing the action.

property state

state: EditorState;
  • A snapshot of the ProseMirror editor state.

property tr

tr: Transaction;
  • The shared ProseMirror Transaction.

property view

view?: EditorView;
  • An instance of the ProseMirror editor view.

Type Aliases

type CommandFunction

type CommandFunction<ExtraProps extends object = object> = (
params: CommandFunctionProps & ExtraProps
) => boolean;
  • A command method for running commands in your editor.

    Remarks

    This groups all the prosemirror command arguments into a single parameter.

    tldr; When dispatch=undefined make sure the command function is **idempotent**.

    One thing to be aware of is that when creating a command function the tr should only be updated when the dispatch method is available. This is because by convention calling the command function with dispatch=undefined is used to check if the function returns true, an indicator that it is enabled, or returns false to indicate it is not enabled.

    If the transaction has been updated outside of the dispatch=true condition then running the command again will result in multiple transaction updates and unpredictable behavior.

    See Also

type Decoration

type Decoration = Decoration$1;

    type DecorationSet

    type DecorationSet = DecorationSet$1;

      type DispatchFunction

      type DispatchFunction = (tr: Transaction) => void;
      • Used to apply the Prosemirror transaction to the current EditorState.

      type EditorSchema

      type EditorSchema = Schema;

        type EditorState

        type EditorState = Readonly<EditorState$1>;

          type EditorView

          type EditorView = EditorView$1;

            type Fragment

            type Fragment = Fragment$1;

              type InputRule

              type InputRule = InputRule$1;

                type Mapping

                type Mapping = Mapping$1;

                  type Mark

                  type Mark = Mark$1;

                    type MarkType

                    type MarkType = MarkType$1;

                      type NodeType

                      type NodeType = NodeType$1;

                        type NodeView

                        type NodeView = NodeView$1;

                          type NonChainableCommandFunction

                          type NonChainableCommandFunction<Extra extends object = object> = Brand<
                          CommandFunction<Extra>,
                          'non-chainable'
                          >;
                          • Brands a command as non chainable so that it can be excluded from the inferred chainable commands.

                          type PluginKey

                          type PluginKey<PluginState = any> = PluginKey$1<PluginState>;

                            type ProsemirrorCommandFunction

                            type ProsemirrorCommandFunction = (
                            state: EditorState,
                            dispatch: DispatchFunction | undefined,
                            view: EditorView | undefined
                            ) => boolean;
                            • This is the type signature for commands within the prosemirror editor.

                              Remarks

                              A command function takes an editor state and optionally a dispatch function that it can use to dispatch a transaction. It should return a boolean that indicates whether it could perform any action.

                              When no dispatch callback is passed, the command should do a 'dry run', determining whether it is applicable, but not actually performing any action.

                            type ProsemirrorNode

                            type ProsemirrorNode = Node;

                              type ProsemirrorPlugin

                              type ProsemirrorPlugin<PluginState = any> = Plugin<PluginState>;

                                type ResolvedPos

                                type ResolvedPos = ResolvedPos$1;

                                  type Selection

                                  type Selection = Selection$1;

                                    type Slice

                                    type Slice = Slice$1;

                                      type Transaction

                                      type Transaction = Transaction$1;

                                        Package Files (1)

                                        Dependencies (19)

                                        Dev Dependencies (0)

                                        No dev dependencies.

                                        Peer Dependencies (0)

                                        No peer dependencies.

                                        Badge

                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@remirror/pm.

                                        • Markdown
                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@remirror/pm)
                                        • HTML
                                          <a href="https://www.jsdocs.io/package/@remirror/pm"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>