Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ Terminal.prototype.initGlobal = function() {
if (this.useStyle) {
Terminal.insertStyle(document, this.colors[256], this.colors[257]);
}

this.fixFirefoxPaste();
};

/**
Expand Down Expand Up @@ -597,6 +599,39 @@ Terminal.bindCopy = function(document) {
});
};

/**
* We set design mode because in firefox, this is the only way
* to get the paste event to fire because of this bug:
* https://bugzilla.mozilla.org/show_bug.cgi?id=846674
*
*/
Terminal.prototype.fixFirefoxPaste = function () {
var window = document.defaultView;

function disableDesignMode () {
if (Terminal.setDesignMode) {
document.designMode = Terminal.originalDesignMode;
Terminal.setDesignMode = false;
}
}

function enableDesignMode () {
Terminal.originalDesignMode = document.designMode;
Terminal.setDesignMode = true;
document.designMode = "on";
}

//When a right click menu is available, enable design mode so the paste event will fire.
on(document, 'contextmenu', enableDesignMode);

//Make sure we snap out of design mode after any action that would hide the context menu
//and actually allow the user to start modifying the document.
on(window, 'blur', disableDesignMode);
on(document, 'mousedown', disableDesignMode, true);
on(window, 'paste', disableDesignMode, true);
};


/**
* Fix Mobile
*/
Expand Down