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

Add optional onToggleFullScreen support from options #16

Merged
merged 1 commit into from
Jul 31, 2018
Merged

Add optional onToggleFullScreen support from options #16

merged 1 commit into from
Jul 31, 2018

Conversation

n-3-0
Copy link

@n-3-0 n-3-0 commented Jul 15, 2018

I have a project that wraps your editor in a React component, and I needed a way to append a class to a wrapper component. This change allowed me to set my component's state, thereby giving me the opportunity to conditionally style it.
Here is how I use your library, as well as the proposed change:

import EasyMDE from "easymde/src/js/easymde";

//In the component class
componentDidMount() {
    this.mde = new EasyMDE({
        onToggleFullScreen: this.onToggleFullscreen,
        //...the rest of the properties I pass in
    });
    //... the rest of my code here uses the "blur" and "change" events of this.mde.codemirror to bridge the React gap
}

//A single parameter is passed in, which is the current fullscreen state of the editor
onToggleFullscreen = (fullscreen) => {
    this.setState({ fullscreen });
}

This change works with both the side-by-side mode, and the fullscreen mode, as well as any call to EasyMDE.toggleFullScreen or EasyMDE.prototype.toggleFullScreen that other developers might use. I've thoroughly tested it with my project, and so far I've been unable to break it unless someone enters a non-function truthy value for onToggleFullScreen.

I'm not sure how to create a JSFiddle for this specific project, but since it's a small change I'm not sure if it's entirely warranted. Finally, I'd be happy to add the necessary documentation for this, but I'm not sure if I should add a section to the EasyMDE part of the README, or append it to the SimpleMDE part that has the rest of the props.

@Ionaru Ionaru merged commit 9b735ce into Ionaru:development Jul 31, 2018
@Ionaru
Copy link
Owner

Ionaru commented Jul 31, 2018

I'll add the documentation to the SimpleMDE part for consistency, but in the future that'll get rewritten.

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 this pull request may close these issues.

2 participants