What I’m trying to do
I am trying to create a template that copies the current open notes name (not path) to my clipboard (without the .md suffix). I am trying to do this without knowing JavaScript.
Things I have tried
I asked ChatGPT and it gave the following code for the template, which worked, but it would also prints it in the note.
<% await navigator.clipboard.writeText(tp.file.title) %>
Copied: <% tp.file.title %>
I removed Copied: <% tp.file.title %> and it still works but also prints “undefined” in the note.
So I asked ChatGPT again how to copy the current open note to the clipboard without printing to the note and this time it suggested creating the following script:
module.exports = async (tp) => {
await navigator.clipboard.writeText(tp.file.title);
};
I did this and the script shows up in Templater but ChatGPT says to click on “Manage User Scripts” then Click “Add Command” [These options do not appear]
Looking again at Templater instructions I interpret that I need to create a template to call the script so I made up the following to call “copyTitleToClipboard.js” in my “scripts” folder:
<% tp.user.copyTitleToClipboard(tp.file.title) %>
When I use this template I get a Template parsing error.
I would appreciate any help in trying to correct this error.
Is there an easier way to do this note name copy?