Review main Merged

81295[BUGFIX] Apply CKEditor5 CSS scoping client-side

Benjamin Franzke CR +2 V +2 Expert +481 −679 updated 10/02/23, 10:44

Commit message

Download CSS via fetch() and apply CSS scoping and
URL rebasing on the client in order to avoid the
need for a server side SASS wrapper that:
 * can not relocate relative paths
 * can not easily check if the resource is web accessible
 * had to use regex-replacements instead of straight
   forward replacements on a properly parsed syntax tree

Commands executed:
  composer remove scssphp/scssphp
  composer remove scssphp/scssphp -d typo3/sysext/core --no-update
  cd Build
  npm install --save css-tree
  npm install --save-dev @types/css-tree
  npm run build

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oliver Hader +1
    • Benjamin Kott +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Oliver Hader +1
    • Benjamin Kott +1
    • core-ci +1 CI

Issues 3

Files 23

Review log 2227

Show 12 earlier messages
  1. Benjamin Franzke uploaded patch set 1 09/28/23, 12:49

  2. core-ci voted on patch set 1 V +1 09/28/23, 12:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47284

  1. Benjamin Franzke uploaded patch set 2 V +1 09/28/23, 13:36

  2. Benjamin Franzke commented on patch set 2 09/28/23, 13:38

    We could probably leave the dependency in place in the v12 backport, in case some classic mode extensions rely on it being shipped. Thoughts?
  3. core-ci voted on patch set 2 V +1 09/28/23, 13:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47285

  4. Andreas Kienast voted on patch set 2 V +1 CR +1 09/28/23, 13:51

  5. Benjamin Franzke commented on patch set 2 09/28/23, 14:21

    Reply

    Just did some scraping and found an example for such an extension: https://extensions.typo3.org/extension/ws_scss I leave this comment "open" until merge, so we do not forget to keep the dependency in the v12 backport.
    Decided against that: CSSStyleSheet parsing would still require selectors to be parsed manually and relocation via `new CSSStyleSheet({baseURL: url})` did not work for me.
  6. Oliver Hader commented on patch set 2 09/29/23, 10:18

    ckeditor5.ts:187

    I'm just leaving a reference to an earlier discussion on adopted styles in the light DOM here (https://review.typo3.org/c/Packages/TYPO3.CMS/+/80664/comment/d76fcea0_80f1e8ad/ ): > Benjamin Franzke: > Do you see a possibility to not leak the registered styles forever? > I mean, if an element is removed from the DOM, it's style would never be removed right now. > Rough idea: > keep a reference to the constructed stylesheets of the component, then array_filter document.adoptedStyleSheetrs in disconnectedCallback() to filter out own style objects.
  7. Benjamin Franzke uploaded patch set 3 CR +1 V +1 09/29/23, 14:45

  8. Benjamin Franzke commented on patch set 3 09/29/23, 14:45

    ckeditor5.ts:187 Reply

    Yup, right. I somehow made a difference here, because I thought our ckeditor element isn't used temporarily on a "long-living" document anyway (so disconnectedCallback won't fire right now), but that may change so better be non-leaking right away. Done in patchset 3 (can be tested by removing `<typo3-rte-ckeditor-ckeditor5>` from the dome and asserting that `document.adoptedStyleSheets.length` equals `0` afterwards.)
  9. Benjamin Franzke commented on patch set 3 09/29/23, 14:46

    ckeditor5.ts:187 Reply

    I meant "from the DOM" ;)
  10. core-ci voted on patch set 3 V +1 09/29/23, 14:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47308

  11. Georg Ringer commented on patch set 3 09/30/23, 08:31

    should we really use the wording frontend, until now in typo3 world this is the rendered website
  12. Benjamin Franzke uploaded patch set 4 V +1 09/30/23, 10:52

  13. Benjamin Franzke commented on patch set 4 09/30/23, 10:52

    Reply

    Ack, updated.
  14. core-ci voted on patch set 4 V +1 09/30/23, 10:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47317

  15. Benjamin Kott voted on patch set 4 V +1 CR +1 10/02/23, 07:35

  16. Oli Bartsch voted on patch set 4 CR +1 10/02/23, 08:25

  17. Oliver Hader commented on patch set 4 10/02/23, 08:37

    css-prefixer.ts:26

    What about `data:` URIs? e.g. `background: url(data:image/png;base64,...)`
  18. Oliver Hader uploaded patch set 5 CR +1 V +1 10/02/23, 08:59

  19. Oliver Hader voted on patch set 5 V +1 CR +1 10/02/23, 08:59

  20. Oliver Hader commented on patch set 5 10/02/23, 09:00

    css-prefixer.ts:26 Reply

    Done
  21. core-ci voted on patch set 5 V +1 10/02/23, 09:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47339

  22. Benjamin Kott voted on patch set 5 V +1 CR +1 10/02/23, 10:18

  23. Benjamin Franzke commented on patch set 5 V +2 CR +2 10/02/23, 10:38

    Reply

    Done
  24. Benjamin Franzke commented on patch set 5 10/02/23, 10:44

    css-prefixer.ts:26 Reply

    Thanks!
  25. Benjamin Franzke merged patch set 6 10/02/23, 10:44