Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render share link text as readonly div #183372

Merged
merged 1 commit into from May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/vs/workbench/contrib/share/browser/share.contribution.ts
Expand Up @@ -3,8 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import 'vs/css!./share';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { Codicon } from 'vs/base/common/codicons';
import { MarkdownString } from 'vs/base/common/htmlContent';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { localize } from 'vs/nls';
import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
Expand Down Expand Up @@ -78,19 +80,23 @@ class ShareWorkbenchContribution {

const uri = await shareService.provideShare({ resourceUri }, new CancellationTokenSource().token);
if (uri) {
await clipboardService.writeText(uri.toString());
const result = await dialogService.input(
const uriText = uri.toString();
await clipboardService.writeText(uriText);
dialogService.prompt(
{
type: Severity.Info,
inputs: [{ type: 'text', value: uri.toString() }],
message: localize('shareSuccess', 'Copied link to clipboard!'),
custom: { icon: Codicon.check },
primaryButton: localize('open link', 'Open Link')
custom: {
icon: Codicon.check,
markdownDetails: [{
markdown: new MarkdownString(`<div aria-label='${uriText}'>${uriText}</div>`, { supportHtml: true }),
classes: ['share-dialog-input']
}]
},
cancelButton: localize('close', 'Close'),
buttons: [{ label: localize('open link', 'Open Link'), run: () => { urlService.open(uri, { openExternal: true }); } }]
}
);
if (result.confirmed) {
urlService.open(uri, { openExternal: true });
}
}
}
});
Expand Down
18 changes: 18 additions & 0 deletions src/vs/workbench/contrib/share/browser/share.css
@@ -0,0 +1,18 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

div.share-dialog-input {
border: 1px solid var(--vscode-input-border, transparent);
border-radius: 2px;
color: var(--vscode-input-foreground);
background-color: var(--vscode-input-background);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
padding: 2px;
user-select: all;
line-height: 24px;
}