Sign up (with export icon)

utils/dom/adoptglobalstylesheet

Api-module iconmodule

Functions

  • Chevron-right icon

    adoptGlobalStyleSheet( doc, css ) → void

    Ships a stylesheet that has to reach the light DOM, whatever tree the editor itself lives in.

    For the few rules that a shadow-scoped theme stylesheet cannot express, because they style nodes no shadow root can contain: the <html> and <body> elements, or third-party UI mounted in document.body. Anything that styles the editor UI belongs in a theme stylesheet instead, where an integrator can see and override it.

    Safe to call from any number of editors sharing a document, and at any time: the same stylesheet text is adopted once per document. The stylesheet then stays for the lifetime of the document, inert unless the classes it targets are present.

    Parameters

    doc: Document

    The document to adopt the stylesheet into.

    css: string

    The stylesheet text. Pass a constant – repeated calls with the same text are a no-op.

    Returns

    void