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

When user select interface mode as "Use System Settings" which is in dark mode then ckeditor will show in light mode. #146

Closed
rajat-bhatt-codes opened this issue Jun 11, 2024 · 1 comment
Labels
issue: bug Something isn't working priority: low

Comments

@rajat-bhatt-codes
Copy link

rajat-bhatt-codes commented Jun 11, 2024

Describe the bug

  1. When user select interface mode as "Use System Settings" which is in dark mode then ckeditor will show in light mode.
  2. Also we need to reload everytime when we change theme to apply changes.

To Reproduce
Steps to reproduce the behavior:

  1. Go to profile section
  2. Click on 'Interface mode'
  3. Select 'User system settings'
  4. Check ck editor field

Expected behavior
it should work as per system settings

Screenshots
image
image

@rajat-bhatt-codes rajat-bhatt-codes changed the title When user select interface mode as "Use System Settings" then ckeditor will be in light mode. When user select interface mode as "Use System Settings" which is in dark mode then ckeditor will show in light mode. Jun 11, 2024
@rajat-bhatt-codes
Copy link
Author

rajat-bhatt-codes commented Jun 11, 2024

i can suggest a simple solution to this problem that worked for me. for first point
Need to make changes in @_sh\strapi-plugin-ckeditor\admin\src\components\Input\CKEditor\styling.js file.

import baseTheme from "./theme";
import { createGlobalStyle } from "styled-components";

const getSystemColorScheme = () => {
  if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    return "dark";
    }    
    return "light";
}

export const getGlobalStyling = () => {
    
  const variant = localStorage.getItem("STRAPI_THEME") || "light";

  const { theme: userTheme, themeOverwrite: overwrite } = globalThis.CKEditorConfig || {};

  const theme = overwrite ? userTheme : { ...baseTheme, ...userTheme};

  const selectedThemeVariant = variant === "system" ? getSystemColorScheme() : variant

  return createGlobalStyle`
       ${theme.common}
       ${theme[selectedThemeVariant]}
       ${theme.additional}
   `;
}

@rajat-bhatt-codes rajat-bhatt-codes changed the title When user select interface mode as "Use System Settings" which is in dark mode then ckeditor will show in light mode. When user select interface mode as "Use System Settings" which is in dark mode then ckeditor will show in light mode. Jun 12, 2024
@nshenderov nshenderov added issue: bug Something isn't working priority: low labels Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Something isn't working priority: low
Projects
None yet
Development

No branches or pull requests

2 participants