editor: add keyboard shortcut "h" to hide selection and widget drag / resize handles while pressed

This commit is contained in:
jean-emmanuel 2022-10-25 18:12:19 +02:00
parent 3022ee4703
commit a19a6ac22d
4 changed files with 45 additions and 4 deletions

View file

@ -2,6 +2,9 @@
## 1.18.4
- editor
- add keyboard shortcut "h" to hide selection and widget drag / resize handles while pressed
- widgets
- input: add `maxLength` property

View file

@ -107,6 +107,7 @@ Multiple widgets can be edited at once.
| ++"Page Down"++ | Bring selected widget closer |
| ++"End"++ | Bring selected widget to front |
| ++"F2"++ | Bring "label" property input into view if selected widget has one |
| ++h++ | Hide selection area and widget resize / drag handles while pressed |
=== "Mac"
@ -144,3 +145,4 @@ Multiple widgets can be edited at once.
| ++"Page Down"++ | Bring selected widget closer |
| ++"End"++ | Bring selected widget to front |
| ++"F2"++ | Bring "label" property input into view if selected widget has one |
| ++h++ | Hide selection area and widget resize / drag handles while pressed |

View file

@ -210,13 +210,17 @@ class Editor {
'home',
'end',
't',
'f2'
'f2',
'h'
]
for (let c of combos) {
keyboardJS.bind(c, (e)=>{
e.catchedByEditor = true
this.handleKeyboard(c, e)
this.handleKeydown(c, e)
}, (e)=>{
e.catchedByEditor = true
this.handleKeyup(c, e)
})
}
@ -267,7 +271,7 @@ class Editor {
}
handleKeyboard(combo, e){
handleKeydown(combo, e){
if (
this.inspector.helpModalOpened ||
@ -464,13 +468,33 @@ class Editor {
input.scrollIntoView({block: 'center'})
}
break
case 'h':
document.body.classList.add('editor-hide-selection')
break
}
}
handleKeyup(combo, e){
if (
this.inspector.helpModalOpened ||
e && e.target && e.target.tagName.match(/INPUT|TEXTAREA|SELECT/)
) return
if (e) e.preventDefault()
switch (combo) {
case 'h':
document.body.classList.remove('editor-hide-selection')
break
}
}
toggleGrid() {
this.grid = !this.grid

View file

@ -58,3 +58,15 @@
from {--color-accent: var(--color-warning)}
to {--color-accent: transparent}
}
.editor-hide-selection {
#drag-resize {
display: none;
}
.widget.editing:after,
.tablink.editing:after,
.modal-container.editing > .popup > .popup-wrapper:after {
display: none;
}
}