提交 10d5b927 编写于 作者: B Benjamin Pasero

debt - archive html iframe editor input

上级 da4a123f
......@@ -35,7 +35,6 @@ import {FileStat, NewStatPlaceholder} from 'vs/workbench/parts/files/common/expl
import {ExplorerView} from 'vs/workbench/parts/files/browser/views/explorerView';
import {ExplorerViewlet} from 'vs/workbench/parts/files/browser/explorerViewlet';
import {CACHE} from 'vs/workbench/parts/files/common/editors/textFileEditorModel';
import {HTMLFrameEditorInput} from 'vs/workbench/parts/files/common/editors/htmlFrameEditorInput';
import {DerivedFrameEditorInput} from 'vs/workbench/parts/files/common/editors/derivedFrameEditorInput';
import {IActionProvider} from 'vs/base/parts/tree/browser/actionsRenderer';
import {WorkingFileEntry, WorkingFilesModel} from 'vs/workbench/parts/files/common/workingFilesModel';
......@@ -967,65 +966,6 @@ export class FileImportedEvent extends Files.LocalFileChangeEvent {
}
}
// Preview HTML File
export class PreviewHTMLAction extends Action {
private element: IFileStat;
constructor(
element: IFileStat,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IInstantiationService private instantiationService: IInstantiationService,
@ITextFileService private textFileService: ITextFileService
) {
super('workbench.files.action.previewHTMLFromExplorer', nls.localize('openPreview', "Open Preview"));
this.element = element;
this.enabled = true;
}
public run(): Promise {
let htmlInput = this.instantiationService.createInstance(HTMLFrameEditorInput, this.element.resource);
let savePromise = Promise.as(null);
if (this.textFileService.isDirty(this.element.resource)) {
savePromise = this.textFileService.save(this.element.resource);
}
return savePromise.then(() => {
return this.editorService.openEditor(htmlInput);
});
}
}
export class PreviewHTMLEditorInputAction extends EditorInputAction {
constructor(
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IInstantiationService private instantiationService: IInstantiationService,
@ITextFileService private textFileService: ITextFileService
) {
super('workbench.files.action.previewHTMLFromEditor', nls.localize('openPreview', "Open Preview"));
this.class = 'file-editor-action action-open-preview';
}
public run(event?: any): Promise {
let input = <Files.FileEditorInput>this.input;
let sideBySide = !!(event && (event.ctrlKey || event.metaKey));
let htmlInput = this.instantiationService.createInstance(HTMLFrameEditorInput, input.getResource());
let savePromise = Promise.as(null);
if (this.textFileService.isDirty(input.getResource())) {
savePromise = this.textFileService.save(input.getResource());
}
return savePromise.then(() => {
return this.editorService.openEditor(htmlInput, null, sideBySide);
});
}
}
// Copy File/Folder
let fileToCopy: FileStat;
export class CopyFileAction extends BaseFileAction {
......
......@@ -23,7 +23,6 @@ import {FILE_EDITOR_INPUT_ID, VIEWLET_ID} from 'vs/workbench/parts/files/common/
import {FileTracker} from 'vs/workbench/parts/files/browser/fileTracker';
import {SaveParticipant} from 'vs/workbench/parts/files/common/editors/saveParticipant';
import {FileEditorInput} from 'vs/workbench/parts/files/browser/editors/fileEditorInput';
import {HTMLFrameEditorInput} from 'vs/workbench/parts/files/common/editors/htmlFrameEditorInput';
import {TextFileEditor} from 'vs/workbench/parts/files/browser/editors/textFileEditor';
import {BinaryFileEditor} from 'vs/workbench/parts/files/browser/editors/binaryFileEditor';
import {IInstantiationService, INullService} from 'vs/platform/instantiation/common/instantiation';
......@@ -146,24 +145,6 @@ class FileEditorInputFactory implements IEditorInputFactory {
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditorInputFactory(FILE_EDITOR_INPUT_ID, FileEditorInputFactory);
// Register HTML Frame Editor Input Factory
class HTMLFrameEditorInputFactory implements IEditorInputFactory {
constructor(@INullService ns) {}
public serialize(editorInput: EditorInput): string {
let htmlInput = <HTMLFrameEditorInput>editorInput;
return htmlInput.getResource().toString();
}
public deserialize(instantiationService: IInstantiationService, resourceRaw: string): EditorInput {
return instantiationService.createInstance(HTMLFrameEditorInput, URI.parse(resourceRaw));
}
}
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditorInputFactory(HTMLFrameEditorInput.ID, HTMLFrameEditorInputFactory);
// Register File Tracker
(<IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench)).registerWorkbenchContribution(
FileTracker
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import nls = require('vs/nls');
import URI from 'vs/base/common/uri';
import paths = require('vs/base/common/paths');
import {EditorModel} from 'vs/workbench/common/editor';
import {DerivedFrameEditorInput} from 'vs/workbench/parts/files/common/editors/derivedFrameEditorInput';
import {IFrameEditorModel} from 'vs/workbench/common/editor/iframeEditorModel';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
/**
* An editor input derived from DerivedFrameEditorInput to show a rendered version of a HTML file.
*/
export class HTMLFrameEditorInput extends DerivedFrameEditorInput {
public static ID: string = 'vs.html';
constructor(
resource: URI,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) {
super(resource, nls.localize('preview', "Preview '{0}'", paths.basename(resource.fsPath)));
}
public createNew(resource: URI): HTMLFrameEditorInput {
return this.instantiationService.createInstance(HTMLFrameEditorInput, resource);
}
public getId(): string {
return HTMLFrameEditorInput.ID;
}
protected createModel(): EditorModel {
let model = new IFrameEditorModel(this.getResource());
model.setUrl(this.getResource().toString());
return model;
}
public matches(otherInput: any): boolean {
if (!(otherInput instanceof HTMLFrameEditorInput)) {
return false;
}
return super.matches(otherInput);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册