feat: type / to trigger a popup action toolbox

This commit is contained in:
joytzli 2023-07-17 14:13:27 +08:00
parent 41dc65274d
commit 45ede48bb6
3 changed files with 16 additions and 0 deletions

View file

@ -54,6 +54,11 @@ function BlockAPI(
* @returns {boolean}
*/
get isEmpty(): boolean {
// if block content is only a SLASH, replace the SLASH with selected Tool
const holderContent = block.holder.innerText;
if(holderContent === '/'){
return true;
}
return block.isEmpty;
},

View file

@ -52,6 +52,9 @@ export default class BlockEvents extends Module {
case _.keyCodes.TAB:
this.tabPressed(event);
break;
case _.keyCodes.SLASH:
this.slashPressed();
break;
}
}
@ -147,6 +150,13 @@ export default class BlockEvents extends Module {
}
}
/**
* Type slash to open Toolbox
*/
public slashPressed(): void {
this.activateToolbox();
}
/**
* Add drop target styles
*

View file

@ -56,6 +56,7 @@ export const keyCodes = {
RIGHT: 39,
DELETE: 46,
META: 91,
SLASH: 191,
};
/**