Skip to content

Modified superscript and subscript text styles to be mutually exclusive.#20116

Open
martnpaneq wants to merge 10 commits into
masterfrom
ck/20000
Open

Modified superscript and subscript text styles to be mutually exclusive.#20116
martnpaneq wants to merge 10 commits into
masterfrom
ck/20000

Conversation

@martnpaneq
Copy link
Copy Markdown
Contributor

@martnpaneq martnpaneq commented Apr 28, 2026

🚀 Summary

The superscript and subscript text styles are now mutually exclusive: applying one to text that already has the other replaces it, matching the behavior of common word processors. The previous behavior, where both attributes could coexist on the same text, can be restored by setting config.basicStyles.superscript.allowNesting or config.basicStyles.subscript.allowNesting to true, which is useful for content such as isotope notation or tensor indices.


📌 Related issues


💡 Additional information

Screen.Recording.2026-04-28.at.12.31.35.mov

🧾 Checklists

Use the following checklists to ensure important areas were not overlooked.
This does not apply to feature-branch merges.
If an item is not relevant to this type of change, simply leave it unchecked.

Author checklist

  • Is the changelog entry intentionally omitted? (Changelog entry included.)
  • Is the change backward-compatible? (No, but it is treated as a fix. It changes the behaviour of superscript and subscript to be aligned with other solutions on the market.)
  • Have you considered the impact on different editor setups and core interactions? (e.g., classic/inline/multi-root/many editors, typing, selection, paste, tables, lists, images, collaboration, pagination) (Should not impact other editor setups in unpredicted way.)
  • Has the change been manually verified in the relevant setups? (Verified in a manual test.)
  • Does this change affect any of the above? (Not relevant.)
  • Is performance impacted? (Performance not impacted.)
  • Is accessibility affected? (Accessibility not affected.)
  • Have tests been added that fail without this change (against regression)? (Appropriate tests added.)
  • Have the API documentation, guides, feature digest, and related feature sections been updated where needed? (Documentation updated.)
  • Have metadata files (ckeditor5-metadata.json) been updated if needed? (Not relevant.)
  • Are there any changes the team should be informed about (e.g. architectural, difficult to revert in future versions or having impact on other features)? (This change does not have a big impact.)
  • Were these changes documented (in Logbook)?

Reviewer checklist

  • PR description explains the changes and the chosen approach (especially when performance, API, or UX is affected).
  • The changelog entry is clear, user‑ or integrator-facing, and it describes any breaking changes.
  • All new external dependencies have been approved and mentioned in LICENSE.md (if any).
  • All human-readable, translateable strings in this PR been introduced using t() (if any).
  • I manually verified the change (e.g., in manual tests or documentation).
  • The target branch is correct.

@martnpaneq martnpaneq marked this pull request as ready for review April 29, 2026 10:33
@martnpaneq martnpaneq requested a review from a team as a code owner April 29, 2026 10:33
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 44ef9f6. Configure here.

Comment thread packages/ckeditor5-basic-styles/src/augmentation.ts
Comment thread packages/ckeditor5-basic-styles/src/subscript/subscriptcommand.ts Outdated
Comment thread .changelog/20260428123311_ck_20000.md
Comment thread .changelog/20260428123311_ck_20000.md Outdated
Copy link
Copy Markdown
Contributor

@jacek-cke jacek-cke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pomek
Copy link
Copy Markdown
Member

pomek commented May 11, 2026

Edge case, but what would happen when both the subscript and superscript attributes are defined in the data on the editor load?

<p>
  Test: <sup><sub>2</sub></sup>.
</p>

I am wondering about the alternative approach:

Use a schema to control both attributes. This way, we do not have to provide additional configuration options. Instead, our docs can share a code snippet that would turn off this check.

By adding a postfixer, this approach resolves the potential issue with invalid HTML when creating the editor.

One caveat: we need to decide which attribute is more important. For the following conflict: <sup><sub>2</sub></sup>, do we expect that editor keeps

  • <sup>2</sup>, or
  • <sub>2</sub>

Maybe we can solve it at the upcast level, but I am not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Superscript and subscript can be active at the same time (formatting conflict)

3 participants