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,8 +509,8 @@ function editor(root, inputData, options) {
}
let pastedData = event.originalEvent.clipboardData.getData('text/plain')
try {
let items = JSON.parse(pastedData.toString());
let item = $(this).parents('.list-item')
let id = item.attr('data-id')
@ -520,10 +520,22 @@ function editor(root, inputData, options) {
})
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) {