Datalayer VS Code Extension - v0.0.14
    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

    _callbacks: Map<string | number, (response: unknown) => void> = ...

    Map of request ID to response callbacks for request/response message pattern.

    _context: ExtensionContext

    VS Code extension context providing access to storage, subscriptions, etc.

    _messageRouter: DocumentMessageRouter

    Message router for handling webview messages and routing to appropriate handlers.

    _networkBridge: NetworkBridgeService

    Network bridge service for HTTP/WebSocket communication between extension and webview.

    _onDidChangeCustomDocument: EventEmitter<
        CustomDocumentEditEvent<LexicalDocument>,
    > = ...

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

    _runners: Map<WebviewPanel, Runner> = ...

    Map of webview panels to their Runner instances. Runners handle tool execution via the BridgeExecutor pattern.

    _runtimeBridge: RuntimeBridgeService

    Runtime bridge service for managing runtime lifecycle and selection.

    adapterConnectionTimes: Map<string, number> = ...
    adapterCreationTimes: Map<string, number> = ...
    adapterToWebview: Map<string, string> = ...
    autoConnectService: AutoConnectService = ...

    Auto-connect service for automatically connecting to runtimes

    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.

    _instance: LexicalProvider
    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

    • Clean LLM completion output by removing markdown code blocks.

      Parameters

      • completion: string

        Raw completion from LLM

      Returns string

      Cleaned completion

    • Proactively create LSP virtual documents for all Python and Markdown JupyterInputNodes. Parses the Lexical editor state JSON and extracts code blocks. This allows Pylance to start analyzing BEFORE the webview finishes loading, providing instant completions when the user presses Tab.

      Parameters

      • lexicalId: string

        Unique lexical document identifier

      • documentData: Uint8Array

        Raw .dlex file bytes (Lexical editor state JSON)

      Returns Promise<void>

    • Get completion configuration from VS Code settings. Reads user preferences for inline completions (code and prose).

      Returns InlineCompletionConfig

      InlineCompletionConfig with user settings or defaults

    • 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

    • Requests completion from VS Code's Language Model API. Uses GitHub Copilot if available, falls back to other models. Supports both code and prose completions with appropriate prompts.

      Parameters

      • prefix: string

        Text before cursor position

      • suffix: string

        Text after cursor position

      • language: string

        Programming language (e.g., 'python')

      • contentType: "code" | "prose" = "code"

        Content type ('code' or 'prose') for prompt selection

      Returns Promise<string>

      Completion text or null if unavailable

      Requires VS Code 1.90+ with Language Model API enabled. Automatically cleans markdown formatting from LLM responses.

    • 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

    • Initializes a Runner for a webview panel. Subclasses should call this in their resolveCustomEditor implementation.

      The Runner uses a BridgeExecutor to send tool execution requests to the webview, where they are executed by the webview's own Runner with DefaultExecutor.

      Parameters

      • webviewPanel: WebviewPanel

        The webview panel to create a Runner for

      Returns Promise<Runner>

      The created Runner instance

      async resolveCustomEditor(document, webviewPanel, token) {
      // Initialize Runner for this webview
      await this.initializeRunnerForWebview(webviewPanel);

      // ... rest of setup
      }
    • 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

    • Refreshes collaboration config for all active webviews. Called when auth state changes (login/logout) to update usernames.

      Returns Promise<void>

    • 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

    • Send a message to a specific Lexical webview

      Parameters

      • uri: Uri
      • message: unknown

      Returns Promise<void>

    • Send a message to a specific Lexical webview and wait for response

      Parameters

      • uri: Uri
      • message: unknown
      • requestId: string

      Returns Promise<unknown>

    • Attempts to auto-connect the document to a runtime using configured strategies.

      Parameters

      • documentUri: Uri

        URI of the document being opened

      Returns Promise<void>

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

      Parameters

      • context: ExtensionContext

        Extension context for resource management

      Returns Disposable

      Disposable for cleanup