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:
Tom Moor
2017-07-17 09:03:29 -07:00
committed by GitHub
parent e0d5d1bbbe
commit b6616cd05a
7 changed files with 88 additions and 11 deletions

View File

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