Skip to content

Make sure all data parsing or schema related checks use proper/actual root #20026

@niegowski

Description

@niegowski

Describe the task

CKEditor 5 contains numerous places where '$root' is hardcoded as the schema context for validation, data parsing, and command enable-state checks.

This works today because $root is the only root element name in use. However, once #20029 lands - allowing config.root.modelElement to configure a custom root element name - all those hardcoded references will silently operate against the wrong schema context, causing:

  • Commands being incorrectly enabled/disabled in editors with a custom root
  • DataController.parse() / toModel() validating content against $root schema rules instead of the actual configured root's rules, potentially dropping valid content
  • Schema allowIn: '$root' registrations not covering the custom root, breaking content insertion

Definition of Done

  • Audit complete - all literal '$root' usages in packages/*/src/ are categorized as: (a) schema definition (intentional, defines the $root element itself), (b) schema context check (needs fixing), or (c) safe (e.g. clipboard's $clipboardHolder pattern - a different context).
  • Commands are context-aware - refresh() / isEnabled logic in all commands reads the actual root element name from the selection or document instead of hardcoding '$root'. A shared utility or accessor is used to avoid divergence.
  • Data parsing calls pass explicit context - every call to DataController.parse() and toModel() outside of the engine core passes the actual ModelRootElement (or its name) as the context, not relying on the '$root' default.
  • Schema allowIn registrations are root-agnostic - features that register allowIn: '$root' either use the schema's generic $container/$block inheritance chain where applicable, or dynamically read the configured root name from config.root.modelElement (introduced in Allow passing config.root.modelElement etc. in the configuration to define the model root #20029).
  • No regression on the $root default - editors that do not configure config.root.modelElement continue to behave identically to today.
  • Automated tests cover all changed command refresh() paths and data parsing paths with a non-$root root context.

Metadata

Metadata

Assignees

Labels

squad:coreIssue to be handled by the Core team.type:taskThis issue reports a chore (non-production change) and other types of "todos".

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions