@codingame/monaco-vscode-dialogs-service-override 2.1.4 → 2.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dialogs.js +3 -4
- package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
- package/package.json +3 -4
- package/vscode/src/vs/workbench/contrib/welcomeDialog/browser/media/welcomeWidget.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.js +103 -0
- package/vscode/src/vs/workbench/contrib/welcomeDialog/browser/welcomeWidget.js +179 -0
package/dialogs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import './vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js';
|
|
2
1
|
import { DialogService } from './vscode/src/vs/workbench/services/dialogs/common/dialogService.js';
|
|
3
2
|
import './override/vs/platform/dialogs/common/dialogs.js';
|
|
4
3
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
5
4
|
import { AbstractFileDialogService } from './vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js';
|
|
6
|
-
import getServiceOverride$1 from '@codingame/monaco-vscode-layout-service-override';
|
|
7
5
|
import { unsupported } from './tools.js';
|
|
6
|
+
import './vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js';
|
|
7
|
+
import './vscode/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.js';
|
|
8
8
|
import { IDialogService, IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
9
9
|
|
|
10
10
|
class FileDialogService extends AbstractFileDialogService {
|
|
@@ -50,8 +50,7 @@ class FileDialogService extends AbstractFileDialogService {
|
|
|
50
50
|
function getServiceOverride() {
|
|
51
51
|
return {
|
|
52
52
|
[( IDialogService.toString())]: new SyncDescriptor(DialogService, undefined, true),
|
|
53
|
-
[( IFileDialogService.toString())]: new SyncDescriptor(FileDialogService, undefined, true)
|
|
54
|
-
...getServiceOverride$1()
|
|
53
|
+
[( IFileDialogService.toString())]: new SyncDescriptor(FileDialogService, undefined, true)
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
2
|
+
|
|
3
|
+
export { n as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-dialogs-service-override",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.0-next.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"module": "index.js",
|
|
19
19
|
"types": "index.d.ts",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"vscode": "npm:@codingame/monaco-vscode-api@2.1
|
|
22
|
-
"vscode-marked": "npm:marked@=3.0.2"
|
|
23
|
-
"@codingame/monaco-vscode-layout-service-override": "2.1.4"
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@2.2.0-next.1",
|
|
22
|
+
"vscode-marked": "npm:marked@=3.0.2"
|
|
24
23
|
}
|
|
25
24
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
|
|
2
|
+
|
|
3
|
+
var css = ".monaco-dialog-box{border-radius:6px}.dialog-message-detail-title>div>p>.codicon[class*=codicon-]:before{color:var(--vscode-textLink-foreground);font-size:larger;padding-right:10px;position:relative}.dialog-message-detail-title{font-size:large;height:22px}.monaco-dialog-box .monaco-action-bar .actions-container{justify-content:flex-end}";
|
|
4
|
+
n(css,{});
|
|
5
|
+
|
|
6
|
+
export { css, css as default };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
3
|
+
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
4
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
5
|
+
import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
|
|
6
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
7
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
+
import { ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
9
|
+
import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
|
|
10
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
11
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
12
|
+
import { WelcomeWidget } from './welcomeWidget.js';
|
|
13
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
14
|
+
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
15
|
+
import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
16
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
17
|
+
import { applicationConfigurationNodeBase } from 'vscode/vscode/vs/workbench/common/configuration';
|
|
18
|
+
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
19
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
20
|
+
|
|
21
|
+
const configurationKey = 'workbench.welcome.experimental.dialog';
|
|
22
|
+
let WelcomeDialogContribution = class WelcomeDialogContribution extends Disposable {
|
|
23
|
+
constructor(storageService, environmentService, configurationService, contextService, codeEditorService, instantiationService, commandService, telemetryService, openerService, editorService) {
|
|
24
|
+
super();
|
|
25
|
+
this.contextService = contextService;
|
|
26
|
+
this.codeEditorService = codeEditorService;
|
|
27
|
+
this.instantiationService = instantiationService;
|
|
28
|
+
this.commandService = commandService;
|
|
29
|
+
this.telemetryService = telemetryService;
|
|
30
|
+
this.openerService = openerService;
|
|
31
|
+
this.editorService = editorService;
|
|
32
|
+
this.isRendered = false;
|
|
33
|
+
if (!storageService.isNew(-1 )) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const setting = configurationService.inspect(configurationKey);
|
|
37
|
+
if (!setting.value) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const welcomeDialog = environmentService.options?.welcomeDialog;
|
|
41
|
+
if (!welcomeDialog) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this._register(editorService.onDidActiveEditorChange(() => {
|
|
45
|
+
if (!this.isRendered) {
|
|
46
|
+
const codeEditor = codeEditorService.getActiveCodeEditor();
|
|
47
|
+
if (codeEditor?.hasModel()) {
|
|
48
|
+
const scheduler = ( new RunOnceScheduler(() => {
|
|
49
|
+
const notificationsVisible = contextService.contextMatchesRules(ContextKeyExpr.deserialize('notificationCenterVisible')) ||
|
|
50
|
+
contextService.contextMatchesRules(ContextKeyExpr.deserialize('notificationToastsVisible'));
|
|
51
|
+
if (codeEditor === codeEditorService.getActiveCodeEditor() && !notificationsVisible) {
|
|
52
|
+
this.isRendered = true;
|
|
53
|
+
const welcomeWidget = ( new WelcomeWidget(
|
|
54
|
+
codeEditor,
|
|
55
|
+
instantiationService,
|
|
56
|
+
commandService,
|
|
57
|
+
telemetryService,
|
|
58
|
+
openerService
|
|
59
|
+
));
|
|
60
|
+
welcomeWidget.render(welcomeDialog.title, welcomeDialog.message, welcomeDialog.buttonText, welcomeDialog.buttonCommand);
|
|
61
|
+
}
|
|
62
|
+
}, 3000));
|
|
63
|
+
this._register(codeEditor.onDidChangeModelContent((e) => {
|
|
64
|
+
if (!this.isRendered) {
|
|
65
|
+
scheduler.schedule();
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
WelcomeDialogContribution = ( __decorate([
|
|
74
|
+
( __param(0, IStorageService)),
|
|
75
|
+
( __param(1, IBrowserWorkbenchEnvironmentService)),
|
|
76
|
+
( __param(2, IConfigurationService)),
|
|
77
|
+
( __param(3, IContextKeyService)),
|
|
78
|
+
( __param(4, ICodeEditorService)),
|
|
79
|
+
( __param(5, IInstantiationService)),
|
|
80
|
+
( __param(6, ICommandService)),
|
|
81
|
+
( __param(7, ITelemetryService)),
|
|
82
|
+
( __param(8, IOpenerService)),
|
|
83
|
+
( __param(9, IEditorService))
|
|
84
|
+
], WelcomeDialogContribution));
|
|
85
|
+
( Registry.as(Extensions.Workbench))
|
|
86
|
+
.registerWorkbenchContribution(WelcomeDialogContribution, 4 );
|
|
87
|
+
const configurationRegistry = ( Registry.as(Extensions$1.Configuration));
|
|
88
|
+
configurationRegistry.registerConfiguration({
|
|
89
|
+
...applicationConfigurationNodeBase,
|
|
90
|
+
properties: {
|
|
91
|
+
'workbench.welcome.experimental.dialog': {
|
|
92
|
+
scope: 1 ,
|
|
93
|
+
type: 'boolean',
|
|
94
|
+
default: false,
|
|
95
|
+
tags: ['experimental'],
|
|
96
|
+
description: ( localizeWithPath(
|
|
97
|
+
'vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution',
|
|
98
|
+
'workbench.welcome.dialog',
|
|
99
|
+
"When enabled, a welcome widget is shown in the editor"
|
|
100
|
+
))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import './media/welcomeWidget.css.js';
|
|
2
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { $, hide, append } from 'vscode/vscode/vs/base/browser/dom';
|
|
4
|
+
import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
|
|
5
|
+
import { MarkdownRenderer } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
|
|
6
|
+
import { ButtonBar } from 'vscode/vscode/vs/base/browser/ui/button/button';
|
|
7
|
+
import { mnemonicButtonLabel } from 'vscode/vscode/vs/base/common/labels';
|
|
8
|
+
import { defaultButtonStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
|
|
9
|
+
import { Action } from 'vscode/vscode/vs/base/common/actions';
|
|
10
|
+
import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
|
|
11
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
12
|
+
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
13
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
14
|
+
import { parseLinkedText } from 'vscode/vscode/vs/base/common/linkedText';
|
|
15
|
+
import { Link } from 'vscode/vscode/vs/platform/opener/browser/link';
|
|
16
|
+
import { renderLabelWithIcons } from 'vscode/vscode/vs/base/browser/ui/iconLabel/iconLabels';
|
|
17
|
+
import { renderFormattedText } from 'vscode/vscode/vs/base/browser/formattedTextRenderer';
|
|
18
|
+
import { registerThemingParticipant } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
19
|
+
import { editorWidgetBackground, widgetShadow, widgetBorder, contrastBorder, editorWidgetForeground } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
|
|
20
|
+
|
|
21
|
+
class WelcomeWidget extends Disposable {
|
|
22
|
+
constructor(_editor, instantiationService, commandService, telemetryService, openerService) {
|
|
23
|
+
super();
|
|
24
|
+
this._editor = _editor;
|
|
25
|
+
this.instantiationService = instantiationService;
|
|
26
|
+
this.commandService = commandService;
|
|
27
|
+
this.telemetryService = telemetryService;
|
|
28
|
+
this.openerService = openerService;
|
|
29
|
+
this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
30
|
+
this._isVisible = false;
|
|
31
|
+
this._rootDomNode = document.createElement('div');
|
|
32
|
+
this._rootDomNode.className = 'welcome-widget';
|
|
33
|
+
this.element = this._rootDomNode.appendChild($('.monaco-dialog-box'));
|
|
34
|
+
this.element.setAttribute('role', 'dialog');
|
|
35
|
+
hide(this._rootDomNode);
|
|
36
|
+
this.messageContainer = this.element.appendChild($('.dialog-message-container'));
|
|
37
|
+
}
|
|
38
|
+
async executeCommand(commandId, ...args) {
|
|
39
|
+
try {
|
|
40
|
+
await this.commandService.executeCommand(commandId, ...args);
|
|
41
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', {
|
|
42
|
+
id: commandId,
|
|
43
|
+
from: 'welcomeWidget'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (ex) {
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async render(title, message, buttonText, buttonAction) {
|
|
50
|
+
if (!this._editor._getViewModel()) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
await this.buildWidgetContent(title, message, buttonText, buttonAction);
|
|
54
|
+
this._editor.addOverlayWidget(this);
|
|
55
|
+
this._show();
|
|
56
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', {
|
|
57
|
+
id: 'welcomeWidgetRendered',
|
|
58
|
+
from: 'welcomeWidget'
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async buildWidgetContent(title, message, buttonText, buttonAction) {
|
|
62
|
+
const actionBar = this._register(( new ActionBar(this.element, {})));
|
|
63
|
+
const action = this._register(( new Action('dialog.close', ( localizeWithPath(
|
|
64
|
+
'vs/workbench/contrib/welcomeDialog/browser/welcomeWidget',
|
|
65
|
+
'dialogClose',
|
|
66
|
+
"Close Dialog"
|
|
67
|
+
)), ThemeIcon.asClassName(Codicon.dialogClose), true, async () => {
|
|
68
|
+
this._hide();
|
|
69
|
+
})));
|
|
70
|
+
actionBar.push(action, { icon: true, label: false });
|
|
71
|
+
const renderBody = (message, icon) => {
|
|
72
|
+
const mds = ( new MarkdownString(undefined, { supportThemeIcons: true, supportHtml: true }));
|
|
73
|
+
mds.appendMarkdown(`<a class="copilot">$(${icon})</a>`);
|
|
74
|
+
mds.appendMarkdown(message);
|
|
75
|
+
return mds;
|
|
76
|
+
};
|
|
77
|
+
const titleElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail-title'));
|
|
78
|
+
const titleElementMdt = this.markdownRenderer.render(renderBody(title, 'zap'));
|
|
79
|
+
titleElement.appendChild(titleElementMdt.element);
|
|
80
|
+
this.buildStepMarkdownDescription(this.messageContainer, ( message.split('\n').filter(x => x).map(text => parseLinkedText(text))));
|
|
81
|
+
const buttonsRowElement = this.messageContainer.appendChild($('.dialog-buttons-row'));
|
|
82
|
+
const buttonContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
|
|
83
|
+
const buttonBar = this._register(( new ButtonBar(buttonContainer)));
|
|
84
|
+
const primaryButton = this._register(buttonBar.addButtonWithDescription({ title: true, secondary: false, ...defaultButtonStyles }));
|
|
85
|
+
primaryButton.label = mnemonicButtonLabel(buttonText, true);
|
|
86
|
+
this._register(primaryButton.onDidClick(async () => {
|
|
87
|
+
await this.executeCommand(buttonAction);
|
|
88
|
+
}));
|
|
89
|
+
buttonBar.buttons[0].focus();
|
|
90
|
+
}
|
|
91
|
+
buildStepMarkdownDescription(container, text) {
|
|
92
|
+
for (const linkedText of text) {
|
|
93
|
+
const p = append(container, $('p'));
|
|
94
|
+
for (const node of linkedText.nodes) {
|
|
95
|
+
if (typeof node === 'string') {
|
|
96
|
+
const labelWithIcon = renderLabelWithIcons(node);
|
|
97
|
+
for (const element of labelWithIcon) {
|
|
98
|
+
if (typeof element === 'string') {
|
|
99
|
+
p.appendChild(renderFormattedText(element, { inline: true, renderCodeSegments: true }));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
p.appendChild(element);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const link = this.instantiationService.createInstance(Link, p, node, {
|
|
108
|
+
opener: (href) => {
|
|
109
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', {
|
|
110
|
+
id: 'welcomeWidetLinkAction',
|
|
111
|
+
from: 'welcomeWidget'
|
|
112
|
+
});
|
|
113
|
+
this.openerService.open(href, { allowCommands: true });
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
this._register(link);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return container;
|
|
121
|
+
}
|
|
122
|
+
getId() {
|
|
123
|
+
return 'editor.contrib.welcomeWidget';
|
|
124
|
+
}
|
|
125
|
+
getDomNode() {
|
|
126
|
+
return this._rootDomNode;
|
|
127
|
+
}
|
|
128
|
+
getPosition() {
|
|
129
|
+
return {
|
|
130
|
+
preference: 0
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
_show() {
|
|
134
|
+
if (this._isVisible) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this._isVisible = true;
|
|
138
|
+
this._rootDomNode.style.display = 'block';
|
|
139
|
+
}
|
|
140
|
+
_hide() {
|
|
141
|
+
if (!this._isVisible) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this._isVisible = true;
|
|
145
|
+
this._rootDomNode.style.display = 'none';
|
|
146
|
+
this._editor.removeOverlayWidget(this);
|
|
147
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', {
|
|
148
|
+
id: 'welcomeWidgetDismissed',
|
|
149
|
+
from: 'welcomeWidget'
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
registerThemingParticipant((theme, collector) => {
|
|
154
|
+
const addBackgroundColorRule = (selector, color) => {
|
|
155
|
+
if (color) {
|
|
156
|
+
collector.addRule(`.monaco-editor ${selector} { background-color: ${color}; }`);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const widgetBackground = theme.getColor(editorWidgetBackground);
|
|
160
|
+
addBackgroundColorRule('.welcome-widget', widgetBackground);
|
|
161
|
+
const widgetShadowColor = theme.getColor(widgetShadow);
|
|
162
|
+
if (widgetShadowColor) {
|
|
163
|
+
collector.addRule(`.welcome-widget { box-shadow: 0 0 8px 2px ${widgetShadowColor}; }`);
|
|
164
|
+
}
|
|
165
|
+
const widgetBorderColor = theme.getColor(widgetBorder);
|
|
166
|
+
if (widgetBorderColor) {
|
|
167
|
+
collector.addRule(`.welcome-widget { border-left: 1px solid ${widgetBorderColor}; border-right: 1px solid ${widgetBorderColor}; border-bottom: 1px solid ${widgetBorderColor}; }`);
|
|
168
|
+
}
|
|
169
|
+
const hcBorder = theme.getColor(contrastBorder);
|
|
170
|
+
if (hcBorder) {
|
|
171
|
+
collector.addRule(`.welcome-widget { border: 1px solid ${hcBorder}; }`);
|
|
172
|
+
}
|
|
173
|
+
const foreground = theme.getColor(editorWidgetForeground);
|
|
174
|
+
if (foreground) {
|
|
175
|
+
collector.addRule(`.welcome-widget { color: ${foreground}; }`);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
export { WelcomeWidget };
|