Skip to content

Build your personal knowledge base with Trilium Notes

chore(skills): flag a text editor icon font that lags the editor's SVGs

Elian Doranf0aeb32ebc2a
diff --git a/.claude/skills/ckeditor5-plugin-development/SKILL.md b/.claude/skills/ckeditor5-plugin-development/SKILL.md
index 476199faf8..eaee99e459 100644
--- a/.claude/skills/ckeditor5-plugin-development/SKILL.md
+++ b/.claude/skills/ckeditor5-plugin-development/SKILL.md
@@ -157,8 +157,12 @@ Key rules (inherited from the upstream conventions via `eslint-config-ckeditor5`
(`import fooIcon from '../../icons/foo.svg?raw';`); there is no `icons` export any more.
- Every editor icon, CKEditor's and ours, is also a glyph in the built-in `cke` icon font that the
User Guide uses to name toolbar buttons (`cke-table-merge-cell`, `cke-trilium-kbd`). Adding,
- renaming or removing an SVG, or bumping `ckeditor5`, means regenerating that font and checking
- the docs for the old class. See "The `cke` icon pack" in `references/ui-and-localization.md`.
+ renaming or removing an SVG, or bumping `ckeditor5`, means regenerating that font **in the same
+ change**: `pnpm --filter @triliumnext/icon-pack-builder start cke`, then commit
+ `apps/client/src/fonts/text-editor-icons.woff2` and
+ `packages/trilium-core/src/services/icon_pack_text_editor.json`. A renamed or removed icon also
+ means grepping `docs/User Guide` for the old class. Naming rules and what survives the
+ conversion: "The `cke` icon pack" in `references/ui-and-localization.md`.
## Minimal end-to-end example (inline text attribute)
diff --git a/.claude/skills/writing-documentation/SKILL.md b/.claude/skills/writing-documentation/SKILL.md
index c23b1ae9e0..77dc5c8793 100644
--- a/.claude/skills/writing-documentation/SKILL.md
+++ b/.claude/skills/writing-documentation/SKILL.md
@@ -144,6 +144,12 @@ skeletons per page kind are [references/page-templates.md](references/page-templ
8. A button is shown by its icon: `<span class="tn-icon cke cke-<name>"></span>` for a text-editor
toolbar button, `<span class="tn-icon bx bx-<name>"></span>` for the rest of the app, followed by
"button"/"icon"/"menu". Never a cropped screenshot of a button. `icons` finds the class.
+ **A toolbar button with no `cke` class means the font is stale**, not that the icon is missing:
+ the `cke` pack is built from the editor's SVGs and is not rebuilt with them. Run
+ `pnpm --filter @triliumnext/icon-pack-builder start cke` and commit both outputs,
+ `apps/client/src/fonts/text-editor-icons.woff2` and
+ `packages/trilium-core/src/services/icon_pack_text_editor.json`. `icons` and `check` both flag
+ a Trilium SVG the font lacks. A Trilium SVG `src/icons/foo.svg` becomes `cke-trilium-foo`.
9. Callouts: `> [!NOTE]` context/history · `> [!TIP]` a better way · `> [!IMPORTANT]` beta status,
requirement, third-party disclaimer · `> [!WARNING]` data/security risk or a version-gated break.
10. Version facts: "Since v0.104.0, …", "Starting with v0.104.0, …", "Versions prior to v0.103.0 …".
@@ -172,6 +178,7 @@ rediscovers them. Fix what you pass by; none blocks a change:
affordances; wire a new page through them.
- **working-with-translations** — the English strings `impact --diff` reads come from those catalogues.
- **ckeditor5-plugin-development** — the `cke` icon pack: an editor icon added, renamed or removed
- means regenerating the font and grepping the docs for the old `cke-<name>` class.
+ means regenerating the font (rule 8 has the command) and grepping the docs for the old
+ `cke-<name>` class.
- [references/pipeline.md](references/pipeline.md) — how the trees, the meta files, the in-app help and
the docs site are produced and consumed, and which identifiers are load-bearing.
diff --git a/.claude/skills/writing-documentation/docs.mjs b/.claude/skills/writing-documentation/docs.mjs
index 2824cdd210..4e32317b4b 100644
--- a/.claude/skills/writing-documentation/docs.mjs
+++ b/.claude/skills/writing-documentation/docs.mjs
@@ -55,6 +55,9 @@ const ICON_PACKS = {
bx: "packages/trilium-core/src/services/icon_pack_boxicons-v2.json",
cke: "packages/trilium-core/src/services/icon_pack_text_editor.json"
};
+const CKE_BUILDER = "apps/icon-pack-builder/src/providers/ckeditor.ts";
+const CKE_REBUILD = "run `pnpm --filter @triliumnext/icon-pack-builder start cke` and commit "
+ + "apps/client/src/fonts/text-editor-icons.woff2 with " + ICON_PACKS.cke;
/** `apps/client/src/services/doc_renderer.ts` refuses any other character in a help page path. */
const DOC_NAME_CHARS = /^[a-zA-Z0-9_/\- ()&.,`]+$/;
@@ -367,6 +370,8 @@ function icons() {
console.log(problems.length ? `${problems.length} unknown icon class(es)` : "every icon class in the docs exists in a built-in pack");
return;
}
+ const stale = packs.includes("cke") ? staleCkeIcons() : [];
+ if (stale.length) console.log(`! cke font is out of date, no glyph for ${stale.join(", ")}\n ${CKE_REBUILD}\n`);
const query = flags._.map((q) => q.toLowerCase());
if (!query.length) die("usage: icons <query...> [--pack bx|cke] | icons --check");
for (const pack of packs) {
@@ -448,6 +453,8 @@ function check() {
checkContent(index, errors, warnings);
if (treeName === "user") checkHtmlMirror(index, errors, warnings);
}
+ const stale = staleCkeIcons();
+ if (stale.length) warnings.push(`cke font is out of date, no glyph for ${stale.join(", ")}: ${CKE_REBUILD}`);
if (trees.includes("user")) {
checkCodeReferences(loadTree("user"), errors);
checkUrlLiterals(errors);
@@ -868,6 +875,27 @@ function loadIconPack(pack) {
return iconCache.get(pack);
}
+/**
+ * The `cke-trilium-*` classes of the SVGs in `packages/ckeditor5` that the font has no glyph for.
+ * The folders come from `TRILIUM_ICON_DIRS` in the builder, so the two cannot drift.
+ */
+function staleCkeIcons() {
+ const source = fs.readFileSync(path.join(ROOT, CKE_BUILDER), "utf-8");
+ const list = /TRILIUM_ICON_DIRS\s*=\s*\[([^\]]*)\]/.exec(source)?.[1] ?? "";
+ const known = loadIconPack("cke").icons;
+ const stale = [];
+ for (const [, dir] of list.matchAll(/"([^"]+)"/g)) {
+ const fullDir = path.join(ROOT, "packages/ckeditor5", dir);
+ if (!fs.existsSync(fullDir)) continue;
+ for (const file of fs.readdirSync(fullDir).filter((f) => f.endsWith(".svg"))) {
+ const name = file.slice(0, -".svg".length);
+ const id = name === "trilium" ? "cke-trilium" : `cke-trilium-${name}`;
+ if (!(id in known)) stale.push(id);
+ }
+ }
+ return stale;
+}
+
/** `bx bx-star`, `bx bxs-grid`, `cke cke-quote`, with optional modifiers such as `bx-flip-horizontal`. */
function iconExists(cls) {
const parts = cls.trim().split(/\s+/);
diff --git a/.claude/skills/writing-documentation/references/style-guide.md b/.claude/skills/writing-documentation/references/style-guide.md
index e216504472..9eb64677a2 100644
--- a/.claude/skills/writing-documentation/references/style-guide.md
+++ b/.claude/skills/writing-documentation/references/style-guide.md
@@ -152,7 +152,8 @@ A button, menu or toolbar control is named by its icon, never by a cropped scree
services/icon_pack_text_editor.json`); upstream `IconTableMergeCell` → `cke-table-merge-cell`,
Trilium's own SVGs → `cke-trilium-<file>` (`cke-trilium-kbd`, `cke-trilium-ai`). `bx` is
`icon_pack_boxicons-v2.json` (1635). `docs.mjs icons <terms>` searches both; `icons --check`
- validates every class in the docs. `iconClass` in the meta uses `bx` only.
+ validates every class in the docs. `iconClass` in the meta uses `bx` only. The `cke` font is
+ rebuilt by hand, so a new editor button can be missing from it; see rule 8 in `SKILL.md`.
## Lists, tables, code