-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit reworks a large part of the VS Code integration package by updating the user-facing API and adding editor features. At the heart of the user-facing API lies the "GlspVscodeConnector". This component acts as a bridge between a diagram client and a graphical language server implementation, both of which the extension authors provide via the connector's options. The connector will propagate any message sent by the server to the client and vice-versa. It intercepts messages of certain types to add VS Code native functionality, for example, it processes the "setMarkers" action sent by the server to render diagnostics within VS Code. The VS Code connector exposes methods to interact with active clients. The "sendActionToActiveClient" method can be used to send various GLSP-Protocol Actions to the currently active client. Extension authors can use this action to interact with the diagram through user-triggered VS Code commands. Extension authors can use interceptor functions in the connector configuration to control how the VS Code integration behaves when it receives messages. The new package API now provides "quickstart components" that reduce the necessary boilerplate code to get started. Quickstart components include a helper class to launch the default GLSP language server, a default editor provider to render webviews, and a helper class to connect a language server to the VS Code integration. Complete Changelog: - Added native editor functionality - Clipboard support - SVG Export - Native menu contributions - Rework API for extension authors - Component to bridge client and server (GlspVscodeConnector) - Interceptors - Method to interact with currently active diagram editor (sendActionToActiveClient) - Exposure of currently selected elements within the diagram editor - Add quickstart components - GLSP server launcher - Default editor provider - Helper class to connect language server to VS Code integration - Add documentation
- Loading branch information
Showing
37 changed files
with
2,040 additions
and
1,228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
example/workflow/extension/src/workflow-editor-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.01 | ||
********************************************************************************/ | ||
|
||
import * as vscode from 'vscode'; | ||
import * as path from 'path'; | ||
|
||
import { GlspVscodeConnector } from '@eclipse-glsp/vscode-integration'; | ||
import { GlspEditorProvider } from '@eclipse-glsp/vscode-integration/lib/quickstart-components'; | ||
|
||
export default class WorkflowEditorProvider extends GlspEditorProvider { | ||
diagramType = 'workflow-diagram'; | ||
|
||
constructor( | ||
protected readonly extensionContext: vscode.ExtensionContext, | ||
protected readonly glspVscodeConnector: GlspVscodeConnector | ||
) { | ||
super(glspVscodeConnector); | ||
} | ||
|
||
setUpWebview(_document: vscode.CustomDocument, webviewPanel: vscode.WebviewPanel, _token: vscode.CancellationToken, clientId: string): void { | ||
const localResourceRootsUri = vscode.Uri.file( | ||
path.join(this.extensionContext.extensionPath, './pack') | ||
); | ||
|
||
const webviewScriptSourceUri = vscode.Uri.file( | ||
path.join(this.extensionContext.extensionPath, './pack/webview.js') | ||
); | ||
|
||
webviewPanel.webview.options = { | ||
localResourceRoots: [localResourceRootsUri], | ||
enableScripts: true | ||
}; | ||
|
||
webviewPanel.webview.html = ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, height=device-height"> | ||
<link | ||
rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" | ||
integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" | ||
crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
<div id="${clientId}_container" style="height: 100%;"></div> | ||
<script src="${webviewPanel.webview.asWebviewUri(webviewScriptSourceUri).toString()}"></script> | ||
</body> | ||
</html>`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.