if the title/filename is already belong to another file. The the 1st note file remain. In the reading file, the content of the new snip is being replaced by the [[link]] while its content is deleted (no warning of existing note ).
For people who are are new to markdown, the definition of next line maybe a bit fuzzy when text is wrapped. If you select text within the line, then it just turn that highlighted selection into new link
Should alert people on choosing new default location for new notes (instead of main vault). Cause the vault fill up quite fast when you snip (especially with hotkey)
Always make a copy of the original note (either alert reminder or auto copy feature). (because after reading and snip, the original file is shredded with [[link title]]. most of the important points are already being shorten/cut/snipped away)
If the title of the note contain symbols and OS block file creation, then Obsidian do nothing (great!).
If note heading already exist, give alert for new name OR auto adding a number behind new notes. maybe also 1 option to name the new notes as foldername_# (# to make it unique)
I made some tweaks to your code. Thanks for the nice snippet!
These changes limit the characters in the filename, save in the default note folder, link to the actual basename (in case of existing file) and doesn’t delete the text but rather leaves it as a selection so you can choose to delete it yourself.
i tried implementing your code but it show this error:
app.js:1 Uncaught (in promise) TypeError: Cannot read property 'lastIndexOf' of undefined
at K (app.js:1)
at e.getNewFileParent (app.js:1)
at Object.extractSelection [as callback] (<anonymous>:10:40)
at N (app.js:1)
at e.executeCommandById (app.js:1)
at e.onTrigger (app.js:1)
at e.handleKey (app.js:1)
at e.onKeyEvent (app.js:1)