diff --git a/editor/src/editor.js b/editor/src/editor.js index a8ae69f..11efa59 100644 --- a/editor/src/editor.js +++ b/editor/src/editor.js @@ -528,8 +528,8 @@ function Editor(holder, input) { }) editor.replaceChildren(id, results) }).then(function () { - editor.render() - }) + editor.render() + }) } } }); diff --git a/list-editor/index.js b/list-editor/index.js index 2b234ee..c130e71 100644 --- a/list-editor/index.js +++ b/list-editor/index.js @@ -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) })