Update indent after moving items
This commit is contained in:
parent
8fd30fdb03
commit
ae857feb72
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user