mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 23:13:02 +01:00
Merge pull request #44 from orta/store_code
Let changes to the test file persist
This commit is contained in:
commit
155292c59d
1 changed files with 21 additions and 9 deletions
|
|
@ -33,12 +33,9 @@
|
||||||
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
|
<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
require([
|
let text = localStorage.getItem("code")
|
||||||
'vs/basic-languages/monaco.contribution',
|
if (!text) {
|
||||||
'vs/language/typescript/monaco.contribution'
|
text = [
|
||||||
], function() {
|
|
||||||
var editor = monaco.editor.create(document.getElementById('container'), {
|
|
||||||
value: [
|
|
||||||
'/* Game of Life',
|
'/* Game of Life',
|
||||||
' * Implemented in TypeScript',
|
' * Implemented in TypeScript',
|
||||||
' * To learn more about TypeScript, please visit http://www.typescriptlang.org/',
|
' * To learn more about TypeScript, please visit http://www.typescriptlang.org/',
|
||||||
|
|
@ -164,11 +161,26 @@
|
||||||
'',
|
'',
|
||||||
'var game = new Conway.GameOfLife();',
|
'var game = new Conway.GameOfLife();',
|
||||||
|
|
||||||
].join('\n'),
|
].join('\n')
|
||||||
language: 'typescript'
|
}
|
||||||
|
|
||||||
|
require([
|
||||||
|
'vs/basic-languages/monaco.contribution',
|
||||||
|
'vs/language/typescript/monaco.contribution'
|
||||||
|
], function() {
|
||||||
|
|
||||||
|
var editor = monaco.editor.create(document.getElementById('container'), {
|
||||||
|
value: text,
|
||||||
|
language: 'typescript',
|
||||||
|
lightbulb: { enabled: true }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.onDidChangeModelContent(() => {
|
||||||
|
const code = editor.getModel().getValue()
|
||||||
|
localStorage.setItem("code", code)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue