Class RteCssRules

java.lang.Object
com.vaadin.swingbridge.surrogates.internal.RteCssRules

public final class RteCssRules extends Object
Rewrites author CSS (as handed to HTMLEditorKit's StyleSheet.addRule) into rules that apply to RTE's rendered content.

Two transformations, both forced by where the content actually lives. RTE renders the pane's HTML as real elements inside a .ql-editor div in the component's shadow root, so every selector is confined under that class — otherwise a rule like button { … } would also hit the editor toolbar. And the document root selectors body / html have no counterpart inside the editor, so they map onto the content element itself rather than becoming a descendant selector that matches nothing — which matters because body { font-family: … } is the single most common rule in the field.

Scoping to one pane needs no help from the selector: the stylesheet is injected into that instance's own shadow root, which is already a style boundary. (A :host([theme~="…"]) prefix would be required only for the static themeFor delivery shape, where one stylesheet is shared.)

At-rules (@media, @import, @font-face) are skipped whole, nested body included, and reported so the caller can WARN — emitting a half-parsed @media block would inject broken CSS rather than none.

  • Field Details

    • CONTENT_ROOT

      public static final String CONTENT_ROOT
      The element RTE renders pane content into, inside its shadow root.
      See Also:
  • Method Details

    • translate

      public static RteCssRules.Translated translate(String css)
      Translate a CSS fragment. Accepts anything StyleSheet.addRule does — a single rule or a whole stylesheet's worth.