Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(skills): bring the CKEditor 5 skills in line with the consolidation
Elian Doran1295e0b88852
diff --git a/.claude/skills/ckeditor5-plugin-development/SKILL.md b/.claude/skills/ckeditor5-plugin-development/SKILL.mdindex e46ece285b..7f2fc810e3 100644--- a/.claude/skills/ckeditor5-plugin-development/SKILL.md+++ b/.claude/skills/ckeditor5-plugin-development/SKILL.md@@ -2,15 +2,15 @@name: ckeditor5-plugin-developmentdescription: >-Write, extend, and review CKEditor 5 plugins in the Trilium (TriliumNext- Notes) monorepo — the rich-text-note editor under packages/ckeditor5 and the- @triliumnext/ckeditor5-<feature> plugin packages. Use when building or+ Notes) monorepo — the rich-text-note editor under packages/ckeditor5, whose+ plugins live in src/plugins/, plus the @triliumnext/ckeditor5-math package.+ Use when building orreviewing a Trilium CKEditor 5 feature/plugin, or when working with theediting engine (model, view, schema, conversion/upcast-downcast), commands,the UI library (buttons, dropdowns, dialogs, balloons, toolbars), widgets- (block/inline, toWidget, nested editables), keystrokes, localization (t()/.po),+ (block/inline, toWidget, nested editables), keystrokes, localization (t()),registering a plugin into plugins.ts / the editor classes / toolbar.ts, or- adding a plugin to the aggregator (or, for large features, a new- @triliumnext/ckeditor5-* package). Covers the architecture,+ adding a new plugin folder under src/plugins/. Covers the architecture,idiomatic patterns, Trilium packaging/registration, code-style conventions,and a review checklist.---@@ -20,24 +20,24 @@ description: >-CKEditor 5 is **plugin-based**: every feature — even typing and `<p>` support — is aplugin. Without plugins the editor is an empty API. This skill is specific to **Trilium(TriliumNext Notes)**, whose rich-text note editor is built from the CKEditor 5 library-(external dep, pinned `48.2.0`) plus Trilium's own plugins. In this repo the editor build-lives in `packages/ckeditor5` (`@triliumnext/ckeditor5`) and custom features live in-sibling `packages/ckeditor5-<feature>` workspace packages (`@triliumnext/ckeditor5-<feature>`:-admonition, collapsible, footnotes, keyboard-marker, math, mermaid). The editor is consumed-by `apps/client` (the text note widget). This skill distills how to write new Trilium plugins-and review existing ones idiomatically.+(external dep, pinned `48.3.1`) plus Trilium's own plugins. Both the editor build and the+plugins live in `packages/ckeditor5` (`@triliumnext/ckeditor5`): each feature is a folder under+`src/plugins/` — admonition, collapsible, footnotes, keyboard_marker, mermaid, mention, snippets+and the rest — with its tests co-located beside it. `@triliumnext/ckeditor5-math` is the only+feature still shipped as its own workspace package, because it owns a heavy exclusive dependency+(`mathlive`). The editor is consumed by `apps/client` (the text note widget). This skill distills+how to write new Trilium plugins and review existing ones idiomatically.## When to use this skill-Use it whenever the task involves a Trilium CKEditor 5 plugin/feature: creating one (by default an-in-aggregator plugin under `packages/ckeditor5/src/plugins/`; a separate-`@triliumnext/ckeditor5-<feature>` package only for large self-contained features), extending one,+Use it whenever the task involves a Trilium CKEditor 5 plugin/feature: creating one (a folder under+`packages/ckeditor5/src/plugins/` — separate packages are not the pattern any more), extending one,debugging editing behavior, registering aplugin so it reaches the editor, or reviewing plugin code for correctness and conventioncompliance. Trigger concepts include: model/view/schema, conversion (upcast/downcast),`Command`, `editor.model.change()`, `ButtonView`/`componentFactory`, widgets (`toWidget`),`ContextualBalloon`/`Dialog`, `editor.keystrokes`, `t()` localization, the `plugins.ts`-registry / editor classes / `toolbar.ts`, or a `@triliumnext/ckeditor5-*` package.+registry / editor classes / `toolbar.ts`, or the `@triliumnext/ckeditor5-math` package.## The three pillars@@ -65,7 +65,7 @@ data (HTML) ──upcast──▶ MODEL ──editing downcast──▶ editing## Importing CKEditor in Trilium-Import everything from the single **`ckeditor5`** aggregate package (pinned `48.2.0`; it is a+Import everything from the single **`ckeditor5`** aggregate package (pinned `48.3.1`; it is a`peerDependency` + `devDependency` of every plugin package). There is no premium package: everypremium plugin Trilium used has an in-tree GPL replacement, and the editor always runs under the`GPL` license key:@@ -74,8 +74,9 @@ premium plugin Trilium used has an in-tree GPL replacement, and the editor alwayimport { Plugin, ButtonView, Command, _setModelData } from 'ckeditor5';```-- **Cross-plugin** imports use the workspace package name, e.g.- `import { Kbd } from '@triliumnext/ckeditor5-keyboard-marker';`.+- **Cross-plugin** imports inside `packages/ckeditor5` are **relative**, e.g.+ `import Kbd from './keyboard_marker/keyboard_marker.js';`. The only workspace-package import+ left is `@triliumnext/ckeditor5-math`, which the aggregate pulls in from `plugins.ts`.- **Every import includes its file extension** (`.js`/`.ts`/`.json`) — enforced by`eslint-config-ckeditor5` (`require-file-extensions-in-imports`), with`allow-imports-only-from-main-package-entry-point` and `no-legacy-imports` also active.@@ -123,13 +124,20 @@ export default class Foo extends Plugin {}```-Per-package `src/` layout (e.g. `packages/ckeditor5-admonition/src/`): `{feature}.ts` glue,-`{feature}editing.ts`, `{feature}ui.ts`, optional `{feature}command.ts`, `augmentation.ts`-(the `declare module 'ckeditor5'` types), and `index.ts` (re-exports glue + sub-plugins +-command types, plus `export const icons = { fooIcon }`). Complex plugins add `constants.ts`+Plugin folder layout (e.g. `packages/ckeditor5/src/plugins/admonition/`), all files flat and+snake_case: `{feature}.ts` glue, `{feature}_editing.ts`, `{feature}_ui.ts`, optional+`{feature}_command.ts`. Put the `declare module 'ckeditor5'` augmentation at the **bottom of the+glue file**: every folded-in plugin dropped its separate `augmentation.ts` and `index.ts` barrel+that way, so consumers import the specific module they need. (`syntax_highlighting` still uses the+older separate-file shape — leave it, but don't copy it.) Complex plugins add `constants.ts`(`ELEMENTS`/`ATTRIBUTES`/`COMMANDS`/`CLASSES`), `utils.ts` (model-query helpers), and split-`schema.ts`/`converters.ts`. Assets: `theme/{feature}.css`, `theme/icons/*.svg`,-`lang/en.po` + `lang/contexts.json`, `tests/`. See `references/conventions.md`.+`schema.ts`/`converters.ts`. Tests sit beside the source as `*.spec.ts`.++Assets live in the package's shared folders, not per plugin: stylesheets in+`packages/ckeditor5/src/theme/{feature}.css` (imported from the glue plugin) and icons in+`packages/ckeditor5/src/icons/`, prefixed where the name would otherwise be generic+(`mermaid-info.svg`). A plugin derived from third-party code also keeps a `README.md` recording+its provenance, and a `LICENSE.md` where upstream requires one. See `references/conventions.md`.Key rules (inherited from the upstream conventions via `eslint-config-ckeditor5`):@@ -214,11 +222,10 @@ converters instead of `attributeToElement`; see `references/widgets.md`.## Development workflow-1. **Write the plugin.** **Default: an in-aggregator plugin** — a file/folder under- `packages/ckeditor5/src/plugins/`. Create a separate `packages/ckeditor5-<feature>` workspace- package (`@triliumnext/ckeditor5-<feature>`, `main: "src/index.ts"`, ships TS source) **only for- a large, self-contained feature**. See `references/tooling-and-packaging.md` ("Where a new plugin- goes").+1. **Write the plugin.** A folder under `packages/ckeditor5/src/plugins/`. Separate workspace+ packages are no longer the pattern — every one that existed has been folded in, since none had+ consumers outside the aggregate or was ever published. See+ `references/tooling-and-packaging.md` ("Where a new plugin goes").2. **Register it so it reaches the editor** (full flow in `references/tooling-and-packaging.md`):- For a new workspace package, add `"@triliumnext/ckeditor5-<feature>": "workspace:*"` to`packages/ckeditor5/package.json`.@@ -276,10 +283,10 @@ review (workflow, CKEditor-specific defect patterns, contribution process), use## Scope & sourcesThis skill is specific to the **Trilium (TriliumNext Notes) monorepo's** CKEditor 5 integration.-Repository paths it cites — `packages/ckeditor5`, `packages/ckeditor5-<feature>`, `apps/client/...` —-are **this repository**, and examples come from Trilium's own plugins (admonition, collapsible,-footnotes, keyboard-marker, math, mermaid). The CKEditor 5 **library** is an external dependency-pinned to **48.2.0**; its mechanics were distilled from the upstream docs (ckeditor.com/docs) and+Repository paths it cites — `packages/ckeditor5`, `packages/ckeditor5/src/plugins/<name>/`,+`packages/ckeditor5-math`, `apps/client/...` — are **this repository**, and examples come from+Trilium's own plugins (admonition, collapsible, footnotes, keyboard_marker, math, mermaid). The CKEditor 5 **library** is an external dependency+pinned to **48.3.1**; its mechanics were distilled from the upstream docs (ckeditor.com/docs) andsource (github.com/ckeditor/ckeditor5, commit 9ecca53627). Where a snippet cites an upstream librarypackage (e.g. ckeditor5-basic-styles, -link, -image), that is the library's own source — not aTrilium package.diff --git a/.claude/skills/ckeditor5-plugin-development/references/architecture.md b/.claude/skills/ckeditor5-plugin-development/references/architecture.mdindex 3c17c0c09c..eca93a6b2c 100644--- a/.claude/skills/ckeditor5-plugin-development/references/architecture.md+++ b/.claude/skills/ckeditor5-plugin-development/references/architecture.md@@ -3,12 +3,12 @@The conceptual foundation. Read this before working on editing behavior.> **Scope.** Everything here is engine mechanics from the **`ckeditor5` library** (the npm-> aggregate, pinned to `48.2.0` in the Trilium monorepo). The APIs (`editor.model`,+> aggregate, pinned to `48.3.1` in the Trilium monorepo). The APIs (`editor.model`,> `editor.editing`, `Plugin`, the writer, schema, conversion) are the library's, imported as> `import { Plugin } from 'ckeditor5'` (with file extensions). Paths under-> `packages/ckeditor5-*` (admonition, collapsible, footnotes, keyboard-marker, math, mermaid)-> are **Trilium's own** plugins that consume these APIs; the editor build/aggregator lives in-> `packages/ckeditor5`. Trilium examples are cited throughout — they exercise the same library+> `packages/ckeditor5/src/plugins/` (admonition, collapsible, footnotes, keyboard_marker, mermaid,+> …) and `packages/ckeditor5-math` are **Trilium's own** plugins that consume these APIs; the+> editor build itself is `packages/ckeditor5`. Trilium examples are cited throughout — they exercise the same library> mechanics described below.## Editor classes@@ -146,10 +146,10 @@ Behavior that flags produce (observable in the block-widget feature):- `isLimit` — element can't be split (Enter) or emptied/left by Backspace; good for titles.- `isObject` / `$blockObject` / `$inlineObject` — selected/deleted/copied as a unit.-Trilium's block features lean on exactly these: `ckeditor5-admonition` and-`ckeditor5-collapsible` register block elements inheriting from `$blockObject` and mark inner+Trilium's block features lean on exactly these: `admonition` and+`collapsible` register block elements inheriting from `$blockObject` and mark innertitle/content regions with `isLimit`, then guard structure with one or more-`registerPostFixer` invariants (see `core-plugin-patterns.md` → post-fixers). `ckeditor5-footnotes`+`registerPostFixer` invariants (see `core-plugin-patterns.md` → post-fixers). `footnotes`splits its schema across `schema.ts` / `converters.ts` with shared `constants.ts`.Custom checks for disallowing in specific contexts:diff --git a/.claude/skills/ckeditor5-plugin-development/references/commands.md b/.claude/skills/ckeditor5-plugin-development/references/commands.mdindex a1e6f79e3b..6b0a37584f 100644--- a/.claude/skills/ckeditor5-plugin-development/references/commands.md+++ b/.claude/skills/ckeditor5-plugin-development/references/commands.md@@ -5,12 +5,12 @@ by `refresh()`). Commands encapsulate feature logic so UI, keystrokes, other plu`editor.execute()` can all trigger and observe it. Most editor features expose their behavioras commands.-> `Command` and `AttributeCommand` come from the **`ckeditor5` library** (`48.2.0`), imported+> `Command` and `AttributeCommand` come from the **`ckeditor5` library** (`48.3.1`), imported> as `from 'ckeditor5'` (with file extensions). In Trilium you don't always write a command> class: simple `$text`-attribute features reuse the built-in `AttributeCommand` —-> `ckeditor5-keyboard-marker` registers `new AttributeCommand( editor, '<attr>' )` and lets the+> `keyboard_marker` registers `new AttributeCommand( editor, '<attr>' )` and lets the> library handle toggle/refresh (see `core-plugin-patterns.md` → Reusable AttributeCommand).-> Features with bespoke model mutations (e.g. `ckeditor5-admonition`, `ckeditor5-footnotes`)+> Features with bespoke model mutations (e.g. `admonition`, `footnotes`)> write a custom `Command` subclass as below.## Defining and registeringdiff --git a/.claude/skills/ckeditor5-plugin-development/references/conventions.md b/.claude/skills/ckeditor5-plugin-development/references/conventions.mdindex d167cb045a..7fc2663b5d 100644--- a/.claude/skills/ckeditor5-plugin-development/references/conventions.md+++ b/.claude/skills/ckeditor5-plugin-development/references/conventions.md@@ -57,9 +57,10 @@ Follow the existing files in the package you touch; don't add or strip headers w`@ckeditor/ckeditor5-*` paths (`allow-imports-only-from-main-package-entry-point`,`no-legacy-imports`). The only allowed `@ckeditor/*` deep imports are the dev/debug packages`@ckeditor/ckeditor5-icons` and `@ckeditor/ckeditor5-inspector`.-- **Cross-plugin** imports use the workspace package name- (`import { Kbd } from '@triliumnext/ckeditor5-keyboard-marker';`); **same-package** imports are- relative (`import FooEditing from './fooediting.js';`).+- **Cross-plugin** imports inside `packages/ckeditor5` are relative+ (`import Kbd from './keyboard_marker/keyboard_marker.js';`), as are same-plugin imports+ (`import FooEditing from './foo_editing.js';`). `@triliumnext/ckeditor5-math` is the one+ remaining workspace-package import.- **All imports include file extensions** (`.ts`/`.js`/`.json`) — `import './augmentation.js';`even though the source is `.ts` (`require-file-extensions-in-imports`).- SVG icons import with the `?raw` suffix (`import fooIcon from '../theme/icons/foo.svg?raw';`) and@@ -94,12 +95,13 @@ declare module 'ckeditor5' {## Package & workspace-- Scope is **`@triliumnext/`**; package name `@triliumnext/ckeditor5-<feature>`,- `"type": "module"`, `"main": "src/index.ts"` (ships TS source — no per-package dist for- consumers), `peerDependencies: { "ckeditor5": "48.2.0" }`.-- Cross-package deps use the **`workspace:*`** protocol; the aggregator pulls plugins in via- `"@triliumnext/ckeditor5-<feature>": "workspace:*"`. See `references/tooling-and-packaging.md`- for the full registration flow.+- A new plugin needs **no packaging at all** — it is a folder under+ `packages/ckeditor5/src/plugins/` and is registered by editing `plugins.ts`. See+ `references/tooling-and-packaging.md` for the registration flow.+- The one surviving plugin package, `@triliumnext/ckeditor5-math`, shows the older shape:+ scope `@triliumnext/`, `"type": "module"`, `"main": "src/index.ts"` (ships TS source — no+ per-package dist), `peerDependencies: { "ckeditor5": "48.3.1" }`, pulled in with+ `workspace:*`. Don't copy it for new work.## TypeScript configdiff --git a/.claude/skills/ckeditor5-plugin-development/references/conversion.md b/.claude/skills/ckeditor5-plugin-development/references/conversion.mdindex c047580cb5..3f567dcf29 100644--- a/.claude/skills/ckeditor5-plugin-development/references/conversion.md+++ b/.claude/skills/ckeditor5-plugin-development/references/conversion.md@@ -5,10 +5,10 @@ of truth**; HTML/data is just I/O. That is why helper names look "reversed": con`<mark>` element ↔ `highlight` model attribute uses `attributeToElement` (you name the**model** side first).-> All helpers and writers here come from the **`ckeditor5` library** (`48.2.0`); import as+> All helpers and writers here come from the **`ckeditor5` library** (`48.3.1`); import as> `from 'ckeditor5'` with file extensions. Trilium's own plugins under `packages/ckeditor5-*`> register converters via `editor.conversion`; real examples cited below are-> `ckeditor5-math` and `ckeditor5-mermaid` (external/async-rendered widgets built with+> `ckeditor5-math` and `mermaid` (external/async-rendered widgets built with> `createUIElement` render callbacks plus a data-processor wrap) and Trilium's reference-link> conversion.@@ -195,7 +195,7 @@ processor.toView = data => toView( preprocess( data ) ); // and mirror toDataUse sparingly — prefer real converters. It's for cases the converter layer can't reach, such aspreserving newlines inside a formula or shielding a fragment from generic HTML normalization.-This is the pattern Trilium's `ckeditor5-math` / `ckeditor5-mermaid` use: a data-processor wrap+This is the pattern Trilium's `ckeditor5-math` / `mermaid` use: a data-processor wrapguards the raw formula/diagram source while a `createUIElement` render callback (see the elementcallbacks above) renders the external/async output into the editing view.diff --git a/.claude/skills/ckeditor5-plugin-development/references/core-plugin-patterns.md b/.claude/skills/ckeditor5-plugin-development/references/core-plugin-patterns.mdindex 28e693e604..48b04a7f00 100644--- a/.claude/skills/ckeditor5-plugin-development/references/core-plugin-patterns.md+++ b/.claude/skills/ckeditor5-plugin-development/references/core-plugin-patterns.md@@ -3,7 +3,7 @@> **The source paths below (`packages/ckeditor5-basic-styles`, `-link`, `-image`, `-ui`, etc.)> point into the CKEditor 5 *library* source> ([github.com/ckeditor/ckeditor5](https://github.com/ckeditor/ckeditor5)) — the external-> dependency Trilium pins at `48.2.0` — NOT into Trilium's monorepo.** They show where each idiom+> dependency Trilium pins at `48.3.1` — NOT into Trilium's monorepo.** They show where each idiom> lives in the library's own source. These are the upstream library packages (basic-styles, link,> image, engine, ui, core, widget, typing); do **not** confuse them with Trilium's own> `packages/ckeditor5-*` plugins (admonition, collapsible, footnotes, keyboard-marker, math,@@ -11,7 +11,7 @@> Trilium files — the symbols ship inside the `ckeditor5` npm package.Real-world idioms mined from the actual library `packages/*/src` source (verified against-`[email protected]`). These go beyond the tutorials and are the patterns the official plugins+`[email protected]`). These go beyond the tutorials and are the patterns the official pluginsactually use — and the patterns Trilium's plugins follow. Each item cites its source file in theCKEditor library repository.@@ -69,7 +69,7 @@ untyped. (See also `tooling-and-packaging.md`.)Inline-style features don't hand-roll the command — they reuse `AttributeCommand` and tag theattribute as formatting so it behaves natively (copied on Enter, replicated on paste). Trilium's-`ckeditor5-keyboard-marker` follows this exactly: it registers a built-in `AttributeCommand` for+`keyboard_marker` follows this exactly: it registers a built-in `AttributeCommand` forits `$text` attribute rather than writing a custom command.```ts@@ -260,7 +260,7 @@ editor.editing.view.document.registerPostFixer( writer => { /* view-side cleanupPost-fixers run after each change (model) or downcast (view) and re-run until all return `false`.Use to guarantee structure (e.g. a required paragraph inside an editable, no two adjacent X).-Trilium's `ckeditor5-admonition` and `ckeditor5-collapsible` register **multiple**+Trilium's `admonition` and `collapsible` register **multiple**`registerPostFixer`s to keep their block structure valid (e.g. an enforced title/content region).## Inserting content — option detailsdiff --git a/.claude/skills/ckeditor5-plugin-development/references/recipes.md b/.claude/skills/ckeditor5-plugin-development/references/recipes.mdindex c2a00cfd11..75a6dc7d98 100644--- a/.claude/skills/ckeditor5-plugin-development/references/recipes.md+++ b/.claude/skills/ckeditor5-plugin-development/references/recipes.md@@ -1,7 +1,7 @@# Recipes (task-oriented how-tos)Task-oriented snippets for Trilium's CKEditor plugins (`packages/ckeditor5-*`). All library-symbols import from `ckeditor5` (48.2.0); local imports carry file extensions. All model+symbols import from `ckeditor5` (48.3.1); local imports carry file extensions. All modelmutations run inside `editor.model.change( writer => … )`. In Trilium the "document" is thecontent of a single text note, so these recipes operate over that note's model root.diff --git a/.claude/skills/ckeditor5-plugin-development/references/tooling-and-packaging.md b/.claude/skills/ckeditor5-plugin-development/references/tooling-and-packaging.mdindex 7b54ad6cb9..08bc285509 100644--- a/.claude/skills/ckeditor5-plugin-development/references/tooling-and-packaging.md+++ b/.claude/skills/ckeditor5-plugin-development/references/tooling-and-packaging.md@@ -3,40 +3,46 @@How CKEditor 5 plugins are packaged, registered, built, and debugged in the **Trilium(TriliumNext Notes)** monorepo. This is a pnpm workspace (`[email protected]`, `nodeLinker: hoisted`,no nx/turbo) with packages under `packages/*` and apps under `apps/*`, org scope `@triliumnext/`.-The CKEditor 5 **library** is an external dependency pinned to `48.2.0`; there is no package-generator here — you add a plugin by hand. **By default a new plugin lives inside the aggregator**-(a file/folder under `packages/ckeditor5/src/plugins/`); a separate workspace package is the-exception, reserved for large self-contained features (see "Where a new plugin goes" below).+The CKEditor 5 **library** is an external dependency pinned to `48.3.1`; there is no package+generator here — you add a plugin by hand, as a folder under `packages/ckeditor5/src/plugins/`.+Separate workspace packages are no longer the pattern (see "Where a new plugin goes" below).## Where the editor lives-- `packages/ckeditor5` — `@triliumnext/ckeditor5`, the **editor build / aggregator**. `src/index.ts`- defines the editor classes; `src/plugins.ts` is the plugin registry; built with **Vite**.-- `packages/ckeditor5-{admonition,collapsible,footnotes,keyboard-marker,math,mermaid}` — Trilium's- custom plugin packages, each `@triliumnext/ckeditor5-<feature>`.+- `packages/ckeditor5` — `@triliumnext/ckeditor5`, the **editor build**. `src/index.ts` defines the+ editor classes; `src/plugins.ts` is the plugin registry; `src/plugins/` holds every plugin+ (admonition, collapsible, footnotes, keyboard_marker, mermaid, mention, snippets, …), each a+ folder with its tests co-located; `src/theme/` and `src/icons/` hold their assets; built with+ **Vite**.+- `packages/ckeditor5-math` — `@triliumnext/ckeditor5-math`, the one remaining plugin package. It+ stayed separate because it owns a heavy exclusive dependency (`mathlive`); everything else was+ folded in.- `apps/client/src/widgets/type_widgets/text/` — the rich-text note widget that instantiates theeditor (`config.ts`, `CKEditorWithWatchdog.tsx`, `toolbar.ts`).The library's own packages (basic-styles, link, image, engine, ui, core, widget, typing, …) are**upstream** and not present in this repo — they ship inside the `ckeditor5` npm aggregate.-## Where a new plugin goes (default: in the aggregator)+## Where a new plugin goes-**Project direction: keep new plugins inside the aggregator.** The default home for a new feature-is an **in-aggregator plugin** — a file or folder under `packages/ckeditor5/src/plugins/`, written-as a normal `Plugin` class and registered in `TRILIUM_PLUGINS`. No new package, `package.json`,-tsconfig, build, or workspace wiring; just the code and one line in `plugins.ts`. This is the right-choice for the large majority of features.+**A new plugin is a folder under `packages/ckeditor5/src/plugins/`**, written as a normal `Plugin`+class and registered in `TRILIUM_PLUGINS` (or `EXTERNAL_PLUGINS` if it derives from third-party+code). No package.json, tsconfig, vitest config or workspace wiring — just the code, its co-located+`*.spec.ts`, and one line in `plugins.ts`.-**Create a separate `@triliumnext/ckeditor5-<feature>` workspace package only for large,-self-contained external plugins** — substantial code with their own theme/lang/tests that could-plausibly stand alone (the existing ones: math, footnotes, mermaid, admonition, collapsible,-keyboard-marker). When in doubt, start in-aggregator and promote to a package later if it grows.+Trilium used to ship features as sibling `@triliumnext/ckeditor5-<feature>` packages. All of them+have been folded in: none had a consumer outside the aggregate, none was published, and each was+carrying a `ckeditor5-package-generator` scaffold — sample pages, its own ESLint/Stylelint/vitest+configs, typings — that no script or CI job ever ran. Folding them in also put them under the+aggregate's 100% coverage gate, which is where several latent bugs surfaced.-The package layout below applies **only to the separate-package case**. An in-aggregator plugin-needs none of it.+`packages/ckeditor5-math` is the sole exception, kept because it owns `mathlive` outright. Note+that even that is a weak reason: `mathlive` is loaded through a dynamic `import()` in the source,+so code-splitting does not depend on the package boundary.-## Plugin package layout (`packages/ckeditor5-<feature>`, the separate-package exception)+The package layout below is documented **only** for reading `ckeditor5-math`. Do not copy it.++## Plugin package layout (`packages/ckeditor5-math` only — historical)`package.json`:@@ -46,7 +52,7 @@ needs none of it."type": "module","main": "src/index.ts", // ships TS SOURCE — no per-package dist for consumers"license": "GPL-2.0-or-later",- "peerDependencies": { "ckeditor5": "48.2.0" },+ "peerDependencies": { "ckeditor5": "48.3.1" },"scripts": {"lint": "eslint \"**/*.{js,ts}\" --quiet","stylelint": "stylelint --quiet --allow-empty-input 'theme/**/*.css'",@@ -70,7 +76,7 @@ currently lacks `eslint.config.js`/stylelint + lint scripts):- `eslint.config.js` — `eslint-config-ckeditor5` + `eslint-plugin-ckeditor5-rules`.- `stylelint-config-ckeditor5` for theme CSS.-Plugin packages have **no `vite.config.ts`** — only the aggregator (`packages/ckeditor5`) builds;+Plugin packages have **no `vite.config.ts`** — only `packages/ckeditor5` builds;each plugin just ships raw TS via `main: src/index.ts`, compiled by whatever bundles the editor.`src/` files: `{feature}.ts` (glue), `{feature}editing.ts`, `{feature}ui.ts`, optional@@ -106,9 +112,13 @@ Four steps:`POPUP_EDITOR_PLUGINS` = `COMMON_PLUGINS` + `BlockToolbar`.```ts- import { Footnotes } from '@triliumnext/ckeditor5-footnotes';+ import Footnotes from './plugins/footnotes/footnotes.js';const EXTERNAL_PLUGINS: typeof Plugin[] = [ Kbd, Mermaid, Admonition, Collapsible, Footnotes, Math, AutoformatMath ];```++ `EXTERNAL_PLUGINS` is a historical grouping — it holds the features that began life as+ third-party or separate packages, while `TRILIUM_PLUGINS` holds the ones written here. Both+ now live under `src/plugins/`; put a new plugin in whichever array matches its provenance.3. **Editor classes pick it up automatically.** The classes in `packages/ckeditor5/src/index.ts`expose those arrays via `static get builtinPlugins()`, so adding to the array is enough — noper-class edit needed (unless the plugin is editor-specific).@@ -135,7 +145,7 @@ always carries `licenseKey: "GPL"`. `_setModelData`/inspector aside, all symbols## Vite build`packages/ckeditor5` builds with Vite (`vite.config.ts`); `vitest.config.ts` drives tests. Because-plugin packages expose `main: src/index.ts`, the aggregator and ultimately `apps/client` compile+plugin packages expose `main: src/index.ts`, the aggregate and ultimately `apps/client` compilethe plugin TS sources directly through the bundler — there is no intermediate per-package build tokeep in sync. `src/index.ts` imports `ckeditor5/ckeditor5.css` and the Trilium theme CSS.@@ -183,7 +193,7 @@ For test setup, model/view assertions, and command/UI test patterns, use the sep## Scope-Paths here (`packages/ckeditor5`, `packages/ckeditor5-<feature>`, `apps/client/...`) are **this+Paths here (`packages/ckeditor5`, `packages/ckeditor5/src/plugins/<name>/`, `packages/ckeditor5-math`, `apps/client/...`) are **thisTrilium repository**. The CKEditor 5 library mechanics referenced (editor bases `BalloonEditor`/`DecoupledEditor`, `EditorConfig`, the watchdog) come from the external `ckeditor5` package at-`48.2.0`.+`48.3.1`.diff --git a/.claude/skills/ckeditor5-plugin-development/references/ui-and-localization.md b/.claude/skills/ckeditor5-plugin-development/references/ui-and-localization.mdindex 2538297fc1..968cb4b659 100644--- a/.claude/skills/ckeditor5-plugin-development/references/ui-and-localization.md+++ b/.claude/skills/ckeditor5-plugin-development/references/ui-and-localization.md@@ -1,7 +1,7 @@# UI library & localization (Trilium)In the Trilium monorepo every CKEditor plugin (`packages/ckeditor5-*`) builds its UI with the-library's UI layer, imported from `ckeditor5` (pinned 48.2.0). It is a small MVC: **Views**+library's UI layer, imported from `ckeditor5` (pinned 48.3.1). It is a small MVC: **Views**render DOM via **Templates**, expose **observable** properties, and are organized into**collections** that form the UI tree. Features talk to views through observables — never thenative DOM directly. Trilium's text editor runs as one of three classes — `AttributeEditor`@@ -75,8 +75,8 @@ editor.ui.componentFactory.add( 'admonition', locale => {A registered name only appears in the editor when it is added to `toolbar.ts`; registering thecomponent factory entry alone is not enough. Real examples: the admonition button/dropdown-(`packages/ckeditor5-admonition/src/admonitionui.ts`), the footnotes insert button + dynamic-"insert existing footnote" dropdown (`packages/ckeditor5-footnotes/src/footnote-ui.ts`).+(`packages/ckeditor5/src/plugins/admonition/admonition_ui.ts`), the footnotes insert button + dynamic+"insert existing footnote" dropdown (`packages/ckeditor5/src/plugins/footnotes/footnote_ui.ts`).**Best practice:** on any user action (button/dropdown execute), call`editor.editing.view.focus()` so the editor keeps focus.@@ -140,14 +140,15 @@ import { IconBold, IconCheck, IconCancel, IconQuote } from 'ckeditor5';button.set( { icon: IconBold } );```-For a **custom** icon, Trilium plugins import the raw SVG XML string with the `?raw` suffix,-keep the file under `theme/icons/`, and re-export an `icons` map from `index.ts` (so the-aggregator can collect them):+For a **custom** icon, Trilium plugins import the raw SVG XML string with the `?raw` suffix. The+file lives in the package-wide `packages/ckeditor5/src/icons/` folder — prefixed when the bare name+would be too generic (`mermaid-info.svg`) — and is imported directly by whichever plugin file needs+it. The folded-in plugins used to re-export an `icons` map from a barrel `index.ts`; those barrels+are gone, and nothing consumed the maps:```ts-// index.ts-import admonitionIcon from '../theme/icons/admonition.svg?raw';-export const icons = { admonitionIcon };+// src/plugins/admonition/admonition_ui.ts+import admonitionIcon from '../../icons/admonition.svg?raw';// admonitionui.tsbutton.set( { icon: admonitionIcon } ); // the raw SVG string@@ -190,9 +191,9 @@ addMenuToDropdown( dropdown, editor.body.ui.view, [Even when `withText` is false, set `label` for screen readers.In Trilium, the admonition type picker is a list dropdown built from `ADMONITION_TYPES`-(`packages/ckeditor5-admonition/src/admonitionui.ts`), and footnotes builds its list+(`packages/ckeditor5/src/plugins/admonition/admonition_ui.ts`), and footnotes builds its listdynamically from the footnotes already present in the note-(`packages/ckeditor5-footnotes/src/footnote-ui.ts`) — re-reading the model each time the+(`packages/ckeditor5/src/plugins/footnotes/footnote_ui.ts`) — re-reading the model each time thedropdown opens.## Contextual balloon@@ -337,9 +338,12 @@ Each Trilium plugin keeps two files under `lang/`:{ "Admonition": "Toolbar button tooltip for the Admonition feature." }```-When you add a new `t( '…' )` string, add a matching `msgid`/`msgctxt`/`msgstr` block to-`en.po` and an entry to `contexts.json`. See `packages/ckeditor5-admonition/lang/` for the-canonical pair.+**Note:** the `.po`/`contexts.json` workflow described above is effectively dormant in Trilium.+The folded-in plugins' `lang/` directories were dropped during consolidation because nothing in the+build or CI consumed them — only `packages/ckeditor5-math/lang/contexts.json` survives. New+user-facing strings reach the UI either through CKEditor's own `t()` dictionary+(`packages/ckeditor5/src/translation_overrides.ts`) or, for Trilium-specific strings, through the+host's `translate` config callback described below.### Custom `translate` config fallback@@ -352,6 +356,6 @@ const translate = ( editor.config.get( 'translate' ) as?? ( ( key: string ) => key );```-See `packages/ckeditor5-collapsible/src/collapsible-ui.ts` and `collapsible-editing.ts`. This+See `packages/ckeditor5/src/plugins/collapsible/collapsible_ui.ts` and `collapsible-editing.ts`. Thisis independent of `editor.t()`/PO catalogs — it lets the host (Trilium) inject its owntranslator for plugin-specific labels.diff --git a/.claude/skills/ckeditor5-plugin-development/references/widgets.md b/.claude/skills/ckeditor5-plugin-development/references/widgets.mdindex 3fdaee6da9..3b5ca788cf 100644--- a/.claude/skills/ckeditor5-plugin-development/references/widgets.md+++ b/.claude/skills/ckeditor5-plugin-development/references/widgets.md@@ -6,10 +6,10 @@ regions. The widget system ships in `ckeditor5` (engine + widget layer); importfrom `ckeditor5`.In the Trilium monorepo the live examples are:-- **admonition** (`packages/ckeditor5-admonition`) and **collapsible**- (`packages/ckeditor5-collapsible`) — block widgets with nested editable content, schema+- **admonition** (`packages/ckeditor5/src/plugins/admonition`) and **collapsible**+ (`packages/ckeditor5/src/plugins/collapsible`) — block widgets with nested editable content, schemainvariants enforced by `registerPostFixer`.-- **math** (`packages/ckeditor5-math`, KaTeX) and **mermaid** (`packages/ckeditor5-mermaid`) —+- **math** (`packages/ckeditor5-math`, KaTeX) and **mermaid** (`packages/ckeditor5/src/plugins/mermaid`) —external/async-rendered widgets (see the dedicated section below).Two flavors:@@ -204,13 +204,13 @@ class SimpleBoxToolbar extends Plugin {```This is the same mechanism images/tables use to show their contextual toolbars. In Trilium,-mermaid registers its widget toolbar this way (`packages/ckeditor5-mermaid/src/mermaidtoolbar.ts`),+mermaid registers its widget toolbar this way (`packages/ckeditor5/src/plugins/mermaid/mermaid_toolbar.ts`),hosting the source/preview/split-mode buttons.## External / async-rendered widgets (math, mermaid)Trilium's **math** (KaTeX, `packages/ckeditor5-math`) and **mermaid**-(`packages/ckeditor5-mermaid`) plugins are the real-world references for this section. Widgets+(`packages/ckeditor5/src/plugins/mermaid`) plugins are the real-world references for this section. Widgetsthat render the output of an external library need a few patterns beyond the static-widgetbasics. The model stores the **source** (the LaTeX string / mermaid diagram code) as anattribute; the **data downcast** emits that source wrapped in plain markup (so `getData()` is@@ -286,7 +286,7 @@ expose one command per mode that sets it, render different DOM per mode in the edowncast, and bind the widget-toolbar buttons' `isOn` to each command's value so they reflectthe current mode. Mermaid is exactly this: separate `mermaidSourceViewCommand`,`mermaidPreviewCommand`, and `mermaidSplitViewCommand`-(`packages/ckeditor5-mermaid/src/commands/`) drive the mode, surfaced through the widget+(`packages/ckeditor5/src/plugins/mermaid/`) drive the mode, surfaced through the widgettoolbar from `mermaidtoolbar.ts`.**Pre-process input with a data processor.** To accept the raw source on load, wrap/transformdiff --git a/.claude/skills/ckeditor5-reviewing/SKILL.md b/.claude/skills/ckeditor5-reviewing/SKILL.mdindex 1b2b8984f2..fdb5432aa1 100644--- a/.claude/skills/ckeditor5-reviewing/SKILL.md+++ b/.claude/skills/ckeditor5-reviewing/SKILL.md@@ -2,8 +2,8 @@name: ckeditor5-reviewingdescription: >-Review or audit CKEditor 5 plugin code in the Trilium (TriliumNext Notes)- monorepo, or a PR/diff touching packages/ckeditor5-* or the packages/ckeditor5- build. Use when checking a Trilium CKEditor 5 plugin for correctness and idiom:+ monorepo, or a PR/diff touching packages/ckeditor5 (including its in-tree+ plugins under src/plugins/) or packages/ckeditor5-math. Use when checking a Trilium CKEditor 5 plugin for correctness and idiom:schema / conversion / command / UI / widget code, CKEditor-specific defects(asymmetric upcast/downcast, unconsumed upcast elements, missing inline-widgetposition mapping, command refresh/isEnabled bugs, memory leaks, t() gaps,@@ -23,7 +23,7 @@ the companion skills rather than duplicating them:- **`ckeditor5-plugin-development`** — its `references/review-checklist.md` (architecture, schema,conversion, commands, UI, a11y) and `references/conventions.md` (naming, imports, JSDoc, TS).-- **`ckeditor5-testing`** — its review checklist and patterns for the test side (Vitest, happy-dom+- **`ckeditor5-testing`** — its review checklist and patterns for the test side (Vitest, browser-modevs. `@vitest/browser-webdriverio` browser mode, real `ClassicEditor.create`).Use those for "does this follow the conventions"; use this skill for **how to drive the review**@@ -32,17 +32,19 @@ and **what subtle things tend to be wrong**.## Scope & sourcesThis skill reviews **CKEditor 5 plugin code in the Trilium monorepo** (scope `@triliumnext/`). The-CKEditor 5 library itself is the **external `ckeditor5` dependency pinned at 48.2.0** — its docs+CKEditor 5 library itself is the **external `ckeditor5` dependency pinned at 48.3.1** — its docs([ckeditor.com/docs](https://ckeditor.com/docs)) and source([github.com/ckeditor/ckeditor5](https://github.com/ckeditor/ckeditor5)) are *external references*,-not the code under review. The Trilium plugins live in `packages/ckeditor5-{admonition,collapsible,-footnotes,keyboard-marker,math,mermaid}`; they are assembled by the build/aggregator package-`packages/ckeditor5` and wired into the editor UI from `apps/client`.+not the code under review. Nearly all Trilium plugins live **inside** `packages/ckeditor5`, under+`src/plugins/<name>/` — admonition, collapsible, footnotes, keyboard_marker, mermaid and the+in-tree plugins alongside them. `packages/ckeditor5-math` is the only remaining separate package.+The aggregate assembles them all and is wired into the editor UI from `apps/client`.## When to use-Reviewing a PR or diff that touches a Trilium CKEditor 5 plugin (`packages/ckeditor5-*`), the-aggregator (`packages/ckeditor5`), or the toolbar config in `apps/client`; auditing an existing+Reviewing a PR or diff that touches a Trilium CKEditor 5 plugin (`packages/ckeditor5/src/plugins/`+or `packages/ckeditor5-math`), the aggregate itself, or the toolbar config in `apps/client`;+auditing an existingplugin; sanity-checking your own feature before opening a PR. For *writing* the feature, use`ckeditor5-plugin-development`; for *writing tests*, use `ckeditor5-testing`.@@ -50,8 +52,8 @@ plugin; sanity-checking your own feature before opening a PR. For *writing* the1. **Scope the diff against Trilium's structure.** What surface changed — editing(schema/conversion/command), UI (componentFactory/buttons/dropdowns/balloons), a widget, config?- Which Trilium plugin package (`packages/ckeditor5-<x>`)? Does it also touch the aggregator- (`packages/ckeditor5/src/plugins.ts`, `src/index.ts`) or the toolbar+ Which plugin (`packages/ckeditor5/src/plugins/<name>/`, or `packages/ckeditor5-math`)? Does it+ also touch the aggregate's wiring (`packages/ckeditor5/src/plugins.ts`, `src/index.ts`) or the toolbar(`apps/client/src/widgets/type_widgets/text/toolbar.ts`)? This tells you which checklists, defectgroups, and integration checks apply.2. **Read model-first.** The model is the source of truth; trace the feature in order@@ -73,9 +75,9 @@ plugin; sanity-checking your own feature before opening a PR. For *writing* the(`require-file-extensions-in-imports`, `allow-imports-only-from-main-package-entry-point`,`no-legacy-imports`) and `stylelint-config-ckeditor5` — a diff that breaks them fails lint.5. **Run the tests for the affected package.** Use Vitest via- `pnpm --filter @triliumnext/ckeditor5-<f> test` (math + mermaid run sequentially). Note the test- environment: admonition/collapsible use **happy-dom**; math/mermaid/footnotes/keyboard-marker use- **`@vitest/browser-webdriverio` browser mode** (NOT Playwright). Coverage ≠ correctness: confirm+ `pnpm --filter @triliumnext/ckeditor5 test` (or `...-math`); the two run sequentially because+ each spins up headless Chrome. Both use **`@vitest/browser-webdriverio` browser mode** (NOT+ Playwright) and gate `src/**` at **100% coverage**. Coverage ≠ correctness: confirmthe *change itself* is tested, not just that lines are hit. A bug fix with no new/changed test isa red flag even when coverage stays green.6. **Observe behavior.** Attach the CKEditor Inspector (model / view / schema / commands), then:@@ -135,9 +137,10 @@ I don't see a `dataDowncast`.") rather than a false assertion.## Provenance & source referencesThe CKEditor-general defect patterns are distilled from the companion skills and the CKEditor 5-library at the pinned **48.2.0**; `docs/…` / `packages/…` paths in those patterns point into the+library at the pinned **48.3.1**; `docs/…` / `packages/…` paths in those patterns point into the**external CKEditor 5 repository** ([github.com/ckeditor/ckeditor5](https://github.com/ckeditor/ckeditor5)),-not the Trilium code under review. The Trilium-specific paths (`packages/ckeditor5-*`,-`packages/ckeditor5/src/{plugins,index}.ts`, `apps/client/src/widgets/type_widgets/text/toolbar.ts`,-`lang/en.po`) point into the **Trilium monorepo**. To refresh, re-check those paths against the+not the Trilium code under review. The Trilium-specific paths+(`packages/ckeditor5/src/plugins/<name>/`, `packages/ckeditor5-math`,+`packages/ckeditor5/src/{plugins,index}.ts`, `apps/client/src/widgets/type_widgets/text/toolbar.ts`)+point into the **Trilium monorepo**. To refresh, re-check those paths against thecurrent Trilium tree and bump the CKEditor version if the `ckeditor5` pin changes.diff --git a/.claude/skills/ckeditor5-reviewing/references/defect-patterns.md b/.claude/skills/ckeditor5-reviewing/references/defect-patterns.mdindex f21f5dabac..20fb73ce85 100644--- a/.claude/skills/ckeditor5-reviewing/references/defect-patterns.md+++ b/.claude/skills/ckeditor5-reviewing/references/defect-patterns.md@@ -3,7 +3,7 @@The high-value, easy-to-miss failure modes to hunt during a correctness review of a TriliumCKEditor 5 plugin. Each: **symptom**, how to **spot** it in a diff, **why** it's wrong, and the**fix**. Grouped by layer. The **Conversion → Tests** groups are CKEditor-library-general (they-apply unchanged to Trilium's `packages/ckeditor5-*` plugins); the final **Trilium integration**+apply unchanged to Trilium's plugins); the final **Trilium integration**group covers the monorepo wiring/convention defects. For the idiomatic "how it should look," see the`ckeditor5-plugin-development` skill.@@ -145,17 +145,17 @@ group covers the monorepo wiring/convention defects. For the idiomatic "how it s- Why: breaks headless/server-side use and reuse of the editing layer.- Fix: editing logic in `*Editing`, UI in `*UI`, glue plugin requiring both.-**Outdated / mixed imports (Trilium pins ckeditor5 48.2.0).**+**Outdated / mixed imports (Trilium pins ckeditor5 48.3.1).**- Spot: deep imports `@ckeditor/ckeditor5-*/src/...`; any `@ckeditor/*` package import instead of the`ckeditor5` aggregate; a `ckeditor5`/`@triliumnext/...` import *missing the file extension*;removed/renamed symbols (the UI model class is `ViewModel` — what Trilium's plugins use — not theold `Model`; `icons.check` → `IconCheck`).-- Why: Trilium always imports from the `ckeditor5` aggregate (pinned 48.2.0) or cross-plugin- `@triliumnext/ckeditor5-<x>`, **with explicit file extensions** — `eslint-config-ckeditor5`+- Why: Trilium always imports from the `ckeditor5` aggregate (pinned 48.3.1), or by relative path+ within `packages/ckeditor5`, **with explicit file extensions** — `eslint-config-ckeditor5`(`require-file-extensions-in-imports`, `allow-imports-only-from-main-package-entry-point`,`no-legacy-imports`) fails the build otherwise; deep `@ckeditor/*` paths also risk duplicatemodule instances; renamed symbols don't exist.-- Fix: import from `ckeditor5` (or `@triliumnext/ckeditor5-<x>`) with the file extension; use current+- Fix: import from `ckeditor5` (or a relative path inside the package) with the file extension; use currentsymbol names. (See the Trilium integration group below for the augmentation-module variant.)## Localization@@ -182,7 +182,7 @@ group covers the monorepo wiring/convention defects. For the idiomatic "how it s`afterEach`; legacy Chai/Sinon left in a touched file.- Fix: test the change itself; assert on stringified model/view; cover collapsed + ranged +schema-disallowed; tear down. Tests are **Vitest** with real `ClassicEditor.create` and helpers- from `ckeditor5`; run them via `pnpm --filter @triliumnext/ckeditor5-<f> test`.+ from `ckeditor5`; run them via `pnpm --filter @triliumnext/ckeditor5 test`.## Trilium integration@@ -200,12 +200,14 @@ nothing loads it, no button shows, or lint/license/localization is off.- Fix: export the plugin and add it to the appropriate array so it reaches `builtinPlugins`.**Unnecessary separate package.**-- Spot: a small/simple feature shipped as a new `@triliumnext/ckeditor5-<feature>` workspace- package (its own `package.json`/tsconfig/build/`workspace:*` wiring).-- Why: project direction is to keep new plugins **in the aggregator** (`packages/ckeditor5/src/plugins/`,- registered in `TRILIUM_PLUGINS`). A separate package is reserved for large, self-contained features- (math, footnotes, mermaid, …); a thin one is needless overhead.-- Fix: move it into `packages/ckeditor5/src/plugins/` unless it's genuinely large/standalone. (Minor.)+- Spot: a feature shipped as a new `@triliumnext/ckeditor5-<feature>` workspace package (its own+ `package.json`/tsconfig/vitest config/`workspace:*` wiring).+- Why: every plugin package has been folded into `packages/ckeditor5/src/plugins/` — none of them+ earned its scaffolding, since none had consumers outside the aggregate or was ever published.+ New plugins belong in `src/plugins/<name>/`, registered in `TRILIUM_PLUGINS` or+ `EXTERNAL_PLUGINS`. Only `ckeditor5-math` is still separate, and only because it owns a heavy+ exclusive dependency (`mathlive`).+- Fix: move it into `packages/ckeditor5/src/plugins/`.**Toolbar component not wired up.**- Spot: a plugin that registers a `componentFactory` button but no corresponding entry in@@ -214,18 +216,22 @@ nothing loads it, no button shows, or lint/license/localization is off.- Fix: add the component name to the toolbar config.**Import not from the aggregate / missing file extension.**-- Spot: imports from `@ckeditor/ckeditor5-*` (deep or top-level), or `ckeditor5` /- `@triliumnext/ckeditor5-<x>` imports **without a file extension**.+- Spot: imports from `@ckeditor/ckeditor5-*` (deep or top-level), or `ckeditor5` / relative+ imports **without a file extension**.- Why: `eslint-config-ckeditor5` (`require-file-extensions-in-imports`,`allow-imports-only-from-main-package-entry-point`, `no-legacy-imports`) fails the build.-- Fix: import from `ckeditor5` or cross-plugin `@triliumnext/ckeditor5-<x>`, always with the file+- Fix: import from `ckeditor5` or by relative path inside the package, always with the fileextension. (See "Outdated / mixed imports" above.)**License header inconsistent with the package.**- Spot: a new file that adds or omits the CKSource header against the package's existing convention.-- Why: header/license practice is **not uniform** across Trilium's CKEditor packages (admonition- carries the CKSource header; footnotes/math are `ISC`; keyboard-marker `GPL-3.0`; etc.).-- Fix: match the other source files in that package — don't add or strip headers wholesale. (Minor.)+- Why: the folded-in plugins keep the provenance of whatever they were derived from, recorded per+ folder in `src/plugins/<name>/README.md` (plus a `LICENSE.md` where upstream required one) —+ admonition and mermaid carry CKSource headers on the files genuinely derived from CKEditor,+ footnotes and math are `ISC`, keyboard_marker `GPL-3.0`. Files written for Trilium carry no+ upstream header, and stamping one on them misattributes the work.+- Fix: match the sibling files in that plugin folder and its README — don't add or strip headers+ wholesale. (Minor.)**Augmentation via the wrong module.**- Spot: `declare module '@ckeditor/ckeditor5-core'` (the upstream pattern) in a `.d.ts` /@@ -241,12 +247,13 @@ nothing loads it, no button shows, or lint/license/localization is off.- Fix: add the string to `lang/en.po` and its context note to `lang/contexts.json`. (See theLocalization group above.)-**Wrong test environment.**-- Spot: a widget/toolbar/layout-dependent test (anything needing real DOM geometry, focus, or- rendering) running under **happy-dom** instead of browser mode; or vice-versa, a plain- model/conversion test forced into the heavier browser mode.-- Why: Trilium splits environments — admonition/collapsible use **happy-dom**;- math/mermaid/footnotes/keyboard-marker use **`@vitest/browser-webdriverio` browser mode** (NOT- Playwright). A widget test under happy-dom gives false passes/failures because layout isn't real.-- Fix: match the plugin's configured environment; move browser-dependent assertions to a- browser-mode package/config.+**Test written against the wrong DOM assumptions.**+- Spot: a synthetic event dispatched without `cancelable: true` whose `preventDefault()` is then+ expected to suppress native behaviour; an assertion made immediately after an event the browser+ dispatches asynchronously (`<details>` `toggle`, for one); or `preventDefault` used as proof+ that a handler ran when a CKEditor plugin also calls it.+- Why: both CKEditor packages run in **real headless Chrome** (`@vitest/browser-webdriverio`, NOT+ Playwright). Tests ported from the old happy-dom setup relied on stubbed layout and synchronous+ events, and pass or fail for the wrong reasons here.+- Fix: make synthetic events cancelable, await the real event before asserting, and prove a handler+ ran by spying on `editor.execute` or asserting the model.diff --git a/.claude/skills/ckeditor5-testing/SKILL.md b/.claude/skills/ckeditor5-testing/SKILL.mdindex ce9a40fe8e..b42bcb6f86 100644--- a/.claude/skills/ckeditor5-testing/SKILL.md+++ b/.claude/skills/ckeditor5-testing/SKILL.md@@ -2,10 +2,10 @@name: ckeditor5-testingdescription: >-Testing CKEditor 5 plugins in the Trilium monorepo. Use when adding or- reviewing unit tests for a packages/ckeditor5-* package, debugging a failing- test, or setting up a package's test runner. Covers the two Vitest- environments Trilium uses (happy-dom and the WebdriverIO browser mode), the- per-package vitest.config.ts, testing against a real ClassicEditor, the+ reviewing unit tests for the packages/ckeditor5 aggregate (including its+ in-tree plugins under src/plugins/) or packages/ckeditor5-math, debugging a+ failing test, or setting up a package's test runner. Covers the WebdriverIO+ browser-mode Vitest setup, the vitest.config.ts, testing against a real ClassicEditor, themodel/view helpers imported from 'ckeditor5' (_setModelData / _getModelData /_getViewData and their {}/[] selection syntax), vi spies/mocks, idiomaticpatterns for schema/conversion/command/UI tests, the pnpm --filter runner, and@@ -15,17 +15,17 @@ description: >-# CKEditor 5 testing (Trilium)-Testing CKEditor 5 plugins in the **Trilium (TriliumNext Notes) monorepo**. **Tests are co-located-`*.spec.ts` next to the source** for the aggregator (`packages/ckeditor5`), in-aggregator plugins,-and any new code — matching the repo-wide convention. The existing standalone packages-(`packages/ckeditor5-<name>/`) keep their legacy `tests/` directories. Browser-mode packages gate-`src/**` at **100% coverage**, so every code change should ship with a test.+Testing CKEditor 5 plugins in the **Trilium (TriliumNext Notes) monorepo**. Nearly everything lives+in one package, `packages/ckeditor5`, with **tests co-located as `*.spec.ts` next to the source** —+including every plugin under `src/plugins/`. `packages/ckeditor5-math` is the last separate package+and still keeps a legacy `tests/` directory. Both gate `src/**` at **100% coverage** on all four+metrics, so every code change must ship with a test.## Scope & sourcesThis skill covers testing CKEditor 5 plugins in the **Trilium (TriliumNext Notes) monorepo**-(`packages/ckeditor5-*`). The CKEditor 5 library is pinned to 48.2.0. For general (non-CKEditor)-Trilium testing, see the `writing-unit-tests` skill.+(`packages/ckeditor5` and `packages/ckeditor5-math`). The CKEditor 5 library is pinned to 48.3.1.+For general (non-CKEditor) Trilium testing, see the `writing-unit-tests` skill.## When to use this skill@@ -35,33 +35,35 @@ Trilium testing (Preact components, jQuery widgets, server routes), use `writing## The current setup at a glance-- **Runner:** Vitest (`[email protected]`). **No shared factory** — each package has its own+- **Runner:** Vitest (`[email protected]`). **No shared factory** — each package has its own`vitest.config.ts` built with `defineConfig` directly.-- **Two environments**, chosen per package:- - **happy-dom** (`environment: "happy-dom"`) — used by `admonition`, `collapsible`. Light, no- coverage thresholds. happy-dom is **not a real browser**: `getBoundingClientRect()` returns- zeros, layout is stubbed, `ResizeObserver` is stubbed. Fine for model/conversion/command- logic; wrong for anything that measures the DOM.- - **WebdriverIO browser mode** (`@vitest/browser-webdriverio`, headless Chrome) — used by- `footnotes`, `keyboard-marker`, `math`, `mermaid`. Real DOM/layout. Gates `src/**` coverage- at 100% (lines/functions/branches/statements). This is **not Playwright**.+- **One environment: WebdriverIO browser mode** (`@vitest/browser-webdriverio`, headless Chrome),+ used by both `ckeditor5` and `ckeditor5-math`. Real DOM and real layout, so+ `getBoundingClientRect()`, `elementFromPoint()` and pointer events behave as in a browser. Gates+ `src/**` coverage at 100% (lines/functions/branches/statements). This is **not Playwright**.+ - Trilium used to run some plugins on **happy-dom**; that is gone. If you are porting an old+ test, note the two differences that bite: happy-dom returned zeros from layout APIs (so+ measurement-dependent code silently "passed"), and it fired some DOM events synchronously+ where a real browser defers them — `<details>` fires `toggle` on a later task, for one.+ Synthetic events also need `cancelable: true` before `preventDefault()` means anything.- **Real editor, no test-editor factories.** Tests create a real `ClassicEditor` against a realDOM element (see below). There is **no** `ModelTestEditor`/`VirtualTestEditor`/`ClassicTestEditor`in Trilium — those live only in the upstream ckeditor5 monorepo's `tests/_utils`.- **Helpers from `'ckeditor5'`:** `_setModelData`, `_getModelData`, `_getViewData` are importedfrom the `ckeditor5` package.-- **Test-file location:** **co-located `*.spec.ts`** next to the source is the default — the- aggregator, in-aggregator plugins (`src/plugins/foo.spec.ts`), and new code, with vitest- `include: ['src/**/*.spec.ts']` (as on `feature/collapsible_experiment`). The existing standalone- packages instead use a `tests/` dir (`include: ['tests/**/*.[jt]s']`, no `.spec` suffix) — leave- them; new standalone packages should use co-located `.spec.ts` too. `globals: true`. Coverage- provider `v8`, `include: src/**` (test files themselves excluded from coverage). The aggregate- (`packages/ckeditor5`) must also `exclude: ['**/ckeditor5-*/**']` + `allowExternal: false` or the- imported sibling packages bleed in (see `references/running-and-config.md`).+- **Test-file location:** **co-located `*.spec.ts`** next to the source, including inside plugin+ folders (`src/plugins/<name>/<name>.spec.ts`), with vitest `include: ['src/**/*.spec.ts']`.+ `packages/ckeditor5-math` is the exception and still uses a `tests/` dir+ (`include: ['tests/**/*.[jt]s']`, no `.spec` suffix); fold new math tests in alongside those, but+ anything new elsewhere is co-located. `globals: true`. Coverage provider `v8`,+ `include: src/**` (test files themselves excluded from coverage). The aggregate keeps+ `allowExternal: false` so an imported sibling package cannot bleed into its report (see+ `references/running-and-config.md`).- **Imports** from `'ckeditor5'`; in-package source imports use a file extension.- **License key:** tests pass `licenseKey: 'GPL'` in the editor config.-- Some packages (`admonition`, `footnotes`, `keyboard-marker`) have a vitest config but **no- tests yet** — adding tests is encouraged.+- **Every plugin folded into the aggregate carries its own tests**, and the 100% gate keeps it+ that way. Unreachable code is the usual reason the gate cannot be met — see+ `references/test-conventions.md` for how Trilium handles it.## Running tests@@ -78,8 +80,8 @@ vitest --inspect-brk --no-file-parallelism --browser.headless=false```Root orchestration: `pnpm test:parallel` runs the light packages in parallel; `pnpm-test:sequential` runs `math` and `mermaid` **sequentially** (browser resource limits).-`pnpm test:all` runs both. Each package exposes `"test": "vitest"` and+test:sequential` runs `ckeditor5` and `ckeditor5-math` **sequentially** (browser resource+limits), alongside the server. `pnpm test:all` runs both. Each package exposes `"test": "vitest"` and`"test:debug": "vitest --inspect-brk --no-file-parallelism --browser.headless=false"`.## Anatomy of a test@@ -172,14 +174,14 @@ into later specs.) See `references/patterns.md` for the recipe.|------|-----------|| `references/test-utilities.md` | Testing against a real `ClassicEditor` (lifecycle, `licenseKey: 'GPL'`), and the `_setModelData`/`_getModelData`/`_getViewData` helpers from `'ckeditor5'` + the `[]`/`{}` selection syntax. || `references/patterns.md` | Idiomatic recipes per concern (schema, conversion round-trips, commands, UI, keystrokes, events, async), all against a real editor; the `glob`/clipboard/jQuery-`$` stubbing recipe (via the globals kit's `installGlobMock`/`mockClipboard`); note on the 100% coverage gate for browser-mode packages. |-| `references/running-and-config.md` | Per-package `vitest.config.ts` (happy-dom shape and WebdriverIO browser shape), `pnpm --filter` commands, the debug command, `pnpm test:parallel`/`test:sequential` (math+mermaid sequential), coverage thresholds. |-| `references/test-conventions.md` | Trilium test **conventions & gotchas**: choosing happy-dom vs. browser mode, real-editor teardown, the both-assertion-styles note, sequential math/mermaid, and the pointer to `writing-unit-tests`. |+| `references/running-and-config.md` | The WebdriverIO `vitest.config.ts` shape, `pnpm --filter` commands, the debug command, `pnpm test:parallel`/`test:sequential` (ckeditor5 + math sequential), coverage thresholds. |+| `references/test-conventions.md` | Trilium test **conventions & gotchas**: real-browser event timing, real-editor teardown, the both-assertion-styles note, unreachable code vs. the 100% gate, and the pointer to `writing-unit-tests`. |## Quick review checklistWhen reviewing tests: editor created in `beforeEach` with `licenseKey: 'GPL'` and **destroyed**in `afterEach` (plus `editorElement.remove()`); model/view asserted via`_getModelData`/`_getViewData` with correct `[]`/`{}` selection syntax; spies via `vi`; behavior-covered for collapsed **and** ranged selections and schema-disallowed contexts; for browser-mode-packages, new `src/` lines covered (100% gate); no reliance on real layout when the package uses-happy-dom.+covered for collapsed **and** ranged selections and schema-disallowed contexts; new `src/` lines+covered (100% gate), with any `/* v8 ignore */` carrying a comment that justifies why the code is+unreachable.diff --git a/.claude/skills/ckeditor5-testing/references/patterns.md b/.claude/skills/ckeditor5-testing/references/patterns.mdindex c7a1ed9045..f9312f7e80 100644--- a/.claude/skills/ckeditor5-testing/references/patterns.md+++ b/.claude/skills/ckeditor5-testing/references/patterns.md@@ -104,8 +104,8 @@ it( 'editing-downcasts to <mark> in the editing view', () => {```For widgets, assert the editing view contains the widget classes/attributes (`ck-widget`,-`contenteditable`) while `getData()` stays clean. Widget rendering needs real layout — run such-tests in a **browser-mode** package, not happy-dom.+`contenteditable`) while `getData()` stays clean. Widget rendering needs real layout, which the+browser-mode runner provides.## Commands@@ -203,10 +203,20 @@ it( 'throws on invalid config', () => {For `CKEditorError`, match the error id substring.-## Reaching 100% coverage (browser-mode packages)+## Reaching 100% coverage-Browser-mode packages (`footnotes`, `keyboard-marker`, `math`, `mermaid`) gate `src/**` at 100%+Both `ckeditor5` and `ckeditor5-math` gate `src/**` at 100%(lines/functions/branches/statements, provider `v8`). Every branch needs a test: both states ofeach boolean, each schema-allowed/disallowed path, collapsed vs. ranged selection, and error/guard-branches. happy-dom packages (`admonition`, `collapsible`) have **no** threshold. Run the package's-`test` script and read the coverage text report to find uncovered lines before pushing.+branches. Run the package's `test` script and read the coverage text report to find uncovered+lines before pushing.++When a branch resists covering, first ask whether it is reachable at all — Trilium's plugins have+repeatedly turned out to carry guards that nothing can trigger (an `if` over a non-empty array+literal, a selection fallback on an `isObject` element, a post-fixer branch the model writer+normalises away). The fix is to delete or simplify the dead code, not to invent a test for it. If+the guard genuinely earns its keep, keep it and mark it `/* v8 ignore next N -- why */` with the+reason spelled out. Two traps worth knowing: a disabled CKEditor `Command` silently skips+`execute()`, so a guard inside it needs `command.isEnabled = true` first; and CKEditor's own+plugins may call `preventDefault()` on an event, so use a spy on `editor.execute` (or assert the+model) rather than `preventDefault` to prove your handler ran.diff --git a/.claude/skills/ckeditor5-testing/references/running-and-config.md b/.claude/skills/ckeditor5-testing/references/running-and-config.mdindex df5176a0ce..737687492d 100644--- a/.claude/skills/ckeditor5-testing/references/running-and-config.md+++ b/.claude/skills/ckeditor5-testing/references/running-and-config.md@@ -1,7 +1,9 @@# Running tests & configuration (Trilium)-Trilium gives **each** `packages/ckeditor5-*` package its own `vitest.config.ts` (built with-`defineConfig` directly — there is no shared factory). Vitest is `4.1.8`.+Two packages carry CKEditor 5 tests: `packages/ckeditor5` (the aggregate, which holds every+in-tree plugin under `src/plugins/`) and `packages/ckeditor5-math`. Each has its own+`vitest.config.ts` built with `defineConfig` directly — there is no shared factory. Vitest is+`4.1.10`.## Per-package scripts@@ -21,39 +23,11 @@ pnpm --filter @triliumnext/ckeditor5-math testOr, from the package directory: `vitest run`. Add `-t "name"` to filter by test name, or afilename substring to filter by file.-## Two config shapes+## The config shape-### happy-dom (e.g. `admonition`, `collapsible`)--Light, no coverage thresholds. Not a real browser — `getBoundingClientRect()` is zeroed, layout-and `ResizeObserver` are stubbed. Use for model/conversion/command logic.--```ts-import { defineConfig } from 'vitest/config';-import svg from 'vite-plugin-svgo';--export default defineConfig( {- plugins: [ svg() ],- test: {- environment: 'happy-dom',- include: [ 'tests/**/*.[jt]s' ],- globals: true,- watch: false,- passWithNoTests: true,- coverage: {- provider: 'v8',- include: [ 'src/**/*.{ts,tsx}' ],- exclude: [ '**/*.{test,spec}.{ts,mts,cts,tsx,js,jsx}', '**/*.d.ts' ],- reporter: [ 'text', 'lcov' ]- }- }-} );-```--### WebdriverIO browser mode (e.g. `footnotes`, `keyboard-marker`, `math`, `mermaid`)--Real headless Chrome via `@vitest/browser-webdriverio` (**not** Playwright). Real DOM/layout.-Gates `src/**` coverage at 100%.+Both packages run **WebdriverIO browser mode**: real headless Chrome via+`@vitest/browser-webdriverio` (**not** Playwright), with real DOM and layout, gating `src/**`+coverage at 100%. Trilium previously ran some plugins on happy-dom; no CKEditor package does now.```tsimport { defineConfig } from 'vitest/config';@@ -70,8 +44,8 @@ export default defineConfig( {ui: false,instances: [ { browser: 'chrome' } ]},- include: [ 'tests/**/*.[jt]s' ],- exclude: [ 'tests/setup.ts' ],+ include: [ 'src/**/*.spec.ts' ], // math instead uses [ 'tests/**/*.[jt]s' ]+ setupFiles: [ './test/setup.ts' ], // aggregate only — wires the editor-kit teardownglobals: true,watch: false,coverage: {@@ -85,25 +59,26 @@ export default defineConfig( {} );```-Common to both: `globals: true`, the `vite-plugin-svgo` plugin so `import icon from './x.svg'`+Also standard: `globals: true`, the `vite-plugin-svgo` plugin so `import icon from './x.svg'`resolves, and coverage via `v8` over `src/**` (test files themselves excluded).-**Test-file location depends on where the code lives.** The two configs above are the existing-**standalone packages**, which use a `tests/` directory (`include: ['tests/**/*.[jt]s']`, no-`.spec` suffix) — keep them that way. The **aggregator** (`packages/ckeditor5`), **in-aggregator-plugins** (`src/plugins/`), and **any new code** instead use **co-located `*.spec.ts`** next to the-source — vitest `include: ['src/**/*.spec.ts']` (e.g. `src/plugins/collapsible_list_items.spec.ts`).-This is the repo-wide convention (see the `writing-unit-tests` skill) and what-`feature/collapsible_experiment` uses. New standalone packages should also adopt co-located-`.spec.ts`.+**Test-file location.** `packages/ckeditor5` uses **co-located `*.spec.ts`** next to the source —+`include: ['src/**/*.spec.ts']` — including inside plugin folders, e.g.+`src/plugins/collapsible/collapsible_editing.spec.ts`. That is the repo-wide convention (see the+`writing-unit-tests` skill). `packages/ckeditor5-math` still uses a `tests/` directory+(`include: ['tests/**/*.[jt]s']`, no `.spec` suffix); add math tests there, and use co-located+`.spec.ts` everywhere else.++The aggregate also sets `setupFiles: ['./test/setup.ts']`, which wires the global `afterEach` that+destroys editors created through `test/editor-kit.ts`.## Coverage scope for the aggregate (`packages/ckeditor5`)-The aggregate **imports** the sibling `@triliumnext/ckeditor5-*` workspace packages, so a plain-`--coverage` run instruments their loaded `src/` too — and the `include: ['src/**']` glob matches-those sibling sources. The report then reads a misleading **~48%** instead of the aggregate's real-number. Those siblings carry their own 100% gates in their own packages, so scope the aggregate's-report to its own sources only — `packages/ckeditor5/vitest.config.ts` does this with:+The aggregate **imports** `@triliumnext/ckeditor5-math`, so a plain `--coverage` run instruments+its loaded `src/` too — and the `include: ['src/**']` glob matches those sibling sources, dragging+the report well below the aggregate's real number. Math carries its own 100% gate in its own+package, so scope the aggregate's report to its own sources only —+`packages/ckeditor5/vitest.config.ts` does this with:```tscoverage: {@@ -140,19 +115,17 @@ The root `package.json` splits the run because the browser-mode packages competeresources:```bash-pnpm test:parallel # all but math & mermaid (and server/ckeditor5), in parallel-pnpm test:sequential # math & mermaid (and server/ckeditor5), sequentially+pnpm test:parallel # everything except server, ckeditor5 and ckeditor5-math, in parallel+pnpm test:sequential # server, ckeditor5 and ckeditor5-math, sequentiallypnpm test:all # test:parallel && test:sequential```-`math` and `mermaid` **must** run sequentially — running multiple headless Chrome instances at-once exhausts resources. The aggregator (`ckeditor5`) is also in the sequential group (its-`src/**/*.spec.ts` includes browser-mode specs); `server` is there for a different reason (shared-test DB, per `CLAUDE.md`), not browser limits. Light (happy-dom) packages run in parallel.+`ckeditor5` and `ckeditor5-math` **must** run sequentially — running multiple headless Chrome+instances at once exhausts resources. `server` is in the same group for a different reason (shared+test DB, per `CLAUDE.md`), not browser limits. Everything else runs in parallel.## Notes-- Some packages (`admonition`, `footnotes`, `keyboard-marker`) have a vitest config but **no tests- yet** (`passWithNoTests` / empty `tests/`). Adding tests is encouraged.+- Both packages are at **100% coverage** and gated there, so a change that adds a line adds a test.- There are **no** manual-test or memory-leak harnesses in the Trilium plugin packages (thoseexist only in the upstream ckeditor5 monorepo).diff --git a/.claude/skills/ckeditor5-testing/references/test-conventions.md b/.claude/skills/ckeditor5-testing/references/test-conventions.mdindex a470b9283a..28979ae030 100644--- a/.claude/skills/ckeditor5-testing/references/test-conventions.md+++ b/.claude/skills/ckeditor5-testing/references/test-conventions.md@@ -4,22 +4,22 @@ Trilium never used Karma/Mocha/Sinon — the plugin tests are Vitest from the stmigration to do. This reference collects the Trilium-specific conventions and traps when writingCKEditor 5 plugin tests.-## Choosing an environment: happy-dom vs. browser mode+## The environment: WebdriverIO browser mode-Pick per package (set in the package's `vitest.config.ts`):+Both `packages/ckeditor5` and `packages/ckeditor5-math` run tests in **real headless Chrome** via+`@vitest/browser-webdriverio`, so layout, `getBoundingClientRect()`, `elementFromPoint()` and+pointer events all behave as they do in a browser. Both gate `src/**` at 100% coverage.-- **happy-dom** (`admonition`, `collapsible`) — fast, but **not a real browser**.- `getBoundingClientRect()` returns zeros, layout is stubbed, `ResizeObserver` is stubbed. Good- for model logic, schema, conversion, and command behavior that never measures the DOM.-- **WebdriverIO browser mode** (`footnotes`, `keyboard-marker`, `math`, `mermaid`) — real headless- Chrome, real layout. Required for anything that measures or positions DOM: widget rendering,- balloon/toolbar placement, focus, scrolling, `getBoundingClientRect`. Gates `src/**` at 100%- coverage.+Trilium used to run some plugins on happy-dom. Nothing does now, but the difference matters when+porting an older test:-If a test depends on real measurements and the package is on happy-dom, it will silently get zero-sizes — move the package (or the test) to browser mode rather than working around stubs. The-general `writing-unit-tests` skill reserves `@vitest/browser` for exactly these real-layout needs-(CKEditor, Excalidraw).+- happy-dom returned **zeros** from layout APIs, so measurement-dependent code appeared to work+ while never really being exercised.+- happy-dom dispatched some events **synchronously** that a real browser defers. `<details>` fires+ `toggle` on a later task, for instance, so assert after awaiting the event rather than straight+ after the click.+- Synthetic events need `cancelable: true` for `preventDefault()` to have any effect. Without it,+ native behaviour (a `<summary>` toggling, say) still runs and the test reads as a product bug.## Real-editor lifecycle & teardown@@ -71,18 +71,19 @@ directly: `expect( _getModelData( model ) ).toEqual( '<paragraph>…</paragraph>- Import `_setModelData`, `_getModelData`, `_getViewData` (and editor classes, `keyCodes`, etc.)from `'ckeditor5'`. In-package source imports use a file extension (`../src/foo.js`).- Spies/mocks via `vi` (`vi.spyOn` / `vi.fn` / `vi.useFakeTimers`).-- Test-file location: **co-located `*.spec.ts`** by default (aggregator, in-aggregator plugins,- new code; `include: ['src/**/*.spec.ts']`). The existing standalone packages keep a `tests/` dir- (`tests/**/*.[jt]s`, no `.spec` suffix); new packages should use co-located `.spec.ts`.+- Test-file location: **co-located `*.spec.ts`** in `packages/ckeditor5`, including inside plugin+ folders (`include: ['src/**/*.spec.ts']`). `packages/ckeditor5-math` still keeps a `tests/` dir+ (`tests/**/*.[jt]s`, no `.spec` suffix); everything else is co-located.-## Running math & mermaid+## Running the browser-mode packages-`math` and `mermaid` run **sequentially** at the root (`pnpm test:sequential`) because each spins-up headless Chrome and they exhaust resources if run in parallel. Other packages run via-`pnpm test:parallel`. When running a single package, use `pnpm --filter @triliumnext/ckeditor5-<name> test`.+`ckeditor5` and `ckeditor5-math` run **sequentially** at the root (`pnpm test:sequential`) because+each spins up headless Chrome and they exhaust resources in parallel. Everything else runs via+`pnpm test:parallel`. For a single package, use `pnpm --filter @triliumnext/ckeditor5 test` (or+`...-math`).## See alsoFor general (non-CKEditor) Trilium testing — Preact components, jQuery widgets, client services,-server routes — use the `writing-unit-tests` skill, which also documents happy-dom's limits and-when to reach for `@vitest/browser`.+server routes — use the `writing-unit-tests` skill, which also documents when to reach for+`@vitest/browser` rather than the default happy-dom environment those tests use.