Implement expand/collapseBlock keys
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
86d1a25d4e
commit
7138597d7e
|
@ -42,6 +42,8 @@ function editor(root, inputData, options) {
|
|||
keymap.mapKey('Escape', 'leaveEditor')
|
||||
keymap.mapKey('C-S-ArrowUp', 'blockMoveBackward')
|
||||
keymap.mapKey('C-S-ArrowDown', 'blockMoveForward')
|
||||
keymap.mapKey('C-.', 'expandBlock')
|
||||
keymap.mapKey('C-S->', 'collapseBlock')
|
||||
|
||||
function createStore(inputData) {
|
||||
let data = [
|
||||
|
@ -152,7 +154,10 @@ function editor(root, inputData, options) {
|
|||
leaveEditor,
|
||||
|
||||
blockMoveBackward,
|
||||
blockMoveForward
|
||||
blockMoveForward,
|
||||
|
||||
expandBlock,
|
||||
collapseBlock
|
||||
};
|
||||
|
||||
root.classList.add('root')
|
||||
|
@ -609,6 +614,26 @@ function editor(root, inputData, options) {
|
|||
return false
|
||||
}
|
||||
|
||||
function expandBlock(event) {
|
||||
let open = true
|
||||
store.update(cursor.getId(store), function (item) {
|
||||
item.fold = open ? 'open' : 'closed'
|
||||
return item
|
||||
})
|
||||
trigger('change')
|
||||
return false
|
||||
}
|
||||
|
||||
function collapseBlock(event) {
|
||||
let open = false
|
||||
store.update(cursor.getId(store), function (item) {
|
||||
item.fold = open ? 'open' : 'closed'
|
||||
return item
|
||||
})
|
||||
trigger('change')
|
||||
return false
|
||||
}
|
||||
|
||||
$(root).on('keydown', function (event) {
|
||||
return keymap.handleKey(EDITOR, event)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user