mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 11:08:31 -05:00
119 lines
3.6 KiB
TypeScript
119 lines
3.6 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Dimension } from 'vs/base/browser/dom';
|
|
import { Event } from 'vs/base/common/event';
|
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
|
import { URI } from 'vs/base/common/uri';
|
|
import * as modes from 'vs/editor/common/modes';
|
|
import * as nls from 'vs/nls';
|
|
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
|
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
|
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
|
|
|
/**
|
|
* Set when the find widget in a webview is visible.
|
|
*/
|
|
export const KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE = new RawContextKey<boolean>('webviewFindWidgetVisible', false);
|
|
export const KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED = new RawContextKey<boolean>('webviewFindWidgetFocused', false);
|
|
|
|
export const webviewHasOwnEditFunctionsContextKey = 'webviewHasOwnEditFunctions';
|
|
export const webviewHasOwnEditFunctionsContext = new RawContextKey<boolean>(webviewHasOwnEditFunctionsContextKey, false);
|
|
|
|
export const IWebviewService = createDecorator<IWebviewService>('webviewService');
|
|
|
|
export interface WebviewIcons {
|
|
readonly light: URI;
|
|
readonly dark: URI;
|
|
}
|
|
|
|
/**
|
|
* Handles the creation of webview elements.
|
|
*/
|
|
export interface IWebviewService {
|
|
_serviceBrand: undefined;
|
|
|
|
createWebview(
|
|
id: string,
|
|
options: WebviewOptions,
|
|
contentOptions: WebviewContentOptions,
|
|
): WebviewElement;
|
|
|
|
createWebviewEditorOverlay(
|
|
id: string,
|
|
options: WebviewOptions,
|
|
contentOptions: WebviewContentOptions,
|
|
): WebviewEditorOverlay;
|
|
|
|
setIcons(id: string, value: WebviewIcons | undefined): void;
|
|
}
|
|
|
|
export interface WebviewOptions {
|
|
readonly customClasses?: string;
|
|
readonly enableFindWidget?: boolean;
|
|
readonly tryRestoreScrollPosition?: boolean;
|
|
readonly retainContextWhenHidden?: boolean;
|
|
}
|
|
|
|
export interface WebviewContentOptions {
|
|
readonly allowScripts?: boolean;
|
|
readonly localResourceRoots?: ReadonlyArray<URI>;
|
|
readonly portMapping?: ReadonlyArray<modes.IWebviewPortMapping>;
|
|
readonly enableCommandUris?: boolean;
|
|
}
|
|
|
|
export interface WebviewExtensionDescription {
|
|
readonly location: URI;
|
|
readonly id: ExtensionIdentifier;
|
|
}
|
|
|
|
export interface Webview extends IDisposable {
|
|
|
|
html: string;
|
|
contentOptions: WebviewContentOptions;
|
|
extension: WebviewExtensionDescription | undefined;
|
|
initialScrollProgress: number;
|
|
state: string | undefined;
|
|
|
|
readonly onDidFocus: Event<void>;
|
|
readonly onDidClickLink: Event<string>;
|
|
readonly onDidScroll: Event<{ scrollYPercentage: number }>;
|
|
readonly onDidUpdateState: Event<string | undefined>;
|
|
readonly onMessage: Event<any>;
|
|
readonly onMissingCsp: Event<ExtensionIdentifier>;
|
|
|
|
sendMessage(data: any): void;
|
|
|
|
focus(): void;
|
|
reload(): void;
|
|
|
|
showFind(): void;
|
|
hideFind(): void;
|
|
runFindAction(previous: boolean): void;
|
|
|
|
selectAll(): void;
|
|
|
|
windowDidDragStart(): void;
|
|
windowDidDragEnd(): void;
|
|
}
|
|
|
|
export interface WebviewElement extends Webview {
|
|
mountTo(parent: HTMLElement): void;
|
|
}
|
|
|
|
export interface WebviewEditorOverlay extends Webview {
|
|
readonly container: HTMLElement;
|
|
options: WebviewOptions;
|
|
|
|
claim(owner: any): void;
|
|
release(owner: any): void;
|
|
|
|
getInnerWebview(): Webview | undefined;
|
|
|
|
layoutWebviewOverElement(element: HTMLElement, dimension?: Dimension): void;
|
|
}
|
|
|
|
export const webviewDeveloperCategory = nls.localize('developer', "Developer");
|