note-refactor-obsidian icon indicating copy to clipboard operation
note-refactor-obsidian copied to clipboard

Allow for automatic clean titles in the link when refactoring

Open Krammy opened this issue 4 years ago • 0 comments

When highlighting a piece of text and pressing Ctrl + Shift + N to refactor the note, I would like to be able to set the first line as a clean title and the new note title to have a custom ID, like so:

[[202107062246 - Note Title|Note Title]]

The problem is that there's only a way to collect the new note title rather than the first line of the text you selected, so if you give the new note title an ID the best you can get is this:

[[202107062246 - Note Title|202107062246 - Note Title]]

There are a few different ways of allowing collection of the first line; in order of difficulty (there may be more I haven't thought about):

  1. Add an extra supported placeholder for {{first_line}}, which would use the first line of the text you just refactored.
  2. Add a checkbox for setting automatic clean titles (not ideal).
  3. Allow custom Javascript code within the curly braces (could use {{new_note_title.substring(15)}}, for example).
  4. Allow for a hook into Templater, so it's able to use a template immediately after creating the note. This way I would set the new note title to just the name and have the Templater plug-in add on the date afterwards.

I think the first option would be the easiest, though if you're planning to implement either of the last two they could allow for more interesting solutions for other people.

Thanks!

Krammy avatar Jun 07 '21 21:06 Krammy