Tagger 2.0

linkWelcome Note:

This plugin customizes a note by modifying its name, adding tags, and applying predefined settings based on user input, handling asynchronous interactions with the application API for seamless updates. It enhances note organization by allowing users to add multiple tags and emojis, making it easier to sort and filter notes based on various criteria such as status, priority, or type. The predefined options offer standardized formatting for users who frequently use similar tags or formats, streamlining the customization process.


The intuitive prompt-based interface and asynchronous updates ensure a user-friendly experience and efficient note management. Additionally, the plugin's flexibility and scalability make it adaptable to evolving user needs, providing a practical tool for advanced note organization and customization.


linkDemo:

linkGeneral - Calling the Plugin - Tagger 2.0



linkDocumentation:

This plugin allows users to customize their notes by modifying names, adding tags, and applying predefined settings. It interacts asynchronously with the application API to ensure smooth and responsive updates.

Customize Your Note:

The plugin will prompt you with options to customize the note:

Tags Selection: Choose up to 10 tags to add to the note.

Single Tag: Type a single tag to add to the note.

Emoji Selection: Pick an emoji to represent the note's status or type. Choose its position as either a prefix or suffix.

Predefined Options: Select a predefined sample for quick customization, which includes preset emojis and tags.

Complete Customization:

After providing your inputs, the plugin will:

Update the note’s name with the selected emoji.

Add the specified tags to the note.

Apply predefined settings if no other customization is selected.

>>>


linkTable - Plugin Parameters:

name

Tagger 2.0

icon

label

description

Type {Tagger 2.0} in any note to specify and apply a tag (Existing - up to 10, and Non Existing - up to 1), especially useful in Jots Mode where the tag button is hidden, and includes features like user prompts for tags, emoji selection, position selection, and note name modifications.

instructions

Please fine the Instructions here = Tagger Pro - Insert Text


linkCode Base:

