Problem: some standard copy paste formats do not work
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Solution: add solution for copying text from Roam. This formats looks like: - parent - child 1 - child 2 The first line starts with a dash and space. The other lines also start with spaces (multiple of 4 or 0), dash, space. Every 4 spaces is 1 indent in our format.
This commit is contained in:
parent
2ed65e417f
commit
e4539b520c
|
@ -523,7 +523,26 @@ function editor(root, inputData, options) {
|
||||||
trigger('change')
|
trigger('change')
|
||||||
return false
|
return false
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let items = pastedData.toString().split(/\n+/);
|
let inputString = pastedData.toString()
|
||||||
|
if (inputString.match(/^- /)) {
|
||||||
|
let item = $(this).parents('.list-item')
|
||||||
|
let id = item.attr('data-id')
|
||||||
|
let lines = inputString.split(/( *)- /)
|
||||||
|
lines.shift()
|
||||||
|
const firstItem = store.value(id)
|
||||||
|
const firstIndent = firstItem.indented
|
||||||
|
|
||||||
|
let items = _.map(_.chunk(lines, 2), line => {
|
||||||
|
const indent = Math.trunc(line[0].length / 4);
|
||||||
|
const item = newListItem(firstItem.indented+indent)
|
||||||
|
item.text = _.trimEnd(line[1]).replace(/\n/g, " \n")
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
store.insertAfter(id, ...items)
|
||||||
|
trigger('change')
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
let items = inputString.split(/\n+/);
|
||||||
let item = $(this).parents('.list-item')
|
let item = $(this).parents('.list-item')
|
||||||
let id = item.attr('data-id')
|
let id = item.attr('data-id')
|
||||||
if (items.length === 1) {
|
if (items.length === 1) {
|
||||||
|
@ -540,6 +559,7 @@ function editor(root, inputData, options) {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function moveCursor(event, dir) {
|
function moveCursor(event, dir) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user