Skip to content

feat: theme EditorJS through its own custom properties - #250

Open
daphneslootmans wants to merge 1 commit into
masterfrom
64-editorjs-styling
Open

daphneslootmans wants to merge 1 commit into
masterfrom
64-editorjs-styling

Conversation

@daphneslootmans

@daphneslootmans daphneslootmans commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

What

Ports the EditorJS styling from automator-sumoapp-be-upgrade !18 into the bundle, and wires it up.

Why

Three separate problems:

  1. The component was dead code. assets/scss/components/_editorjs.scss was never listed in _imports.scss, so none of it compiled. It was added once in 4258f3a and never imported.
  2. Its rules were stale. They targeted pre-2.26 EditorJS class names (.ce-toolbox__button, .ce-settings__button, .ce-conversion-toolbar__label) and painted fifteen surfaces with $primary, a brand colour used as a surface token.
  3. A verbatim port would have shipped invisible hovers. The automator rules use var(--bs-secondary-bg) for hover on var(--bs-body-bg) surfaces. This fork sets $body-bg-dark and $body-secondary-bg-dark to the same $gray-800 (#383a43), so the two tokens are identical in dark mode.

How

EditorJS declares its whole popover palette as custom properties on .ce-popover (--color-background, --color-text-primary, --color-border, --color-background-item-hover, and so on). .ce-popover__container, .ce-popover-item, .ce-popover-item__title and .ce-popover-item__icon all read from those, so eight assignments replace roughly fifteen selector overrides and survive EditorJS reshuffling its internal markup.

Only the places EditorJS hardcodes a colour still need a selector: .ce-toolbar__plus / .ce-toolbar__settings-btn (#1d202b), .cdx-search-field (#F8F8F8), .ce-inline-toolbar (its own --color-text-primary: black), plus the notifier and tool-input placeholder.

Colours follow the existing dark-mode convention rather than --bs-* tokens: $gray-850 for elevated surfaces (as in _cards.scss, _list-group.scss), $gray-700 for hover (as in _forms.scss), $gray-600 for borders.

Both colour modes are covered, not just dark.

Changes

File Change
assets/scss/components/_editorjs.scss Rewritten, 119 to 72 lines
assets/scss/_imports.scss Added the missing @import 'components/editorjs';
docs/editorjs.md New
docs/index.md Index row

Test plan

  • sass:build exits 0 and the compiled CSS contains the .ce-popover and .editor-js rules with the expected values
  • stylelint clean against stylelint-config-standard-scss
  • Demo page renders, Stimulus controller and all EditorJS assets resolve
  • Light mode: popover surface, text and border read correctly; hover band visible
  • Dark mode: hover band visibly lighter (#495057) than the popover surface (#2d2f35)
  • Dark mode: inline toolbar, plus button and settings handle readable, with visible hover
  • Popover search field: text and placeholder readable in both modes

Checked locally against framework-design-check with the bundle assets/ symlinked into vendor, EditorJS vendored as ESM and a small demo route.

Notes for the reviewer

  • Conflicts with Add DESIGN.md, fix SCSS entry-point import order, correct docs examples #245. That PR adds the same @import 'components/editorjs'; line. Whichever lands second gets a one-line conflict, resolve by keeping a single copy.
  • Branch name is misleading. 64-editorjs-styling was a stale local pointer at master; issue 64 is unrelated ("Update bundle structure"). Happy to rename.
  • The bundle still ships no EditorJS JavaScript, Stimulus controller, form type or Twig widget. Applications wire that themselves, as the automator does. Say so if that should change.
  • The theming needs EditorJS 2.28 or newer, and nothing enforces that floor. Older versions get the .editor-js height rule and no theming, silently. Documented in docs/editorjs.md.

🤖 Generated with Claude Code

Summary by Sourcery

Theme EditorJS consistently across light and dark colour modes and document the required integration setup.

New Features:

  • Add light and dark mode theming for EditorJS components using EditorJS custom properties.
  • Document EditorJS integration requirements, usage, supported styling, and troubleshooting.

Bug Fixes:

  • Enable the previously uncompiled EditorJS stylesheet by adding it to the SCSS imports.
  • Replace stale EditorJS selectors and unsuitable surface colours with styling compatible with current EditorJS versions and visible dark-mode hover states.

Documentation:

  • Add EditorJS documentation and link it from the documentation index.

The EditorJS component was never listed in _imports.scss, so none of it
compiled. Its rules also targeted pre-2.26 class names and painted fifteen
surfaces with $primary, a brand colour used as a surface token.

Rewrite it based on the styling from automator-sumoapp-be-upgrade !18, with
two changes. EditorJS declares its popover palette as custom properties on
.ce-popover, so eight assignments replace the selector overrides and keep
working when its internal markup changes. And the hover states use $gray-700
instead of --bs-secondary-bg: this fork sets $body-bg-dark and
$body-secondary-bg-dark to the same $gray-800, which would make every hover
band invisible in dark mode.

Both colour modes are covered. Add the missing import and document the
component, including the EditorJS 2.28 floor the theming depends on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR wires the previously uncompiled EditorJS stylesheet into the bundle and rewrites it around EditorJS 2.28+ custom properties, providing maintainable light/dark theming with visible hover states while documenting integration requirements and limitations.

File-Level Changes

Change Details Files
Replaced stale EditorJS selector overrides with palette custom properties for resilient light and dark-mode theming.
  • Defines EditorJS popover surface, text, border, shadow, hover, and focus tokens in both color modes.
  • Uses project gray scale tokens to preserve visible dark-mode elevation and hover contrast.
  • Retains targeted overrides for hardcoded toolbar, search, notification, and input placeholder colors.
assets/scss/components/_editorjs.scss
Enabled compilation of the EditorJS component styles.
  • Adds the missing component import to the SCSS import manifest.
assets/scss/_imports.scss
Documented EditorJS integration, styling coverage, prerequisites, and limitations.
  • Documents the EditorJS 2.28+ requirement and application-owned JavaScript/controller/widget setup.
  • Adds usage, troubleshooting, CSP, theming internals, and dark-mode token guidance.
  • Indexes the new documentation page.
docs/editorjs.md
docs/index.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/editorjs.md
Wrap the editor holder in `.editor-js`, and keep the value in a hidden textarea:

```twig
<div data-controller="editorjs">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wordt dat niet met een formtype gedaan?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ahja, maar dat staat in blocks.html. Overleg anders eens met Ilias. Want ik ben nog niet 100% mee hoe dat werkt. Ik zou denken dat er een formtype is voor EditorJS. En dat die HTML dus eigenlijk in de default forms template moet komen.

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.

2 participants