-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 [#3049] Ensure that the tinymce widgets are re-initialized on theme…
… changes tinyMCE does not handle this itself, you need to explicitly force it to destroy and re-initialize itself. Django has two mechanisms w/r to the theme: * store the selected theme in localStorage (if unset, it's assumed to be 'auto') * set the data-theme attribute on the root html node, which triggers the relevant CSS rules to change the appearance So, whenever the theme changes, the localStorage is updated and the data-attribute on the HTML node changes. We can observe the html node changes, and use that to synchronize our (derived) global state. We don't care about dark/light/auto, only about the resulting theme of a particular choice - this result is stored in the global state. Then, our pages with tinymce editors need to subscribe to the global state changes so that they can re-initialize: * react component, easy, just make sure the 'key' prop changes and react will unmount and remount the node, triggering the re-init in the process from @tinymce/react * the django-tinymce code is trickier, since there we need to get each editor instance ourselves and subscribe to the global state to ensure we reset the editors. This further customizes the overridden code from the upstream package.
- Loading branch information
1 parent
d98e546
commit 98eda60
Showing
4 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters