Ace: Config adjustments in Run JavaScript window

- Use the "Chrome" theme
- Hide the gutter
- Don't highlight the active line
- Remove default iframe borders
- Focus the editor on window open

Ace instances (e.g., Scaffold) are now responsible for setting their own
theme (to avoid a flash of Monokai before a lighter theme appears).
This commit is contained in:
Dan Stillman 2020-12-24 02:43:52 -05:00
parent e095dbb031
commit 2ed4bb1c8f
5 changed files with 23 additions and 7 deletions

View file

@ -98,7 +98,11 @@ var Scaffold = new function() {
_editors.import = importWin.editor;
_editors.code = codeWin.editor;
_editors.tests = testsWin.editor;
for (let i in _editors) {
_editors[i].setTheme('ace/theme/monokai');
}
_editors.code.getSession().setMode(new codeWin.JavaScriptMode);
_editors.code.getSession().setUseSoftTabs(false);
// The first code line is preceeded by some metadata lines, such that

View file

@ -38,5 +38,4 @@ window.addEventListener("DOMContentLoaded", function(e) {
TextMode = require("ace/mode/text").Mode;
EditSession = require("ace/edit_session").EditSession;
editor = ace.edit('ace-div');
editor.setTheme("ace/theme/monokai");
}, false);

View file

@ -78,15 +78,23 @@ document.getElementById('run-label').textContent = `(${shortcut})`;
update();
var codeWin, codeEditor;
var codeEditor;
window.addEventListener("load", function (e) {
if (e.target !== document) {
return;
}
codeWin = document.getElementById("editor-code").contentWindow;
var codeWin = document.getElementById("editor-code").contentWindow;
codeEditor = codeWin.editor;
codeEditor.getSession().setMode(new codeWin.JavaScriptMode);
codeEditor.getSession().setUseSoftTabs(false);
var session = codeEditor.getSession();
session.setMode(new codeWin.JavaScriptMode);
codeEditor.setOptions({
// TODO: Enable if we modify to autocomplete from the Zotero API
//enableLiveAutocompletion: true,
highlightActiveLine: false,
showGutter: false,
theme: "ace/theme/chrome",
});
codeEditor.on('input', handleInput);
codeEditor.focus();
}, false);

View file

@ -60,7 +60,11 @@ input[type=checkbox] {
margin-bottom: 0;
}
textarea {
iframe {
border: 1px solid gray;
}
iframe, textarea {
flex-grow: 1;
margin: 5px 0;
font-family: Monaco, Consolas, Inconsolata, monospace;

View file

@ -45,6 +45,7 @@ const symlinkFiles = [
'resource/ace/keybinding-emacs.js',
'resource/ace/keybinding-vim.js',
'resource/ace/mode-javascript.js',
'resource/ace/theme-chrome.js',
'resource/ace/theme-monokai.js',
'resource/ace/worker-javascript.js',
'update.rdf'