Creates a new LexicalProvider.
Extension context for resource access
Protected Readonly_Map of request ID to response callbacks for request/response message pattern.
Protected Readonly_VS Code extension context providing access to storage, subscriptions, etc.
Protected Readonly_Message router for handling webview messages and routing to appropriate handlers.
Protected Readonly_Network bridge service for HTTP/WebSocket communication between extension and webview.
Protected Readonly_Event emitter for document changes. Subclasses should fire this event when documents change.
Protected Readonly_Map of webview panels to their Runner instances. Runners handle tool execution via the BridgeExecutor pattern.
Protected Readonly_Runtime bridge service for managing runtime lifecycle and selection.
Private ReadonlyadapterPrivate ReadonlyadapterPrivate ReadonlyadapterPrivate ReadonlyautoAuto-connect service for automatically connecting to runtimes
Private ReadonlydocumentsMap of document instances keyed by document URI. Used for dirty state tracking and document operations.
Private ReadonlyloroMap of Loro WebSocket adapters keyed by adapter ID.
ReadonlyonEvent for document changes (required by CustomEditorProvider interface).
Private ReadonlywebviewsMap of currently active webviews keyed by document URI.
Private Static_Private Static ReadonlyviewCreates a backup of a custom document.
Document to backup
Backup context with destination
Cancellation token
Promise resolving to backup descriptor
PrivatecleanClean LLM completion output by removing markdown code blocks.
Raw completion from LLM
Cleaned completion
ProtectedgetGets the URI for a lexical document.
The lexical document
The document URI
PrivategetFind document URI for a given webview panel
PrivategetGenerates the HTML content for the Lexical editor webview.
The webview instance
HTML content for the webview
PrivategetRequests code completion from VS Code's Language Model API. Uses GitHub Copilot if available, falls back to other models.
Code before cursor position
Code after cursor position
Programming language (e.g., 'python')
Completion text or null if unavailable
ProtectedgetGets the Runner for a specific webview panel.
The webview panel
The Runner instance, or undefined if not initialized
PrivatehandleHandles Loro collaboration messages from the webview. Creates/manages WebSocket adapters and forwards messages.
Message from webview
The webview panel
ProtectedinitializeInitializes 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.
The webview panel to create a Runner for
The created Runner instance
ProtectedonHandles messages received from the webview. Delegates to the message router for all message types.
The webview panel that sent the message
The document associated with the webview
The message from the webview
Opens a custom document for the lexical editor.
Document URI to open
Context including backup information
Cancellation token
Promise resolving to the lexical document
ProtectedpostPosts a message to the webview without expecting a response.
Target webview panel
Message type
Message body
Optionalid: stringOptional message ID
ProtectedpostPosts a message to the webview and waits for a response. Uses the request/response pattern with requestId tracking.
Target webview panel
Message type
Message body
Promise resolving to the response
ProtectedregisterRegisters lexical-specific message handlers. Overrides base class to add lexical-specific handlers.
Resolves a custom editor by setting up the webview and initializing collaboration.
The lexical document to display
The webview panel for the editor
Cancellation token
Promise that resolves when editor is ready
Reverts a custom document to its saved state.
Document to revert
Cancellation token
Promise that resolves when revert is complete
Saves a custom document.
Document to save
Cancellation token
Promise that resolves when save is complete
Saves a custom document to a new location.
Document to save
Target URI for saving
Cancellation token
Promise that resolves when save is complete
Send a message to a specific Lexical webview
Send a message to a specific Lexical webview and wait for response
PrivatetryAttempts to auto-connect the document to a runtime using configured strategies.
URI of the document being opened
StaticgetGet the singleton instance of LexicalProvider for message routing
StaticregisterRegisters the Lexical editor provider and commands with VS Code.
Extension context for resource management
Disposable for cleanup
Custom editor provider for Lexical documents. Handles webview lifecycle management, document state synchronization, and collaboration features for rich text editing.
Example