Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Apr 13, 2020
1 parent 2d965f4 commit bee5463
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vs/editor/standalone/browser/standaloneEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { IAccessibilityService } from 'vs/platform/accessibility/common/accessib
import { clearAllFontInfos } from 'vs/editor/browser/config/configuration';
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

Expand Down Expand Up @@ -241,20 +242,26 @@ export function createWebWorker<T>(opts: IWebWorkerOptions): MonacoWebWorker<T>
* Colorize the contents of `domNode` using attribute `data-lang`.
*/
export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void> {
return Colorizer.colorizeElement(StaticServices.standaloneThemeService.get(), StaticServices.modeService.get(), domNode, options);
const themeService = <StandaloneThemeServiceImpl>StaticServices.standaloneThemeService.get();
themeService.registerEditorContainer(domNode);
return Colorizer.colorizeElement(themeService, StaticServices.modeService.get(), domNode, options);
}

/**
* Colorize `text` using language `languageId`.
*/
export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string> {
const themeService = <StandaloneThemeServiceImpl>StaticServices.standaloneThemeService.get();
themeService.registerEditorContainer(document.body);
return Colorizer.colorize(StaticServices.modeService.get(), text, languageId, options);
}

/**
* Colorize a line in a model.
*/
export function colorizeModelLine(model: ITextModel, lineNumber: number, tabSize: number = 4): string {
const themeService = <StandaloneThemeServiceImpl>StaticServices.standaloneThemeService.get();
themeService.registerEditorContainer(document.body);
return Colorizer.colorizeModelLine(model, lineNumber, tabSize);
}

Expand Down

0 comments on commit bee5463

Please sign in to comment.