Various editor fixes (#160)
* Tab should move to body from heading * Focus editor on mount, closes #156 * Closes #154 - Just went for the simple approach here, considered something more complex but this is clear * Added body placeholder
This commit is contained in:
@ -20,6 +20,8 @@ export default function MarkdownShortcuts() {
|
||||
return this.onDash(ev, state);
|
||||
case '`':
|
||||
return this.onBacktick(ev, state);
|
||||
case 'tab':
|
||||
return this.onTab(ev, state);
|
||||
case 'space':
|
||||
return this.onSpace(ev, state);
|
||||
case 'backspace':
|
||||
@ -184,6 +186,17 @@ export default function MarkdownShortcuts() {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* On tab, if at the end of the heading jump to the main body content
|
||||
* as if it is another input field (act the same as enter).
|
||||
*/
|
||||
onTab(ev: SyntheticEvent, state: Object) {
|
||||
if (state.startBlock.type === 'heading1') {
|
||||
ev.preventDefault();
|
||||
return state.transform().splitBlock().setBlock('paragraph').apply();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* On return, if at the end of a node type that should not be extended,
|
||||
* create a new paragraph below it.
|
||||
|
Reference in New Issue
Block a user