From 8655044dfbc9151dc5703d3bc7cb83b970089660 Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Wed, 20 Nov 2019 14:00:06 -0800 Subject: [PATCH] Notebooks cleanup: Remove old out of proc markdown option (#8394) * Remove old out of proc markdown option * Revert change to stats.js --- .../markdown-language-features/package.json | 14 +---- .../src/commands/index.ts | 1 - .../src/commands/showNotebookPreview.ts | 20 ------ .../src/extension.ts | 1 - .../browser/cellViews/textCell.component.ts | 34 +++------- .../notebook/browser/models/notebookUtils.ts | 5 -- .../notebook/browser/notebook.contribution.ts | 13 ---- .../outputs/markdownOutput.component.ts | 63 +++---------------- 8 files changed, 19 insertions(+), 132 deletions(-) delete mode 100644 extensions/markdown-language-features/src/commands/showNotebookPreview.ts diff --git a/extensions/markdown-language-features/package.json b/extensions/markdown-language-features/package.json index 78bfc5a419..29cef108b9 100644 --- a/extensions/markdown-language-features/package.json +++ b/extensions/markdown-language-features/package.json @@ -25,7 +25,6 @@ "onCommand:markdown.showSource", "onCommand:markdown.showPreviewSecuritySelector", "onCommand:markdown.api.render", - "onCommand:notebook.showPreview", "onWebviewPanel:markdown.preview" ], "contributes": { @@ -80,12 +79,7 @@ "command": "markdown.preview.toggleLock", "title": "%markdown.preview.toggleLock.title%", "category": "Markdown" - }, - { - "command": "notebook.showPreview", - "title": "notebook.showPreview", - "category": "Notebook" - } + } ], "menus": { "editor/title": [ @@ -170,11 +164,7 @@ { "command": "markdown.preview.refresh", "when": "markdownPreviewFocus" - }, - { - "command": "notebook.showPreview", - "when": "false" - } + } ] }, "keybindings": [ diff --git a/extensions/markdown-language-features/src/commands/index.ts b/extensions/markdown-language-features/src/commands/index.ts index 63f46adc56..32ef9f37b0 100644 --- a/extensions/markdown-language-features/src/commands/index.ts +++ b/extensions/markdown-language-features/src/commands/index.ts @@ -10,5 +10,4 @@ export { RefreshPreviewCommand } from './refreshPreview'; export { ShowPreviewSecuritySelectorCommand } from './showPreviewSecuritySelector'; export { MoveCursorToPositionCommand } from './moveCursorToPosition'; export { ToggleLockCommand } from './toggleLock'; -export { ShowNotebookPreview } from './showNotebookPreview'; // {{SQL CARBON EDIT}} export { RenderDocument } from './renderDocument'; diff --git a/extensions/markdown-language-features/src/commands/showNotebookPreview.ts b/extensions/markdown-language-features/src/commands/showNotebookPreview.ts deleted file mode 100644 index ddab003f02..0000000000 --- a/extensions/markdown-language-features/src/commands/showNotebookPreview.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -import * as vscode from 'vscode'; - -import { Command } from '../commandManager'; -import { MarkdownEngine } from '../markdownEngine'; - -export class ShowNotebookPreview implements Command { - public readonly id = 'notebook.showPreview'; - - public constructor( - private readonly engine: MarkdownEngine - ) { } - - public async execute(document: vscode.Uri, textContent: string): Promise { - return this.engine.renderText(document, textContent); - } -} \ No newline at end of file diff --git a/extensions/markdown-language-features/src/extension.ts b/extensions/markdown-language-features/src/extension.ts index 6efb6b5a66..567d5291a7 100644 --- a/extensions/markdown-language-features/src/extension.ts +++ b/extensions/markdown-language-features/src/extension.ts @@ -83,7 +83,6 @@ function registerMarkdownCommands( commandManager.register(new commands.ShowPreviewSecuritySelectorCommand(previewSecuritySelector, previewManager)); commandManager.register(new commands.OpenDocumentLinkCommand(engine)); commandManager.register(new commands.ToggleLockCommand(previewManager)); - commandManager.register(new commands.ShowNotebookPreview(engine)); // {{SQL CARBON EDIT}} commandManager.register(new commands.RenderDocument(engine)); return commandManager; } diff --git a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts index 80e90c5c5c..10fc78a437 100644 --- a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts @@ -11,13 +11,11 @@ import { OnInit, Component, Input, Inject, forwardRef, ElementRef, ChangeDetecto import { localize } from 'vs/nls'; import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import * as themeColors from 'vs/workbench/common/theme'; -import { ICommandService } from 'vs/platform/commands/common/commands'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { Emitter } from 'vs/base/common/event'; import { URI } from 'vs/base/common/uri'; import * as DOM from 'vs/base/browser/dom'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { toDisposable } from 'vs/base/common/lifecycle'; import { IMarkdownRenderResult } from 'vs/editor/contrib/markdown/markdownRenderer'; import { NotebookMarkdownRenderer } from 'sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown'; @@ -26,7 +24,6 @@ import { ICellModel } from 'sql/workbench/contrib/notebook/browser/models/modelI import { NotebookModel } from 'sql/workbench/contrib/notebook/browser/models/notebookModel'; import { ISanitizer, defaultSanitizer } from 'sql/workbench/contrib/notebook/browser/outputs/sanitizer'; import { CellToggleMoreActions } from 'sql/workbench/contrib/notebook/browser/cellToggleMoreActions'; -import { useInProcMarkdown, convertVscodeResourceToFileInSubDirectories } from 'sql/workbench/contrib/notebook/browser/models/notebookUtils'; export const TEXT_SELECTOR: string = 'text-cell-component'; const USER_SELECT_CLASS = 'actionselect'; @@ -83,9 +80,6 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(IInstantiationService) private _instantiationService: IInstantiationService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, - @Inject(ICommandService) private _commandService: ICommandService, - @Inject(IConfigurationService) private configurationService: IConfigurationService, - ) { super(); this.isEditMode = true; @@ -171,25 +165,15 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { this._content = this.cellModel.source; } - if (useInProcMarkdown(this.configurationService)) { - this.markdownRenderer.setNotebookURI(this.cellModel.notebookModel.notebookUri); - this.markdownResult = this.markdownRenderer.render({ - isTrusted: true, - value: Array.isArray(this._content) ? this._content.join('') : this._content - }); - this.markdownResult.element.innerHTML = this.sanitizeContent(this.markdownResult.element.innerHTML); - this.setLoading(false); - let outputElement = this.output.nativeElement; - outputElement.innerHTML = this.markdownResult.element.innerHTML; - } else { - this._commandService.executeCommand('notebook.showPreview', this.cellModel.notebookModel.notebookUri, this._content).then((htmlcontent) => { - htmlcontent = convertVscodeResourceToFileInSubDirectories(htmlcontent, this.cellModel); - htmlcontent = this.sanitizeContent(htmlcontent); - let outputElement = this.output.nativeElement; - outputElement.innerHTML = htmlcontent; - this.setLoading(false); - }); - } + this.markdownRenderer.setNotebookURI(this.cellModel.notebookModel.notebookUri); + this.markdownResult = this.markdownRenderer.render({ + isTrusted: true, + value: Array.isArray(this._content) ? this._content.join('') : this._content + }); + this.markdownResult.element.innerHTML = this.sanitizeContent(this.markdownResult.element.innerHTML); + this.setLoading(false); + let outputElement = this.output.nativeElement; + outputElement.innerHTML = this.markdownResult.element.innerHTML; } } diff --git a/src/sql/workbench/contrib/notebook/browser/models/notebookUtils.ts b/src/sql/workbench/contrib/notebook/browser/models/notebookUtils.ts index e3ad554d7f..783defec83 100644 --- a/src/sql/workbench/contrib/notebook/browser/models/notebookUtils.ts +++ b/src/sql/workbench/contrib/notebook/browser/models/notebookUtils.ts @@ -7,7 +7,6 @@ import * as path from 'vs/base/common/path'; import { nb, ServerInfo } from 'azdata'; import { DEFAULT_NOTEBOOK_PROVIDER, DEFAULT_NOTEBOOK_FILETYPE, INotebookService } from 'sql/workbench/services/notebook/browser/notebookService'; import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ICellModel } from 'sql/workbench/contrib/notebook/browser/models/modelInterfaces'; import { URI } from 'vs/base/common/uri'; import { startsWith } from 'vs/base/common/strings'; @@ -129,10 +128,6 @@ export function convertVscodeResourceToFileInSubDirectories(htmlContent: string, return htmlContent; } -export function useInProcMarkdown(configurationService: IConfigurationService): boolean { - return configurationService.getValue('notebook.useInProcMarkdown'); -} - export function getClusterEndpoints(serverInfo: ServerInfo): IEndpoint[] | undefined { let endpoints: RawEndpoint[] = serverInfo.options[clusterEndpointsProperty]; if (!endpoints || endpoints.length === 0) { return []; } diff --git a/src/sql/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/sql/workbench/contrib/notebook/browser/notebook.contribution.ts index 3251fcd3ba..382df5b2b4 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -146,19 +146,6 @@ registerAction({ }); const configurationRegistry = Registry.as(ConfigExtensions.Configuration); -configurationRegistry.registerConfiguration({ - 'id': 'notebook', - 'title': 'Notebook', - 'type': 'object', - 'properties': { - 'notebook.useInProcMarkdown': { - 'type': 'boolean', - 'default': true, - 'description': localize('notebook.inProcMarkdown', "Use in-process markdown viewer to render text cells more quickly (Experimental).") - } - } -}); - configurationRegistry.registerConfiguration({ 'id': 'notebook', 'title': 'Notebook', diff --git a/src/sql/workbench/contrib/notebook/browser/outputs/markdownOutput.component.ts b/src/sql/workbench/contrib/notebook/browser/outputs/markdownOutput.component.ts index 82b4bd519f..d9b261962a 100644 --- a/src/sql/workbench/contrib/notebook/browser/outputs/markdownOutput.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/outputs/markdownOutput.component.ts @@ -7,18 +7,13 @@ import 'vs/css!../cellViews/textCell'; import 'vs/css!../cellViews/media/markdown'; import 'vs/css!../cellViews/media/highlight'; -import { OnInit, Component, Input, Inject, forwardRef, ElementRef, ChangeDetectorRef, ViewChild } from '@angular/core'; -import { ICommandService } from 'vs/platform/commands/common/commands'; -import { ISanitizer, defaultSanitizer } from 'sql/workbench/contrib/notebook/browser/outputs/sanitizer'; +import { OnInit, Component, Input, Inject, ElementRef, ViewChild } from '@angular/core'; import { AngularDisposable } from 'sql/base/browser/lifecycle'; import { IMimeComponent } from 'sql/workbench/contrib/notebook/browser/outputs/mimeRegistry'; -import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { NotebookMarkdownRenderer } from 'sql/workbench/contrib/notebook/browser/outputs/notebookMarkdown'; import { MimeModel } from 'sql/workbench/contrib/notebook/browser/models/mimemodel'; import { ICellModel } from 'sql/workbench/contrib/notebook/browser/models/modelInterfaces'; -import { useInProcMarkdown, convertVscodeResourceToFileInSubDirectories } from 'sql/workbench/contrib/notebook/browser/models/notebookUtils'; import { URI } from 'vs/base/common/uri'; @Component({ @@ -30,7 +25,6 @@ export class MarkdownOutputComponent extends AngularDisposable implements IMimeC @ViewChild('output', { read: ElementRef }) private output: ElementRef; - private _sanitizer: ISanitizer; private _lastTrustedMode: boolean; private _bundleOptions: MimeModel.IOptions; @@ -40,15 +34,10 @@ export class MarkdownOutputComponent extends AngularDisposable implements IMimeC private _markdownRenderer: NotebookMarkdownRenderer; constructor( - @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, - @Inject(ICommandService) private _commandService: ICommandService, - @Inject(INotebookService) private _notebookService: INotebookService, - @Inject(IConfigurationService) private _configurationService: IConfigurationService, @Inject(IInstantiationService) private _instantiationService: IInstantiationService ) { super(); - this._sanitizer = this._notebookService.getMimeRegistry().sanitizer; this._markdownRenderer = this._instantiationService.createInstance(NotebookMarkdownRenderer); } @@ -80,19 +69,6 @@ export class MarkdownOutputComponent extends AngularDisposable implements IMimeC return this.cellModel.notebookModel.notebookUri; } - //Gets sanitizer from ISanitizer interface - private get sanitizer(): ISanitizer { - if (this._sanitizer) { - return this._sanitizer; - } - return this._sanitizer = defaultSanitizer; - } - - private setLoading(isLoading: boolean): void { - this.loading = isLoading; - this._changeRef.detectChanges(); - } - ngOnInit() { this.updatePreview(); } @@ -110,40 +86,17 @@ export class MarkdownOutputComponent extends AngularDisposable implements IMimeC if (trustedChanged || !this._initialized) { this._lastTrustedMode = this.isTrusted; let content = this._bundleOptions.data['text/markdown']; - if (useInProcMarkdown(this._configurationService)) { - this._markdownRenderer.setNotebookURI(this.cellModel.notebookModel.notebookUri); - let markdownResult = this._markdownRenderer.render({ - isTrusted: this.cellModel.trustedMode, - value: content.toString() - }); - let outputElement = this.output.nativeElement; - outputElement.innerHTML = markdownResult.element.innerHTML; - } else { - if (!content) { - - } else { - this._commandService.executeCommand('notebook.showPreview', this._cellModel.notebookModel.notebookUri, content).then((htmlcontent) => { - htmlcontent = convertVscodeResourceToFileInSubDirectories(htmlcontent, this._cellModel); - htmlcontent = this.sanitizeContent(htmlcontent); - let outputElement = this.output.nativeElement; - outputElement.innerHTML = htmlcontent; - this.setLoading(false); - }); - } - } + this._markdownRenderer.setNotebookURI(this.cellModel.notebookModel.notebookUri); + let markdownResult = this._markdownRenderer.render({ + isTrusted: this.cellModel.trustedMode, + value: content.toString() + }); + let outputElement = this.output.nativeElement; + outputElement.innerHTML = markdownResult.element.innerHTML; this._initialized = true; } } - //Sanitizes the content based on trusted mode of Cell Model - private sanitizeContent(content: string): string { - if (this.isTrusted) { - content = this.sanitizer.sanitize(content); - } - return content; - } - - public layout() { // Do we need to update on layout changed? }