Skip to content

Keep Plate's content styles off Volto's own text and table blocks - #128

Open
sneridagh wants to merge 1 commit into
mainfrom
sneridagh/scope-plate-content-css
Open

sneridagh wants to merge 1 commit into
mainfrom
sneridagh/scope-plate-content-css

Conversation

@sneridagh

Copy link
Copy Markdown
Member

The content styles of @plone/plate (styles/content.css, in the plone-content layer since 1.0.0-alpha.42) select Plate's class names. Volto uses two of those names for its own elements, so the styles also reached them:

  • slate-editor wraps the editor of Volto's text blocks (volto-slate). Its overflow: hidden clipped the slash menu: typing / showed nothing, and Enter picked a block you couldn't see. It also stopped text blocks from wrapping around floated images in the editor. It added a border radius, cursor: text, and margins on the elements inside too.
  • slate-table wraps the view of Volto's table block, which got 20px of extra padding above and below.

Found in the QA of the intranet upgrade to 1.0.0-alpha.43 (kitconcept/kitconcept.intranet#598).

Fix

Plate's elements always have a Slate data attribute: data-slate-editor on the editor root (edit and view), and data-slate-node on every element. Volto's wrappers don't. For Volto's elements, a rule in the same layer resets everything the layer sets (all: revert-layer), so they look as if the layer wasn't loaded. It's placed after the import and is more specific than the layer's :where() selectors.

I checked every class and attribute that content.css selects against Volto core, volto-slate and Volto Light Theme. These are the only overlaps, plus block-inner-container. That one is shared on purpose: _main.scss already lays it out the same way for every Volto block.

Tests

New acceptance test, volto-blocks-content-css.test.ts, on a Document with Volto text, list and table blocks:

  • Volto's text editor and table view have the same computed styles with and without the plone-content layer.
  • The slash menu of a text block shows on top.

All three tests fail without the fix. The full acceptance suite passes, except mentions.test.ts:170, which fails locally with and without this change.

Also checked in an intranet production build with this tailwind.css, with these results:

  • The slash menu shows.
  • Volto's text and table blocks have exactly the same computed styles as without the layer: 81 elements in the editor, 27 in the view.
  • Wiki pages (Plate) are unchanged in the editor and the view.
  • The floated-image page matches the intranet's main build pixel for pixel in the view.

Assisted-by: Claude Opus 5.5

The content styles of @plone/plate select Plate's class names, and Volto
uses two of them for its own elements: `slate-editor` wraps volto-slate's
text editor, and `slate-table` wraps the view of Volto's table block.
Their `overflow: hidden` hid the slash menu of Volto's text blocks and
stopped them from wrapping around floated images in the editor, and the
table block got extra padding in the view.

Plate's elements always carry a Slate data attribute, Volto's wrappers
don't, so roll back every declaration of the `plone-content` layer for
those: they now compute the same styles as without the layer.

The acceptance test compares the computed styles of Volto's text editor
and table view with and without the layer, and checks that the slash
menu is painted.

Assisted-by: Claude Opus 5.5

This branch has not been deployed

No deployments
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.

1 participant