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)
|
startEditing(root, store, cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceChildren(id, children)
|
function replaceChildren(id, children) {
|
||||||
{
|
|
||||||
store.replaceChildren(id, children)
|
store.replaceChildren(id, children)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderUpdate()
|
function renderUpdate() {
|
||||||
{
|
|
||||||
disableDragging(drake)
|
disableDragging(drake)
|
||||||
render(root, store);
|
render(root, store);
|
||||||
drake = enableDragging(root)
|
drake = enableDragging(root)
|
||||||
|
@ -281,7 +279,6 @@ function editor(root, inputData, options) {
|
||||||
startID = $(el).attr('data-id')
|
startID = $(el).attr('data-id')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
drake.on('drop', function (el, target, source, sibling) {
|
drake.on('drop', function (el, target, source, sibling) {
|
||||||
let stopID = $(sibling).attr('data-id')
|
let stopID = $(sibling).attr('data-id')
|
||||||
if (startID === stopID) {
|
if (startID === stopID) {
|
||||||
|
@ -294,6 +291,7 @@ function editor(root, inputData, options) {
|
||||||
cursor.set(position)
|
cursor.set(position)
|
||||||
selection.selectOne(position, store)
|
selection.selectOne(position, store)
|
||||||
|
|
||||||
|
_.defer(renderUpdate)
|
||||||
trigger('change')
|
trigger('change')
|
||||||
})
|
})
|
||||||
return drake;
|
return drake;
|
||||||
|
|
|
@ -116,6 +116,8 @@ function Store(inputData) {
|
||||||
*/
|
*/
|
||||||
function insertBefore(beforeId, item) {
|
function insertBefore(beforeId, item) {
|
||||||
let index = _.findIndex(idList, (id) => id === beforeId)
|
let index = _.findIndex(idList, (id) => id === beforeId)
|
||||||
|
let indent = values[idList[index - 1]].indented
|
||||||
|
item.indented = indent
|
||||||
let id = item.id
|
let id = item.id
|
||||||
if (!id) {
|
if (!id) {
|
||||||
let newId = ID()
|
let newId = ID()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user