uiwjs / react-markdown-editor

A markdown editor with preview, implemented with React.js and TypeScript.
https://uiwjs.github.io/react-markdown-editor
MIT License
337 stars 34 forks source link

Switch to fullscreen #217

Closed mauro-rogledi closed 7 months ago

mauro-rogledi commented 7 months ago

Is there a way to know when the user switches from normal to full screen mode? Thanks

jaywcjlove commented 7 months ago

@mauro-rogledi

There are two methods to implement:

  1. Listening to the className of the body DOM node can determine if it is fullscreen.
  2. Customizing Toolbars and adding click events again.
import MarkdownEditor, { preview, fullscreen } from '@uiw/react-markdown-editor';

const customFullscreen: ICommand = {
  ...fullscreen,
  button: (command, props, opts) => (
    <FullscreenButton
      onClick={(evn, isFull) => {}}
      command={command}
      editorProps={{ ...props, ...opts }}
    />
  ),
};

<MarkdownEditor
  value="Hello Markdown!"
  height="200px"
  toolbarsMode={[
    preview, customFullscreen
  ]}
/>

@mauro-rogledi This is a possible way to achieve your requirements.

mauro-rogledi commented 7 months ago

Thanks. Update to 6.1.0 version and works.