clipboard: Improve selection management.
Change-Id: I3b6318f9a0cc544b74564376426baf7d3759ee3e
This commit is contained in:
parent
c4f36953c4
commit
90c73cbf54
1 changed files with 13 additions and 1 deletions
|
@ -479,15 +479,21 @@ L.Clipboard = L.Class.extend({
|
|||
_execOnElement: function(operation) {
|
||||
var serial = this._clipboardSerial;
|
||||
|
||||
var div = this._createDummyDiv('dummy content');
|
||||
var div = this._createDummyDiv('<b style="font-weight:normal; background-color: transparent; color: transparent;"><span> </span></b>');
|
||||
|
||||
var that = this;
|
||||
var doInvoke = function(ev) {
|
||||
console.log('Got event ' + ev.type + ' on transient editable');
|
||||
|
||||
var checkSelect = document.getSelection();
|
||||
if (checkSelect.isCollapsed)
|
||||
console.log('Error: failed to select - cannot copy/paste');
|
||||
|
||||
// forward with proper security credentials now.
|
||||
that[operation].call(that, ev);
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
return false;
|
||||
};
|
||||
var doSelect = function(ev) {
|
||||
|
@ -501,6 +507,12 @@ L.Clipboard = L.Class.extend({
|
|||
var rangeToSelect = document.createRange();
|
||||
rangeToSelect.selectNodeContents(div);
|
||||
sel.addRange(rangeToSelect);
|
||||
|
||||
var checkSelect = document.getSelection();
|
||||
if (checkSelect.isCollapsed)
|
||||
console.log('Error: failed to select - cannot copy/paste');
|
||||
|
||||
return false;
|
||||
};
|
||||
document['on' + operation] = doInvoke;
|
||||
document['onbefore' + operation] = doSelect;
|
||||
|
|
Loading…
Reference in a new issue