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.

    • Optional options: {
          document: ClientDocument;
      } = {}

      Additional options.

      • document: ClientDocument

        A document associated with this editor.

    Returns ProseMirrorEditor

Properties

#isDirtyPlugin: Plugin

The plugin to track the dirty state of the editor.

#editors: Map<string, ProseMirrorEditor> = ...

A list of active editor instances by their UUIDs.

Methods

  • Retire this editor instance and clean up.

    Returns void

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

    Returns boolean

  • 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

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

    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

  • Protected

    Handle an autosave update for an already-open editor.

    Parameters

    • html: string

      The updated editor contents.

    Returns void

  • Create a ProseMirror editor instance.

    Parameters

    • target: HTMLElement

      An HTML element to mount the editor to.

    • Optional content: string = ""

      Content to populate the editor with.

    • Optional options: {
          uuid: string;
          document: ClientDocument;
          fieldName: string;
          plugins: Record<string, Plugin>;
          relativeLinks: boolean;
          collaborate: boolean;
      } = {}

      Additional options to configure the ProseMirror instance.

      • uuid: string

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

      • document: ClientDocument

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

      • fieldName: string

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

      • plugins: Record<string, Plugin>

        Plugins to include with the editor.

      • relativeLinks: boolean

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

      • collaborate: boolean

        Whether to enable collaborative editing for this editor.

    Returns Promise<ProseMirrorEditor>

  • Internal

    Listen for ProseMirror collaboration events.

    Parameters

    • socket: Socket

      The open websocket.

    Returns void

  • 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 editor plugins to load.

    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 editor plugins to load.

    Returns EditorView

  • 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

  • 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>