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

Respect previewOptions className #287

Closed
malcolm-kee opened this issue Nov 9, 2021 · 8 comments
Closed

Respect previewOptions className #287

malcolm-kee opened this issue Nov 9, 2021 · 8 comments

Comments

@malcolm-kee
Copy link

Right now the preview className is fixed as ${prefixCls}-preview due to https://github.com/uiwjs/react-md-editor/blob/master/src/Editor.tsx#L276.

I think it should use className from previewOptions if it is provided.

If that's not what you intends, then maybe remove className from previewOptions type definition.

Either way, happy to create a PR if you can confirm the intentional behavior. Thanks!

@jaywcjlove
Copy link
Member

className,

className is passed to the outermost box.

@malcolm-kee

@malcolm-kee
Copy link
Author

previewOptions object has className.

@jaywcjlove
Copy link
Member

@malcolm-kee Yes, it is passed to the @uiw/react-markdown-preview component.

import MarkdownPreview, { MarkdownPreviewProps, MarkdownPreviewRef } from '@uiw/react-markdown-preview';

@malcolm-kee
Copy link
Author

@jaywcjlove
Copy link
Member

<MDEditor.Markdown
  source={value}
  linkTarget="_blank"
+  className="red-bg"
-  previewOptions={{
-    // this applied but ignore
-    className: "red-bg"
-  }}
/>

@malcolm-kee

@malcolm-kee
Copy link
Author

@jaywcjlove sorry the previous code is wrong 😅 .

I just updated my example:

function App() {
  const [value, setValue] = React.useState(mkdStr);
  return (
    <div className="container">
      <div className="red-bg">style applied</div>
      <MDEditor
        height={200}
        value={value}
        onChange={setValue}
        previewOptions={{
          // this applied but ignore
          className: "red-bg"
        }}
      />
    </div>
  );
}

jaywcjlove added a commit that referenced this issue Nov 10, 2021
@jaywcjlove
Copy link
Member

I fixed this issue.
@malcolm-kee

@malcolm-kee
Copy link
Author

Thanks for the quick fix! You're awesome!

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

No branches or pull requests

2 participants