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

    Custom editor provider for Lexical documents. Handles webview lifecycle management, document state synchronization, and collaboration features for rich text editing.

    const provider = new LexicalProvider(context);
    // Provider is registered automatically via static register method

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _context: ExtensionContext
    _messageRouter: DocumentMessageRouter
    _networkBridge: NetworkBridgeService
    _onDidChangeCustomDocument: EventEmitter<
        CustomDocumentEditEvent<LexicalDocument>,
    > = ...

    Event emitter for document changes. Subclasses should fire this event when documents change.

    _runtimeBridge: RuntimeBridgeService
    adapterConnectionTimes: Map<string, number> = ...
    adapterCreationTimes: Map<string, number> = ...
    adapterToWebview: Map<string, string> = ...
    documents: Map<string, LexicalDocument> = ...

    Map of document instances keyed by document URI. Used for dirty state tracking and document operations.

    loroAdapters: Map<string, LoroWebSocketAdapter> = ...

    Map of Loro WebSocket adapters keyed by adapter ID.

    onDidChangeCustomDocument: Event<CustomDocumentEditEvent<LexicalDocument>> = ...

    Event for document changes (required by CustomEditorProvider interface).

    webviews: Map<string, { resource: string; webviewPanel: WebviewPanel }> = ...

    Map of currently active webviews keyed by document URI.

    viewType: "datalayer.lexical-editor"

    Methods

    • Creates a backup of a custom document.

      Parameters

      • document: LexicalDocument

        Document to backup

      • context: CustomDocumentBackupContext

        Backup context with destination

      • cancellation: CancellationToken

        Cancellation token

      Returns Thenable<CustomDocumentBackup>

      Promise resolving to backup descriptor

    • Find document URI for a given webview panel

      Parameters

      • panel: WebviewPanel

      Returns string

    • Generates the HTML content for the Lexical editor webview.

      Parameters

      • webview: Webview

        The webview instance

      Returns string

      HTML content for the webview

    • Handles Loro collaboration messages from the webview. Creates/manages WebSocket adapters and forwards messages.

      Parameters

      • message: {
            adapterId: string;
            data?: { websocketUrl?: string; [key: string]: unknown };
            type: string;
        }

        Message from webview

      • webviewPanel: WebviewPanel

        The webview panel

      Returns void

    • Posts a message to the webview without expecting a response.

      Parameters

      • panel: WebviewPanel

        Target webview panel

      • type: string

        Message type

      • body: unknown

        Message body

      • Optionalid: string

        Optional message ID

      Returns void

    • Posts a message to the webview and waits for a response. Uses the request/response pattern with requestId tracking.

      Type Parameters

      • R = unknown

      Parameters

      • panel: WebviewPanel

        Target webview panel

      • type: string

        Message type

      • body: unknown

        Message body

      Returns Promise<R>

      Promise resolving to the response

    • Resolves a custom editor by setting up the webview and initializing collaboration.

      Parameters

      • document: LexicalDocument

        The lexical document to display

      • webviewPanel: WebviewPanel

        The webview panel for the editor

      • _token: CancellationToken

        Cancellation token

      Returns Promise<void>

      Promise that resolves when editor is ready

    • Registers the Lexical editor provider and commands with VS Code.

      Parameters

      • context: ExtensionContext

        Extension context for resource management

      Returns Disposable

      Disposable for cleanup