Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in RichText field Headers option #537

Closed
harinij opened this issue Oct 1, 2021 · 4 comments · Fixed by #696
Closed

Bug in RichText field Headers option #537

harinij opened this issue Oct 1, 2021 · 4 comments · Fixed by #696

Comments

@harinij
Copy link
Member

harinij commented Oct 1, 2021

Is your feature request related to a problem? Please describe.
Currently, when someone tries to edit a RichText field in the side drawer, the headers drop down list has a CSS color issue where it is all white in light and dark mode. Needs to fixed

Screen Shot 2021-10-01 at 11 37 35 am

@harinij harinij added the good first issue Good for newcomers label Oct 1, 2021
@acaldwell710
Copy link

Going to try to work on this! (Amber Caldwell)

@htuerker
Copy link
Contributor

htuerker commented Jun 21, 2022

Hello 👋

I did some work here. I'd like to get some direction before opening a PR.

The problem here is the below line is completely useless and has no effect on the editor's UI styling:

content_style: [
theme.palette.mode === "dark" ? contentCssDark : contentCss,
theme.palette.mode === "dark" ? contentUiCssDark : contentUiCss,

As this does nothing, we alter the color to palette.text.primary in content_styles which also affects the dropdown stylings.

html, body { background-color: transparent; }
body {
font-family: ${theme.typography.fontFamily};
color: ${theme.palette.text.primary};

I implemented a tricky solution by importing both tinymce/skins/ui/oxide/skin.min.css and tinymce/skins/ui/oxide-dark/skin.min.css then load the proper one dynamically with React.lazy:

      const OxideTheme = lazy(() => import("@src/theme/RichTextUIDark"));
      const OxideDarkTheme = lazy(() => import("@src/theme/RichTextUILight"));

      {theme.palette.mode === "dark" ? <OxideDarkTheme /> : <OxideTheme />}

Screen Shot 2022-06-21 at 20 14 31

Lastly, this still causes the same problem on theme switches because it has loaded both stylings. I guess there's no easy workaround without customizing the styles. Of course, there's a costly solution over this to destroy and reinitialize the editor when theme changed.

Let me know if I miss something here ❤️

@notsidney
Copy link
Contributor

notsidney commented Jun 27, 2022

Hi @htuerker, thanks for your interest in Rowy!

contentCss and contentUiCss are used to style the actual content of the rich text, so it shouldn’t affect the editor UI. I’m not exactly sure why it’s also part of content_style, but it’s recommended in their example code on how to use it with React: https://www.tiny.cloud/docs/integrations/react/#:~:text=the%20React%20application-,using%20a%20module%20loader,-Tiny%20does%20not

I haven’t checked it in a while, but if I recall correctly, removing that part of content_style may cause the editor content to use the wrong theme when the theme is changed. You can find out about that option in the docs.

Using React.lazy for the CSS is a good idea, but I can’t seem to find where you implemented @src/theme/RichTextUILight. I’m curious why it’s a React component itself.

To solve the theme switching issue, it may be helpful to force the tinymce editor to re-mount with the key prop, although this may cause issues if a user has unsaved changes and they lose those changes. In that case, I think it’s better to leave that unfixed because of how rarely a user would change the theme.

@harinij
Copy link
Member Author

harinij commented Mar 4, 2023

This issue has been resolved.

@harinij harinij closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants