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

@ -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
}