Move into monaco-editor-samples folder

This commit is contained in:
Alex Dima 2021-11-05 12:12:35 +01:00
parent b9969d41cb
commit a9ab892f7a
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9
86 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,2 @@
dist/
.cache

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<h2>Monaco Editor Parcel Bundler Sample</h2>
This sample shows how to load a small subset of the editor:
<ul>
<li>Only the core editor and the find widget</li>
<li>Only the json language coloring</li>
</ul>
To run this sample, you need to:
<pre>
$/browser-esm-parcel> npm install .
$/browser-esm-parcel> npm run build
$/browser-esm-parcel> npm run simpleserver
</pre
>
Then, open <a href="http://localhost:9999/">http://localhost:9999/</a>.
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,17 @@
{
"name": "helloworld",
"dependencies": {},
"scripts": {
"simpleserver": "node ../node_modules/yaserver/bin/yaserver --root ./dist --port 9999",
"build": "npm run build-index && npm run build-json && npm run build-css && npm run build-html && npm run build-ts && npm run build-worker",
"build-index": "parcel build src/index.html",
"build-json": "parcel build ../node_modules/monaco-editor/esm/vs/language/json/json.worker.js --no-source-maps",
"build-css": "parcel build ../node_modules/monaco-editor/esm/vs/language/css/css.worker.js --no-source-maps",
"build-html": "parcel build ../node_modules/monaco-editor/esm/vs/language/html/html.worker.js --no-source-maps",
"build-ts": "parcel build ../node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js --no-source-maps",
"build-worker": "parcel build ../node_modules/monaco-editor/esm/vs/editor/editor.worker.js --no-source-maps"
},
"devDependencies": {
"parcel": "^1.12.4"
}
}

View file

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
<script src="index.js"></script>
</body>
</html>

View file

@ -0,0 +1,24 @@
import * as monaco from 'monaco-editor/esm/vs/editor/editor.main.js';
self.MonacoEnvironment = {
getWorkerUrl: function (moduleId, label) {
if (label === 'json') {
return './json.worker.js';
}
if (label === 'css' || label === 'scss' || label === 'less') {
return './css.worker.js';
}
if (label === 'html' || label === 'handlebars' || label === 'razor') {
return './html.worker.js';
}
if (label === 'typescript' || label === 'javascript') {
return './ts.worker.js';
}
return './editor.worker.js';
}
};
monaco.editor.create(document.getElementById('container'), {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'javascript'
});