diff --git a/list-editor/index.js b/list-editor/index.js index dea12f6..4b8b866 100644 --- a/list-editor/index.js +++ b/list-editor/index.js @@ -94,14 +94,12 @@ function editor(root, inputData, options) { startEditing(root, store, cursor) } - function replaceChildren(id, children) - { + function replaceChildren(id, children) { store.replaceChildren(id, children) } - function renderUpdate() - { + function renderUpdate() { disableDragging(drake) render(root, store); drake = enableDragging(root) @@ -281,7 +279,6 @@ function editor(root, inputData, options) { startID = $(el).attr('data-id') }) - drake.on('drop', function (el, target, source, sibling) { let stopID = $(sibling).attr('data-id') if (startID === stopID) { @@ -294,6 +291,7 @@ function editor(root, inputData, options) { cursor.set(position) selection.selectOne(position, store) + _.defer(renderUpdate) trigger('change') }) return drake; diff --git a/list-editor/store.js b/list-editor/store.js index 81e9317..1ed3b87 100644 --- a/list-editor/store.js +++ b/list-editor/store.js @@ -116,6 +116,8 @@ function Store(inputData) { */ function insertBefore(beforeId, item) { let index = _.findIndex(idList, (id) => id === beforeId) + let indent = values[idList[index - 1]].indented + item.indented = indent let id = item.id if (!id) { let newId = ID() @@ -222,7 +224,7 @@ function Store(inputData) { function remove(first) { let last = lastHigherIndented(first) - idList.splice(first, last-first) + idList.splice(first, last - first) changed = true }