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
chore(skills): add CKEditor 5 reviewing skill
Elian Doranf40ee2ad706c
diff --git a/.claude/skills/ckeditor5-plugin-development/SKILL.md b/.claude/skills/ckeditor5-plugin-development/SKILL.mdindex 3140acdab7..298c8bb637 100644--- a/.claude/skills/ckeditor5-plugin-development/SKILL.md+++ b/.claude/skills/ckeditor5-plugin-development/SKILL.md@@ -214,7 +214,9 @@ upcast + (data & editing) downcast converters; a `Command` whose `refresh()` setcorrectly (disabled where the schema disallows it); UI bound to command state and refocusing theediting view on execute; keyboard accessibility (keystrokes + `accessibility.addKeystrokeInfos`);all user-facing strings wrapped in `t()`; model changes inside `model.change()`; cleanup of-trackers/handlers in `destroy()`. Full version: `references/review-checklist.md`.+trackers/handlers in `destroy()`. Full version: `references/review-checklist.md`. To **drive** a+review (workflow, CKEditor-specific defect patterns, contribution process), use the separate+**`ckeditor5-reviewing`** skill, which delegates back to this checklist.## Provenance & source referencesdiff --git a/.claude/skills/ckeditor5-reviewing/SKILL.md b/.claude/skills/ckeditor5-reviewing/SKILL.mdnew file mode 100644index 0000000000..04773df451--- /dev/null+++ b/.claude/skills/ckeditor5-reviewing/SKILL.md@@ -0,0 +1,105 @@+---+name: ckeditor5-reviewing+description: >-+ Review or audit CKEditor 5 plugin/feature code or a PR/diff. Use when checking+ a CKEditor 5 plugin for correctness, idiom, and project process: schema /+ conversion / command / UI / widget code, CKEditor-specific defects (asymmetric+ upcast/downcast, unconsumed upcast elements, missing inline-widget position+ mapping, command refresh/isEnabled bugs, memory leaks, t() gaps, editing/UI+ split violations, post-v42 import mistakes), and contribution process+ (changelog entries, commits, coverage). Pairs with the+ ckeditor5-plugin-development and ckeditor5-testing skills and delegates their+ checklists.+---++# Reviewing CKEditor 5 plugins++A workflow and defect catalog for **reviewing** CKEditor 5 plugin/feature code — a distinct task+from writing it. This skill orchestrates the review and hunts CKEditor-specific bugs; it+**delegates the per-dimension "is this idiomatic?" checklists** to 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.++Use those for "does this follow the conventions"; use this skill for **how to drive the review**+and **what subtle things tend to be wrong**.++## When to use++Reviewing a PR or diff that touches a CKEditor 5 plugin; auditing an existing plugin; sanity-+checking your own feature before opening a PR. For *writing* the feature, use+`ckeditor5-plugin-development`; for *writing tests*, use `ckeditor5-testing`.++## Review workflow++1. **Scope the diff.** What surface changed — editing (schema/conversion/command), UI+ (componentFactory/buttons/dropdowns/balloons), a widget, an editor type, config? New plugin or+ a change to an existing one? Which package(s)? This tells you which checklists and defect+ groups apply.+2. **Read model-first.** The model is the source of truth; trace the feature in order+ **schema → conversion → command → UI**. Confirm each layer is present and consistent (e.g. a+ new model element has a schema registration *and* upcast *and* downcast *and* an insertion path).+3. **Run the tests + coverage** for the affected package (see `ckeditor5-testing`). CKEditor holds+ **100% branch coverage**, but coverage ≠ correctness: confirm the *change itself* is tested,+ not just that lines are hit. A bug fix with no new/changed test is a red flag even at 100%.+4. **Observe behavior.** Attach the CKEditor Inspector (model / view / schema / commands), then:+ round-trip `editor.getData()` → `setData()` (does content survive a save?); exercise selection+ edge cases (collapsed vs. ranged, inside objects/limits, at attribute boundaries); toggle+ read-only.+5. **Apply the dimension checklists** (delegate to the two companion skills).+6. **Hunt defects** with `references/defect-patterns.md` — the high-value, easy-to-miss failure+ modes specific to CKEditor.+7. **Verify each finding before reporting it** (see below). Reproduce it, or cite the exact line+ and the rule it breaks. Discard the ones that don't hold up.+8. **Check process** (if the project follows CKEditor's): changelog entry, commit/PR conventions,+ CLA, signed commits — `references/contribution-process.md`.+9. **Report** findings: severity-tagged, `file:line`, with the concrete fix or question.++## Triage / severity++- **Blocker** — data loss (content dropped on `getData()`), crashes/console errors, undo+ corruption, broken collaboration (non-OT model mutation), security (unsanitized HTML/XSS),+ schema corruption.+- **Major** — incorrect behavior in real selections, accessibility gaps (no keyboard path, missing+ labels/`addKeystrokeInfos`), memory leaks, command enabled where the schema disallows it.+- **Minor** — convention/naming/import-style issues, missing `t()`, redundant converters,+ non-idiomatic but working code.+- **Nit** — style preferences with no behavioral impact; mark them as optional.++Lead with blockers/majors; don't bury them under nits.++## Verify before reporting (avoid false positives)++A noisy review erodes trust. Confirm a finding is real before raising it. Common **false+positives** to *not* raise:++- "Missing downcast" when the code uses a **two-way** helper (`conversion.attributeToElement(...)`+ registers both directions) — count two-way helpers, not just `for('dataDowncast')`.+- "`getAttribute('data-x')` should be `.dataset`" inside a **converter callback** — that's a view+ element, not DOM; `.dataset` would silently drop the value (see the plugin-dev `conversion.md`+ view-element pitfall).+- "Boolean attribute should be set to `false`" — the idiom is to **remove** it (yields `undefined`).+- "Button state not updated" when it's `bind()`-ed to the command (reactive, not imperative).+- "Listener never removed" when added via `this.listenTo()` (auto-cleaned in `destroy()`).++When unsure, phrase it as a **question** ("Is `<mark>` intended to round-trip through `getData()`?+I don't see a `dataDowncast`.") rather than a false assertion.++## Reference map++| File | Use it for |+|------|-----------|+| `references/defect-patterns.md` | The CKEditor-specific bug catalog: for each, the symptom, how to spot it in a diff, why it's wrong, and the fix. The core of a correctness review. |+| `references/contribution-process.md` | Project process a reviewer validates: file-based changelog entries (`.changelog/`, types/scope/closes), commit & PR conventions, branch naming, CLA, signed commits, coverage expectations. Relevant when reviewing for the ckeditor5 project or a package that adopts its process. |++## Provenance & source references++Self-contained and library-focused. Any `docs/…` / `packages/…` / `.changelog/` paths or the+baseline commit point into the **upstream CKEditor 5 repository**+([github.com/ckeditor/ckeditor5](https://github.com/ckeditor/ckeditor5)), not the project you are+reviewing. Distilled at upstream commit **`9ecca53627`** (mid-2026) from+`docs/framework/contributing/{contributing,changelog-entries,code-style}.md` and the patterns in+the companion skills. To refresh, compare those paths against that commit inside a clone of+ckeditor5 and bump the reference here.diff --git a/.claude/skills/ckeditor5-reviewing/references/contribution-process.md b/.claude/skills/ckeditor5-reviewing/references/contribution-process.mdnew file mode 100644index 0000000000..5255c35377--- /dev/null+++ b/.claude/skills/ckeditor5-reviewing/references/contribution-process.md@@ -0,0 +1,90 @@+# Contribution process (what a reviewer validates)++The process side of a review — relevant when reviewing for the **ckeditor5 project itself**, or a+package that adopts its conventions. (A standalone plugin in your own repo may use a different+process; treat this as the upstream model.) Paths like `.changelog/` refer to the upstream repo.++## Changelog entries (file-based)++CKEditor uses a Markdown, file-based changelog (Changesets-style): each change ships a file in+`.changelog/` that is compiled into the release changelog. **A PR with user-facing changes is+expected to include a changelog entry.**++- Create with **`pnpm run nice`** (NICE = New Individual Changelog Entry). It writes+ `.changelog/YYYYMMDDHHMMSS_{branch-name}.md` with a frontmatter template to fill in. One file =+ **one change** (add several files for several changes).+- Frontmatter fields:+ - `type` (**required**) — one of:+ | type | release | meaning |+ |------|---------|---------|+ | `Feature` | minor | new user-facing functionality |+ | `Fix` | patch | bug fix / small improvement |+ | `Other` | patch | enhancement/refactor, not a fix or feature (e.g. API cleanup) |+ | `Major breaking change` | major | breaks the integration / plugin-dev API |+ | `Minor breaking change` | minor | breaks the low-level customizable API |+ - `scope` (optional) — affected package short name(s), `@ckeditor/` stripped (e.g. `ckeditor5-ui`);+ most-impacted first; omit for broad/generic changes; use `ckeditor5` for the main package.+ - `closes` / `see` (optional) — issues resolved / referenced. Formats: `123`,+ `ckeditor/ckeditor5#123`, or full URL.+ - `communityCredits` (optional) — GitHub usernames of external contributors to credit.+ - **body** (**required**) — a concise, **user-facing** summary (this text ships in the public+ changelog). Reference methods as `ClassName#methodName()`.++Example:++```md+---+type: Fix+scope:+ - ckeditor5-link+closes:+ - 14724+---++The link balloon no longer steals focus when opening via keyboard.+```++**As a reviewer**, validate the entry (the changelog doc assigns this explicitly): correct `type`,+right issue reference(s), breaking-change flagged correctly, grammar, and that the message makes+sense to *other developers* in the context of the whole editor — not just to the author. Fix it via+GitHub suggestions if needed. The new file-based system is for **public, user-facing** changes only+(internal-only changes need no entry).++## Tests & coverage++- **100% code coverage including branches** is required; PRs with missing tests are not accepted.+- Coverage is necessary but not sufficient: **every change must be tested** — a bug fix that doesn't+ move coverage still needs a test proving the fix. A manual test may also be requested.+- See the `ckeditor5-testing` skill for how the suite runs.++## Code style++Enforced partly by Git hooks (lint + style on commit), but not everything is auto-caught — review+against the `ckeditor5-plugin-development` skill's `references/conventions.md`. Don't rely on tools+alone.++## Pull requests++- Open/identify a **ticket** first (skippable only for trivial typo/doc changes); reference the+ ticket(s) the PR resolves.+- Branch naming: **`i/GITHUB-ISSUE-NUMBER`**.+- **Minimal & focused** — only what the ticket describes; no unrelated changes squeezed in.+- Provide context in the PR: how to test, decisions made, known problems.+- Merge: typically **Squash and merge** (the changelog comes from the `.changelog/` file, not the+ commit messages, so you don't copy anything at merge time).++## CLA & signed commits++- A signed **Contributor License Agreement** (cla.ckeditor.com) is required for contributions to be+ accepted.+- Since **January 2025**, all commits to the main branches **must be signed** (Git signing; the GPG+ key's name/email must match the committer). Part of their SOC2 compliance.++## Reviewer checklist (process)++- [ ] Changelog entry present for user-facing changes, with correct `type`/`scope`/`closes` and a+ clear user-facing body.+- [ ] Tests cover the change itself; coverage stays at 100%.+- [ ] PR is minimal and references its ticket; branch is `i/NNN`.+- [ ] Breaking changes flagged (`Major`/`Minor breaking change`) and justified.+- [ ] Commits signed; CLA in place (for external contributors).diff --git a/.claude/skills/ckeditor5-reviewing/references/defect-patterns.md b/.claude/skills/ckeditor5-reviewing/references/defect-patterns.mdnew file mode 100644index 0000000000..06249e46d3--- /dev/null+++ b/.claude/skills/ckeditor5-reviewing/references/defect-patterns.md@@ -0,0 +1,167 @@+# CKEditor 5 defect patterns++The high-value, easy-to-miss failure modes to hunt during a correctness review. Each: **symptom**,+how to **spot** it in a diff, **why** it's wrong, and the **fix**. Grouped by layer. For the+idiomatic "how it should look," see the `ckeditor5-plugin-development` skill.++## Conversion++**Asymmetric / incomplete conversion.**+- Spot: a model element/attribute with an `upcast` but no `dataDowncast` (or vice versa); or only+ `editingDowncast`. Count `for('upcast')` vs `for('dataDowncast')`/`for('editingDowncast')` — but+ remember a **two-way** helper (`conversion.elementToElement`/`attributeToElement`/`attributeToAttribute`)+ registers both directions at once.+- Why: missing `dataDowncast` → content silently dropped on `getData()` (data loss). Missing+ `upcast` → pasted/loaded HTML doesn't become the model. Missing `editingDowncast` → nothing+ renders in the editor.+- Fix: ensure every rendered/round-tripped element & attribute has matching upcast + downcast.++**Editing-only wrapping leaking into data.**+- Spot: `toWidget` / `toWidgetEditable` / UI elements / `contentEditable` / widget classes in a+ `dataDowncast` (or a two-way converter used for a widget).+- Why: `getData()` then emits editor-only markup (`ck-widget`, `contenteditable`) — dirty output.+- Fix: put widget wrapping in `editingDowncast` only; keep `dataDowncast` clean.++**Unconsumed elements in a custom upcast converter → duplication.**+- Spot: a manual `for('upcast').add(dispatcher => …)` that returns early without+ `consumable.consume(...)`, or never consumes the element it handles.+- Why: leftover elements get re-processed by catch-all converters (General HTML Support) →+ duplicated output like `<a><a>…</a></a>`.+- Fix: `test()` before `consume()`, and consume on **every** path that handles the element. (See the+ plugin-dev `conversion.md` consumables section.)++**View element treated as DOM.**+- Spot: `.dataset`, `.classList`, `.getAttributeNS`, `.style.x` on the element inside an+ upcast/downcast callback.+- Why: it's a CKEditor *view* element — those DOM-only APIs return `undefined` and silently drop+ data. Tests that mock the view tree won't catch it.+- Fix: `getAttribute` / `hasAttribute` / `hasClass` / `getClassNames()`; mutate via the view writer.++**Missing reconversion.**+- Spot: an `elementToElement`/`elementToStructure` whose view depends on a model attribute, but the+ attribute isn't listed in the model matcher (`model: { name, attributes: [ 'x' ] }`).+- Why: the view goes stale when the attribute changes (the converter doesn't re-run).+- Fix: declare the attribute to trigger reconversion, or use a separate `attributeToAttribute`/+ `attributeToElement` converter, or `editor.editing.reconvertItem(item)`.++## Schema++**Object/limit flags wrong.**+- Spot: a self-contained element registered without `$blockObject`/`$inlineObject` (or `isObject`);+ a nested editable (title/caption) without `isLimit`.+- Why: without object semantics the element is splittable/partly-selectable/mis-deleted; without+ `isLimit` the caret escapes the editable and Enter/Backspace break it.+- Fix: `inheritAllFrom: '$blockObject' | '$inlineObject'` for atomic elements; `isLimit: true` ++ `allowContentOf` for nested editables.++**Relying on the schema to filter pasted HTML.**+- Spot: assuming a disallowed attribute/element is stripped on paste purely via schema.+- Why: filtering happens at **conversion** — elements/attributes with no registered converter are+ dropped before the schema is consulted. Schema governs structure, not input sanitization.+- Fix: don't register converters for things you don't want; rely on conversion + (if needed) GHS+ config, not schema alone.++**Inline-widget position mapping missing.**+- Spot: an inline object whose view has more content than the model (e.g. `<placeholder>` →+ `<span>{name}</span>`) without a `viewToModelPosition` mapper.+- Why: selecting/traversing it throws `model-nodelist-offset-out-of-bounds`.+- Fix: `editor.editing.mapper.on('viewToModelPosition', viewToModelPositionOutsideModelElement(...))`.++## Commands++**`refresh()` doesn't gate on the schema.**+- Spot: `refresh()` that sets `this.isEnabled = true` unconditionally, or omits a+ `schema.checkAttributeInSelection` / `checkChild` / `findAllowedParent` check.+- Why: the button is enabled where the action is illegal → no-op clicks or schema violations.+- Fix: derive `isEnabled` from a real schema check for the current selection.++**Model mutated outside `model.change()`.**+- Spot: `writer.*` calls or attribute changes not wrapped in `editor.model.change(writer => …)`.+- Why: changes outside a change block don't run conversion/diff → nothing happens (or corruption).+- Fix: wrap all model mutations; one logical operation = one `change()` block = one undo step.++**Boolean attribute stored as `false`.**+- Spot: `writer.setAttribute('secret', false, el)`.+- Why: the idiom is `true` to enable / **remove** to disable (→ `undefined`); `false` leaks into+ data and breaks `value` checks.+- Fix: `setAttribute(key, true)` / `removeAttribute(key)`.++**Collapsed vs. ranged not handled.**+- Spot: an attribute command that only loops `getRanges()` (ignores the collapsed-caret/selection-+ attribute case), or only sets the selection attribute (ignores ranged text).+- Fix: handle both — `getValidRanges()` for ranged, `setSelectionAttribute`/`removeSelectionAttribute`+ for collapsed.++**Read-only correctness.**+- Spot: a command that doesn't change data (opens a dialog, navigates) but gets disabled in+ read-only; or one that *does* change data but stays enabled.+- Fix: set `this.affectsData = false` for non-data commands; leave it `true` (default) otherwise.++**Fighting `refresh()`.**+- Spot: manual `command.isEnabled = false` from outside, undone on the next model change.+- Fix: `command.forceDisabled('MyFeature')` / `clearForceDisabled('MyFeature')`.++## UI++**State set imperatively instead of bound.**+- Spot: `button.isEnabled = …` / `button.isOn = …` updated by hand, or listeners syncing them.+- Why: drifts out of sync with the command.+- Fix: `button.bind('isOn','isEnabled').to(command,'value','isEnabled')`.++**Editor not refocused after an action.**+- Spot: a button/dropdown `execute` handler that runs the command but doesn't+ `editor.editing.view.focus()`.+- Why: focus stays on the button; the user can't keep typing.+- Fix: call `editor.editing.view.focus()` after executing.++**Views created without `locale`; missing a11y.**+- Spot: `new ButtonView()` with no `locale`; no `label` when `withText` is false; keystrokes not in+ `accessibility.addKeystrokeInfos`.+- Fix: pass `locale`; always set `label`; register keystroke info and the button `keystroke`.++## Lifecycle / leaks++**Trackers/handlers/timers not destroyed.**+- Spot: `FocusTracker`, `KeystrokeHandler`, `FocusCycler`, `ResizeObserver`, `setInterval`, or+ manually-added DOM listeners created but no `destroy()` cleaning them; balloon views never removed.+- Why: memory leaks across editor create/destroy cycles (CKEditor even has memory-leak tests).+- Fix: destroy them in the view/plugin `destroy()`; prefer `this.listenTo()` (auto-cleaned).++## Architecture / packaging++**Editing/UI split violated.**+- Spot: schema/converters/commands registered inside the `*UI` plugin; no glue plugin; missing+ `static get requires()` / `pluginName`.+- 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 (post-v42).**+- Spot: deep imports `@ckeditor/ckeditor5-*/src/...`; mixing the `ckeditor5` aggregate with+ individual `@ckeditor/*` packages in an app bundle; removed/renamed symbols (`Model`/`ViewModel`+ → `UIModel`; `icons.check` → `IconCheck` from `@ckeditor/ckeditor5-icons`).+- Why: deep paths aren't a supported entry; mixing risks duplicate module instances; renamed+ symbols don't exist.+- Fix: import from `ckeditor5` (and `ckeditor5-premium-features`); use current symbol names.++## Localization++**`t()` gaps / misuse.**+- Spot: user-facing strings not wrapped in `t()`; `t` renamed or called on a variable (JS static+ analyzer only recognizes a literal-arg `t()`); a reused string creating a new source message+ instead of aliasing `editor.locale.t`.+- Fix: wrap all UI strings in `t()` with a literal first arg; reuse via the `locale.t` alias.++## Undo / batching++**Unintended multiple undo steps.**+- Spot: several sibling `model.change()` blocks for what is one logical edit.+- Why: each block is a separate undo step — jarring UX.+- Fix: one `change()` per logical operation (nested `change()` folds into the outer batch).++## Tests (cross-check with the testing skill)++- Spot: a behavior change with no new/changed test; assertions via DOM instead of+ `_getModelData`/`_getViewData`; only one selection shape covered; editor not destroyed in+ `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.