Update indent after moving items

This commit is contained in:
Peter Stuifzand 2020-10-29 23:09:42 +01:00
parent 8fd30fdb03
commit ae857feb72
2 changed files with 6 additions and 6 deletions

View File

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

View File

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