{
// Define an asynchronous function 'noteOption' that takes 'app' and 'noteUUID' as parameters
async insertText(app, noteUUID) {
// Log the start of the function
// console.log("Starting insertText function");
 
// Find the note using the UUID
const note = await app.findNote({uuid: app.context.noteUUID});
// console.log("Note found:", note);
 
// ------- Display a prompt to customize the note -------
const result = await app.prompt("Customize your note", {
inputs: [
{
label: "Select the tags (Max 10) to add to the Note!",
type: "tags",
limit: 10
},
{
label: "Type a Tag to apply (Not Existing* / Existing) - (* - Preferred)",
placeholder: "Your tag here",
type: "string",
},
{
label: "Select emoji",
type: "select",
options: [
// Task Status
{ label: "Task Status: ✅ Completed", value: "✅" },
{ label: "Task Status: ⚠️ Important", value: "⚠️" },
{ label: "Task Status: 🔴 Urgent", value: "🔴" },
{ label: "Task Status: 🟡 Pending", value: "🟡" },
{ label: "Task Status: 🟢 Done", value: "🟢" },
{ label: "Task Status: ⏳ In Progress", value: "⏳" },
 
// Note Type
{ label: "Note Type: 📝 Note", value: "📝" },
{ label: "Note Type: 💡 Idea", value: "💡" },
{ label: "Note Type: 🔍 Review", value: "🔍" },
{ label: "Note Type: 📚 Research", value: "📚" },
 
// Priority
{ label: "Priority: 📌 Pinned", value: "📌" },
{ label: "Priority: 🔒 Confidential", value: "🔒" },
 
// Time Management
{ label: "Time Management: 📅 Scheduled", value: "📅" },
{ label: "Time Management: 🕒 Later", value: "🕒" },
 
// Work and Personal
{ label: "Work: 💼 Work", value: "💼" },
{ label: "Work: 🎓 Study", value: "🎓" },
{ label: "Personal: 🏠 Home", value: "🏠" },
{ label: "Personal: 🛒 Shopping", value: "🛒" },
{ label: "Personal: ✈️ Travel", value: "✈️" },
{ label: "Personal: 🎉 Event", value: "🎉" },
 
// Miscellaneous
{ label: "Miscellaneous: ⚙️ Settings", value: "⚙️" },
{ label: "Miscellaneous: 🌟 Highlight", value: "🌟" },
{ label: "Miscellaneous: 🎯 Goal", value: "🎯" },
{ label: "Miscellaneous: 🛠️ Maintenance", value: "🛠️" },
{ label: "Miscellaneous: 💬 Discussion", value: "💬" },
{ label: "Miscellaneous: 🚀 Launch", value: "🚀" }
]
},
{
label: "Select position",
type: "select",
options: [
{ label: "Prefix", value: "" }, // Set an empty value for Prefix
{ label: "Suffix", value: "suffix" }
]
},
{
label: "Predefined Options (Advanced - Check+Modify Code Based on your Specific Requirments)",
type: "select",
options: [
{ label: "Predefined Sample 1: Completed", value: "1" },
{ label: "Predefined Sample 2: Ideas", value: "2" },
{ label: "Predefined Sample 3: Travel Goals", value: "3" } // More Options can be added as per your Requirements!
]
}
]
});
 
// Log the result of the prompt
// console.log("Prompt result:", result);
 
// ------- Check if the user has cancelled the operation -------
if (!result) {
// console.log("User cancelled the operation");
app.alert("Operation has been cancelled. Tata! Bye Bye! Cya!");
return;
}
 
// ------- Destructure user inputs -------
const [multiTag, singleTag, emoji, position, predefined] = result;
// console.log("User inputs - multiTag:", multiTag, ", singleTag:", singleTag, ", emoji:", emoji, ", position:", position, ", predefined:", predefined);
 
// ------- Handle Note Name Modifications -------
if (emoji) {
//const noteHandle = await app.findNote({ uuid: noteUUID }); // Find the note using UUID
// console.log("Note handle found:", note);
 
let updatedName = note.name;
 
if (position === "suffix") {
updatedName = `${note.name} ${emoji}`; // Add emoji as suffix
// console.log("Updated name with prefix:", updatedName);
} else { // old version - //} else if (position === "suffix") {
updatedName = `${emoji} ${note.name}`; // Add emoji as prefix
// console.log("Updated name with suffix:", updatedName);
}
 
await app.setNoteName(note, updatedName); // Update the note name
// console.log("Note name updated to:", updatedName);
}
 
// ------- Add tags to the note if provided -------
if (multiTag) {
// Split the multiTag string by commas into an array of tags
const tagsArray = multiTag.split(',').map(tag => tag.trim()); // Trim spaces around each tag
 
// Log the separated tags
// console.log("Multiple tags to be added:", tagsArray);
 
// Add each tag to the note separately
for (const tag of tagsArray) {
if (tag) { // Ensure the tag is not empty
await app.addNoteTag({ uuid: app.context.noteUUID }, tag);
// console.log("Added tag:", tag);
}
}
 
//return null; // Return an empty string after adding tags
}
 
// ------- Add single tag preferably new to the note if provided -------
if (singleTag) {
await app.addNoteTag({ uuid: app.context.noteUUID }, singleTag);
// console.log("Single tag added:", singleTag);
//return null;
}
 
// ------- Handle Predefined Modifications -------
if (!singleTag && !multiTag && !emoji && !position) {
// const noteHandle = await app.findNote({ uuid: noteUUID }); // Find the note using UUID
// console.log("Note handle found:", note);
 
// Define variables outside of the conditional blocks
let prefixz;
let suffixz;
let multiTagsz;
let updatedNamez = note.name;
// console.log("updatedNamez:", updatedNamez);
 
if (predefined === "1") {
prefixz = "✅";
suffixz = "📝";
multiTagsz = "completed, reviewed";
}
else if (predefined === "2") {
prefixz = "💡";
multiTagsz = "ideabox, ideas, thinking";
}
else if (predefined === "3") {
prefixz = "🎯";
suffixz = "✈️";
multiTagsz = "travel, goals";
}
// More Options can be added as per your Requirements!
// Example usage of the variables
// console.log("Prefix:", prefixz);
// console.log("Suffix:", suffixz);
// console.log("Multi Tags:", multiTagsz);
 
updatedNamez = `${prefixz}${note.name}${suffixz}`; // Add emoji as prefix or suffix
await app.setNoteName(note, updatedNamez); // Update the note name
// console.log("Note name updated to:", updatedNamez);
 
// Split the multiTag string by commas into an array of tags
const tagsArrayz = multiTagsz.split(',').map(tagz => tagz.trim()); // Trim spaces around each tag
// console.log("Multiple tags to be added:", tagsArrayz);
 
// Add each tag to the note separately
for (const tagz of tagsArrayz) {
if (tagz) { // Ensure the tag is not empty
await app.addNoteTag({ uuid: app.context.noteUUID }, tagz);
// console.log("Added tag:", tagz);
}
}
 
}
 
return null; // Return an empty string after adding tags
}
}

linkAdditional Information:


linkChange Log:

July 11th, 2024 - Build the framework and all the basic requirements for this Plugin.

Collected all the necessary codes, templates, and references.

Build the Plugin to handle single tag and multiple tags correctly. Also how to handle new tag and already existing tag.

Fixed all the error handling methods.

Added the feature to prefix and suffix the desired Emoji or Any Text can be added by default.

Added the Predefined Template / Format to handle multiple addition in a single click, after be configured in the Code based on users perferences.


linkImplemented & Upcoming:

Understanding the Requirements

Build the framework

Lots of emojis + Groupings

Add prefix and suffixing options

Error handling

handle multi tagging array

handle single tagging along with multi tagging array

handling errors and cleanup nulls or empty spaces

adding console logs and testing the requirements

fix multi tags as single tag issue - for loop

handling default options for select position

cleaned up logs for query optimization

minor tweaks

Testing

changes to error logs

handling spaces

Documentation

Final

change log update

time invested update

Gifts - how tos

documentation fixing

publishing

Future Ideas in the Bucket:

Add Tagger to Multiple Notes / A Particular Tag (Exclusion Criteria's - Involved!)


Code Explanation! For Curious Readers and Explores! Thank you if you have made till here. You are Awesome, if you are reading this! 😀. Have a Great Day Ahead!


Time Invested For this Plugin: 4h 32m [Not including the ideas popping up randomly when doing daily rituals, only Screen Time.]