See and Edit Selected Links in Callout Dialog (#14987)

* Add URL label to linkCallout

* add test for file link
This commit is contained in:
Vasu Bhog
2021-04-06 11:51:53 -07:00
committed by GitHub
parent aba8116648
commit 04af3e161a
3 changed files with 38 additions and 4 deletions

View File

@@ -45,6 +45,7 @@ export class LinkCalloutDialog extends Modal {
dialogPosition: DialogPosition,
dialogProperties: IDialogProperties,
private readonly _defaultLabel: string = '',
private readonly _defaultLinkUrl: string = '',
@IContextViewService private readonly _contextViewService: IContextViewService,
@IThemeService themeService: IThemeService,
@ILayoutService layoutService: ILayoutService,
@@ -134,6 +135,7 @@ export class LinkCalloutDialog extends Modal {
placeholder: constants.linkAddressPlaceholder,
ariaLabel: constants.linkAddressLabel
});
this._linkUrlInputBox.value = this._defaultLinkUrl;
DOM.append(linkAddressRow, linkAddressInputContainer);
}

View File

@@ -296,7 +296,8 @@ export class MarkdownToolbarComponent extends AngularDisposable {
if (type === MarkdownButtonType.LINK_PREVIEW) {
const defaultLabel = this.getCurrentSelectionText();
this._linkCallout = this._instantiationService.createInstance(LinkCalloutDialog, this.insertLinkHeading, dialogPosition, dialogProperties, defaultLabel);
const defaultLinkUrl = this.getCurrentLinkUrl();
this._linkCallout = this._instantiationService.createInstance(LinkCalloutDialog, this.insertLinkHeading, dialogPosition, dialogProperties, defaultLabel, defaultLinkUrl);
this._linkCallout.render();
calloutOptions = await this._linkCallout.open();
}
@@ -318,6 +319,14 @@ export class MarkdownToolbarComponent extends AngularDisposable {
}
}
private getCurrentLinkUrl(): string {
if (document.getSelection().anchorNode.parentNode['protocol'] === 'file:') {
return document.getSelection().anchorNode.parentNode['pathname'] || '';
} else {
return document.getSelection().anchorNode.parentNode['href'] || '';
}
}
private getCellEditorControl(): IEditor | undefined {
// If control doesn't exist, editor may have been destroyed previously when switching edit modes
if (!this._cellEditor?.getEditor()?.getControl()) {