Trilium als Archiv: verwaltete Instanz pro Projekt, MD-Archiv und Dokument-Tab entfernt
- domain/trilium.rs: Runtime-Download (gepinnt 0.104.0), Instanz pro Projekt auf 127.0.0.1 mit FNV-Port, ETAPI (archive_note, search_notes), Token im Keyring - Setup bis aufs Passwort automatisiert: trilium_connect macht new-document (skipDemoDb), set-password und ETAPI-Login; Modul-Flag erst nach Token-Erfolg - write_panel legt direkt eine Trilium-Notiz an (text|path, folder/description/tags); noteopen-Kanal, das Terminal-Fenster öffnet die Notiz (ersetzt archive_panel) - MD-Altbestand raus: archive*/wiki*, archiveHome samt Permissions, panel_set/panel_load/ wiki_open, panel_archive*/archive_docs/*_archive_home, reveal_path, spellcheck - Dokument-Tab raus: Panel = ToDo/Befehle/Suche + Archiv-Knopf (trilium_open); panel-view/archive-form gelöscht, Markup/CSS/Messages bereinigt - Lösch-Stufe Archiv: Instanz stoppen, Trilium-Datadir und Keyring-Token löschen
This commit is contained in:
+39
-98
@@ -1,14 +1,11 @@
|
||||
/// Gemeinsame Panel-Verdrahtung für das angedockte Panel (terminal.ts) und
|
||||
/// das abgelöste Fenster (panel.ts): die Entwurfs-Ansicht als Kern, alle
|
||||
/// weiteren Tabs aus der Modul-Registry (src/modules) — Tab-Knöpfe und
|
||||
/// Content-Container entstehen hier aus der Liste der aktiven Module,
|
||||
/// Erstbefüllung per buffer_read, Updates über `<buffer>-update`-Events.
|
||||
/// Die Element-IDs des Entwurfs-Markups sind in beiden HTML-Dateien
|
||||
/// identisch; die Draft-Controls trägt das Markup als `.draft-only`.
|
||||
/// das abgelöste Fenster (panel.ts): alle Tabs kommen aus der Modul-Registry
|
||||
/// (src/modules) — Tab-Knöpfe und Content-Container entstehen hier aus der
|
||||
/// Liste der aktiven Module, Erstbefüllung per buffer_read, Updates über
|
||||
/// `<buffer>-update`-Events.
|
||||
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { initPanelView, type PanelView } from "./panel-view";
|
||||
import { initPanelMode, type ModeTab, type PanelMode } from "./commands-view";
|
||||
import { panelToast } from "./tiles";
|
||||
import { PANEL_TABS, type ModuleCtx, type ModuleView } from "./modules";
|
||||
@@ -16,12 +13,9 @@ import { t } from "./messages";
|
||||
import "./panel-tiles.css";
|
||||
|
||||
export interface PanelWiring {
|
||||
view: PanelView;
|
||||
/// Modul-Ansichten nach Tab-Modus; enthält nur Tabs aktiver Module.
|
||||
views: Map<string, ModuleView>;
|
||||
mode: { to(m: PanelMode): void; clear(): void; current(): PanelMode | null };
|
||||
/// Entwurfstext beim Start (für die Anfangs-Modus-Entscheidung).
|
||||
draft: string;
|
||||
}
|
||||
|
||||
export async function wirePanel(
|
||||
@@ -29,59 +23,18 @@ export async function wirePanel(
|
||||
onIncoming?: () => void,
|
||||
): Promise<PanelWiring> {
|
||||
const titleEl = document.querySelector(".panel-title") as HTMLElement;
|
||||
const [enabled, defaultLang, draft] = await Promise.all([
|
||||
invoke<string[]>("enabled_modules", { project }),
|
||||
invoke<string>("spellcheck_lang"),
|
||||
invoke<string>("buffer_read", { project, buffer: "panel" }),
|
||||
]);
|
||||
const enabled = await invoke<string[]>("enabled_modules", { project });
|
||||
const tabs = PANEL_TABS.filter((tab) => enabled.includes(tab.module));
|
||||
|
||||
// Ohne Archiv-Modul (abgewählt oder kein Archiv-Home) verschwinden auch
|
||||
// die Archiv-Werkzeuge des Entwurfs-Tabs.
|
||||
if (!enabled.includes("archive")) {
|
||||
for (const sel of ["#panel-archive", "#panel-wiki-jump"]) {
|
||||
const el = document.querySelector<HTMLElement>(sel)!;
|
||||
el.hidden = true;
|
||||
// Raus aus der draft-only-Menge, sonst blendet der Modus-Umschalter
|
||||
// die Archiv-Werkzeuge im Dokument-Modus wieder ein.
|
||||
el.classList.remove("draft-only");
|
||||
}
|
||||
}
|
||||
|
||||
// Jeder Wiki-Sprung (Wikilink, Chip, Dokument-Sprung) geht als ein Invoke an
|
||||
// den Kern; das Ergebnis kommt über den Wiki-Puffer und `wiki-update` zurück.
|
||||
// Fehler (z. B. Ziel nicht im Archiv) erscheinen als Toast.
|
||||
const openWiki = (name: string) =>
|
||||
void invoke("wiki_open", { project, name }).catch((e) => panelToast(String(e)));
|
||||
|
||||
const ctx: ModuleCtx = {
|
||||
project,
|
||||
toast: panelToast,
|
||||
openDoc: (path) =>
|
||||
void invoke("panel_load", { project, path }).catch((e) => panelToast(String(e))),
|
||||
openWiki,
|
||||
};
|
||||
|
||||
const view = initPanelView({
|
||||
content: document.getElementById("panel-content")!,
|
||||
copyBtn: document.getElementById("panel-copy")!,
|
||||
modeBtn: document.getElementById("panel-mode")!,
|
||||
titleEl,
|
||||
editBtn: document.getElementById("panel-title-edit")!,
|
||||
editContentBtn: document.getElementById("panel-content-edit")!,
|
||||
langSelect: document.getElementById("panel-lang") as HTMLSelectElement,
|
||||
defaultLang,
|
||||
onCommit: (text) => invoke("panel_set", { project, text }),
|
||||
onWikiLink: openWiki,
|
||||
});
|
||||
const ctx: ModuleCtx = { project, toast: panelToast };
|
||||
|
||||
// Tab-Leiste und Container aus der Registry. Die Container-IDs
|
||||
// (`<mode>-content`) sind zugleich die CSS-Anker der Ansichten; die
|
||||
// Container reihen sich hinter #panel-content ein.
|
||||
// Container reihen sich hinter der Kopfzeile (.panel-head) ein.
|
||||
const tabsEl = document.getElementById("panel-tabs")!;
|
||||
const views = new Map<string, ModuleView>();
|
||||
const modeTabs: ModeTab[] = [];
|
||||
let anchor = document.getElementById("panel-content")!;
|
||||
let anchor = document.querySelector(".panel-head") as HTMLElement;
|
||||
for (const tab of tabs) {
|
||||
const btn = document.createElement("button");
|
||||
btn.className = "panel-btn";
|
||||
@@ -94,15 +47,12 @@ export async function wirePanel(
|
||||
sep.className = "tab-sep";
|
||||
tabsEl.append(sep);
|
||||
}
|
||||
let content: HTMLElement | null = null;
|
||||
if (tab.init) {
|
||||
content = document.createElement("div");
|
||||
content.id = `${tab.mode}-content`;
|
||||
content.hidden = true;
|
||||
anchor.after(content);
|
||||
anchor = content;
|
||||
views.set(tab.mode, tab.init(content, ctx));
|
||||
}
|
||||
const content = document.createElement("div");
|
||||
content.id = `${tab.mode}-content`;
|
||||
content.hidden = true;
|
||||
anchor.after(content);
|
||||
anchor = content;
|
||||
views.set(tab.mode, tab.init(content, ctx));
|
||||
modeTabs.push({
|
||||
mode: tab.mode,
|
||||
btn,
|
||||
@@ -113,43 +63,34 @@ export async function wirePanel(
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
const mode = initPanelMode({
|
||||
tabs: modeTabs,
|
||||
draftEls: [
|
||||
document.getElementById("panel-content")!,
|
||||
...document.querySelectorAll<HTMLElement>(".draft-only"),
|
||||
],
|
||||
titleEl,
|
||||
flush: () => void view.flush(),
|
||||
});
|
||||
// Archiv-Zugang: fester Knopf hinter den Tabs — öffnet das Trilium-Fenster
|
||||
// des Projekts (kein Modus, kein Content-Container).
|
||||
if (enabled.includes("trilium")) {
|
||||
const btn = document.createElement("button");
|
||||
btn.className = "panel-btn";
|
||||
btn.textContent = t("panel.archiveOpen");
|
||||
btn.title = t("panel.archiveOpenTitle");
|
||||
btn.addEventListener("click", () =>
|
||||
void invoke("trilium_open", { project, noteId: null }).catch((e) =>
|
||||
panelToast(String(e)),
|
||||
),
|
||||
);
|
||||
tabsEl.append(btn);
|
||||
}
|
||||
|
||||
// Sprung Dokument → Wiki: öffnet den Archiv-Navigator (Dokumentseiten im
|
||||
// Wiki gibt es nicht mehr — Dokumente öffnen immer im Dokument-Tab).
|
||||
document
|
||||
.getElementById("panel-wiki-jump")!
|
||||
.addEventListener("click", () => openWiki("tag:"));
|
||||
const mode = initPanelMode({ tabs: modeTabs, titleEl });
|
||||
|
||||
view.set(draft);
|
||||
await listen<string>("panel-update", (e) => {
|
||||
// Erst umschalten, dann setzen: to("draft") restauriert den gemerkten
|
||||
// Titel — der neue Inhalt (und damit sein Titel) muss danach kommen.
|
||||
mode.to("draft");
|
||||
view.set(e.payload);
|
||||
onIncoming?.();
|
||||
});
|
||||
await Promise.all(
|
||||
tabs
|
||||
.filter((tab) => tab.init)
|
||||
.map(async (tab) => {
|
||||
const v = views.get(tab.mode)!;
|
||||
v.set(await invoke<string>("buffer_read", { project, buffer: tab.buffer }));
|
||||
await listen<string>(`${tab.buffer}-update`, (e) => {
|
||||
v.set(e.payload);
|
||||
mode.to(tab.mode);
|
||||
onIncoming?.();
|
||||
});
|
||||
}),
|
||||
tabs.map(async (tab) => {
|
||||
const v = views.get(tab.mode)!;
|
||||
v.set(await invoke<string>("buffer_read", { project, buffer: tab.buffer }));
|
||||
await listen<string>(`${tab.buffer}-update`, (e) => {
|
||||
v.set(e.payload);
|
||||
mode.to(tab.mode);
|
||||
onIncoming?.();
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return { view, views, mode, draft };
|
||||
return { views, mode };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user