@remirror/pm

  • Version 2.0.1
  • Published
  • 98 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, state: EditorState) => EditorState;
  • 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 = import('../view').Decoration;

    type DecorationSet

    type DecorationSet = import('../view').DecorationSet;

      type DispatchFunction

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

      type EditorSchema

      type EditorSchema = import('../model').Schema;

        type EditorState

        type EditorState = Readonly<import('../state').EditorState>;

          type EditorView

          type EditorView = import('../view').EditorView;

            type Fragment

            type Fragment = import('../model').Fragment;

              type InputRule

              type InputRule = import('../inputrules').InputRule;

                type Mapping

                type Mapping = import('../transform').Mapping;

                  type Mark

                  type Mark = import('../model').Mark;

                    type MarkType

                    type MarkType = import('../model').MarkType;

                      type NodeType

                      type NodeType = import('../model').NodeType;

                        type NodeView

                        type NodeView = import('../view').NodeView;

                          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> = import('../state').PluginKey<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 = import('../model').Node;

                              type ProsemirrorPlugin

                              type ProsemirrorPlugin<PluginState = any> = import('../state').Plugin<PluginState>;

                                type ResolvedPos

                                type ResolvedPos = import('../model').ResolvedPos;

                                  type Selection

                                  type Selection = import('../state').Selection;

                                    type Slice

                                    type Slice = import('../model').Slice;

                                      type Transaction

                                      type Transaction = import('../state').Transaction;

                                        Package Files (3)

                                        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>