mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
support bulk libs setup
This commit is contained in:
parent
f5602dc25a
commit
ff09e59985
1 changed files with 28 additions and 0 deletions
|
|
@ -61,6 +61,34 @@ export class LanguageServiceDefaultsImpl implements monaco.languages.typescript.
|
|||
};
|
||||
}
|
||||
|
||||
setExtraLibs(libs: Array<{ content: string; filePath?: string }> = []): IDisposable {
|
||||
const paths = [];
|
||||
|
||||
if (libs && libs.length > 0) {
|
||||
libs.forEach(lib => {
|
||||
const filePath = lib.filePath || `ts:extralib-${Date.now()}`;
|
||||
const content = lib.content;
|
||||
|
||||
this._extraLibs[filePath] = content;
|
||||
paths.push(filePath);
|
||||
});
|
||||
|
||||
this._onDidChange.fire(this);
|
||||
}
|
||||
|
||||
return {
|
||||
dispose: () => {
|
||||
if (paths.length > 0) {
|
||||
paths.forEach(filePath => {
|
||||
delete this._extraLibs[filePath];
|
||||
});
|
||||
|
||||
this._onDidChange.fire(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getCompilerOptions(): monaco.languages.typescript.CompilerOptions {
|
||||
return this._compilerOptions;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue