mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 09:20:10 +01:00
Compare commits
3 commits
e8e70b3154
...
d89eb54d17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d89eb54d17 | ||
|
|
b3250fa2b9 | ||
|
|
9c7b547a98 |
4 changed files with 32 additions and 7 deletions
|
|
@ -28,6 +28,15 @@ You will get:
|
||||||
|
|
||||||
:warning: The monaco editor also ships an `AMD` build for backwards-compatibility reasons, but the `AMD` support is deprecated and will be removed in future versions.
|
:warning: The monaco editor also ships an `AMD` build for backwards-compatibility reasons, but the `AMD` support is deprecated and will be removed in future versions.
|
||||||
|
|
||||||
|
## Localization
|
||||||
|
|
||||||
|
To load the editor in a specific language, make sure that the corresponding nls script file is loaded before the main monaco editor script. For example, to load the editor in German, include the following script tag:
|
||||||
|
```html
|
||||||
|
<script src="path/to/monaco-editor/esm/nls.messages.de.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
Check the sources for available languages.
|
||||||
|
|
||||||
## Concepts
|
## Concepts
|
||||||
|
|
||||||
Monaco editor is best known for being the text editor that powers VS Code. However, it's a bit more nuanced. Some basic understanding about the underlying concepts is needed to use Monaco editor effectively.
|
Monaco editor is best known for being the text editor that powers VS Code. However, it's a bit more nuanced. Some basic understanding about the underlying concepts is needed to use Monaco editor effectively.
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ import nodeResolve from '@rollup/plugin-node-resolve';
|
||||||
import { urlToEsmPlugin } from './rollup-url-to-module-plugin/index.mjs';
|
import { urlToEsmPlugin } from './rollup-url-to-module-plugin/index.mjs';
|
||||||
import { copyFileSync, mkdirSync } from 'fs';
|
import { copyFileSync, mkdirSync } from 'fs';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import { readdirSync } from 'fs';
|
||||||
|
|
||||||
const root = join(import.meta.dirname, '../../');
|
const root = join(import.meta.dirname, '../../');
|
||||||
const outDir = join(root, './out/monaco-editor/esm');
|
const outDir = join(root, './out/monaco-editor/esm');
|
||||||
|
|
@ -40,6 +42,19 @@ const mappedPaths = {
|
||||||
[join(root, 'src/')]: 'vs/',
|
[join(root, 'src/')]: 'vs/',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getNlsEntryPoints() {
|
||||||
|
// Scan for nls.messages.*.js files dynamically
|
||||||
|
const nlsDir = dirname(fileURLToPath(import.meta.resolve('monaco-editor-core/esm/nls.messages.en.js')));
|
||||||
|
const nlsFiles = readdirSync(nlsDir)
|
||||||
|
.filter(file => file.startsWith('nls.messages.') && file.endsWith('.js'))
|
||||||
|
.reduce((acc, file) => {
|
||||||
|
// @ts-ignore
|
||||||
|
acc[file] = join(nlsDir, file);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
return nlsFiles;
|
||||||
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
input: {
|
input: {
|
||||||
entry: join(root, './src/editor/editor.main.ts'),
|
entry: join(root, './src/editor/editor.main.ts'),
|
||||||
|
|
@ -47,6 +62,7 @@ export default defineConfig({
|
||||||
edcoreMain: join(root, './src/editor/edcore.main.ts'),
|
edcoreMain: join(root, './src/editor/edcore.main.ts'),
|
||||||
editorApi: join(root, './src/editor/editor.api.ts'),
|
editorApi: join(root, './src/editor/editor.api.ts'),
|
||||||
editorWorker: join(root, './src/editor/editor.worker.ts'),
|
editorWorker: join(root, './src/editor/editor.worker.ts'),
|
||||||
|
...getNlsEntryPoints(),
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import * as css from '../../language/css/monaco.contribution.js';
|
import * as css from '../../language/css/monaco.contribution';
|
||||||
import * as html from '../../language/html/monaco.contribution.js';
|
import * as html from '../../language/html/monaco.contribution';
|
||||||
import * as json from '../../language/json/monaco.contribution.js';
|
import * as json from '../../language/json/monaco.contribution';
|
||||||
import * as typescript from '../../language/typescript/monaco.contribution.js';
|
import * as typescript from '../../language/typescript/monaco.contribution';
|
||||||
import '../../basic-languages/monaco.contribution.js';
|
import '../../basic-languages/monaco.contribution';
|
||||||
import * as lsp from '@vscode/monaco-lsp-client';
|
import * as lsp from '@vscode/monaco-lsp-client';
|
||||||
|
|
||||||
export * from 'monaco-editor-core';
|
export * from 'monaco-editor-core';
|
||||||
export { createWebWorker, type IWebWorkerOptions } from '../../common/workers.js';
|
export { createWebWorker, type IWebWorkerOptions } from '../../common/workers';
|
||||||
export { css, html, json, typescript, lsp };
|
export { css, html, json, typescript, lsp };
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import * as monaco from 'monaco-editor-core/esm/vs/editor/editor.api.js';
|
import * as monaco from 'monaco-editor-core/esm/vs/editor/editor.api';
|
||||||
|
|
||||||
export function getGlobalMonaco(): any {
|
export function getGlobalMonaco(): any {
|
||||||
return monaco;
|
return monaco;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue