Skip to content

Build your personal knowledge base with Trilium Notes

refactor(docs): take the doc notes' text from the translation catalog

Elian Doran6289f7855085
diff --git a/.gitattributes b/.gitattributes
index 54d36d835c..ef8a6cda45 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3,7 +3,6 @@ package-lock.json linguist-generated=true
**/package-lock.json linguist-generated=true
# Ignore from GitHub language stats.
-apps/server/src/assets/doc_notes/** linguist-vendored=true
apps/edit-docs/demo/** linguist-vendored=true
docs/** linguist-vendored=true
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 974a4ff64e..f51a8adc99 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -34,7 +34,6 @@
"**/node_modules": true,
"docs/**/*.html": true,
"docs/**/*.png": true,
- "apps/server/src/assets/doc_notes/**": true,
"apps/edit-docs/demo/**": true
},
"editor.codeActionsOnSave": {
diff --git a/apps/client/src/services/doc_renderer.spec.ts b/apps/client/src/services/doc_renderer.spec.ts
index aaeb68357d..f7fb380788 100644
--- a/apps/client/src/services/doc_renderer.spec.ts
+++ b/apps/client/src/services/doc_renderer.spec.ts
@@ -1,8 +1,7 @@
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import $ from "jquery";
+import { beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("./i18n.js", () => ({
- getCurrentLanguage: () => mockedLanguage
+ t: (key: string, options?: Record<string, unknown>) => translate(key, options)
}));
vi.mock("./syntax_highlight.js", () => ({
formatCodeBlocks: (arg: unknown) => formatCodeBlocksMock(arg)
@@ -11,147 +10,87 @@ vi.mock("../widgets/type_widgets/text/read_only_helper.js", () => ({
applyReferenceLinks: (arg: unknown) => applyReferenceLinksMock(arg)
}));
-import renderDoc, { isValidDocName } from "./doc_renderer.js";
+import en from "../translations/en/translation.json";
+import renderDoc, { isDocName } from "./doc_renderer.js";
-let mockedLanguage = "en";
const formatCodeBlocksMock = vi.fn((_arg?: unknown) => {});
const applyReferenceLinksMock = vi.fn(async (_arg?: unknown) => {});
+/** Resolves against the shipped English catalog, escaping interpolations the way i18next does. */
+function translate(key: string, options?: Record<string, unknown>) {
+ const entry = (en.doc_notes as Record<string, string>)[key.replace("doc_notes.", "")] ?? key;
+ return entry.replaceAll(/\{\{(\w+)\}\}/g, (_match, name: string) =>
+ String(options?.[name] ?? "").replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"));
+}
+
/** Builds a minimal FNote-like object with the given docName label. */
function fakeNote(docName: string | null) {
return { getLabelValue: (name: string) => (name === "docName" ? docName : null) } as any;
}
-/**
- * Overrides jQuery's `.load(url, cb)` so we can drive the callback deterministically.
- * The handler receives the requested url and the jQuery element so it can inject HTML.
- */
-function stubLoad(handler: (url: string, $el: JQuery<HTMLElement>) => { status?: string } | void) {
- return vi.spyOn($.fn, "load").mockImplementation(function (this: JQuery<HTMLElement>, url: any, cb?: any) {
- const result = handler(url, this) ?? {};
- const status = result.status ?? "success";
- // jQuery invokes the callback with (responseText, status, xhr).
- cb?.call(this, this.html(), status, {});
- return this;
- } as any);
-}
-
-describe("isValidDocName", () => {
- // Every docName in use comes from the hidden subtree definition and names one file directly
- // under doc_notes/<language>/.
- it("accepts the slugs the hidden subtree uses", () => {
- expect(isValidDocName("launchbar_intro")).toBe(true);
- expect(isValidDocName("task_states")).toBe(true);
- expect(isValidDocName("share")).toBe(true);
- expect(isValidDocName("quick-start-guide")).toBe(true);
- expect(isValidDocName("v2")).toBe(true);
+describe("isDocName", () => {
+ it("accepts every name the hidden subtree hands out", () => {
+ // The names in use, from hidden_subtree.ts, hidden_subtree_launcherbar.ts and task_states.ts.
+ for (const name of [
+ "hidden", "share", "user_hidden", "task_state", "task_states", "system_state",
+ "launchbar_intro", "launchbar_command_launcher", "launchbar_note_launcher",
+ "launchbar_script_launcher", "launchbar_spacer", "launchbar_widget_launcher",
+ "launchbar_quick_search", "launchbar_history_navigation"
+ ]) {
+ expect(isDocName(name), name).toBe(true);
+ }
});
- it("rejects anything carrying a separator, so no path can be spelled at all", () => {
- expect(isValidDocName("User Guide/Quick Start")).toBe(false);
- expect(isValidDocName("Quick Start Guide")).toBe(false);
- expect(isValidDocName("Day.js")).toBe(false);
- expect(isValidDocName("Import & Export")).toBe(false);
- expect(isValidDocName("")).toBe(false);
- });
-
- it("rejects path traversal attacks", () => {
- expect(isValidDocName("..")).toBe(false);
- expect(isValidDocName("../etc/passwd")).toBe(false);
- expect(isValidDocName("foo/../bar")).toBe(false);
- expect(isValidDocName("../../../../api/notes/_malicious/open")).toBe(false);
- expect(isValidDocName("..\\etc\\passwd")).toBe(false);
- expect(isValidDocName("foo\\bar")).toBe(false);
- expect(isValidDocName("...")).toBe(false);
- expect(isValidDocName("foo/..")).toBe(false);
- expect(isValidDocName("foo/./bar")).toBe(false);
+ it("rejects anything else, so a label cannot name a page that was never shipped", () => {
+ expect(isDocName("")).toBe(false);
+ expect(isDocName("User Guide/Quick Start")).toBe(false);
+ expect(isDocName("../etc/passwd")).toBe(false);
+ expect(isDocName("HIDDEN")).toBe(false);
});
+});
- it("rejects URL manipulation attacks", () => {
- expect(isValidDocName("../../../../api/notes/_malicious/open?x=")).toBe(false);
- expect(isValidDocName("foo#bar")).toBe(false);
- expect(isValidDocName("%2e%2e")).toBe(false);
- expect(isValidDocName("%2e%2e%2f%2e%2e%2fapi")).toBe(false);
+describe("every shipped name has text, and every text is shipped", () => {
+ it("matches the catalog exactly", () => {
+ const inCatalog = Object.keys(en.doc_notes).sort();
+ const inCode = inCatalog.filter(isDocName).sort();
+ expect(inCode).toEqual(inCatalog);
});
});
describe("renderDoc", () => {
beforeEach(() => {
- mockedLanguage = "en";
formatCodeBlocksMock.mockClear();
applyReferenceLinksMock.mockClear();
- (window as any).glob = { isStandalone: false, isDev: false, assetPath: "assets" };
- });
-
- afterEach(() => {
- vi.restoreAllMocks();
});
- it("resolves with an empty container when the note has no docName (load is never called)", async () => {
- const loadSpy = stubLoad(() => {});
+ it("resolves with an empty container when the note has no docName", async () => {
const $content = await renderDoc(fakeNote(null));
- expect($content.length).toBe(1);
- expect(loadSpy).not.toHaveBeenCalled();
+ expect($content.html()).toBe("");
+ expect(formatCodeBlocksMock).not.toHaveBeenCalled();
});
- it("resolves with an empty container and logs when the docName is invalid", async () => {
+ it("resolves with an empty container and logs when the docName is not one of ours", async () => {
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
- const loadSpy = stubLoad(() => {});
const $content = await renderDoc(fakeNote("../etc/passwd"));
- expect($content.length).toBe(1);
- expect(loadSpy).not.toHaveBeenCalled();
- expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining("Invalid docName"));
+ expect($content.html()).toBe("");
+ expect(errorSpy).toHaveBeenCalledWith(expect.stringContaining("Unknown docName"));
+ errorSpy.mockRestore();
});
- it("loads the localized doc and runs post-processing", async () => {
- mockedLanguage = "de";
- const loadSpy = stubLoad((_url, $el) => {
- $el.html(`<a class="reference-link">x</a>`);
- });
+ it("renders the page and runs post-processing", async () => {
+ const $content = await renderDoc(fakeNote("launchbar_quick_search"));
- const $content = await renderDoc(fakeNote("launchbar_intro"));
-
- // URL is base/doc_notes/<lang>/<docName>.html
- expect(loadSpy.mock.calls[0][0]).toBe("assets/doc_notes/de/launchbar_intro.html");
- expect($content.find(".reference-link").length).toBe(1);
- expect(formatCodeBlocksMock).toHaveBeenCalledTimes(1);
- expect(applyReferenceLinksMock).toHaveBeenCalledTimes(1);
- });
-
- it("falls back to the English doc when the localized load errors", async () => {
- mockedLanguage = "de";
- const requested: string[] = [];
- const loadSpy = stubLoad((url) => {
- requested.push(url);
- // First (German) request errors; the English fallback succeeds.
- return url.includes("/de/") ? { status: "error" } : {};
- });
-
- const $content = await renderDoc(fakeNote("launchbar_intro"));
-
- expect(requested).toEqual([
- "assets/doc_notes/de/launchbar_intro.html",
- "assets/doc_notes/en/launchbar_intro.html"
- ]);
- expect($content.length).toBe(1);
- expect(loadSpy).toHaveBeenCalledTimes(2);
- // processContent runs for the fallback url.
+ expect($content.find("a").first().attr("href")).toBe("#root/_help_Ms1nauBra7gq");
expect(formatCodeBlocksMock).toHaveBeenCalledTimes(1);
expect(applyReferenceLinksMock).toHaveBeenCalledTimes(1);
});
- it("uses the server-assets base path in standalone mode", async () => {
- (window as any).glob = { isStandalone: true, isDev: false, assetPath: "assets" };
- const loadSpy = stubLoad(() => {});
- await renderDoc(fakeNote("launchbar_intro"));
- expect(loadSpy.mock.calls[0][0]).toBe("server-assets/doc_notes/en/launchbar_intro.html");
- });
+ it("interpolates a code example as text, so its markup is not parsed as markup", async () => {
+ const $content = await renderDoc(fakeNote("launchbar_widget_launcher"));
- // In dev the asset path carries a `/src` suffix that the doc notes are not served under.
- it("uses the parent of assetPath in dev mode", async () => {
- (window as any).glob = { isStandalone: false, isDev: true, assetPath: "assets/src" };
- const loadSpy = stubLoad(() => {});
- await renderDoc(fakeNote("launchbar_intro"));
- expect(loadSpy.mock.calls[0][0]).toBe("assets/src/../doc_notes/en/launchbar_intro.html");
+ const $pre = $content.find("pre");
+ expect($pre.text()).toContain(`const TPL = \`<div style="height: 53px; width: 53px;"></div>\`;`);
+ // The example's own <div> must not have become an element of the page.
+ expect($pre.find("div").length).toBe(0);
});
});
diff --git a/apps/client/src/services/doc_renderer.ts b/apps/client/src/services/doc_renderer.ts
index cce861d2dd..1f345f81ee 100644
--- a/apps/client/src/services/doc_renderer.ts
+++ b/apps/client/src/services/doc_renderer.ts
@@ -1,78 +1,92 @@
import type FNote from "../entities/fnote.js";
import { applyReferenceLinks } from "../widgets/type_widgets/text/read_only_helper.js";
-import { getCurrentLanguage } from "./i18n.js";
+import { t } from "./i18n.js";
import { formatCodeBlocks } from "./syntax_highlight.js";
/**
- * Validates a docName to prevent path traversal attacks.
- *
- * A docName names one file directly under `doc_notes/<language>/`, so it is a plain slug with no
- * separators of any kind. The label is note data rather than trusted input, so anything else is
- * turned away instead of being reached for on disk.
+ * The pages that ship with the application, named by the `docName` label that selects one. Their
+ * text lives in the translation catalog under `doc_notes`, so a name is only ever a key into this
+ * closed set — a label carrying anything else resolves to nothing at all.
*/
-export function isValidDocName(docName: string): boolean {
- return /^[a-zA-Z0-9_-]+$/.test(docName);
-}
+const DOC_NAMES = [
+ "hidden",
+ "launchbar_command_launcher",
+ "launchbar_history_navigation",
+ "launchbar_intro",
+ "launchbar_note_launcher",
+ "launchbar_quick_search",
+ "launchbar_script_launcher",
+ "launchbar_spacer",
+ "launchbar_widget_launcher",
+ "share",
+ "system_state",
+ "task_state",
+ "task_states",
+ "user_hidden"
+] as const;
-export default function renderDoc(note: FNote) {
- return new Promise<JQuery<HTMLElement>>((resolve) => {
- const docName = note.getLabelValue("docName");
- const $content = $("<div>");
-
- // find doc based on language
- const url = getUrl(docName, getCurrentLanguage());
-
- if (url) {
- $content.load(url, async (response, status) => {
- // fallback to english doc if no translation available
- if (status === "error") {
- const fallbackUrl = getUrl(docName, "en");
-
- /* v8 ignore next 8 -- the else branch is unreachable: fallbackUrl only differs from the primary url by language, so if the primary url was valid (we got here from a successful .load call) the "en" fallback url is valid too and never null */
- if (fallbackUrl) {
- $content.load(fallbackUrl, async () => {
- await processContent($content);
- resolve($content);
- });
- } else {
- resolve($content);
- }
- return;
- }
-
- await processContent($content);
- resolve($content);
- });
- } else {
- resolve($content);
- }
- });
+export type DocName = (typeof DOC_NAMES)[number];
+
+export function isDocName(value: string): value is DocName {
+ return (DOC_NAMES as readonly string[]).includes(value);
}
-async function processContent($content: JQuery<HTMLElement>) {
+export default async function renderDoc(note: FNote) {
+ const $content = $("<div>");
+ const docName = note.getLabelValue("docName");
+
+ if (!docName) {
+ return $content;
+ }
+
+ if (!isDocName(docName)) {
+ console.error(`Unknown docName: ${docName}`);
+ return $content;
+ }
+
+ $content.html(t(`doc_notes.${docName}`, { sample: SAMPLES[docName] }));
+
formatCodeBlocks($content);
// Apply reference links.
await applyReferenceLinks($content[0]);
+
+ return $content;
}
-function getUrl(docNameValue: string | null, language: string) {
- if (!docNameValue) return;
+/**
+ * Code examples are not prose and have no business in the catalog, so the pages that carry one
+ * leave a `sample` placeholder for it. i18next escapes what it interpolates, which is what keeps
+ * the markup in the examples from being parsed as markup.
+ */
+const SAMPLES: Partial<Record<DocName, string>> = {
+ launchbar_script_launcher: `api.showMessage("Current note is " + api.getActiveContextNote().title);`,
+ launchbar_widget_launcher: `const TPL = \`<div style="height: 53px; width: 53px;"></div>\`;
- if (!isValidDocName(docNameValue)) {
- console.error(`Invalid docName: ${docNameValue}`);
- return null;
+class ExampleLaunchbarWidget extends api.NoteContextAwareWidget {
+ doRender() {
+ this.$widget = $(TPL);
}
- return `${getBasePath()}/doc_notes/${language}/${docNameValue}.html`;
-}
-
-function getBasePath() {
- if (window.glob.isStandalone) {
- return `server-assets`;
+ async refreshWithNote(note) {
+ this.$widget.css("background-color", this.stringToColor(note.title));
}
- if (window.glob.isDev) {
- return `${window.glob.assetPath}/..`;
+
+ stringToColor(str) {
+ let hash = 0;
+ for (let i = 0; i < str.length; i++) {
+ hash = str.charCodeAt(i) + ((hash << 5) - hash);
+ }
+
+ let color = '#';
+ for (let i = 0; i < 3; i++) {
+ const value = (hash >> (i * 8)) & 0xFF;
+ color += ('00' + value.toString(16)).substr(-2);
+ }
+
+ return color;
}
- return window.glob.assetPath;
}
+
+module.exports = new ExampleLaunchbarWidget();`
+};
diff --git a/apps/client/src/translations/cn/translation.json b/apps/client/src/translations/cn/translation.json
index 79e376ea10..923f943d71 100644
--- a/apps/client/src/translations/cn/translation.json
+++ b/apps/client/src/translations/cn/translation.json
@@ -164,6 +164,18 @@
"format": "格式",
"format_html_name": "HTML"
},
+ "doc_notes": {
+ "hidden": "<p>隐藏树用于记录各种应用程序级数据,这些数据大部分时间可以对用户视图隐藏。</p><p>请确保您知道自己在做什么。此子树中的错误更改可能会导致应用程序崩溃。</p>",
+ "launchbar_command_launcher": "<p>此启动器操作的键盘快捷键可以在选项 -&gt; 快捷键中配置。</p>",
+ "launchbar_history_navigation": "<p>后退和前进按钮允许您在导航历史记录中移动。</p><p>这些启动器仅在桌面版本中有效,在服务器版本中将被忽略,您可以使用浏览器原生的导航按钮代替。</p>",
+ "launchbar_intro": "<p>欢迎使用启动栏配置。</p><p>您可以在这里执行以下操作:</p><ul><li>通过拖动将可用的启动器移动到可见列表(从而将它们放入启动栏)</li><li>通过拖动将可见的启动器移动到可用列表(从而将它们从启动栏中隐藏)</li><li>您可以通过拖动重新排序列表中的项目</li><li>您可以通过右键单击“可见启动器”文件夹来创建新的启动器</li><li>如果您想恢复默认设置,可以在上下文菜单中找到“重置”。</li></ul>",
+ "launchbar_note_launcher": "<p>您可以定义以下属性:</p><ol><li><code>target</code> - 激活启动器时应打开的笔记</li><li><code>hoistedNote</code> - 可选,将在打开目标笔记之前更改提升的笔记</li><li><code>keyboardShortcut</code> - 可选,按下键盘快捷键将打开笔记</li></ol><p>启动栏显示启动器的标题/图标,这不一定与目标笔记的标题/图标相同。</p>",
+ "launchbar_script_launcher": "<p>脚本启动器可以执行通过 <code>~script</code> 关系连接的脚本(代码笔记)。</p><ol><li><code>script</code> - 与激活启动器时应执行的脚本笔记的关系</li><li><code>keyboardShortcut</code> - 可选,按下键盘快捷键将激活启动器</li></ol><h4>示例脚本</h4><pre>{{sample}}</pre>",
+ "launchbar_spacer": "<p>间隔器允许您在视觉上将启动器分组。您可以在提升的属性中进行配置:</p><ul><li><code>baseSize</code> - 定义以像素为单位的大小(如果有足够的空间)</li><li><code>growthFactor</code> - 如果您希望间隔器保持恒定的 <code>baseSize</code>,则设置为 0;如果设置为正值,它将增长。</li></ul>",
+ "launchbar_widget_launcher": "<p>请在提升的属性中定义目标小部件笔记。该小部件将用于渲染启动栏图标。</p><h4>示例启动栏小部件</h4><pre>{{sample}}</pre>",
+ "share": "<p>在这里您可以找到所有分享的笔记。</p>",
+ "user_hidden": "<p>此笔记作为保留子树,用于存放用户脚本产生的数据,这些数据不应在隐藏子树中自由创建。</p>"
+ },
"help": {
"noteNavigation": "笔记导航",
"goUpDown": "在笔记列表中向上/向下移动",
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index bcb4d67ded..7867e220d5 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -166,6 +166,22 @@
"export_finished_successfully": "Export finished successfully.",
"format_pdf": "PDF - for printing or sharing purposes."
},
+ "doc_notes": {
+ "hidden": "<p>Hidden tree is used to record various application-level data which can stay most of the time hidden from the user view.</p><p>Make sure you know what you're doing. Incorrect changes in this subtree might potentially crash the application.</p>",
+ "launchbar_command_launcher": "<p>Keyboard shortcut for this launcher action can be configured in Options -&gt; Shortcuts.</p>",
+ "launchbar_history_navigation": "<p>Back and Forward buttons allow you to move in the navigation history.</p><p>These launchers are active only in the desktop build and will be ignored in the server edition where you can use the native browser navigation buttons instead.</p>",
+ "launchbar_intro": "<p>Welcome to the Launchbar configuration.</p><p>You can do the following things here:</p><ul><li>Move available launchers to the visible list (thus putting them into the launchbar) by dragging them</li><li>Move visible launchers to the available list (thus hiding them from the launchbar) by dragging them</li><li>You can reorder the items in the lists by dragging</li><li>You can create new launchers by right-clicking on the \"Visible launchers\" folder</li><li>If you want to get back to the default setup, you can find \"reset\" in the context menu.</li></ul>",
+ "launchbar_note_launcher": "<p>You can define the following attributes:</p><ol><li><code>target</code> - note which should be opened upon activating the launcher</li><li><code>hoistedNote</code> - optional, will change the hoisted note before opening the target note</li><li><code>keyboardShortcut</code> - optional, pressing the keyboard shortcut will open the note</li></ol><p>Launchbar displays the title / icon from the launcher, which does not necessarily mirror those of the target note.</p>",
+ "launchbar_quick_search": "<p>The <a href=\"#root/_help_Ms1nauBra7gq\" target=\"_blank\">quick search bar</a> is displayed only on the horizontal layout, since it is already visible by default in the vertical layout.</p><p>For more information, see <a href=\"#root/_help_x0JgW8UqGXvq\" target=\"_blank\">Vertical and horizontal layout</a>.</p>",
+ "launchbar_script_launcher": "<p>Script launcher can execute a script (code note) connected via <code>~script</code> relation.</p><ol><li><code>script</code> - relation to the script note which should be executed upon launcher activation</li><li><code>keyboardShortcut</code> - optional, pressing the keyboard shortcut will activate the launcher</li></ol><h4>Example script</h4><pre>{{sample}}</pre>",
+ "launchbar_spacer": "<p>Spacer allows you to visually group launchers. You can configure it in the promoted attributes:</p><ul><li><code>baseSize</code> - defines size in pixels (if there's enough space)</li><li><code>growthFactor</code> - set to 0 if you want the spacer to be of constant <code>baseSize</code>, with positive value it will grow.</li></ul>",
+ "launchbar_widget_launcher": "<p>Please define the target widget note in the promoted attributes. The widget will be used to render the launchbar icon.</p><h4>Example launchbar widget</h4><pre>{{sample}}</pre>",
+ "share": "<p>Here you can find all shared notes.</p>",
+ "system_state": "<p>This is a built-in task state and cannot be edited or removed.</p><p>Only its position can be changed, which determines its order in the checkbox toolbar and the keyboard cycle.</p>",
+ "task_state": "<p>This note defines a to-do task state. The note's icon is displayed inside checkboxes to represent this state, and the note's title serves as its display name.</p><p>The state is configured through the following promoted attributes:</p><ul><li><code>Identifier</code> — required. The internal name stored as metadata within the note markup. Only letters, digits, <code>-</code> and <code>_</code> are permitted.<p class=\"admonition warning\">Prefix the identifiers of your custom task states with an underscore <code>_</code> or a hyphen <code>-</code> to avoid clashes with task states that may be introduced in future versions of Trilium.</p>Examples: <code>_postponed</code>, <code>_awaiting-feedback</code>, <code>_validated</code>.</li><li><code>Markdown symbol</code> — the single character used to represent the state when exporting to Markdown; for example, <code>/</code> produces <code>- [/]</code>.</li><li><code>Counts as completed</code> — when enabled, a task in this state is treated as completed.</li><li><code>Color</code> — the checkbox color for this state.</li><li><code>Hidden from toolbar</code> — when enabled, the state is excluded from the state list and the keyboard cycle. Notes already using it continue to render correctly.</li></ul><p class=\"admonition warning\">Changes take effect after the application is reloaded.</p>",
+ "task_states": "<p>This note contains the task states available for to-do checkboxes in the text editor. Each child note represents a single state.</p><p>States can be added, modified, reordered, or removed. To add a new state, create a child note and configure its promoted attributes.</p><p class=\"admonition warning\">Changes take effect after the application is reloaded.</p>",
+ "user_hidden": "<p>This note serves as a subtree reserved for data produced by user scripts which should otherwise not freely create data in the hidden subtree.</p>"
+ },
"help": {
"title": "Cheatsheet",
"editShortcuts": "Edit keyboard shortcuts",
diff --git a/apps/server/src/assets/doc_notes/cn/hidden.html b/apps/server/src/assets/doc_notes/cn/hidden.html
deleted file mode 100644
index f369e0f82b..0000000000
--- a/apps/server/src/assets/doc_notes/cn/hidden.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>隐藏树用于记录各种应用层数据,这些数据大部分时间可能对用户不可见。</p>
-
-<p>确保你知道自己在做什么。对这个子树的错误更改可能会导致应用程序崩溃。</p>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_command_launcher.html b/apps/server/src/assets/doc_notes/cn/launchbar_command_launcher.html
deleted file mode 100644
index 1171d699a3..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_command_launcher.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>此启动器操作的键盘快捷键可以在“选项”->“快捷键”中进行配置。</p>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_history_navigation.html b/apps/server/src/assets/doc_notes/cn/launchbar_history_navigation.html
deleted file mode 100644
index e86b0af1a1..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_history_navigation.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>“后退”和“前进”按钮允许您在导航历史中移动。</p>
-
-<p>这些启动器仅在桌面版本中有效,在服务器版本中将被忽略,您可以使用浏览器的原生导航按钮代替。</p>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_intro.html b/apps/server/src/assets/doc_notes/cn/launchbar_intro.html
deleted file mode 100644
index e7b32a3cd0..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_intro.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<p>欢迎来到启动栏配置界面。</p>
-
-<p>您可以在此处执行以下操作:</p>
-
-<ul>
- <li>通过拖动将可用的启动器移动到可见列表中(从而将它们放入启动栏)</li>
- <li>通过拖动将可见的启动器移动到可用列表中(从而将它们从启动栏中隐藏)</li>
- <li>您可以通过拖动重新排列列表中的项目</li>
- <li>通过右键点击“可见启动器”文件夹来创建新的启动器</li>
- <li>如果您想恢复默认设置,可以在右键菜单中找到“重置”选项。</li>
-</ul>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_note_launcher.html b/apps/server/src/assets/doc_notes/cn/launchbar_note_launcher.html
deleted file mode 100644
index 1bede769ce..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_note_launcher.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<p>您可以定义以下属性:</p>
-
-<ol>
- <li><code>target</code> - 激活启动器时应打开的笔记</li>
- <li><code>hoistedNote</code> - 可选,在打开目标笔记之前将更改提升的笔记</li>
- <li><code>keyboardShortcut</code> - 可选,按下键盘快捷键将打开该笔记</li>
-</ol>
-
-<p>启动栏显示来自启动器的标题/图标,这不一定与目标笔记的标题/图标一致。</p>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_script_launcher.html b/apps/server/src/assets/doc_notes/cn/launchbar_script_launcher.html
deleted file mode 100644
index 6f17afeddc..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_script_launcher.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<p>脚本启动器可以执行通过 <code>~script</code> 关系连接的脚本(代码笔记)。</p>
-
-<ol>
- <li><code>script</code> - 与应在启动器激活时执行的脚本笔记的关系</li>
- <li><code>keyboardShortcut</code> - 可选,按下键盘快捷键将激活启动器</li>
-</ol>
-
-<h4>示例脚本</h4>
-
-<pre>
-api.showMessage("当前笔记是 " + api.getActiveContextNote().title);
-</pre>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_spacer.html b/apps/server/src/assets/doc_notes/cn/launchbar_spacer.html
deleted file mode 100644
index bcc0e3efe1..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_spacer.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<p>间隔器允许您在视觉上将启动器分组。您可以在提升的属性中进行配置:</p>
-
-<ul>
- <li><code>baseSize</code> - 定义以像素为单位的大小(如果有足够的空间)</li>
- <li><code>growthFactor</code> - 如果您希望间隔器保持恒定的 <code>baseSize</code>,则设置为 0;如果设置为正值,它将增长。</li>
-</ul>
diff --git a/apps/server/src/assets/doc_notes/cn/launchbar_widget_launcher.html b/apps/server/src/assets/doc_notes/cn/launchbar_widget_launcher.html
deleted file mode 100644
index 8ef57fa7c1..0000000000
--- a/apps/server/src/assets/doc_notes/cn/launchbar_widget_launcher.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<p>请在提升的属性中定义目标小部件笔记。该小部件将用于渲染启动栏图标。</p>
-
-<h4>示例启动栏小部件</h4>
-
-<pre>
-const TPL = `&lt;div style="height: 53px; width: 53px;"&gt;&lt;/div&gt;`;
-
-class ExampleLaunchbarWidget extends api.NoteContextAwareWidget {
- doRender() {
- this.$widget = $(TPL);
- }
-
- async refreshWithNote(note) {
- this.$widget.css("background-color", this.stringToColor(note.title));
- }
-
- stringToColor(str) {
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
- }
-
- let color = '#';
- for (let i = 0; i < 3; i++) {
- const value = (hash >> (i * 8)) & 0xFF;
- color += ('00' + value.toString(16)).substr(-2);
- }
-
- return color;
- }
-}
-
-module.exports = new ExampleLaunchbarWidget();
-</pre>
diff --git a/apps/server/src/assets/doc_notes/cn/share.html b/apps/server/src/assets/doc_notes/cn/share.html
deleted file mode 100644
index 3eedb8c093..0000000000
--- a/apps/server/src/assets/doc_notes/cn/share.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>在这里您可以找到所有分享的笔记。</p>
diff --git a/apps/server/src/assets/doc_notes/cn/user_hidden.html b/apps/server/src/assets/doc_notes/cn/user_hidden.html
deleted file mode 100644
index 715be770d4..0000000000
--- a/apps/server/src/assets/doc_notes/cn/user_hidden.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>此笔记作为一个子树,用于存储由用户脚本生成的数据,这些数据本应避免在隐藏子树中随意创建。</p>
diff --git a/apps/server/src/assets/doc_notes/en/hidden.html b/apps/server/src/assets/doc_notes/en/hidden.html
deleted file mode 100644
index 2174733857..0000000000
--- a/apps/server/src/assets/doc_notes/en/hidden.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>Hidden tree is used to record various application-level data which can stay most of the time hidden from the user view.</p>
-
-<p>Make sure you know what you're doing. Incorrect changes in this subtree might potentially crash the application.</p>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_command_launcher.html b/apps/server/src/assets/doc_notes/en/launchbar_command_launcher.html
deleted file mode 100644
index 68eb051a24..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_command_launcher.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>Keyboard shortcut for this launcher action can be configured in Options -> Shortcuts.</p>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_history_navigation.html b/apps/server/src/assets/doc_notes/en/launchbar_history_navigation.html
deleted file mode 100644
index bf44115725..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_history_navigation.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>Back and Forward buttons allow you to move in the navigation history.</p>
-
-<p>These launchers are active only in the desktop build and will be ignored in the server edition where you can use the native browser navigation buttons instead.</p>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_intro.html b/apps/server/src/assets/doc_notes/en/launchbar_intro.html
deleted file mode 100644
index cac5224e90..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_intro.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<p>Welcome to the Launchbar configuration.</p>
-
-<p>You can do the following things here:</p>
-
-<ul>
- <li>Move available launchers to the visible list (thus putting them into the launchbar) by dragging them</li>
- <li>Move visible launchers to the available list (thus hiding them from the launchbar) by dragging them</li>
- <li>You can reorder the items in the lists by dragging</li>
- <li>You can create new launchers by right-clicking on the "Visible launchers" folder</li>
- <li>If you want to get back to the default setup, you can find "reset" in the context menu.</li>
-</ul>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_note_launcher.html b/apps/server/src/assets/doc_notes/en/launchbar_note_launcher.html
deleted file mode 100644
index 8d4d15b059..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_note_launcher.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<p>You can define the following attributes:</p>
-
-<ol>
- <li><code>target</code> - note which should be opened upon activating the launcher</li>
- <li><code>hoistedNote</code> - optional, will change the hoisted note before opening the target note</li>
- <li><code>keyboardShortcut</code> - optional, pressing the keyboard shortcut will open the note</li>
-</ol>
-
-<p>Launchbar displays the title / icon from the launcher, which does not necessarily mirror those of the target note.</p>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_quick_search.html b/apps/server/src/assets/doc_notes/en/launchbar_quick_search.html
deleted file mode 100644
index 79945ab2c8..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_quick_search.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<p>The <a href="#root/_help_Ms1nauBra7gq" target="_blank">quick search bar</a> is displayed only on the horizontal layout, since it is already visible by default in the vertical layout.</p>
-<p>For more information, see <a href="#root/_help_x0JgW8UqGXvq" target="_blank">Vertical and horizontal layout</a>.</p>
\ No newline at end of file
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_script_launcher.html b/apps/server/src/assets/doc_notes/en/launchbar_script_launcher.html
deleted file mode 100644
index 49e315487e..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_script_launcher.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<p>Script launcher can execute a script (code note) connected via <code>~script</code> relation.</p>
-
-<ol>
- <li><code>script</code> - relation to the script note which should be executed upon launcher activation</li>
- <li><code>keyboardShortcut</code> - optional, pressing the keyboard shortcut will activate the launcher</li>
-</ol>
-
-<h4>Example script</h4>
-
-<pre>
-api.showMessage("Current note is " + api.getActiveContextNote().title);
-</pre>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_spacer.html b/apps/server/src/assets/doc_notes/en/launchbar_spacer.html
deleted file mode 100644
index 720899a73e..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_spacer.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<p>Spacer allows you to visually group launchers. You can configure it in the promoted attributes:</p>
-
-<ul>
- <li><code>baseSize</code> - defines size in pixels (if there's enough space)</li>
- <li><code>growthFactor</code> - set to 0 if you want the spacer to be of constant <code>baseSize</code>, with positive value it will grow.</li>
-</ul>
diff --git a/apps/server/src/assets/doc_notes/en/launchbar_widget_launcher.html b/apps/server/src/assets/doc_notes/en/launchbar_widget_launcher.html
deleted file mode 100644
index 3df3afa9c9..0000000000
--- a/apps/server/src/assets/doc_notes/en/launchbar_widget_launcher.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<p>Please define the target widget note in the promoted attributes. The widget will be used to render the launchbar icon.</p>
-
-<h4>Example launchbar widget</h4>
-
-<pre>
-const TPL = `&lt;div style="height: 53px; width: 53px;"&gt;&lt;/div&gt;`;
-
-class ExampleLaunchbarWidget extends api.NoteContextAwareWidget {
- doRender() {
- this.$widget = $(TPL);
- }
-
- async refreshWithNote(note) {
- this.$widget.css("background-color", this.stringToColor(note.title));
- }
-
- stringToColor(str) {
- let hash = 0;
- for (let i = 0; i < str.length; i++) {
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
- }
-
- let color = '#';
- for (let i = 0; i < 3; i++) {
- const value = (hash >> (i * 8)) & 0xFF;
- color += ('00' + value.toString(16)).substr(-2);
- }
-
- return color;
- }
-}
-
-module.exports = new ExampleLaunchbarWidget();
-</pre>
diff --git a/apps/server/src/assets/doc_notes/en/share.html b/apps/server/src/assets/doc_notes/en/share.html
deleted file mode 100644
index 499cf35e87..0000000000
--- a/apps/server/src/assets/doc_notes/en/share.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>Here you can find all shared notes.</p>
\ No newline at end of file
diff --git a/apps/server/src/assets/doc_notes/en/system_state.html b/apps/server/src/assets/doc_notes/en/system_state.html
deleted file mode 100644
index ee0c7b024d..0000000000
--- a/apps/server/src/assets/doc_notes/en/system_state.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<p>This is a built-in task state and cannot be edited or removed.</p>
-
-<p>Only its position can be changed, which determines its order in the checkbox toolbar and the keyboard cycle.</p>
diff --git a/apps/server/src/assets/doc_notes/en/task_state.html b/apps/server/src/assets/doc_notes/en/task_state.html
deleted file mode 100644
index cca9e253b5..0000000000
--- a/apps/server/src/assets/doc_notes/en/task_state.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<p>This note defines a to-do task state. The note's icon is displayed inside checkboxes to represent this state, and the note's title serves as its display name.</p>
-
-<p>The state is configured through the following promoted attributes:</p>
-
-<ul>
- <li>
- <code>Identifier</code> — required. The internal name stored as metadata within the note markup.
- Only letters, digits, <code>-</code> and <code>_</code> are permitted.
-
- <p class="admonition warning">
- Prefix the identifiers of your custom task states with an underscore <code>_</code> or a hyphen <code>-</code> to avoid clashes with task states that may be introduced in future versions of Trilium.
- </p>
-
- Examples: <code>_postponed</code>, <code>_awaiting-feedback</code>, <code>_validated</code>.</li>
- <li><code>Markdown symbol</code> — the single character used to represent the state when exporting to Markdown; for example, <code>/</code> produces <code>- [/]</code>.</li>
- <li><code>Counts as completed</code> — when enabled, a task in this state is treated as completed.</li>
- <li><code>Color</code> — the checkbox color for this state.</li>
- <li><code>Hidden from toolbar</code> — when enabled, the state is excluded from the state list and the keyboard cycle. Notes already using it continue to render correctly.</li>
-</ul>
-
-<p class="admonition warning">Changes take effect after the application is reloaded.</p>
diff --git a/apps/server/src/assets/doc_notes/en/task_states.html b/apps/server/src/assets/doc_notes/en/task_states.html
deleted file mode 100644
index dc78f575a9..0000000000
--- a/apps/server/src/assets/doc_notes/en/task_states.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<p>This note contains the task states available for to-do checkboxes in the text editor. Each child note represents a single state.</p>
-
-<p>States can be added, modified, reordered, or removed. To add a new state, create a child note and configure its promoted attributes.</p>
-
-<p class="admonition warning">Changes take effect after the application is reloaded.</p>
diff --git a/apps/server/src/assets/doc_notes/en/user_hidden.html b/apps/server/src/assets/doc_notes/en/user_hidden.html
deleted file mode 100644
index 4925502446..0000000000
--- a/apps/server/src/assets/doc_notes/en/user_hidden.html
+++ /dev/null
@@ -1 +0,0 @@
-<p>This note serves as a subtree reserved for data produced by user scripts which should otherwise not freely create data in the hidden subtree.</p>
diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts
index fa31e78fbe..1c4559109e 100644
--- a/apps/server/src/routes/assets.ts
+++ b/apps/server/src/routes/assets.ts
@@ -55,10 +55,10 @@ async function register(app: express.Application) {
base: `/${assetUrlFragment}/`
});
app.use(`/${assetUrlFragment}/`, (req, res, next) => {
- if (req.url.startsWith("/images/") || req.url.startsWith("/doc_notes/") || req.url.startsWith("/help/")) {
- // Images, doc notes and the in-app help's assets are served as static assets from
- // the server. Anything not listed here is handed to Vite, which answers unknown
- // paths with index.html — a 200 that looks fine until you read the body.
+ if (req.url.startsWith("/images/") || req.url.startsWith("/help/")) {
+ // Images and the in-app help's assets are served as static assets from the server.
+ // Anything not listed here is handed to Vite, which answers unknown paths with
+ // index.html — a 200 that looks fine until you read the body.
next();
return;
}
@@ -99,7 +99,6 @@ async function register(app: express.Application) {
app.use(`/share/assets/`, express.static(getShareThemeAssetDir(), STATIC_OPTIONS));
app.use(`/pdfjs/`, persistentCacheStatic(getPdfjsAssetDir()));
app.use(`/${assetUrlFragment}/images`, persistentCacheStatic(path.join(resourceDir, "assets", "images")));
- app.use(`/${assetUrlFragment}/doc_notes`, persistentCacheStatic(path.join(resourceDir, "assets", "doc_notes")));
// Images and attachments of the in-app help. They are not committed under the server's assets
// — the User Guide owns them — so in a source checkout they are served straight out of docs/,
// while a packaged build copies them in (see scripts/build.ts).
diff --git a/apps/server/src/services/llm/index.spec.ts b/apps/server/src/services/llm/index.spec.ts
index c317ca8a00..fe44cb79e5 100644
--- a/apps/server/src/services/llm/index.spec.ts
+++ b/apps/server/src/services/llm/index.spec.ts
@@ -2,7 +2,6 @@ import { describe, expect, it, vi } from "vitest";
const registrations = vi.hoisted(() => ({
hostProviders: [] as { type: string; factory: () => unknown }[],
- docNoteReader: undefined as ((note: unknown) => string | null) | undefined,
skillReader: undefined as ((file: string) => string | null) | undefined,
toolRegistries: [] as unknown[]
}));
@@ -16,9 +15,6 @@ vi.mock("@triliumnext/core/src/services/llm/skills.js", async (importOriginal) =
...await importOriginal<typeof import("@triliumnext/core/src/services/llm/skills.js")>(),
registerSkillReader: (reader: (file: string) => string | null) => { registrations.skillReader = reader; }
}));
-vi.mock("@triliumnext/core/src/services/llm/tools/helpers.js", () => ({
- registerDocNoteHtmlReader: (reader: (note: unknown) => string | null) => { registrations.docNoteReader = reader; }
-}));
import { registerServerLlmExtensions } from "./index.js";
import { ClaudeAgentProvider } from "./providers/claude_agent.js";
@@ -31,8 +27,6 @@ describe("registerServerLlmExtensions", () => {
// constructed until a chat asks for it.
expect(registrations.hostProviders.map(p => p.type)).toEqual(["claude-agent"]);
expect(registrations.hostProviders[0].factory()).toBeInstanceOf(ClaudeAgentProvider);
- // The User Guide reader, which core's note-content helper calls for doc notes.
- expect(registrations.docNoteReader).toBeTypeOf("function");
// The skill sheets: core owns the catalog and the tool, the server only
// knows how to get a sheet off disk.
expect(registrations.skillReader?.("search_syntax.md")).toContain("#");
diff --git a/apps/server/src/services/llm/index.ts b/apps/server/src/services/llm/index.ts
index ed7b884d9a..c34a5acc34 100644
--- a/apps/server/src/services/llm/index.ts
+++ b/apps/server/src/services/llm/index.ts
@@ -3,10 +3,9 @@
*
* The stack itself lives in `@triliumnext/core`, so the browser-hosted
* (standalone) build can run it too. What could not follow it there is anything
- * that needs Node: the provider that spawns the Claude Code CLI, and the User
- * Guide tools, which read pages off disk. Core exposes a seam for each; this is
- * where the server fills them in — including the skill sheets, whose catalog is
- * core's while the reading is per-runtime.
+ * that needs Node: the provider that spawns the Claude Code CLI, and the skill
+ * sheets, whose catalog is core's while the reading is per-runtime. Core exposes
+ * a seam for each; this is where the server fills them in.
*
* Each seam is keyed rather than bespoke, so the next host-provided provider
* (GitHub Copilot and the like) is one more line here and one more entry in
@@ -15,11 +14,9 @@
import { registerHostProvider } from "@triliumnext/core/src/services/llm/index.js";
import { registerSkillReader } from "@triliumnext/core/src/services/llm/skills.js";
-import { registerDocNoteHtmlReader } from "@triliumnext/core/src/services/llm/tools/helpers.js";
import { loadSkillSheet } from "../../core_assets.js";
import { ClaudeAgentProvider } from "./providers/claude_agent.js";
-import { getDocNoteHtml } from "./tools/doc_notes.js";
/**
* Contribute those pieces to core. Called once from startup, beside the other
@@ -29,6 +26,5 @@ import { getDocNoteHtml } from "./tools/doc_notes.js";
*/
export function registerServerLlmExtensions() {
registerHostProvider("claude-agent", () => new ClaudeAgentProvider());
- registerDocNoteHtmlReader(getDocNoteHtml);
registerSkillReader(loadSkillSheet);
}
diff --git a/apps/server/src/services/llm/tools/doc_notes.spec.ts b/apps/server/src/services/llm/tools/doc_notes.spec.ts
deleted file mode 100644
index 7a47520b45..0000000000
--- a/apps/server/src/services/llm/tools/doc_notes.spec.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import type { BNote } from "@triliumnext/core";
-import { beforeEach, describe, expect, it, vi } from "vitest";
-
-/** Fake on-disk help pages: path suffix → HTML content. */
-const docFiles = vi.hoisted(() => new Map<string, string>());
-
-// Doc notes read their HTML from disk — serve them from the docFiles fixture
-// map and pass every other path through to the real fs.
-vi.mock("fs", async (importOriginal) => {
- const actual = await importOriginal<typeof import("fs")>();
- const readFileSync = ((filePath: unknown, ...rest: unknown[]) => {
- const pathStr = String(filePath);
- for (const [suffix, content] of docFiles) {
- if (pathStr.endsWith(suffix)) return content;
- }
- if (pathStr.includes("doc_notes")) {
- throw new Error(`ENOENT: ${pathStr}`);
- }
- return (actual.readFileSync as (...args: unknown[]) => unknown)(filePath, ...rest);
- }) as typeof actual.readFileSync;
- const mocked = { ...actual, readFileSync };
- return { ...mocked, default: mocked };
-});
-
-import { getDocNoteHtml } from "./doc_notes.js";
-
-/** Minimal BNote stub exposing only the label lookup the reader performs. */
-function docNoteStub(docName: string | null) {
- return {
- noteId: "n1",
- type: "doc",
- getLabelValue: (name: string) => (name === "docName" ? docName : null)
- } as unknown as BNote;
-}
-
-describe("getDocNoteHtml", () => {
- beforeEach(() => docFiles.clear());
-
- it("reads the page HTML from disk under doc_notes/en", () => {
- docFiles.set("Cloning Notes.html", "<h2>Cloning</h2>");
- expect(getDocNoteHtml(docNoteStub("User Guide/User Guide/Cloning Notes"))).toBe("<h2>Cloning</h2>");
- });
-
- it("returns null without a docName label, on a missing file, and on path traversal attempts", () => {
- expect(getDocNoteHtml(docNoteStub(null))).toBeNull();
- expect(getDocNoteHtml(docNoteStub("User Guide/Nonexistent Page"))).toBeNull();
- // Traversal attempts must be rejected before touching the filesystem —
- // register a catch-all fixture so any read would be visible.
- docFiles.set(".html", "<p>leaked</p>");
- expect(getDocNoteHtml(docNoteStub("../../../../etc/passwd"))).toBeNull();
- expect(getDocNoteHtml(docNoteStub("/etc/passwd"))).toBeNull();
- });
-});
diff --git a/apps/server/src/services/llm/tools/doc_notes.ts b/apps/server/src/services/llm/tools/doc_notes.ts
deleted file mode 100644
index 9de8602686..0000000000
--- a/apps/server/src/services/llm/tools/doc_notes.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Filesystem-backed resolution of `doc` notes, for the LLM tools.
- *
- * Kept out of `@triliumnext/core`'s LLM code because it is the one tool helper
- * that reads from `RESOURCE_DIR`: these pages ship as static HTML on disk, which
- * the browser-hosted (standalone) build has no way to read synchronously.
- */
-
-import type { BNote } from "@triliumnext/core";
-import { readFileSync } from "fs";
-import path from "path";
-
-import resourceDir from "../../resource_dir.js";
-
-/**
- * Resolve the on-disk HTML of a `doc` note (identified by its `#docName` label),
- * or null if it cannot be resolved. The `en` tree is always used: the assistant
- * reads these pages to answer in its own words, so a translation would only
- * narrow what it can match against.
- */
-export function getDocNoteHtml(note: BNote): string | null {
- const docName = note.getLabelValue("docName");
- if (!docName) {
- return null;
- }
-
- const docNotesDir = path.resolve(resourceDir.RESOURCE_DIR, "doc_notes");
- const filePath = path.resolve(docNotesDir, "en", `${docName}.html`);
- if (!filePath.startsWith(docNotesDir + path.sep)) {
- // Path traversal guard — the docName label is note data, not trusted input.
- return null;
- }
-
- try {
- return readFileSync(filePath, "utf-8");
- } catch {
- return null;
- }
-}
diff --git a/packages/trilium-core/src/services/llm/tools/helpers.spec.ts b/packages/trilium-core/src/services/llm/tools/helpers.spec.ts
index 054d7d3c51..7cf7a9e895 100644
--- a/packages/trilium-core/src/services/llm/tools/helpers.spec.ts
+++ b/packages/trilium-core/src/services/llm/tools/helpers.spec.ts
@@ -17,10 +17,8 @@ import {
flag,
getAttachmentContentPreview,
getContentPreview,
- getDocNoteHtml,
getNoteContentForLlm,
getNoteMeta,
- registerDocNoteHtmlReader,
setNoteContentFromLlm
} from "./helpers.js";
@@ -110,26 +108,14 @@ describe("getNoteContentForLlm", () => {
});
describe("doc notes", () => {
- beforeEach(() => registerDocNoteHtmlReader(() => null));
-
- it("resolves a doc note's HTML through the registered reader", () => {
- registerDocNoteHtmlReader(note => (note.getLabelValue("docName") ? "<h2>Cloning</h2>" : null));
- expect(getDocNoteHtml(docNoteStub("User Guide/Cloning Notes"))).toBe("<h2>Cloning</h2>");
- expect(getDocNoteHtml(docNoteStub(null))).toBeNull();
- });
-
- it("getNoteContentForLlm converts the reader's HTML to Markdown", () => {
- registerDocNoteHtmlReader(() => "<h2>Cloning</h2><p>Place a note in two locations.</p>");
- const content = getNoteContentForLlm(docNoteStub("User Guide/Cloning Notes"));
- expect(content).toContain("## Cloning");
- expect(content).toContain("Place a note in two locations.");
- });
-
- it("degrades gracefully when no reader is registered — as in the browser build", () => {
+ // Their page is picked by the `docName` label out of the client's translation catalog, so
+ // there is nothing here for the backend to read.
+ it("report no content, whichever page they name", () => {
getBlobMock.mockReturnValue(null);
- const note = docNoteStub("User Guide/Cloning Notes");
- expect(getNoteContentForLlm(note)).toBe("[doc content not available]");
- expect(getContentPreview(note)).toBeNull();
+ for (const note of [ docNoteStub("launchbar_intro"), docNoteStub(null) ]) {
+ expect(getNoteContentForLlm(note)).toBe("[doc content not available]");
+ expect(getContentPreview(note)).toBeNull();
+ }
});
});
diff --git a/packages/trilium-core/src/services/llm/tools/helpers.ts b/packages/trilium-core/src/services/llm/tools/helpers.ts
index c787780e06..c18b04bfc2 100644
--- a/packages/trilium-core/src/services/llm/tools/helpers.ts
+++ b/packages/trilium-core/src/services/llm/tools/helpers.ts
@@ -17,30 +17,6 @@ const CONTENT_PREVIEW_SIZE_THRESHOLD = 10_000;
/** Note IDs that must not be deleted, moved, or cloned by the LLM. */
export const PROTECTED_SYSTEM_NOTES = new Set(["root", "_hidden", "_share", "_lbRoot", "_globalNoteMap"]);
-/** Host-provided reader for doc-note HTML. See {@link registerDocNoteHtmlReader}. */
-let docNoteHtmlReader: ((note: BNote) => string | null) | null = null;
-
-/**
- * Register the host's reader for doc-note HTML.
- *
- * `doc` notes — the explanatory pages of the hidden subtree, such as the launcher
- * bar's — keep no content in the database: their HTML ships as static files, which
- * the server reads off disk. The browser-hosted build has no synchronous way to do
- * that, so hosts that can supply it register a reader here and the rest simply
- * report the content as unavailable.
- */
-export function registerDocNoteHtmlReader(reader: (note: BNote) => string | null) {
- docNoteHtmlReader = reader;
-}
-
-/**
- * Resolve the HTML of a `doc` note via the registered reader, or null when no
- * reader is registered or it cannot resolve the page.
- */
-export function getDocNoteHtml(note: BNote): string | null {
- return docNoteHtmlReader?.(note) ?? null;
-}
-
/**
* Return `true` if the value is truthy, otherwise `undefined`.
* Since `undefined` values are omitted from JSON serialization,
@@ -57,10 +33,9 @@ export function flag(value: boolean | undefined): true | undefined {
*/
export function getNoteContentForLlm(note: BNote) {
if (note.type === "doc") {
- // Doc notes store no content in the database — their HTML lives on disk
- // and is fetched by the client.
- const html = getDocNoteHtml(note);
- return html ? markdownExport.toMarkdown(html) : "[doc content not available]";
+ // Doc notes hold no content of their own: the client renders an explanatory page picked
+ // by their `docName` label, out of its own translation catalog.
+ return "[doc content not available]";
}
const content = note.getContent();
diff --git a/renovate.json b/renovate.json
index f029afe21a..abcc13c9f5 100644
--- a/renovate.json
+++ b/renovate.json
@@ -17,7 +17,6 @@
"ignorePaths": [
"**/node_modules/**",
"apps/edit-docs/demo/**",
- "apps/server/src/assets/doc_notes/**",
"docs/**",
"apps/server/Dockerfile.legacy",
"apps/mobile/android/**"