Note Interface: Query or perform actions on a note

linkPlugin API Reference Documentation: Note interface

The note interface provides a more convenient way to interact with the app interface functions that operate on a specific noteHandle. Note that - like a noteHandle - the note described by the note interface may or may not exist. Calling functions that modify the note content will create the note if it doesn't already exist.


linknote.addTag

Add a tag to the note. See app.addNoteTag for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const added = await note.addTag("some-tag");
app.alert(added ? "Tag added" : "Failed to add tag");
}
}


linknote.attachMedia

Attach a media file (image or video) to the note. See app.attachNoteMedia for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
// 1x1 gray PNG (from http://png-pixel.com)
const dataURL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mPcsv/MfwAHrgNAOkBd9gAAAABJRU5ErkJggg==";
const imageURL = await note.attachMedia(dataURL);
app.alert(`ImageURL: ` + imageURL);
}
}


linknote.attachments

Gets a list of attachments in the note. See app.getNoteAttachments for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const attachments = await note.attachments();
await app.alert(`${ attachments.length } attachments`);
}
}


linknote.backlinkContents

Get the content of backlinks from a specific source note to the note. See app.getNoteBacklinkContents for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
 
const sourceNoteHandles = await app.backlinks();
if (sourceNoteHandles.length > 0) {
const sourceNoteHandle = sourceNoteHandles[0];
const backlinkContents = await note.backlinkContents(sourceNoteHandle);
await app.alert(backlinkContents.join("\n\n"));
} else {
await app.alert("Note has no backlinks");
}
}
}



linknote.backlinks

Gets the list of notes that link to the note. See app.getNoteBacklinks for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
 
let count = 0;
for await (const referencingNoteHandle of note.backlinks()) {
count++;
}
await app.alert("backlinks count: " + count);
}
}


linknote.content

Get the content of the note, as markdown. See app.getNoteContent for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
app.alert(await note.content());
}
}


linknote.delete

Delete the note. See app.deleteNote for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
await note.delete();
}
}


linknote.images

Get all inline images in the note. See app.getNoteImages for more details..

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const images = await note.images();
await app.alert("image count: " + images.length);
}
}


linknote.insertContent

Inserts content at the beginning of a note. See app.insertNoteContent for more details.

{
noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
note.insertContent("this is some **bold** text");
}
}


linknote.insertTask

Inserts a new task at the beginning of a note. See app.insertTask for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const taskUUID = await note.insertTask({ content: "this is a task" });
app.alert(taskUUID);
}
}


linknote.name (title)

Get the title of the note.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
app.alert(`This note is named ${ note.name }`);
}
}


linknote.publicURL

Get a link to the published version of a note, if the note is published. See app.getNotePublicURL for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
 
const publicURL = await note.publicURL();
await app.alert("public URL: " + (publicURL || "none"));
}
}


linknote.publish

Publish the note, see app.publishNote for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
 
const publicURL = await note.publish();
await app.alert("Public URL: " + publicURL);
}
}


linknote.removeTag

Remove a tag from the note. See app.removeNoteTag for details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const removed = await note.removeTag("some-tag");
app.alert(removed ? "Tag removed" : "Failed to remove tag");
}
}


linknote.replaceContent

Replaces the content of the entire note, or a section of the note, with new content. See app.replaceNoteContent for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
await note.replaceContent("**new content**");
}
}


linknote.sections

Gets the sections in the note. See app.getNoteSections for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const sections = await note.sections();
app.alert("Section count: " + sections);
}
}


linknote.setName

Sets a new name for the note. See app.setNoteName for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
await note.setName(note.name + " more");
}
}


linknote.tags

Returns an Array of tags that are applied to the note.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const tags = note.tags;
app.alert(`Note has ${ tags.length } tags: ${ tags.join(",") }`);
}
}


linknote.tasks

Gets the tasks in the note. See app.getNoteTasks for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const tasks = await note.tasks();
app.alert(`Note has ${ tasks.length } tasks`);
}
}


linknote.updateImage

Update a specific image in the note. See app.updateNoteImage for more details.


{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const images = await note.images();
 
for (let i = 0; i < images.length; i++) {
const image = images[i];
await note.updateImage(image, { caption: "**new caption**" });
}
}
}


linknote.url

Returns the String URL of the note. See app.getNoteURL for more details.

{
async noteOption(app, noteUUID) {
const note = await app.notes.find(noteUUID);
const noteURL = await note.url();
app.alert(`Note URL: ${ noteURL }`);
}
}