@codingame/monaco-vscode-share-service-override 25.1.2 → 26.0.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-share-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - share service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -44,8 +44,12 @@ const targetMenus = [
|
|
|
44
44
|
MenuId.ExplorerContextShare
|
|
45
45
|
];
|
|
46
46
|
let ShareWorkbenchContribution = class ShareWorkbenchContribution extends Disposable {
|
|
47
|
-
static {
|
|
48
|
-
|
|
47
|
+
static {
|
|
48
|
+
ShareWorkbenchContribution_1 = this;
|
|
49
|
+
}
|
|
50
|
+
static {
|
|
51
|
+
this.SHARE_ENABLED_SETTING = "workbench.experimental.share.enabled";
|
|
52
|
+
}
|
|
49
53
|
constructor(shareService, configurationService) {
|
|
50
54
|
super();
|
|
51
55
|
this.shareService = shareService;
|
|
@@ -58,8 +62,7 @@ let ShareWorkbenchContribution = class ShareWorkbenchContribution extends Dispos
|
|
|
58
62
|
const settingValue = this.configurationService.getValue(ShareWorkbenchContribution_1.SHARE_ENABLED_SETTING);
|
|
59
63
|
if (settingValue === true && this._disposables === undefined) {
|
|
60
64
|
this.registerActions();
|
|
61
|
-
}
|
|
62
|
-
else if (settingValue === false && this._disposables !== undefined) {
|
|
65
|
+
} else if (settingValue === false && this._disposables !== undefined) {
|
|
63
66
|
this._disposables?.clear();
|
|
64
67
|
this._disposables = undefined;
|
|
65
68
|
}
|
|
@@ -75,8 +78,12 @@ let ShareWorkbenchContribution = class ShareWorkbenchContribution extends Dispos
|
|
|
75
78
|
this._disposables = ( new DisposableStore());
|
|
76
79
|
}
|
|
77
80
|
this._disposables.add(registerAction2(class ShareAction extends Action2 {
|
|
78
|
-
static {
|
|
79
|
-
|
|
81
|
+
static {
|
|
82
|
+
this.ID = "workbench.action.share";
|
|
83
|
+
}
|
|
84
|
+
static {
|
|
85
|
+
this.LABEL = ( localize2(11275, "Share..."));
|
|
86
|
+
}
|
|
80
87
|
constructor() {
|
|
81
88
|
super({
|
|
82
89
|
id: ShareAction.ID,
|
|
@@ -86,18 +93,20 @@ let ShareWorkbenchContribution = class ShareWorkbenchContribution extends Dispos
|
|
|
86
93
|
precondition: ( ContextKeyExpr.and(( ShareProviderCountContext.notEqualsTo(0)), ( WorkspaceFolderCountContext.notEqualsTo(0)))),
|
|
87
94
|
keybinding: {
|
|
88
95
|
weight: KeybindingWeight.WorkbenchContrib,
|
|
89
|
-
primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.KeyS
|
|
96
|
+
primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.KeyS
|
|
90
97
|
},
|
|
91
|
-
menu: [
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
menu: [{
|
|
99
|
+
id: MenuId.CommandCenter,
|
|
100
|
+
order: 1000
|
|
101
|
+
}]
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
104
|
async run(accessor, ...args) {
|
|
97
105
|
const shareService = accessor.get(IShareService);
|
|
98
106
|
const activeEditor = accessor.get(IEditorService)?.activeEditor;
|
|
99
|
-
const resourceUri = (activeEditor && EditorResourceAccessor.getOriginalUri(activeEditor, {
|
|
100
|
-
|
|
107
|
+
const resourceUri = (activeEditor && EditorResourceAccessor.getOriginalUri(activeEditor, {
|
|
108
|
+
supportSideBySide: SideBySideEditor.PRIMARY
|
|
109
|
+
})) ?? accessor.get(IWorkspaceContextService).getWorkspace().folders[0].uri;
|
|
101
110
|
const clipboardService = accessor.get(IClipboardService);
|
|
102
111
|
const dialogService = accessor.get(IDialogService);
|
|
103
112
|
const urlService = accessor.get(IOpenerService);
|
|
@@ -105,24 +114,36 @@ let ShareWorkbenchContribution = class ShareWorkbenchContribution extends Dispos
|
|
|
105
114
|
const selection = accessor.get(ICodeEditorService).getActiveCodeEditor()?.getSelection() ?? undefined;
|
|
106
115
|
const result = await progressService.withProgress({
|
|
107
116
|
location: ProgressLocation.Window,
|
|
108
|
-
detail: ( localize(
|
|
109
|
-
}, async () => shareService.provideShare({
|
|
117
|
+
detail: ( localize(11276, "Generating link..."))
|
|
118
|
+
}, async () => shareService.provideShare({
|
|
119
|
+
resourceUri,
|
|
120
|
+
selection
|
|
121
|
+
}, CancellationToken.None));
|
|
110
122
|
if (result) {
|
|
111
123
|
const uriText = ( result.toString());
|
|
112
|
-
const isResultText = typeof result ===
|
|
124
|
+
const isResultText = typeof result === "string";
|
|
113
125
|
await clipboardService.writeText(uriText);
|
|
114
126
|
dialogService.prompt({
|
|
115
127
|
type: Severity.Info,
|
|
116
|
-
message: isResultText ? ( localize(
|
|
128
|
+
message: isResultText ? ( localize(11277, "Copied text to clipboard!")) : ( localize(11278, "Copied link to clipboard!")),
|
|
117
129
|
custom: {
|
|
118
130
|
icon: Codicon.check,
|
|
119
131
|
markdownDetails: [{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
132
|
+
markdown: ( new MarkdownString(`<div aria-label='${uriText}'>${uriText}</div>`, {
|
|
133
|
+
supportHtml: true
|
|
134
|
+
})),
|
|
135
|
+
classes: [isResultText ? "share-dialog-input-text" : "share-dialog-input-link"]
|
|
136
|
+
}]
|
|
123
137
|
},
|
|
124
|
-
cancelButton: ( localize(
|
|
125
|
-
buttons: isResultText ? [] : [{
|
|
138
|
+
cancelButton: ( localize(11279, "Close")),
|
|
139
|
+
buttons: isResultText ? [] : [{
|
|
140
|
+
label: ( localize(11280, "Open Link")),
|
|
141
|
+
run: () => {
|
|
142
|
+
urlService.open(result, {
|
|
143
|
+
openExternal: true
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}]
|
|
126
147
|
});
|
|
127
148
|
}
|
|
128
149
|
}
|
|
@@ -135,26 +156,23 @@ let ShareWorkbenchContribution = class ShareWorkbenchContribution extends Dispos
|
|
|
135
156
|
}
|
|
136
157
|
}
|
|
137
158
|
};
|
|
138
|
-
ShareWorkbenchContribution = ShareWorkbenchContribution_1 = ( __decorate([
|
|
139
|
-
( __param(0, IShareService)),
|
|
140
|
-
( __param(1, IConfigurationService))
|
|
141
|
-
], ShareWorkbenchContribution));
|
|
159
|
+
ShareWorkbenchContribution = ShareWorkbenchContribution_1 = ( __decorate([( __param(0, IShareService)), ( __param(1, IConfigurationService))], ShareWorkbenchContribution));
|
|
142
160
|
const workbenchContributionsRegistry = ( Registry.as(Extensions.Workbench));
|
|
143
161
|
workbenchContributionsRegistry.registerWorkbenchContribution(ShareWorkbenchContribution, LifecyclePhase.Eventually);
|
|
144
162
|
( Registry.as(Extensions$1.Configuration)).registerConfiguration({
|
|
145
163
|
...workbenchConfigurationNodeBase,
|
|
146
164
|
properties: {
|
|
147
|
-
|
|
148
|
-
type:
|
|
165
|
+
"workbench.experimental.share.enabled": {
|
|
166
|
+
type: "boolean",
|
|
149
167
|
default: false,
|
|
150
|
-
tags: [
|
|
168
|
+
tags: ["experimental"],
|
|
151
169
|
markdownDescription: ( localize(
|
|
152
|
-
|
|
170
|
+
11281,
|
|
153
171
|
"Controls whether to render the Share action next to the command center when {0} is {1}.",
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
"`#window.commandCenter#`",
|
|
173
|
+
"`true`"
|
|
156
174
|
)),
|
|
157
|
-
restricted: false
|
|
175
|
+
restricted: false
|
|
158
176
|
}
|
|
159
177
|
}
|
|
160
178
|
});
|
|
@@ -12,9 +12,15 @@ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platfo
|
|
|
12
12
|
import { ToggleTitleBarConfigAction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/parts/titlebar/titlebarActions';
|
|
13
13
|
import { IsCompactTitleBarContext, WorkspaceFolderCountContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contextkeys';
|
|
14
14
|
|
|
15
|
-
const ShareProviderCountContext = ( new RawContextKey(
|
|
15
|
+
const ShareProviderCountContext = ( new RawContextKey("shareProviderCount", 0, ( localize(11282, "The number of available share providers"))));
|
|
16
16
|
let ShareService = class ShareService {
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(
|
|
18
|
+
contextKeyService,
|
|
19
|
+
labelService,
|
|
20
|
+
quickInputService,
|
|
21
|
+
codeEditorService,
|
|
22
|
+
telemetryService
|
|
23
|
+
) {
|
|
18
24
|
this.contextKeyService = contextKeyService;
|
|
19
25
|
this.labelService = labelService;
|
|
20
26
|
this.quickInputService = quickInputService;
|
|
@@ -37,40 +43,44 @@ let ShareService = class ShareService {
|
|
|
37
43
|
return [];
|
|
38
44
|
}
|
|
39
45
|
async provideShare(item, token) {
|
|
40
|
-
const language = this.codeEditorService.getActiveCodeEditor()?.getModel()?.getLanguageId() ??
|
|
41
|
-
const providers = [...( this._providers.values())]
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
const language = this.codeEditorService.getActiveCodeEditor()?.getModel()?.getLanguageId() ?? "";
|
|
47
|
+
const providers = [...( this._providers.values())].filter(
|
|
48
|
+
p => score(p.selector, item.resourceUri, language, true, undefined, undefined) > 0
|
|
49
|
+
).sort((a, b) => a.priority - b.priority);
|
|
44
50
|
if (providers.length === 0) {
|
|
45
51
|
return undefined;
|
|
46
52
|
}
|
|
47
53
|
if (providers.length === 1) {
|
|
48
|
-
this.telemetryService.publicLog2(
|
|
54
|
+
this.telemetryService.publicLog2("shareService.share", {
|
|
55
|
+
providerId: providers[0].id
|
|
56
|
+
});
|
|
49
57
|
return providers[0].provideShare(item, token);
|
|
50
58
|
}
|
|
51
|
-
const items = ( providers.map(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
const items = ( providers.map(p => ({
|
|
60
|
+
label: p.label,
|
|
61
|
+
provider: p
|
|
62
|
+
})));
|
|
63
|
+
const selected = await this.quickInputService.pick(items, {
|
|
64
|
+
canPickMany: false,
|
|
65
|
+
placeHolder: ( localize(
|
|
66
|
+
11283,
|
|
67
|
+
"Choose how to share {0}",
|
|
68
|
+
this.labelService.getUriLabel(item.resourceUri)
|
|
69
|
+
))
|
|
70
|
+
}, token);
|
|
57
71
|
if (selected !== undefined) {
|
|
58
|
-
this.telemetryService.publicLog2(
|
|
72
|
+
this.telemetryService.publicLog2("shareService.share", {
|
|
73
|
+
providerId: selected.provider.id
|
|
74
|
+
});
|
|
59
75
|
return selected.provider.provideShare(item, token);
|
|
60
76
|
}
|
|
61
77
|
return;
|
|
62
78
|
}
|
|
63
79
|
};
|
|
64
|
-
ShareService = ( __decorate([
|
|
65
|
-
( __param(0, IContextKeyService)),
|
|
66
|
-
( __param(1, ILabelService)),
|
|
67
|
-
( __param(2, IQuickInputService)),
|
|
68
|
-
( __param(3, ICodeEditorService)),
|
|
69
|
-
( __param(4, ITelemetryService))
|
|
70
|
-
], ShareService));
|
|
80
|
+
ShareService = ( __decorate([( __param(0, IContextKeyService)), ( __param(1, ILabelService)), ( __param(2, IQuickInputService)), ( __param(3, ICodeEditorService)), ( __param(4, ITelemetryService))], ShareService));
|
|
71
81
|
registerAction2(class ToggleShareControl extends ToggleTitleBarConfigAction {
|
|
72
82
|
constructor() {
|
|
73
|
-
super(
|
|
83
|
+
super("workbench.experimental.share.enabled", ( localize(11284, "Share")), ( localize(11285, "Toggle visibility of the Share action in title bar")), 3, ( ContextKeyExpr.and(( IsCompactTitleBarContext.toNegated()), ( ContextKeyExpr.has("config.window.commandCenter")), ( ContextKeyExpr.and(( ShareProviderCountContext.notEqualsTo(0)), ( WorkspaceFolderCountContext.notEqualsTo(0)))))));
|
|
74
84
|
}
|
|
75
85
|
});
|
|
76
86
|
|