mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
Remove quotes from inserted markdown links (#16457)
This commit is contained in:
@@ -34,3 +34,16 @@ export function escapeUrl(unescapedUrl: string): string {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes single or double quotes that enclose another string.
|
||||
* @param quotedText The text to unquote
|
||||
*/
|
||||
export function unquoteText(quotedText: string): string {
|
||||
let doubleQuotesRegex = /^[\"\'](.*)[\"\']$/;
|
||||
let matches = doubleQuotesRegex.exec(quotedText);
|
||||
if (matches && matches[1]) {
|
||||
quotedText = matches[1];
|
||||
}
|
||||
return quotedText;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Checkbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||
import { RadioButton } from 'sql/base/browser/ui/radioButton/radioButton';
|
||||
import { attachCalloutDialogStyler } from 'sql/workbench/common/styler';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { unquoteText } from 'sql/workbench/contrib/notebook/browser/calloutDialog/common/utils';
|
||||
|
||||
export interface IImageCalloutDialogOptions {
|
||||
insertTitle?: string,
|
||||
@@ -199,7 +200,7 @@ export class ImageCalloutDialog extends Modal {
|
||||
|
||||
public insert(): void {
|
||||
this.hide('ok');
|
||||
let imgPath = this._imageUrlInputBox.value;
|
||||
let imgPath = unquoteText(this._imageUrlInputBox.value);
|
||||
let imageName = path.basename(imgPath);
|
||||
this._selectionComplete.resolve({
|
||||
embedImage: this._imageEmbedCheckbox.checked,
|
||||
|
||||
@@ -21,7 +21,7 @@ import { Deferred } from 'sql/base/common/promise';
|
||||
import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
|
||||
import { attachCalloutDialogStyler } from 'sql/workbench/common/styler';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { escapeLabel, escapeUrl } from 'sql/workbench/contrib/notebook/browser/calloutDialog/common/utils';
|
||||
import { escapeLabel, escapeUrl, unquoteText } from 'sql/workbench/contrib/notebook/browser/calloutDialog/common/utils';
|
||||
|
||||
export interface ILinkCalloutDialogOptions {
|
||||
insertTitle?: string,
|
||||
@@ -158,7 +158,7 @@ export class LinkCalloutDialog extends Modal {
|
||||
public insert(): void {
|
||||
this.hide('ok');
|
||||
let escapedLabel = escapeLabel(this._linkTextInputBox.value);
|
||||
let escapedUrl = escapeUrl(this._linkUrlInputBox.value);
|
||||
let escapedUrl = escapeUrl(unquoteText(this._linkUrlInputBox.value));
|
||||
|
||||
if (this._previouslySelectedRange) {
|
||||
// Reset selection to previous state before callout was open
|
||||
|
||||
Reference in New Issue
Block a user