editor: add F2 keyboard shortcut to bring label property input into viewif selected widget has one

This commit is contained in:
jean-emmanuel 2022-10-18 15:05:05 +02:00
parent 6a0471c8fd
commit c0a3953a0a
4 changed files with 23 additions and 2 deletions

View file

@ -22,6 +22,9 @@
- client-options: add `clientSync` option to allow disabling client synchronization
- client-options: add `altTraversing` option
- editor
- add `F2` keyboard shortcut to bring label property input into viewif selected widget has one
## 1.17.0
- bug fixes

View file

@ -106,6 +106,7 @@ Multiple widgets can be edited at once.
| ++"Page Up"++ | Send selected widget farther |
| ++"Page Down"++ | Bring selected widget closer |
| ++"End"++ | Bring selected widget to front |
| ++"F2"++ | Bring "label" property input into view if selected widget has one |
=== "Mac"
@ -142,3 +143,4 @@ Multiple widgets can be edited at once.
| ++"Page Up"++ | Send selected widget farther |
| ++"Page Down"++ | Bring selected widget closer |
| ++"End"++ | Bring selected widget to front |
| ++"F2"++ | Bring "label" property input into view if selected widget has one |

View file

@ -53,7 +53,7 @@ module.exports = {
if (selector.indexOf('>') === 0) selector = ':scope ' + selector
if (selector.indexOf(' ') === -1 && selector.indexOf(',') === -1) {
if (selector.indexOf(' ') === -1 && selector.indexOf(',') === -1 && selector.indexOf('[') === -1) {
if (selector.indexOf('#') === 0 && context === document) {
nodes = [document.getElementById(selector.substr(1, selector.length - 1))]
} else if (selector.lastIndexOf('.') === 0) {

View file

@ -209,7 +209,8 @@ class Editor {
'pagedown',
'home',
'end',
't'
't',
'f2'
]
for (let c of combos) {
@ -448,6 +449,21 @@ class Editor {
this.widgetTree.blinkSelected()
break
case 'f2':
if (!this.selectedWidgets.length) return
if (!this.inspector.expandedCategories.includes('style')) {
var header = DOM.get(this.inspector.container, '.category-header[data-name="style"]')[0]
if (header) {
header.parentNode.classList.add('expanded')
this.inspector.expandedCategories.push('style')
}
}
var input = DOM.get(this.inspector.container, 'textarea[name="label"]')[0]
if (input) {
input.focus()
input.scrollIntoView({block: 'center'})
}
break
}