New Note Inheriting Tags

name

New Note Inheriting Tags

Description

Creates a new note tagged with the tags from the note you currently have selected.

Each new note created can include a link back to the source note from which it came.

The link back can be contained in a task or as regular text.

Keywords: Inherit, auto tag

Icon

🟢

Setting

Link back (yes/no)

Setting

Link as task or text

Setting

Link prefix

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const title = note.name;
const tags = note.tags;
const new_uuid = await app.createNote("", tags);
const newnote = await app.notes.find(new_uuid);
 
var include_source = app.settings['Link back (yes/no)'] || 'yes';
var include_source = include_source.trim().toLowerCase() || 'yes';
 
var link_prefix = app.settings['Link prefix'] || '';
 
/* Boil down choice to a yes */
var yes_list = ['yes', 'y', '1', 'true', 't'];
if(yes_list.includes(include_source)){
include_source = true;
}else{
include_source = false;
}
 
 
/* Create link back to original note */
if(include_source){
/* Assemble markdown link */
const link_text = link_prefix + "[" + title + "](https://www.amplenote.com/notes/" + noteUUID + ")";
 
/* User can choose to have link back placed in a task or as regular text */
var link_task_or_text = app.settings['Link as task or text'] || 'task';
link_task_or_text = link_task_or_text.trim().toLowerCase();
 
if(link_task_or_text == "text"){
newnote.insertContent(link_text);
}else if(link_task_or_text == "task"){
const taskUUID = await newnote.insertTask({ content: link_text });
}else{
/* Give feedback to user to correct settings. */
app.alert('When "Link back (yes/no)" is true, "Link as task or text" must be set to "task" or "text".');
}
}
 
/* Bring user to the new note */
app.navigate("https://www.amplenote.com/notes/" + new_uuid);
}
}