Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • ProseMirrorEditor

Index

Constructors

  • new ProseMirrorEditor(uuid: string, view: EditorView, isDirtyPlugin: Plugin, collaborate: boolean, options?: { document: Document }): ProseMirrorEditor
  • 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.

    • options: { document: Document } = {}
      • document: Document

    Returns ProseMirrorEditor

Properties

options: { document: Document }

Type declaration

  • document: Document
#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

  • destroy(): void
  • Retire this editor instance and clean up.

    Returns void

  • isDirty(): boolean
  • Have the contents of the editor been edited by the user?

    Returns boolean

  • 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

  • _disableSourceCodeEditing(): void
  • Disable source code editing if the user was editing it when new steps arrived.

    Returns void

  • _resync(): void
  • The state of this ProseMirror editor has fallen too far behind the central authority's and must be re-synced.

    Returns void

  • _updateUserDisplay(users: string[]): void
  • Handle users joining or leaving collaborative editing.

    Parameters

    • users: string[]

      The IDs of users currently editing (including ourselves).

    Returns void

  • _handleAutosave(html: string): void
  • Handle an autosave update for an already-open editor.

    Parameters

    • html: string

      The updated editor contents.

    Returns void

  • create(target: HTMLElement, content?: string, [options]?: { uuid: string; document: Document; fieldName: string; plugins: any; relativeLinks: boolean; collaborate: boolean }): Promise<ProseMirrorEditor>
  • Create a ProseMirror editor instance.

    Parameters

    • target: HTMLElement

      An HTML element to mount the editor to.

    • content: string = ""
    • [options]: { uuid: string; document: Document; fieldName: string; plugins: any; relativeLinks: boolean; collaborate: boolean } = {}

      Additional options to configure the ProseMirror instance.

      • uuid: string
      • document: Document
      • fieldName: string
      • plugins: any
      • relativeLinks: boolean
      • collaborate: boolean

    Returns Promise<ProseMirrorEditor>

  • _activateSocketListeners(socket: Socket): void
  • Listen for ProseMirror collaboration events.

    internal

    Parameters

    • socket: Socket

      The open websocket.

    Returns void

  • _createCollaborativeEditorView(uuid: string, target: HTMLElement, state: EditorState, plugins: Plugin[]): Promise<EditorView>
  • 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>

  • _createLocalEditorView(target: HTMLElement, state: EditorState, plugins: Plugin[]): EditorView
  • 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

  • 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

  • _onResync(uuid: string): void
  • 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

  • _onUsersEditing(uuid: string, users: string[]): void
  • 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

  • _onAutosave(uuid: string, html: string): Promise<void>
  • 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>