提交 a101ecec 编写于 作者: M Matt Bierner

Remove onCommand from markdown preview

上级 388a62fe
......@@ -57,7 +57,7 @@ export class CspAlerter {
notification.setAttribute('role', 'button');
notification.setAttribute('aria-label', strings.cspAlertMessageLabel);
notification.onclick = () => {
this.messaging!.postMessage('markdown.showPreviewSecuritySelector', [settings.source]);
this.messaging!.postMessage('showPreviewSecuritySelector', { source: settings.source });
};
document.body.appendChild(notification);
}
......
......@@ -133,7 +133,7 @@ document.addEventListener('click', event => {
}
if (node.href.startsWith('file://') || node.href.startsWith('vscode-resource:')) {
const [path, fragment] = node.href.replace(/^(file:\/\/|vscode-resource:)/i, '').split('#');
messaging.postCommand('_markdown.openDocumentLink', [{ path, fragment }]);
messaging.postMessage('clickLink', { path, fragment });
event.preventDefault();
event.stopPropagation();
break;
......
......@@ -10,11 +10,6 @@ export interface MessagePoster {
* Post a message to the markdown extension
*/
postMessage(type: string, body: object): void;
/**
* Post a command to be executed to the markdown extension
*/
postCommand(command: string, args: any[]): void;
}
export const createPosterForVsCode = (vscode: any) => {
......@@ -26,9 +21,6 @@ export const createPosterForVsCode = (vscode: any) => {
body
});
}
postCommand(command: string, args: any[]) {
this.postMessage('command', { command, args });
}
};
};
......@@ -20,7 +20,7 @@ function normalizeLink(
// Assume it must be an relative or absolute file path
// Use a fake scheme to avoid parse warnings
const tempUri = vscode.Uri.parse(`fake-scheme:${link}`);
const tempUri = vscode.Uri.parse(`vscode-resource:${link}`);
let resourcePath = tempUri.path;
if (!tempUri.path) {
......
......@@ -128,10 +128,6 @@ export class MarkdownPreview {
this.onCacheImageSizes(e.body);
break;
case 'command':
vscode.commands.executeCommand(e.body.command, ...e.body.args);
break;
case 'revealLine':
this.onDidScrollPreview(e.body.line);
break;
......@@ -140,6 +136,10 @@ export class MarkdownPreview {
this.onDidClickPreview(e.body.line);
break;
case 'clickLink':
vscode.commands.executeCommand('_markdown.openDocumentLink', e.body);
break;
case 'showPreviewSecuritySelector':
vscode.commands.executeCommand('markdown.showPreviewSecuritySelector', e.body.source);
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册