Type Alias DocAuthEditor

DocAuthEditor: {
    setCurrentDocument(doc: DocAuthDocument): void;
    currentDocument(): DocAuthDocument;
    destroy(): void;
    docAuthSystem(): DocAuthSystem;
    on(event: EventName, handler: (payload: EventPayload) => void): DocAuthEditor;
    off(event: EventName, handler?: (payload: EventPayload) => void): DocAuthEditor;
    once(event: EventName, handler: (payload: EventPayload) => void): DocAuthEditor;
}

Type declaration

  • setCurrentDocument:function
    • Attaches the provided document as the current document to the editor.

      Parameters

      Returns void

  • currentDocument:function
  • destroy:function
    • Removes all DOM elements and releases resources held by the editor. Note: This does not release the underlying DocAuthSystem. Use DocAuthSystem.destroy after calling DocAuthEditor.destroy for a complete teardown.

      Returns void

  • docAuthSystem:function
  • on:function
    • Adds an event listener that will be called every time the specified event is emitted.

      Parameters

      • event: EventName
      • handler: (payload: EventPayload) => void

      Returns DocAuthEditor

      The editor instance for method chaining

      // Get the latest document content
      editor.on('content.change', async () => console.log(await editor.currentDocument().saveDocument()));
      Event name Event payload Description
      document.load none Fired when a document is initially loaded into the editor. This event is triggered once per document load, including when switching documents.
      content.change none Fired when the document content has changed due to user editing or programmatic modifications. Use this event to react to document changes, such as saving drafts or updating UI state.
  • off:function
    • Removes an event listener. If no handler is provided, removes all listeners for the event.

      Parameters

      • event: EventName
      • Optionalhandler: (payload: EventPayload) => void

      Returns DocAuthEditor

      The editor instance for method chaining

      // Remove specific handler
      editor.off('content.change', myHandler);

      // Remove all handlers for an event
      editor.off('content.change');
      Event name Event payload Description
      document.load none Fired when a document is initially loaded into the editor. This event is triggered once per document load, including when switching documents.
      content.change none Fired when the document content has changed due to user editing or programmatic modifications. Use this event to react to document changes, such as saving drafts or updating UI state.
  • once:function
    • Adds an event listener that will be called only once when the specified event is emitted. The listener is automatically removed after being called.

      Parameters

      • event: EventName
      • handler: (payload: EventPayload) => void

      Returns DocAuthEditor

      The editor instance for method chaining

      editor.once('document.load', () => {
      console.log('Document loaded for the first time');
      });
      Event name Event payload Description
      document.load none Fired when a document is initially loaded into the editor. This event is triggered once per document load, including when switching documents.
      content.change none Fired when the document content has changed due to user editing or programmatic modifications. Use this event to react to document changes, such as saving drafts or updating UI state.