41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
/**
|
|
* rNotes applet definitions — Vault Note.
|
|
*/
|
|
|
|
import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types";
|
|
|
|
const vaultNote: AppletDefinition = {
|
|
id: "vault-note",
|
|
label: "Vault Note",
|
|
icon: "🗒️",
|
|
accentColor: "#065f46",
|
|
ports: [
|
|
{ name: "note-in", type: "json", direction: "input" },
|
|
{ name: "content-out", type: "text", direction: "output" },
|
|
],
|
|
renderCompact(data: AppletLiveData): string {
|
|
const { snapshot } = data;
|
|
const title = (snapshot.title as string) || "Note";
|
|
const vault = (snapshot.vault as string) || "";
|
|
const tags = (snapshot.tags as string[]) || [];
|
|
const preview = (snapshot.preview as string) || "Empty note";
|
|
|
|
return `
|
|
<div>
|
|
<div style="font-size:13px;font-weight:600;margin-bottom:2px">${title}</div>
|
|
${vault ? `<div style="font-size:10px;color:#94a3b8;margin-bottom:4px">📁 ${vault}</div>` : ""}
|
|
${tags.length > 0 ? `<div style="font-size:9px;color:#065f46;margin-bottom:4px">${tags.map(t => `#${t}`).join(" ")}</div>` : ""}
|
|
<div style="font-size:11px;color:#cbd5e1;line-height:1.4;max-height:50px;overflow:hidden">${preview}</div>
|
|
</div>
|
|
`;
|
|
},
|
|
onInputReceived(portName, value, ctx) {
|
|
if (portName === "note-in" && value && typeof value === "object") {
|
|
const note = value as Record<string, unknown>;
|
|
ctx.emitOutput("content-out", (note.content as string) || "");
|
|
}
|
|
},
|
|
};
|
|
|
|
export const notesApplets: AppletDefinition[] = [vaultNote];
|