mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-25 06:10:30 -04:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -14,27 +14,26 @@ import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
|
||||
import { HtmlInput, HtmlInputOptions } from '../common/htmlInput';
|
||||
import { HtmlPreviewPart } from 'vs/workbench/parts/html/browser/htmlPreviewPart';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { WebviewElement } from 'vs/workbench/parts/html/browser/webview';
|
||||
import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI | string) {
|
||||
const uri = resource instanceof URI ? resource : URI.parse(resource);
|
||||
return accessor.get(IWorkbenchEditorService).getVisibleEditors()
|
||||
.filter(c => c instanceof HtmlPreviewPart && c.model)
|
||||
.map(e => e as HtmlPreviewPart)
|
||||
.filter(e => e.model.uri.scheme === uri.scheme && e.model.uri.fsPath === uri.fsPath);
|
||||
.filter(e => e.model.uri.scheme === uri.scheme && e.model.uri.toString() === uri.toString());
|
||||
}
|
||||
|
||||
// --- Register Editor
|
||||
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(HtmlPreviewPart.ID,
|
||||
localize('html.editor.label', "Html Preview"),
|
||||
'vs/workbench/parts/html/browser/htmlPreviewPart',
|
||||
'HtmlPreviewPart'),
|
||||
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(
|
||||
HtmlPreviewPart,
|
||||
HtmlPreviewPart.ID,
|
||||
localize('html.editor.label', "Html Preview")),
|
||||
[new SyncDescriptor(HtmlInput)]);
|
||||
|
||||
// --- Register Commands
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface HtmlPreviewEditorViewState {
|
||||
}
|
||||
|
||||
/** A context key that is set when a webview editor has focus. */
|
||||
export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS = new RawContextKey<boolean>('webviewEditorFocus', undefined);
|
||||
export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS = new RawContextKey<boolean>('webviewEditorFocus', false);
|
||||
/** A context key that is set when a webview editor does not have focus. */
|
||||
export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS.toNegated();
|
||||
/** A context key that is set when the find widget find input in webview editor webview is focused. */
|
||||
@@ -31,6 +31,12 @@ export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED = new Ra
|
||||
/** A context key that is set when the find widget find input in webview editor webview is not focused. */
|
||||
export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED.toNegated();
|
||||
|
||||
/** A context key that is set when the find widget in a webview is visible. */
|
||||
export const KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('webviewFindWidgetVisible', false);
|
||||
/** A context key that is set when the find widget in a webview is not visible. */
|
||||
export const KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_NOT_VISIBLE: ContextKeyExpr = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.toNegated();
|
||||
|
||||
|
||||
/**
|
||||
* This class is only intended to be subclassed and not instantiated.
|
||||
*/
|
||||
@@ -40,6 +46,7 @@ export abstract class WebviewEditor extends BaseWebviewEditor {
|
||||
protected _webview: WebView;
|
||||
protected content: HTMLElement;
|
||||
protected contextKey: IContextKey<boolean>;
|
||||
private findWidgetVisible: IContextKey<boolean>;
|
||||
protected findInputFocusContextKey: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
@@ -53,16 +60,19 @@ export abstract class WebviewEditor extends BaseWebviewEditor {
|
||||
if (contextKeyService) {
|
||||
this.contextKey = KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS.bindTo(contextKeyService);
|
||||
this.findInputFocusContextKey = KEYBINDING_CONTEXT_WEBVIEWEDITOR_FIND_WIDGET_INPUT_FOCUSED.bindTo(contextKeyService);
|
||||
this.findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(contextKeyService);
|
||||
}
|
||||
}
|
||||
|
||||
public showFind() {
|
||||
if (this._webview) {
|
||||
this._webview.showFind();
|
||||
this.findWidgetVisible.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
public hideFind() {
|
||||
this.findWidgetVisible.reset();
|
||||
if (this._webview) {
|
||||
this._webview.hideFind();
|
||||
}
|
||||
@@ -91,7 +101,7 @@ export abstract class WebviewEditor extends BaseWebviewEditor {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract createEditor(parent: Builder);
|
||||
protected abstract createEditor(parent: Builder): void;
|
||||
}
|
||||
|
||||
class ShowWebViewEditorFindCommand extends Command {
|
||||
@@ -137,7 +147,9 @@ class HideWebViewEditorFindCommand extends Command {
|
||||
}
|
||||
const hideCommand = new HideWebViewEditorFindCommand({
|
||||
id: 'editor.action.webvieweditor.hideFind',
|
||||
precondition: KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS,
|
||||
precondition: ContextKeyExpr.and(
|
||||
KEYBINDING_CONTEXT_WEBVIEWEDITOR_FOCUS,
|
||||
KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE),
|
||||
kbOpts: {
|
||||
primary: KeyCode.Escape
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class WebviewFindWidget extends SimpleFindWidget {
|
||||
this.onInputChanged = this.onInputChanged.bind(this);
|
||||
}
|
||||
|
||||
public find(previous) {
|
||||
public find(previous: boolean) {
|
||||
let val = this.inputValue;
|
||||
if (this.webview !== null && val) {
|
||||
this.webview.find(val, { findNext: true, forward: !previous });
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
|
||||
|
||||
|
||||
export interface HtmlInputOptions {
|
||||
@@ -25,8 +26,9 @@ export class HtmlInput extends ResourceEditorInput {
|
||||
description: string,
|
||||
resource: URI,
|
||||
public readonly options: HtmlInputOptions,
|
||||
@ITextModelService textModelResolverService: ITextModelService
|
||||
@ITextModelService textModelResolverService: ITextModelService,
|
||||
@IHashService hashService: IHashService
|
||||
) {
|
||||
super(name, description, resource, textModelResolverService);
|
||||
super(name, description, resource, textModelResolverService, hashService);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user