A class responsible for managing state and collaborative editing of a single ProseMirror instance.

Constructors

  • Parameters

    • uuid: string

      A string that uniquely identifies this ProseMirror instance.

    • view: EditorView

      The ProseMirror EditorView.

    • isDirtyPlugin: Plugin

      The plugin to track the dirty state of the editor.

    • collaborate: boolean

      Whether this is a collaborative editor.

    • Optionaloptions: { document?: any } = {}

      Additional options.

      • Optionaldocument?: any

        A document associated with this editor.

    Returns ProseMirrorEditor

Methods

  • Retire this editor instance and clean up.

    Returns void

  • Have the contents of the editor been edited by the user?

    Returns boolean

  • Protected

    Disable source code editing if the user was editing it when new steps arrived.

    Returns void

  • Protected

    Handle an autosave update for an already-open editor.

    Parameters

    • html: string

      The updated editor contents.

    Returns void

  • Protected

    Handle new editing steps supplied by the server.

    Parameters

    • offset: string

      The offset into the history, representing the point at which it was last truncated.

    • history: ProseMirrorHistory[]

      The entire edit history.

    Returns void

  • Protected

    The state of this ProseMirror editor has fallen too far behind the central authority's and must be re-synced.

    Returns void

  • Protected

    Handle users joining or leaving collaborative editing.

    Parameters

    • users: string[]

      The IDs of users currently editing (including ourselves).

    Returns void

  • Internal

    Listen for ProseMirror collaboration events.

    Parameters

    • socket: Socket

      The open websocket.

    Returns void

  • Create a ProseMirror editor instance.

    Parameters

    • target: HTMLElement

      An HTML element to mount the editor to.

    • Optionalcontent: string = ""

      Content to populate the editor with.

    • Optionaloptions: {
          collaborate?: boolean;
          document?: any;
          fieldName?: string;
          plugins?: Record<string, Plugin>;
          props?: object;
          relativeLinks?: boolean;
          uuid?: string;
      } = {}

      Additional options to configure the ProseMirror instance.

      • Optionalcollaborate?: boolean

        Whether collaborative editing enabled.

      • Optionaldocument?: any

        A Document whose content is being edited. Required for collaborative editing and relative UUID generation.

      • OptionalfieldName?: string

        The field within the Document that is being edited. Required for collaborative editing.

      • Optionalplugins?: Record<string, Plugin>

        Plugins to include with the editor.

      • Optionalprops?: object

        Additional ProseMirror editor properties.

      • OptionalrelativeLinks?: boolean

        Whether to generate relative UUID links to Documents that are dropped on the editor.

      • Optionaluuid?: string

        A string to uniquely identify this ProseMirror instance. Ignored for a collaborative editor.

    Returns Promise<ProseMirrorEditor>

  • Protected

    Create an EditorView with collaborative editing enabled.

    Parameters

    • uuid: string

      The ProseMirror instance UUID.

    • target: HTMLElement

      An HTML element to mount the editor view to.

    • state: EditorState

      The ProseMirror editor state.

    • plugins: Plugin[]

      The ProseMirror editor plugins to load.

    • props: object

      Additional ProseMirror editor properties.

    Returns Promise<EditorView>

  • Protected

    Create a plain EditorView without collaborative editing.

    Parameters

    • target: HTMLElement

      An HTML element to mount the editor view to.

    • state: EditorState

      The ProseMirror editor state.

    • plugins: Plugin[]

      The ProseMirror editor plugins to load.

    • props: object

      Additional ProseMirror editor properties.

    Returns EditorView

  • Protected

    Update client state when the editor contents are autosaved server-side.

    Parameters

    • uuid: string

      The UUID that uniquely identifies the ProseMirror instance.

    • html: string

      The updated editor contents.

    Returns Promise<void>

  • Protected

    Handle new editing steps supplied by the server.

    Parameters

    • uuid: string

      The UUID that uniquely identifies the ProseMirror instance.

    • offset: number

      The offset into the history, representing the point at which it was last truncated.

    • history: ProseMirrorHistory[]

      The entire edit history.

    Returns void

  • Protected

    Our client is too far behind the central authority's state and must be re-synced.

    Parameters

    • uuid: string

      The UUID that uniquely identifies the ProseMirror instance.

    Returns void

  • Protected

    Handle users joining or leaving collaborative editing.

    Parameters

    • uuid: string

      The UUID that uniquely identifies the ProseMirror instance.

    • users: string[]

      The IDs of the users editing (including ourselves).

    Returns void