You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, SilverBullet does not have a robust attachment management system ( see #72 ).
To address this, I created a space script that allows querying for orphaned attachments:
silverbullet.registerFunction({ name: "getOrphanAttachments" }, async () => {
// List of folders to exclude
const excludeFolders = ["_plugs", "silverbullet_utils"];
// Get all attachments in the space, filtering out excluded folders
const allAttachments = await space.listAttachments();
const filteredAttachments = allAttachments.filter(attachment => {
return !excludeFolders.some(folder => attachment.name.startsWith(`${folder}/`));
});
// Get all links in notes pointing to files
const allLinks = await datastore.query({ type: "link" });
// Filter links to include only those with the "link" tag and a non-empty `toFile`
const linkedFiles = allLinks
.filter(entry => entry.value.tag === "link" && entry.value.toFile && entry.value.toFile.trim() !== "")
.map(entry => entry.value.toFile);
// Find attachments that are not present in links
const orphanAttachments = filteredAttachments.filter(attachment => {
return !linkedFiles.includes(attachment.name);
});
return orphanAttachments;
});
Now I would like to create a query from this list where each row of the query has a delete button.
What type of space script do I need to implement so that clicking the button/link would trigger the space.deleteAttachment(fileName) syscall?
Side Issue:
When clicking on the link of the file reference in a query result, I get an error: Page name cannot end with a file extension. However, when the result of the query is embedded, clicking the file reference opens the file in a new tab, as expected.
Thank you
The text was updated successfully, but these errors were encountered:
simone-viozzi
changed the title
Support for Parameterized Buttons in Template Queries to Trigger specific Actions based on the row
Support for Parameterized Buttons in Template Queries to Trigger Actions based on the Row
Nov 6, 2024
Hi, my use case is:
Currently, SilverBullet does not have a robust attachment management system ( see #72 ).
To address this, I created a space script that allows querying for orphaned attachments:
Now I would like to create a query from this list where each row of the query has a delete button.
Something like:
or
something like this:
Request:
What type of space script do I need to implement so that clicking the button/link would trigger the
space.deleteAttachment(fileName)
syscall?Side Issue:
When clicking on the link of the file reference in a query result, I get an error:
Page name cannot end with a file extension
. However, when the result of the query is embedded, clicking the file reference opens the file in a new tab, as expected.Thank you
The text was updated successfully, but these errors were encountered: