mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Allow embedders to intercept trustedTypes.createPolicy calls (#184093)
This commit is contained in:
parent
9ea4f2590f
commit
828118d55e
|
@ -14,10 +14,32 @@ declare namespace monaco {
|
|||
export type Thenable<T> = PromiseLike<T>;
|
||||
|
||||
export interface Environment {
|
||||
/**
|
||||
* Define a global `monaco` symbol.
|
||||
* This is true by default in AMD and false by default in ESM.
|
||||
*/
|
||||
globalAPI?: boolean;
|
||||
/**
|
||||
* The base url where the editor sources are found (which contains the vs folder)
|
||||
*/
|
||||
baseUrl?: string;
|
||||
/**
|
||||
* A web worker factory.
|
||||
* NOTE: If `getWorker` is defined, `getWorkerUrl` is not invoked.
|
||||
*/
|
||||
getWorker?(workerId: string, label: string): Promise<Worker> | Worker;
|
||||
/**
|
||||
* Return the location for web worker scripts.
|
||||
* NOTE: If `getWorker` is defined, `getWorkerUrl` is not invoked.
|
||||
*/
|
||||
getWorkerUrl?(workerId: string, label: string): string;
|
||||
/**
|
||||
* Create a trust types policy (same API as window.trustedTypes.createPolicy)
|
||||
*/
|
||||
createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||
policyName: string,
|
||||
policyOptions?: Options,
|
||||
): undefined | Pick<TrustedTypePolicy<Options>, 'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>>;
|
||||
}
|
||||
|
||||
export interface IDisposable {
|
||||
|
|
|
@ -10,22 +10,9 @@
|
|||
"vs/workbench/services/keybinding/test/node/keyboardMapperTestUtils.ts"
|
||||
],
|
||||
"ban-trustedtypes-createpolicy": [
|
||||
"vs/base/browser/dom.ts",
|
||||
"vs/base/browser/markdownRenderer.ts",
|
||||
"vs/base/browser/defaultWorkerFactory.ts",
|
||||
"vs/base/browser/trustedTypes.ts",
|
||||
"vs/base/worker/workerMain.ts",
|
||||
"vs/editor/contrib/markdownRenderer/browser/markdownRenderer.ts",
|
||||
"vs/editor/contrib/stickyScroll/browser/stickyScrollWidget.ts",
|
||||
"vs/editor/browser/view/domLineBreaksComputer.ts",
|
||||
"vs/editor/browser/view/viewLayer.ts",
|
||||
"vs/editor/browser/widget/diffEditorWidget.ts",
|
||||
"vs/editor/contrib/inlineCompletions/browser/ghostTextWidget.ts",
|
||||
"vs/editor/browser/widget/diffReview.ts",
|
||||
"vs/editor/standalone/browser/colorizer.ts",
|
||||
"vs/workbench/api/worker/extHostExtensionService.ts",
|
||||
"vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.ts",
|
||||
"vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts",
|
||||
"vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts"
|
||||
"vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts"
|
||||
],
|
||||
"ban-worker-calls": [
|
||||
"vs/base/browser/defaultWorkerFactory.ts",
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { COI } from 'vs/base/common/network';
|
||||
import { IWorker, IWorkerCallback, IWorkerFactory, logOnceWebWorkerWarning } from 'vs/base/common/worker/simpleWorker';
|
||||
|
||||
const ttPolicy = window.trustedTypes?.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });
|
||||
const ttPolicy = createTrustedTypesPolicy('defaultWorkerFactory', { createScriptURL: value => value });
|
||||
|
||||
export function createBlobWorker(blobUrl: string, options?: WorkerOptions): Worker {
|
||||
if (!blobUrl.startsWith('blob:')) {
|
||||
|
|
35
src/vs/base/browser/trustedTypes.ts
Normal file
35
src/vs/base/browser/trustedTypes.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
export function createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||
policyName: string,
|
||||
policyOptions?: Options,
|
||||
): undefined | Pick<TrustedTypePolicy<Options>, 'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>> {
|
||||
|
||||
interface IMonacoEnvironment {
|
||||
createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||
policyName: string,
|
||||
policyOptions?: Options,
|
||||
): undefined | Pick<TrustedTypePolicy<Options>, 'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>>;
|
||||
}
|
||||
const monacoEnvironment: IMonacoEnvironment | undefined = (globalThis as any).MonacoEnvironment;
|
||||
|
||||
if (monacoEnvironment?.createTrustedTypesPolicy) {
|
||||
try {
|
||||
return monacoEnvironment.createTrustedTypesPolicy(policyName, policyOptions);
|
||||
} catch (err) {
|
||||
onUnexpectedError(err);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return window.trustedTypes?.createPolicy(policyName, policyOptions);
|
||||
} catch (err) {
|
||||
onUnexpectedError(err);
|
||||
return undefined;
|
||||
}
|
||||
}
|
|
@ -3,17 +3,18 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
|
||||
import { FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { applyFontInfo } from 'vs/editor/browser/config/domFontInfo';
|
||||
import { LineInjectedText } from 'vs/editor/common/textModelEvents';
|
||||
import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
|
||||
import { FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { InjectedTextOptions } from 'vs/editor/common/model';
|
||||
import { ILineBreaksComputer, ILineBreaksComputerFactory, ModelLineProjectionData } from 'vs/editor/common/modelLineProjectionData';
|
||||
import { LineInjectedText } from 'vs/editor/common/textModelEvents';
|
||||
|
||||
const ttPolicy = window.trustedTypes?.createPolicy('domLineBreaksComputer', { createHTML: value => value });
|
||||
const ttPolicy = createTrustedTypesPolicy('domLineBreaksComputer', { createHTML: value => value });
|
||||
|
||||
export class DOMLineBreaksComputerFactory implements ILineBreaksComputerFactory {
|
||||
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { BugIndicatingError } from 'vs/base/common/errors';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import * as viewEvents from 'vs/editor/common/viewEvents';
|
||||
import { ViewportData } from 'vs/editor/common/viewLayout/viewLinesViewportData';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { BugIndicatingError } from 'vs/base/common/errors';
|
||||
|
||||
/**
|
||||
* Represents a visible line
|
||||
|
@ -371,7 +372,7 @@ interface IRendererContext<T extends IVisibleLine> {
|
|||
|
||||
class ViewLayerRenderer<T extends IVisibleLine> {
|
||||
|
||||
private static _ttPolicy = window.trustedTypes?.createPolicy('editorViewLayer', { createHTML: value => value });
|
||||
private static _ttPolicy = createTrustedTypesPolicy('editorViewLayer', { createHTML: value => value });
|
||||
|
||||
readonly domNode: HTMLElement;
|
||||
readonly host: IVisibleLinesHost<T>;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
import * as dom from 'vs/base/browser/dom';
|
||||
import { createFastDomNode, FastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
|
||||
import { IBoundarySashes, ISashEvent, IVerticalSashLayoutProvider, Orientation, Sash, SashState } from 'vs/base/browser/ui/sash/sash';
|
||||
import * as assert from 'vs/base/common/assert';
|
||||
|
@ -14,7 +15,9 @@ import { Codicon } from 'vs/base/common/codicons';
|
|||
import { Color } from 'vs/base/common/color';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { MarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import 'vs/css!./media/diffEditor';
|
||||
|
@ -26,10 +29,11 @@ import { EditorExtensionsRegistry, IDiffEditorContributionDescription } from 'vs
|
|||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { StableEditorScrollState } from 'vs/editor/browser/stableEditorScroll';
|
||||
import { CodeEditorWidget, ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffNavigator } from 'vs/editor/browser/widget/diffNavigator';
|
||||
import { DiffReview } from 'vs/editor/browser/widget/diffReview';
|
||||
import { IDiffLinesChange, InlineDiffMargin } from 'vs/editor/browser/widget/inlineDiffMargin';
|
||||
import { WorkerBasedDocumentDiffProvider } from 'vs/editor/browser/widget/workerBasedDocumentDiffProvider';
|
||||
import { boolean as validateBooleanOption, clampedInt, EditorFontLigatures, EditorLayoutInfo, EditorOption, EditorOptions, IDiffEditorOptions, stringSet as validateStringSetOption, ValidDiffEditorBaseOptions, clampedFloat } from 'vs/editor/common/config/editorOptions';
|
||||
import { clampedFloat, clampedInt, EditorFontLigatures, EditorLayoutInfo, EditorOption, EditorOptions, IDiffEditorOptions, boolean as validateBooleanOption, stringSet as validateStringSetOption, ValidDiffEditorBaseOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { IDimension } from 'vs/editor/common/core/dimension';
|
||||
import { IPosition, Position } from 'vs/editor/common/core/position';
|
||||
|
@ -38,6 +42,7 @@ import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
|||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { IChange, ICharChange, IDiffComputationResult, ILineChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { IModelDecorationsChangeAccessor, IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { ILineBreaksComputer } from 'vs/editor/common/modelLineProjectionData';
|
||||
|
@ -57,10 +62,6 @@ import { IEditorProgressService, IProgressRunner } from 'vs/platform/progress/co
|
|||
import { defaultInsertColor, defaultRemoveColor, diffDiagonalFill, diffInserted, diffOverviewRulerInserted, diffOverviewRulerRemoved, diffRemoved } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
|
||||
import { getThemeTypeSelector, IColorTheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { MarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { DiffNavigator } from 'vs/editor/browser/widget/diffNavigator';
|
||||
|
||||
export interface IDiffCodeEditorWidgetOptions {
|
||||
originalEditor?: ICodeEditorWidgetOptions;
|
||||
|
@ -173,7 +174,7 @@ let DIFF_EDITOR_ID = 0;
|
|||
|
||||
const diffInsertIcon = registerIcon('diff-insert', Codicon.add, nls.localize('diffInsertIcon', 'Line decoration for inserts in the diff editor.'));
|
||||
const diffRemoveIcon = registerIcon('diff-remove', Codicon.remove, nls.localize('diffRemoveIcon', 'Line decoration for removals in the diff editor.'));
|
||||
const ttPolicy = window.trustedTypes?.createPolicy('diffEditorWidget', { createHTML: value => value });
|
||||
const ttPolicy = createTrustedTypesPolicy('diffEditorWidget', { createHTML: value => value });
|
||||
|
||||
const ariaNavigationTip = nls.localize('diff-aria-navigation-tip', ' use Shift + F7 to navigate changes');
|
||||
|
||||
|
|
|
@ -3,38 +3,39 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'vs/css!./media/diffReview';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
import 'vs/css!./media/diffReview';
|
||||
import { applyFontInfo } from 'vs/editor/browser/config/domFontInfo';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { IComputedEditorOptions, EditorOption, EditorFontLigatures } from 'vs/editor/common/config/editorOptions';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { EditorFontLigatures, EditorOption, IComputedEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { ILineChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { ILanguageIdCodec } from 'vs/editor/common/languages';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model';
|
||||
import { LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { RenderLineInput, renderViewLine2 as renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { ViewLineRenderingData } from 'vs/editor/common/viewModel';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { Constants } from 'vs/base/common/uint';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import * as nls from 'vs/nls';
|
||||
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILineChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
|
||||
import { ILanguageIdCodec } from 'vs/editor/common/languages';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
|
||||
|
||||
const DIFF_LINES_PADDING = 3;
|
||||
|
||||
|
@ -87,7 +88,7 @@ const diffReviewCloseIcon = registerIcon('diff-review-close', Codicon.close, nls
|
|||
|
||||
export class DiffReview extends Disposable {
|
||||
|
||||
private static _ttPolicy = window.trustedTypes?.createPolicy('diffReview', { createHTML: value => value });
|
||||
private static _ttPolicy = createTrustedTypesPolicy('diffReview', { createHTML: value => value });
|
||||
|
||||
private readonly _diffEditor: DiffEditorWidget;
|
||||
private _isVisible: boolean;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IObservable, autorun, derived, observableFromEvent, observableSignalFromEvent, observableValue } from 'vs/base/common/observable';
|
||||
|
@ -321,4 +322,4 @@ function renderLines(domNode: HTMLElement, tabSize: number, lines: LineData[], o
|
|||
domNode.innerHTML = trustedhtml as string;
|
||||
}
|
||||
|
||||
const ttPolicy = window.trustedTypes?.createPolicy('editorGhostText', { createHTML: value => value });
|
||||
const ttPolicy = createTrustedTypesPolicy('editorGhostText', { createHTML: value => value });
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { MarkdownRenderOptions, MarkedOptions, renderMarkdown } from 'vs/base/browser/markdownRenderer';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IMarkdownString, MarkdownStringTrustedOptions } from 'vs/base/common/htmlContent';
|
||||
|
@ -33,7 +34,7 @@ export interface IMarkdownRendererOptions {
|
|||
*/
|
||||
export class MarkdownRenderer {
|
||||
|
||||
private static _ttpTokenizer = window.trustedTypes?.createPolicy('tokenizeToString', {
|
||||
private static _ttpTokenizer = createTrustedTypesPolicy('tokenizeToString', {
|
||||
createHTML(html: string) {
|
||||
return html;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,19 @@
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorLayoutInfo, EditorOption, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
||||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { RenderLineInput, renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
|
||||
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import 'vs/css!./stickyScroll';
|
||||
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
|
||||
import { EditorLayoutInfo, EditorOption, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { StringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
|
||||
import { RenderLineInput, renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
|
||||
export class StickyScrollWidgetState {
|
||||
constructor(
|
||||
|
@ -21,7 +23,7 @@ export class StickyScrollWidgetState {
|
|||
) { }
|
||||
}
|
||||
|
||||
const _ttPolicy = window.trustedTypes?.createPolicy('stickyScrollViewLayer', { createHTML: value => value });
|
||||
const _ttPolicy = createTrustedTypesPolicy('stickyScrollViewLayer', { createHTML: value => value });
|
||||
|
||||
export class StickyScrollWidget extends Disposable implements IOverlayWidget {
|
||||
|
||||
|
|
|
@ -3,18 +3,19 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IViewLineTokens, LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ColorId, FontStyle, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ILanguageIdCodec, ITokenizationSupport, TokenizationRegistry } from 'vs/editor/common/languages';
|
||||
import { FontStyle, ColorId, MetadataConsts } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IViewLineTokens, LineTokens } from 'vs/editor/common/tokens/lineTokens';
|
||||
import { RenderLineInput, renderViewLine2 as renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { ViewLineRenderingData } from 'vs/editor/common/viewModel';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneTheme';
|
||||
import { MonarchTokenizer } from 'vs/editor/standalone/common/monarch/monarchLexer';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneTheme';
|
||||
|
||||
const ttPolicy = window.trustedTypes?.createPolicy('standaloneColorizer', { createHTML: value => value });
|
||||
const ttPolicy = createTrustedTypesPolicy('standaloneColorizer', { createHTML: value => value });
|
||||
|
||||
export interface IColorizerOptions {
|
||||
tabSize?: number;
|
||||
|
|
22
src/vs/monaco.d.ts
vendored
22
src/vs/monaco.d.ts
vendored
|
@ -14,10 +14,32 @@ declare namespace monaco {
|
|||
export type Thenable<T> = PromiseLike<T>;
|
||||
|
||||
export interface Environment {
|
||||
/**
|
||||
* Define a global `monaco` symbol.
|
||||
* This is true by default in AMD and false by default in ESM.
|
||||
*/
|
||||
globalAPI?: boolean;
|
||||
/**
|
||||
* The base url where the editor sources are found (which contains the vs folder)
|
||||
*/
|
||||
baseUrl?: string;
|
||||
/**
|
||||
* A web worker factory.
|
||||
* NOTE: If `getWorker` is defined, `getWorkerUrl` is not invoked.
|
||||
*/
|
||||
getWorker?(workerId: string, label: string): Promise<Worker> | Worker;
|
||||
/**
|
||||
* Return the location for web worker scripts.
|
||||
* NOTE: If `getWorker` is defined, `getWorkerUrl` is not invoked.
|
||||
*/
|
||||
getWorkerUrl?(workerId: string, label: string): string;
|
||||
/**
|
||||
* Create a trust types policy (same API as window.trustedTypes.createPolicy)
|
||||
*/
|
||||
createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||
policyName: string,
|
||||
policyOptions?: Options,
|
||||
): undefined | Pick<TrustedTypePolicy<Options>, 'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>>;
|
||||
}
|
||||
|
||||
export interface IDisposable {
|
||||
|
|
|
@ -4,20 +4,21 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { createTrustedTypesPolicy } from 'vs/base/browser/trustedTypes';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import * as languages from 'vs/editor/common/languages';
|
||||
import { ColorId } from 'vs/editor/common/encodedTokenAttributes';
|
||||
import * as languages from 'vs/editor/common/languages';
|
||||
import { tokenizeLineToHTML } from 'vs/editor/common/languages/textToHtmlTokenizer';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { BaseCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/view/notebookRenderingCommon';
|
||||
|
||||
class EditorTextRenderer {
|
||||
|
||||
private static _ttPolicy = window.trustedTypes?.createPolicy('cellRendererEditorText', {
|
||||
private static _ttPolicy = createTrustedTypesPolicy('cellRendererEditorText', {
|
||||
createHTML(input) { return input; }
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue