Fix drag and drop of items

This commit is contained in:
Peter Stuifzand 2020-11-02 21:56:42 +01:00
parent 7138597d7e
commit 7ede2e8054

View File

@ -364,21 +364,26 @@ function editor(root, inputData, options) {
}) })
drake.on('drop', function (el, target, source, sibling) { drake.on('drop', function (el, target, source, sibling) {
let wasEditing = editing
stopEditing(root, store, currentEditor) stopEditing(root, store, currentEditor)
let stopID = $(sibling).attr('data-id') let stopID = $(sibling).attr('data-id')
if (startID === stopID) { if (startID === stopID) {
return return
} }
let id = store.moveBefore(startID, stopID) let newPosition = store.moveBefore(startID, stopID)
if (id === startID) { cursor.set(newPosition)
return
}
let position = store.index(id); _.defer(() => {
cursor.set(position) trigger('change')
if (wasEditing) {
startEditing(root, store, cursor);
}
})
trigger('change')
}) })
return drake; return drake;
} }
@ -401,11 +406,6 @@ function editor(root, inputData, options) {
}) })
}) })
if (store.hasChanged()) {
trigger('change')
store.clearChanged()
}
let $span = $('<div class="content">'); let $span = $('<div class="content">');
options.transform(text, $span, id, EDITOR) options.transform(text, $span, id, EDITOR)
element.replaceWith($span); element.replaceWith($span);