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

View File

@ -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()