From c30156dd103c4d7c001ecc8f93e077232aa12ec7 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sun, 9 Jan 2022 23:46:54 +0100 Subject: [PATCH] Problem: copy and paste always creates new nodes Solution: allow one line text as normals text --- list-editor/index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/list-editor/index.js b/list-editor/index.js index edcd1bf..c644428 100644 --- a/list-editor/index.js +++ b/list-editor/index.js @@ -526,14 +526,18 @@ function editor(root, inputData, options) { 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') + if (items.length === 1) { + return true + } else { + 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 } });