Datalayer VS Code Extension - v0.0.17
    Preparing search index...

    Class LexicalDocument

    Represents a lexical document in VS Code custom editor. Manages document lifecycle, content state, and collaboration features.

    This class implements the VS Code CustomDocument interface to provide document management for Datalayer's lexical editor integration.

    Hierarchy (View Summary)

    Implements

    • CustomDocument
    Index

    Properties

    _disposables: Disposable[] = []

    Collection of child disposables to clean up.

    onDidChange: Event<void> = ...

    Event fired when document state changes. Indicates document is dirty or collaborative sync occurred.

    onDidChangeContent: Event<{ content?: Uint8Array }> = ...

    Event fired when document content changes. VS Code CustomDocument interface compliance.

    onDidDispose: Event<void> = ...

    Event fired when document is disposed. VS Code CustomDocument interface compliance.

    Accessors

    • get documentData(): Uint8Array

      Gets the current document content as binary data.

      Returns Uint8Array

      Binary representation of the document content.

    • get isDirty(): boolean

      Whether the document has unsaved changes.

      In collaborative mode, this always returns false since changes are automatically synchronized to the platform.

      Returns boolean

      True if document has unsaved changes, false otherwise.

    • get isDisposed(): boolean

      Gets whether this instance has been disposed.

      Returns boolean

      True if disposed, false otherwise.

    • get uri(): Uri

      Gets the document's URI.

      Returns Uri

      The VS Code URI identifying this document.

    Methods

    • Registers a disposable to be cleaned up when this instance is disposed.

      Type Parameters

      • T extends Disposable

      Parameters

      • value: T

        The disposable to register.

      Returns T

      The registered disposable.

    • Creates a backup of the document.

      Saves the current document state to a backup location and returns a backup descriptor that can be used for restoration.

      Parameters

      • destination: Uri

        URI for the backup location.

      • cancellation: CancellationToken

        Cancellation token for aborting the backup operation.

      Returns Promise<CustomDocumentBackup>

      Promise resolving to backup descriptor with delete callback.

    • Disposes of the document and releases all associated resources.

      Fires disposal events and calls the parent disposable cleanup. Should be called when the document is no longer needed.

      Returns void

    • Records an edit operation on the document.

      In non-collaborative mode, marks the document as dirty and fires change events. In collaborative mode, only fires change events since the document state is managed externally.

      Parameters

      • _edit: unknown

        The edit operation data (currently unused).

      Returns void

    • Reverts the document to its last saved state.

      Reloads content from disk, clears the dirty state, and notifies listeners of the content change.

      Parameters

      • _cancellation: CancellationToken

        Cancellation token (currently unused).

      Returns Promise<void>

    • Saves the document to its original location.

      In collaborative mode, this operation is a no-op since changes are automatically synchronized. Otherwise, retrieves current content from the webview and writes it to the file system.

      Parameters

      • cancellation: CancellationToken

        Cancellation token for aborting the save operation.

      Returns Promise<void>

    • Saves the document to a new location.

      Retrieves current content from the webview and writes it to the specified target location. Does not change the document's original URI.

      Parameters

      • targetResource: Uri

        URI where to save the document.

      • cancellation: CancellationToken

        Cancellation token for aborting the save operation.

      Returns Promise<void>

    • Sets the collaborative mode for this document.

      When collaborative mode is enabled, the document becomes read-only and changes are automatically synchronized to the Datalayer platform. The dirty state is cleared when entering collaborative mode.

      Parameters

      • isCollaborative: boolean

        Whether to enable collaborative mode.

      Returns void

    • Creates a new LexicalDocument instance from a URI.

      Handles both regular files and backup scenarios. For backup restoration, the backupId parameter should contain the backup file URI.

      Parameters

      • uri: Uri

        The document URI to open.

      • backupId: string

        Optional backup ID for document restoration.

      • delegate: LexicalDocumentDelegate

        Delegate providing webview content retrieval capabilities.

      Returns Promise<LexicalDocument>

      Promise resolving to the created document instance.