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

Disable alerts on cancel/refresh? #269

Closed
dasuchin opened this issue Jul 14, 2016 · 8 comments
Closed

Disable alerts on cancel/refresh? #269

dasuchin opened this issue Jul 14, 2016 · 8 comments

Comments

@dasuchin
Copy link

Is there a way to disable the alerts if someone cancels or attempts to refresh the page?

@anthonyjb
Copy link
Member

anthonyjb commented Jul 14, 2016

There isn't an option at the moment, the best I can offer right now is a patch you could apply:

editor.init(...);

// Disable refresh message
window.removeEventListener('beforeunload', editor._handleBeforeUnload);

// Disable cancel message
editor.addEventListener('revert', function(ev) {
    ev.preventDefault();

    // Revert
    this.revertToSnapshot(this.history.goTo(0), false);
    this.history.stopWatching();

    // Hide UI
    this._toolbox.hide();
    this._inspector.hide();

    // Reset the editor
    this._history = null;
    this._regions = {};
    this._state = 'ready';

    // Blue any existing focused element
    if (ContentEdit.Root.get().focused()) {
        this._allowEmptyRegions = function () {
                ContentEdit.Root.get().focused().blur();
        }
    }
});

@dasuchin
Copy link
Author

That worked, thanks.

@Petah
Copy link

Petah commented Oct 26, 2016

+1 on making this an option

@anthonyjb
Copy link
Member

Hi @Petah - I've reopened this and flagged as an enhancement.

@krebul
Copy link

krebul commented Nov 23, 2016

+1 for making this an option

@patrikengborg
Copy link

+1

@Smashr
Copy link

Smashr commented Jul 8, 2017

+1 ...

@anthonyjb
Copy link
Member

This feature is now supported, to disable the cancel/refresh alerts simply set the ContentTools.CANCEL_MESSAGE value to null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants