mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 11:35:40 +01:00
update samples
This commit is contained in:
parent
a4d7907bd4
commit
b19105b7e7
24 changed files with 294 additions and 3505 deletions
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none'; script-src file: 'sha256-RtE3AqQ1tBhtcwykhJsEKY7jjCqiGy5yH1mRDwu6gEE='; style-src 'unsafe-inline' file:; font-src file:"
|
||||
/>
|
||||
<title>Monaco Editor!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Monaco Editor in Electron!</h1>
|
||||
<div id="container" style="width: 500px; height: 300px; border: 1px solid #ccc"></div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
const path = require('path');
|
||||
const amdLoader = require('../node_modules/monaco-editor/min/vs/loader.js');
|
||||
const amdRequire = amdLoader.require;
|
||||
const amdDefine = amdLoader.require.define;
|
||||
|
||||
function uriFromPath(_path) {
|
||||
var pathName = path.resolve(_path).replace(/\\/g, '/');
|
||||
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
|
||||
pathName = '/' + pathName;
|
||||
}
|
||||
return encodeURI('file://' + pathName);
|
||||
}
|
||||
|
||||
amdRequire.config({
|
||||
baseUrl: uriFromPath(path.join(__dirname, '../node_modules/monaco-editor/min'))
|
||||
});
|
||||
|
||||
// workaround monaco-css not understanding the environment
|
||||
self.module = undefined;
|
||||
|
||||
amdRequire(['vs/editor/editor.main'], function () {
|
||||
var editor = monaco.editor.create(document.getElementById('container'), {
|
||||
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
|
||||
language: 'javascript'
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</html>
|
||||
18
samples/legacy/electron-amd-nodeIntegration/index.html
Normal file
18
samples/legacy/electron-amd-nodeIntegration/index.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h2>Monaco Editor Electron Sample</h2>
|
||||
|
||||
To run this sample, you need to
|
||||
<a href="https://github.com/electron/electron/releases">download Electron</a>
|
||||
and then execute:
|
||||
|
||||
<pre>
|
||||
$/electron-amd> electron main.js
|
||||
</pre
|
||||
>
|
||||
</body>
|
||||
</html>
|
||||
37
samples/legacy/electron-amd-nodeIntegration/main.js
Normal file
37
samples/legacy/electron-amd-nodeIntegration/main.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
const electron = require('electron');
|
||||
const app = electron.app;
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
|
||||
let mainWindow;
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
worldSafeExecuteJavaScript: true,
|
||||
sandbox: false,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
mainWindow.loadURL(`file://${__dirname}/electron-index.html`);
|
||||
mainWindow.webContents.openDevTools();
|
||||
mainWindow.on('closed', function () {
|
||||
mainWindow = null;
|
||||
});
|
||||
}
|
||||
|
||||
app.on('ready', createWindow);
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', function () {
|
||||
if (mainWindow === null) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
7
samples/legacy/electron-amd-nodeIntegration/package.json
Normal file
7
samples/legacy/electron-amd-nodeIntegration/package.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "electron-amd-node-integration",
|
||||
"scripts": {
|
||||
"execute": "node ../node_modules/electron/cli.js ."
|
||||
},
|
||||
"main": "./main"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue