Problem: can't copy and paste multiline text as multiple items
All checks were successful
continuous-integration/drone/push Build is passing

Solution: split text and add multiple items
This commit is contained in:
Peter Stuifzand 2022-01-09 22:15:48 +01:00
parent 258dd4f7ab
commit e2aa173432

View File

@ -509,21 +509,33 @@ function editor(root, inputData, options) {
}
let pastedData = event.originalEvent.clipboardData.getData('text/plain')
let items = JSON.parse(pastedData.toString());
try {
let items = JSON.parse(pastedData.toString());
let item = $(this).parents('.list-item')
let id = item.attr('data-id')
let item = $(this).parents('.list-item')
let id = item.attr('data-id')
// reset ids
_.each(items, item => {
item.id = null
})
// reset ids
_.each(items, item => {
item.id = null
})
store.insertAfter(id, ...items)
trigger('change')
return false
store.insertAfter(id, ...items)
trigger('change')
return false
} catch (e) {
let items = pastedData.toString().split(/\n+/);
let item = $(this).parents('.list-item')
let id = item.attr('data-id')
const firstItem = store.value(id)
items = _.map(items, text => {
const item = newListItem(firstItem.indented)
item.text = text
return item
})
store.insertAfter(id, ...items)
trigger('change')
return false
}
});
function moveCursor(event, dir) {