Skip to content

Commit

Permalink
Merge pull request #349 from CodinGame/full-workbench-mode
Browse files Browse the repository at this point in the history
Full workbench mode
  • Loading branch information
CGNonofr authored Feb 26, 2024
2 parents c6d475b + a133ca1 commit 0611236
Show file tree
Hide file tree
Showing 61 changed files with 2,656 additions and 1,804 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,30 @@ Additionally, several packages that include the VSCode version of some services
- Support for the outline view. *Hint*: It only makes sense to enable it when *Views* service is used.
- **Timeline**: `@codingame/monaco-vscode-timeline-service-override`
- Support for the timeline view. *Hint*: It only makes sense to enable it when *Views* service is used.
- **Workbench**: `@codingame/monaco-vscode-workbench-service-override`
- Allows to render the full workbench layout. Is exclusive with the `views` service. Do not use both services at the same time.
- **Comments**
- Enables comments extension api
- **Edit-sessions**
- Enable cloudchanges
- **Emmet**
- Enables the `triggerExpansionOnTab` command for the emmet default extension
- **Interactive**
- Interactive notbooks
- **Issue**
- Issue reporting
- **Multi diff editor**
- Multi diff editor support (https://code.visualstudio.com/updates/v1_85#_multifile-diff-editor)
- **Performance**
- Performance monitoring
- **Relauncher**
- Detects changes that require a reload (like settings change) and prompt the user for it
- **Share**
- Enables the share extension api
- **Survey**
- Survey/feedback support
- **Update**
- Update detection, release notes...

Usage:

Expand Down
62 changes: 0 additions & 62 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,6 @@
<link rel="icon" href="/favicon.ico" type="image/x-icon">
</head>
<body>
<div id="app">
<div id="workbench-container">
<div id="titleBar"></div>
<div id="banner"></div>
<div id="workbench-top">
<div style="display: flex; flex: none; border: 1px solid var(--vscode-editorWidget-border)">
<div id="activityBar"></div>
<div id="sidebar" style="width: 400px"></div>
<div id="auxiliaryBar-left" style="max-width: 300px"></div>
</div>
<div style="flex: 1; min-width: 0">
<h1>Editor</h1>
<div id="editors"></div>

<button id="run">Run with debugger</button>
<button id="filesystem">Attach filesystem</button>
<button id="customEditorPanel">Open custom editor panel</button>
<button id="clearStorage">Clear user data</button>
<br />
<button id="togglePanel">Toggle Panel</button>
<button id="toggleAuxiliary">Toggle Secondary Panel</button>
<br />
<label for="localeSelect">Language:</label>
<select id="localeSelect">
<option value="">English</option>
<option value="cs">Czech</option>
<option value="de">German</option>
<option value="es">Spanish</option>
<option value="fr">French</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="pl">Polish</option>
<option value="pt-br">Portuguese (Brazil)</option>
<option value="qps-ploc">Pseudo Language</option>
<option value="ru">Russian</option>
<option value="tr">Turkish</option>
<option value="zh-hans">Chinese (Simplified)</option>
<option value="zh-hant">Chinese (Traditional)</option>
</select>
</div>
<div style="display: flex; flex: none; border: 1px solid var(--vscode-editorWidget-border);">
<div id="sidebar-right" style="max-width: 500px"></div>
<div id="activityBar-right"></div>
<div id="auxiliaryBar" style="max-width: 300px"></div>
</div>
</div>

<div id="panel"></div>

<div id="statusBar"></div>
</div>

<h1>Settings<span id="settings-dirty"></span></h1>
<button id="settingsui">Open settings UI</button>
<button id="resetsettings">Reset settings</button>
<div id="settings-editor" class="standalone-editor"></div>
<h1>Keybindings<span id="keybindings-dirty"></span></h1>
<button id="keybindingsui">Open keybindings UI</button>
<button id="resetkeybindings">Reset keybindings</button>
<div id="keybindings-editor" class="standalone-editor"></div>
</div>
<script type="module" src="/src/loader.ts"></script>
</body>
</html>
424 changes: 194 additions & 230 deletions demo/package-lock.json

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"compile": "tsc",
"start": "NODE_OPTIONS=--experimental-import-meta-resolve vite --config vite.config.ts",
"start:debug": "vite --config vite.config.ts --debug --force",
"build": "tsc --noEmit && vite --config vite.config.ts build",
"build": "vite --config vite.config.ts build",
"build:github": "tsc --noEmit && vite --config vite.github-page.config.ts build && touch dist/.nojekyll",
"start:debugServer": "node --loader ts-node/esm src/debugServer.ts",
"start:extHostServer": "WEB_ENDPOINT_URL_TEMPLATE=http://localhost:5173/ vscode-ext-host-server --without-connection-token"
Expand All @@ -21,7 +21,6 @@
"@types/node": "^20.11.4",
"@types/wicg-file-system-access": "^2023.10.4",
"@types/ws": "^8.5.10",
"fast-glob": "^3.3.2",
"ts-node": "^10.9.2",
"typescript": "~5.3.3",
"vite": "~5.1.3"
Expand Down Expand Up @@ -163,9 +162,22 @@
"@codingame/monaco-vscode-view-status-bar-service-override": "file:../dist/service-override-view-status-bar",
"@codingame/monaco-vscode-view-title-bar-service-override": "file:../dist/service-override-view-title-bar",
"@codingame/monaco-vscode-views-service-override": "file:../dist/service-override-views",
"@codingame/monaco-vscode-workbench-service-override": "file:../dist/service-override-workbench",
"@codingame/monaco-vscode-welcome-service-override": "file:../dist/service-override-welcome",
"@codingame/monaco-vscode-working-copy-service-override": "file:../dist/service-override-working-copy",
"@codingame/monaco-vscode-workspace-trust-service-override": "file:../dist/service-override-workspace-trust",
"@codingame/monaco-vscode-comments-service-override": "file:../dist/service-override-comments",
"@codingame/monaco-vscode-edit-sessions-service-override": "file:../dist/service-override-edit-sessions",
"@codingame/monaco-vscode-emmet-service-override": "file:../dist/service-override-emmet",
"@codingame/monaco-vscode-interactive-service-override": "file:../dist/service-override-interactive",
"@codingame/monaco-vscode-issue-service-override": "file:../dist/service-override-issue",
"@codingame/monaco-vscode-multi-diff-editor-service-override": "file:../dist/service-override-multi-diff-editor",
"@codingame/monaco-vscode-performance-service-override": "file:../dist/service-override-performance",
"@codingame/monaco-vscode-relauncher-service-override": "file:../dist/service-override-relauncher",
"@codingame/monaco-vscode-share-service-override": "file:../dist/service-override-share",
"@codingame/monaco-vscode-speech-service-override": "file:../dist/service-override-speech",
"@codingame/monaco-vscode-survey-service-override": "file:../dist/service-override-survey",
"@codingame/monaco-vscode-update-service-override": "file:../dist/service-override-update",
"@codingame/monaco-vscode-xml-default-extension": "file:../dist/default-extension-xml",
"@codingame/monaco-vscode-yaml-default-extension": "file:../dist/default-extension-yaml",
"ansi-colors": "^4.1.3",
Expand Down
29 changes: 15 additions & 14 deletions demo/src/features/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ const { getApi } = registerExtension({
enabledApiProposals: ['aiRelatedInformation']
}, ExtensionHostKind.LocalProcess)

const vscode = await getApi()
vscode.commands.registerCommand('aiSuggestedCommand', () => {
void vscode.window.showInformationMessage('Hello', {
detail: 'You just run the AI suggested command',
modal: true
void getApi().then(async vscode => {
vscode.commands.registerCommand('aiSuggestedCommand', () => {
void vscode.window.showInformationMessage('Hello', {
detail: 'You just run the AI suggested command',
modal: true
})
})
vscode.ai.registerRelatedInformationProvider(vscode.RelatedInformationType.CommandInformation, {
provideRelatedInformation () {
return [{
type: vscode.RelatedInformationType.CommandInformation,
command: 'aiSuggestedCommand',
weight: 9999
}]
}
})
})
vscode.ai.registerRelatedInformationProvider(vscode.RelatedInformationType.CommandInformation, {
provideRelatedInformation () {
return [{
type: vscode.RelatedInformationType.CommandInformation,
command: 'aiSuggestedCommand',
weight: 9999
}]
}
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IDialogService, EditorInput, ITelemetryService, IThemeService, IStorageService, createInstance, IInstantiationService } from 'vscode/services'
import { registerCustomView, registerEditorPane, registerEditor, registerEditorSerializer, ViewContainerLocation, SimpleEditorPane, SimpleEditorInput, RegisteredEditorPriority, IEditorCloseHandler, ConfirmResult, IEditorSerializer } from '@codingame/monaco-vscode-views-service-override'
import { IEditorCloseHandler, IEditorSerializer, registerCustomView, registerEditorPane, registerEditor, registerEditorSerializer, ViewContainerLocation, SimpleEditorPane, SimpleEditorInput, RegisteredEditorPriority, ConfirmResult } from '@codingame/monaco-vscode-views-service-override'
import * as monaco from 'monaco-editor'

registerCustomView({
Expand Down Expand Up @@ -82,7 +82,7 @@ class CustomEditorInput extends SimpleEditorInput implements IEditorCloseHandler
this.setName('Custom editor pane input')
}

async confirm (): Promise<ConfirmResult> {
async confirm (): Promise<number> {
const { confirmed } = await this.dialogService.confirm({
message: 'Are you sure you want to close this INCREDIBLE editor pane?'
})
Expand Down
139 changes: 139 additions & 0 deletions demo/src/features/customView.workbench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { IDialogService, EditorInput, ITelemetryService, IThemeService, IStorageService, createInstance, IInstantiationService } from 'vscode/services'
import { IEditorCloseHandler, IEditorSerializer, registerCustomView, registerEditorPane, registerEditor, registerEditorSerializer, ViewContainerLocation, SimpleEditorPane, SimpleEditorInput, RegisteredEditorPriority, ConfirmResult } from '@codingame/monaco-vscode-workbench-service-override'
import * as monaco from 'monaco-editor'

registerCustomView({
id: 'custom-view',
name: 'Custom demo view',
order: 0,
default: true,
renderBody: function (container: HTMLElement): monaco.IDisposable {
container.style.display = 'flex'
container.style.alignItems = 'center'
container.style.justifyContent = 'center'
container.innerHTML = 'This is a custom view<br />You can render anything you want here'

return {
dispose () {
}
}
},
location: ViewContainerLocation.Panel,
icon: new URL('../Visual_Studio_Code_1.35_icon.svg', import.meta.url).toString(),
actions: [{
id: 'custom-action',
title: 'Custom action',
render (element) {
const button = document.createElement('button')
button.innerText = 'Ugly button'
button.style.height = '30px'
button.onclick = () => {
alert('What did you expect?')
}
element.append(button)
}
}, {
id: 'custom-action2',
title: 'Custom action2',
icon: 'dialogInfo',
async run (accessor) {
void accessor.get(IDialogService).info('This is a custom view action button')
}
}]
})

class CustomEditorPane extends SimpleEditorPane {
static readonly ID = 'workbench.editors.customEditor'

constructor (
@ITelemetryService telemetryService: ITelemetryService, @IThemeService themeService: IThemeService, @IStorageService storageService: IStorageService
) {
super(CustomEditorPane.ID, telemetryService, themeService, storageService)
}

initialize (): HTMLElement {
const container = document.createElement('div')
container.style.display = 'flex'
container.style.alignItems = 'center'
container.style.justifyContent = 'center'
container.innerHTML = 'This is a custom editor pane<br />You can render anything you want here'
return container
}

async renderInput (input: EditorInput): Promise<monaco.IDisposable> {
if (input.resource != null) {
this.container.innerHTML = 'Opened file: ' + input.resource.path
} else {
this.container.innerHTML = 'This is a custom editor pane<br />You can render anything you want here'
}

return {
dispose () {
}
}
}
}
class CustomEditorInput extends SimpleEditorInput implements IEditorCloseHandler {
constructor (resource: monaco.Uri | undefined, @IDialogService private dialogService: IDialogService) {
super(resource)

this.closeHandler = this

this.setName('Custom editor pane input')
}

async confirm (): Promise<number> {
const { confirmed } = await this.dialogService.confirm({
message: 'Are you sure you want to close this INCREDIBLE editor pane?'
})
return confirmed ? ConfirmResult.DONT_SAVE : ConfirmResult.CANCEL
}

showConfirm (): boolean {
return true
}

get typeId (): string {
return CustomEditorPane.ID
}
}

registerEditorPane('custom-editor-pane', 'Custom editor pane', CustomEditorPane, [CustomEditorInput])

registerEditor('*.customeditor', {
id: CustomEditorPane.ID,
label: 'Custom editor pane input',
priority: RegisteredEditorPriority.default
}, {
singlePerResource: true
}, {
async createEditorInput (editorInput) {
return {
editor: await createInstance(CustomEditorInput, editorInput.resource)
}
}
})

interface ISerializedCustomEditorInput {
resourceJSON?: monaco.UriComponents
}
registerEditorSerializer(CustomEditorPane.ID, class implements IEditorSerializer {
canSerialize (): boolean {
return true
}

serialize (editor: CustomEditorInput): string | undefined {
const serializedFileEditorInput: ISerializedCustomEditorInput = {
resourceJSON: editor.resource?.toJSON()
}

return JSON.stringify(serializedFileEditorInput)
}

deserialize (instantiationService: IInstantiationService, serializedEditor: string): EditorInput | undefined {
const serializedFileEditorInput: ISerializedCustomEditorInput = JSON.parse(serializedEditor)
return instantiationService.createInstance(CustomEditorInput, monaco.Uri.revive(serializedFileEditorInput.resourceJSON))
}
})

export { CustomEditorInput }
Loading

0 comments on commit 0611236

Please sign in to comment.