diff --git a/package-lock.json b/package-lock.json
index d279a90b..fbc07eeb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,7 +16,7 @@
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.18.0",
"@electron/remote": "2.0.8",
- "ace-builds": "1.24.1",
+ "ace-builds": "1.39.0",
"ansi-html": "0.0.9",
"babelify": "10.0.0",
"balanced-match": "2.0.0",
@@ -3272,8 +3272,9 @@
"license": "ISC"
},
"node_modules/ace-builds": {
- "version": "1.24.1",
- "license": "BSD-3-Clause"
+ "version": "1.39.0",
+ "resolved": "https://registry.npmjs.org/ace-builds/-/ace-builds-1.39.0.tgz",
+ "integrity": "sha512-MqoZojv4gpc5QyTMor/dS6kmruDV9db9LVZbCiT4qYz6WsDiv4qyG5f7ZPc+wjUl6oLMqgCAsBjo1whdSVyMlQ=="
},
"node_modules/acorn": {
"version": "7.4.1",
diff --git a/package.json b/package.json
index 63dc5246..02d048cb 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.18.0",
"@electron/remote": "2.0.8",
- "ace-builds": "1.24.1",
+ "ace-builds": "1.39.0",
"ansi-html": "0.0.9",
"babelify": "10.0.0",
"balanced-match": "2.0.0",
diff --git a/src/client/editor/index.js b/src/client/editor/index.js
index 0ff1d34a..07962e2c 100644
--- a/src/client/editor/index.js
+++ b/src/client/editor/index.js
@@ -211,7 +211,8 @@ class Editor {
'end',
't',
'f2',
- 'h'
+ 'h',
+ 'mod + f'
]
for (let c of combos) {
@@ -455,7 +456,7 @@ class Editor {
break
case 'f2':
if (!this.selectedWidgets.length) return
- if (this.selectedWidgets[0].props.top === undefined) return
+ if (this.selectedWidgets[0].props.label === undefined && this.selectedWidgets[0].props.html === undefined) return
if (!this.inspector.expandedCategories.includes('style')) {
var header = DOM.get(this.inspector.container, '.category-header[data-name="style"]')[0]
if (header) {
@@ -463,16 +464,24 @@ class Editor {
this.inspector.expandedCategories.push('style')
}
}
- var input = DOM.get(this.inspector.container, 'textarea[name="label"]')[0]
+ var labelProp = this.selectedWidgets[0].props.label === undefined ? 'html' : 'label'
+ var input = DOM.get(this.inspector.container, `textarea[name="${labelProp}"]`)[0]
if (input) {
- input.focus()
- input.setSelectionRange(0, input.value.length)
- input.scrollIntoView({block: 'center'})
+ if (input._ace_input) {
+ input._ace_input.focus()
+ } else {
+ input.focus()
+ input.setSelectionRange(0, input.value.length)
+ input.scrollIntoView({block: 'center'})
+ }
}
break
case 'h':
document.body.classList.add('editor-hide-selection')
break
+ case 'mod + f':
+ this.widgetTree.filter.focus()
+ break
}
@@ -483,7 +492,7 @@ class Editor {
if (
this.inspector.helpModalOpened ||
- e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/)
+ (e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/))
) return
if (e) e.preventDefault()
diff --git a/src/client/ui/ui-code-editor.js b/src/client/ui/ui-code-editor.js
index 040ed4a6..101cc675 100644
--- a/src/client/ui/ui-code-editor.js
+++ b/src/client/ui/ui-code-editor.js
@@ -14,6 +14,15 @@ var UiModal = require('./ui-modal'),
ace.config.set('basePath', '/client/workers/')
+function setCommandEnabled(editor, name, enabled) {
+ var command = editor.commands.byName[name]
+ if (!command.bindKeyOriginal)
+ command.bindKeyOriginal = command.bindKey
+ command.bindKey = enabled ? command.bindKeyOriginal : null
+ editor.commands.addCommand(command)
+}
+
+
class CodeEditor {
constructor(parent, name, language, syntaxChecker) {
@@ -119,25 +128,47 @@ class CodeEditor {
editor.fullscreen = false
input.style.display = 'none'
input._ace_input = editor.textarea
+ input.tabIndex = -1
+
editor.setValue(input.value)
editor.textarea.osc_input = input
+ editor.textarea.tabIndex = 0
editor.selection.setRange({start:0,end:0})
if (!this.widget || widget.hash !== this.widget.hash) {
// preserve active line if widget is the same
editor.gotoLine(0)
}
+
editor.removeAllListeners('focus')
this.editor.on('focus', (e)=>{
this.parent.focusedInput = this.input
this.editor.setHighlightActiveLine(true)
this.editor.setHighlightGutterLine(true)
+
this.editor.removeAllListeners('blur')
this.editor.removeAllListeners('change')
+ this.editor.removeAllListeners('changeSelection')
this.editor.on('change', (e)=>{
this.input.value = this.editor.getValue()
- // this.parent.focusedInput = this.input
this.editor.dirty = true
})
+
+ var pos = this.editor.getCursorPosition()
+ if (pos.row === undefined || pos.column === undefined) this.editor.gotoLine(0)
+
+ this.typing = false
+ setCommandEnabled(this.editor, "indent", false)
+ setCommandEnabled(this.editor, "outdent", false)
+
+ this.editor.on('changeSelection', ()=>{
+ if (this.typing) return
+ let pos = this.editor.getCursorPosition()
+ if (pos.row || pos.column) {
+ setCommandEnabled(this.editor, "indent", true)
+ setCommandEnabled(this.editor, "outdent", true)
+ }
+ this.typing = true
+ })
this.editor.on('blur', (e)=>{
this.editor.setHighlightActiveLine(false)
this.editor.setHighlightGutterLine(false)
diff --git a/src/client/ui/ui-inspector-field.js b/src/client/ui/ui-inspector-field.js
index 70c92b1d..94b2c741 100644
--- a/src/client/ui/ui-inspector-field.js
+++ b/src/client/ui/ui-inspector-field.js
@@ -30,14 +30,14 @@ class UiInspectorField extends UiWidget {
if (this.widget.props.type == 'tab' || this.widget.props.type == 'root') {
this.container.appendChild(html`
-
+
`)
return
}
this.createInput()
- var select = html``
+ var select = html``
for (let cname in categories) {
@@ -64,7 +64,7 @@ class UiInspectorField extends UiWidget {
JSON.stringify(this.value, null, ' ').replace(/\n\s\s\s\s/g, ' ').replace(/\n\s\s(\}|\])/g, ' $1') : this.value
- let input = html``
+ let input = html``
if (this.name === 'id' && this.widget.props.type === 'root') input.disabled = true
@@ -80,7 +80,7 @@ class UiInspectorField extends UiWidget {
if (this.default.choices) {
let wrapper = html`