Simplemde-markdown-editor: Catch full screen event?

Created on 25 Sep 2016  路  7Comments  路  Source: sparksuite/simplemde-markdown-editor

Hi guys,

Can you show me how to catch "full screen" event? I have a problem when use SME with Drawer (Material Design Lite). See my attach file please.

Regard,
Huka.

smde.png

Most helpful comment

@hukacode
You can explicitly set your toolbar items and wrap the SimpleMDE.toggleFullScreen function call with your own logic.

var simplemde = new SimpleMDE({
    toolbar: [{
            name: "fullscreen",
            action: handleToggleFullscreen,
            className: "fa fa-arrows-alt no-disable no-mobile",
            title: "Toggle Fullscreen",
        },
        ...
    ],
    ...
});

const handleToggleFullscreen = () => {
  //perform whatever logic you want
  simplemde.toggleFullScreen()
}

All 7 comments

@hukacode
You can explicitly set your toolbar items and wrap the SimpleMDE.toggleFullScreen function call with your own logic.

var simplemde = new SimpleMDE({
    toolbar: [{
            name: "fullscreen",
            action: handleToggleFullscreen,
            className: "fa fa-arrows-alt no-disable no-mobile",
            title: "Toggle Fullscreen",
        },
        ...
    ],
    ...
});

const handleToggleFullscreen = () => {
  //perform whatever logic you want
  simplemde.toggleFullScreen()
}

Hi @CodyJamesCasey ,

It's worked like a magic. Thank you so much!

The custom code won't fire if the user exits full screen by pressing the Esc key though. Is there no other alternate way?

Ended up just doing a monkey-patch on CodeMirror's setOption:

const oldEditorSetOption = editor.codemirror.setOption;
editor.codemirror.setOption = function(option, value) {
    oldEditorSetOption.apply(this, arguments);

    if (option === 'fullScreen') {
        // your code...
    }
};

@CodyJamesCasey

This won't work if user press keyboard shortcuts F11 to toggle fullscreen

@CodyJamesCasey used this for a custom image upload modal, thanks a bunch!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodsimpson picture rodsimpson  路  3Comments

liniu picture liniu  路  3Comments

christianmalek picture christianmalek  路  5Comments

andrelgarcia picture andrelgarcia  路  4Comments

jasonlewis picture jasonlewis  路  4Comments