Review main Merged

87515[BUGFIX] Update CKEditor model in source edit view on input

Andreas Kienast CR +2 V +2 Easy +24 −5 updated 03/04/25, 18:48

Commit message

This patch fixes a bug where changes made in "Source" editing mode
would not be checked during FormEngine validation, mistakenly allowing
to save records when an RTE field is marked as 'required'.

Our CKEditor integration allows to edit the editor document's source
code by default by toggling the "Source" button in the UI. Originally,
the editor model is updated once either the document is saved or the
user disables source editing again.

This has the disadvantage that FormEngine cannot intercept any changes
in an early state, e.g. marking a field as "changed". If source editing
gets enabled, an event listener for the `input` event is now registered
on the textarea that is rendered by source editing, which we have to
pick by ourselves as it is considered private API. The custom event
handler updates the editor model on every input. Since this might cause
performance bottlenecks, the update is debounced every few milliseconds.

Since we deal with private API which might break in future CKEditor
updates, an error is explicitly thrown if the textarea cannot be found.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2130

Show 45 earlier messages
  1. Andreas Kienast uploaded patch set 1 12/16/24, 15:57

  2. core-ci voted on patch set 1 V +1 12/16/24, 16:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71208

  3. Garvin Hicking commented on patch set 2 V +1 12/16/24, 16:06

    Published edit on patch set 1.
  4. Garvin Hicking updated the commit message in patch set 3 12/16/24, 16:07

  5. Garvin Hicking commented on patch set 4 12/16/24, 16:10

    Published edit on patch set 3.
  1. core-ci voted on patch set 2 V +1 12/16/24, 16:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71209

  2. core-ci voted on patch set 3 V +1 12/16/24, 16:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71210

  3. core-ci voted on patch set 4 V -1 12/16/24, 16:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71211

  4. Garvin Hicking commented on patch set 5 V -1 12/16/24, 16:19

    Published edit on patch set 4.
  5. core-ci voted on patch set 5 V +1 12/16/24, 16:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71212

  6. Garvin Hicking commented on patch set 5 V -1 12/17/24, 06:45

    Sadly this doesn't work for me, tested in EXT:styleguide required rte_1: * Entered Text in WYSIWYG mode. Switched to source mode. Removed text. Field does not get marked as invalid. * Empty Text in WYSIWYG mode. Switched to source mode. Entered text. Field does not get marked as valid. Chromium+Firefox OSX. No error gets thrown. Cache cleared. Added console.logs() the code gets used. Debounce events do get called if I add console.logs() also there.
  7. Andreas Kienast commented on patch set 5 CR -1 12/17/24, 07:16

    Reply

    I love CKEditor...
  8. Andreas Kienast uploaded patch set 6 CR -1 V +1 12/17/24, 10:58

  9. core-ci voted on patch set 6 V +1 12/17/24, 11:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/71258

  10. Andreas Kienast commented on patch set 6 12/17/24, 11:13

    Reply

    I hope I've fixed this without breaking anything...
  11. Garvin Hicking commented on patch set 6 CR +1 V +1 12/18/24, 08:55

    lgtm
  12. Garvin Hicking uploaded patch set 7 CR +1 V +1 01/13/25, 09:22

    Fix merge conflict
  13. Garvin Hicking wrote 01/13/25, 09:23

    Topic set to FormEngine
  14. Garvin Hicking voted on patch set 7 CR +1 V +1 01/13/25, 09:23

  15. core-ci voted on patch set 7 V +1 01/13/25, 09:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72297

  16. Benjamin Franzke commented on patch set 7 CR -1 01/13/25, 09:38

    will have a look
  17. Garvin Hicking commented on patch set 7 02/28/25, 21:59

    Just had another data inconsistency in a project accidentally caused by this - Benjamin, did you get the chance to look at this maybe?
  18. Benjamin Franzke uploaded patch set 8 CR +1 V +1 03/03/25, 18:28

  19. Benjamin Franzke commented on patch set 8 03/03/25, 18:28

    I'm still not happy that we have to update the view model (even if we debounce) but couldn't find a better solution (we could actually have only listend on the editor.ui update event that is fired during source editing mode, but that would allow to check if the value is empty/validates. So I think we should merge this now…

    Reply

    Found a way to avoid the manual lookup and just API instead.

    ckeditor5.ts:177

    I don't know if this has been another bug, but we need this listener in any case, not just when `SourceEditing` is active. Moved it out of the condition.
  20. Benjamin Franzke uploaded patch set 9 CR +1 V +1 03/03/25, 18:29

  21. core-ci voted on patch set 8 V +1 03/03/25, 18:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75040

  22. core-ci voted on patch set 9 V +1 03/03/25, 18:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75041

  23. Garvin Hicking commented on patch set 9 CR +1 V +1 03/04/25, 14:29

    Thanks, works for my case!
  24. Benjamin Franzke voted on patch set 9 CR +2 V +2 03/04/25, 14:42

  25. Benjamin Franzke merged patch set 10 03/04/25, 18:48