feat: #61 Plugin system — backend API, sandboxed Web Worker, hooks wired to real app flow, user guide, 47+21 tests
CI / lint (push) Failing after 30s
CI / test (push) Skipped
CI / build (push) Skipped
CI / e2e (push) Skipped
CI / security (push) Successful in 35s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
CI / lint (push) Failing after 30s
CI / test (push) Skipped
CI / build (push) Skipped
CI / e2e (push) Skipped
CI / security (push) Successful in 35s
Desktop Build / build-windows (push) Canceled after 0s
Desktop Build / build-linux (push) Canceled after 0s
This commit is contained in:
@@ -12,6 +12,7 @@ import { DashboardStatsWidget, DashboardRecentWidget, DashboardBookmarkWidget, D
|
||||
import { openShareDialog } from './config.js';
|
||||
import { cacheViewedFile, getCachedFile } from './offline.js';
|
||||
import { t } from './i18n.js';
|
||||
import { onFileRender } from './plugins.js';
|
||||
|
||||
// ── Multi-format export ────────────────────────────────────────────────────
|
||||
// Downloads a file export (HTML / MD bundle / ePub) via the authenticated
|
||||
@@ -877,6 +878,29 @@ export function renderFile(data) {
|
||||
|
||||
// Initialize outline/TOC for this document
|
||||
OutlineManager.init();
|
||||
|
||||
// Plugin hooks: onFileRender — allow plugins to transform the rendered
|
||||
// content or append custom widgets beneath it. Async + non-blocking so a
|
||||
// slow/failed plugin never delays the normal file render.
|
||||
if (data.content && data.is_markdown) {
|
||||
onFileRender(data.vault, data.content, data.path).then((fr) => {
|
||||
if (!fr) return;
|
||||
if (typeof fr.replace === 'string' && fr.replace !== data.content) {
|
||||
const rendered = document.getElementById('file-rendered-content');
|
||||
if (rendered) rendered.innerHTML = fr.replace;
|
||||
}
|
||||
if (Array.isArray(fr.append) && fr.append.length > 0) {
|
||||
const out = el('div', { class: 'plugin-render-output' });
|
||||
fr.append.forEach((html) => {
|
||||
const w = el('div', { class: 'plugin-widget' });
|
||||
w.innerHTML = html;
|
||||
out.appendChild(w);
|
||||
});
|
||||
area.appendChild(out);
|
||||
safeCreateIcons();
|
||||
}
|
||||
}).catch(() => { /* plugins must never break rendering */ });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user