I don’t see where to input this code. I’m missing something!
// grab current draft
const currentContent = draft.processTemplate(“[[selection]]”);
It should be this line being replaced.
const currentContent = draft.content.trim();
But that was back in 2021.
If you check the first post, in the thread, Greg notes he updated it and replaced it with a totally new version in 2022 - which is presumably why you can’t find that line.
The new action has this:
// process lines of current draft
let lines = draft.lines.map(x => x.trim())
I think you want to switch out draft.lines
with the selection as Greg previously listed, but also split()
by new lines into an array of lines.
Untested, but I think it should look like this to do what that previous request did.
// process lines of current draft selection
let lines = draft.processTemplate("[[selection]]").split('\n').map(x => x.trim())
@sylumer Thanks a lot! It works.
Two more steps:
- Is the same possible with only the line where the cursor currently is (instead of actual selecting the line)?
- And moving the line(s) from current draft to the target draft? Instead of copy and paste.
- Yes. You just need to extend the selection first then then same applies.
- Absolutely. You using scripting you can store the value in a a variable and manipulate the two drafts content to remove and add that content without going via the clipboard.
There are lots of actions that do these things, so you’ll need to d a little exploring to transplant the equivalent code.