2021-12-29 01:32:56 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Monaco</title>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
html, body {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="container" style="width: 100%; height: 100%"></div>
|
|
|
|
|
|
|
|
<script src="resource://zotero/vs/loader.js"></script>
|
|
|
|
<script>
|
2022-06-28 19:05:11 +00:00
|
|
|
/**
|
|
|
|
* @param {Object} [params = {}]
|
|
|
|
* @return {Promise<void>}
|
|
|
|
*/
|
|
|
|
function loadMonaco(params = {}) {
|
|
|
|
let container = document.getElementById('container');
|
2021-12-29 01:32:56 +00:00
|
|
|
|
2022-06-28 19:05:11 +00:00
|
|
|
require.config({ paths: { vs: 'resource://zotero/vs' } });
|
2021-12-29 01:32:56 +00:00
|
|
|
|
2022-06-28 19:05:11 +00:00
|
|
|
let proxy = URL.createObjectURL(
|
|
|
|
new Blob(
|
|
|
|
[`
|
|
|
|
self.MonacoEnvironment = {
|
|
|
|
baseUrl: 'resource://zotero/'
|
|
|
|
};
|
|
|
|
importScripts('resource://zotero/vs/base/worker/workerMain.js');
|
|
|
|
`],
|
|
|
|
{ type: "text/javascript" }
|
|
|
|
)
|
|
|
|
);
|
|
|
|
window.MonacoEnvironment = { getWorkerUrl: () => proxy };
|
2021-12-29 01:32:56 +00:00
|
|
|
|
2022-06-28 19:05:11 +00:00
|
|
|
return new Promise(resolve => require(['vs/editor/editor.main'], function () {
|
|
|
|
globalEditor = monaco;
|
2021-12-29 01:32:56 +00:00
|
|
|
|
2022-06-28 19:05:11 +00:00
|
|
|
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
|
|
|
target: monaco.languages.typescript.ScriptTarget.ES6,
|
|
|
|
allowNonTsExtensions: true // needed for peeking definitions from in-memory models to work
|
|
|
|
});
|
2021-12-29 01:32:56 +00:00
|
|
|
|
2022-06-28 19:05:11 +00:00
|
|
|
editor = monaco.editor.create(container, {
|
|
|
|
theme: 'vs-dark',
|
|
|
|
language: 'javascript',
|
|
|
|
scrollBeyondLastLine: false,
|
|
|
|
minimap: { enabled: false },
|
|
|
|
// Clicking links doesn't actually work, so disable them (for now)
|
|
|
|
links: false,
|
2022-07-11 17:03:48 +00:00
|
|
|
insertSpaces: false,
|
|
|
|
detectIndentation: false,
|
2022-06-28 19:05:11 +00:00
|
|
|
...params
|
|
|
|
});
|
2024-05-07 16:10:57 +00:00
|
|
|
|
|
|
|
editor.getModel().setEOL(monaco.editor.EndOfLineSequence.LF);
|
2021-12-29 01:32:56 +00:00
|
|
|
|
2022-06-28 19:05:11 +00:00
|
|
|
window.onresize = function () {
|
|
|
|
editor.layout();
|
|
|
|
};
|
|
|
|
|
|
|
|
resolve({ monaco, editor });
|
|
|
|
}));
|
|
|
|
}
|
2021-12-29 01:32:56 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|