Modifying note content

Thanks for Joplin and thanks for providing APIs to work with it!

I'm writing a plugin to summarize highlights from a note and insert a summary at the top of the page. I can generate the summary section, I can identify the range of lines of an existing summary that need to be removed and I can insert the new section at the current cursor position with joplin.commands.execute('insertText', new_text)...

I haven't figured out how to control the insertion point for insertText or how to delete lines.

  • Is there a way to get and set the cursor position?
  • Is there a way to delete lines?
  • Is there an existing example of how to do this sort of thing?
  • Or, is the intent to always go through the data API?

Thanks in advance!

After some experimentation I was able to get things working by two methods. The first was to use textSelectAll followed by replaceSelection to replace the entire note with the modified note. The second was using scrollToHash followed by insertText.

2 Likes