Allow paste from external clipboard in dialogs
Change-Id: Ife7a32ada356a3a594bdd314ff5a0a4b7d10eb50
This commit is contained in:
parent
181af63b56
commit
869248929c
4 changed files with 33 additions and 13 deletions
|
@ -288,7 +288,7 @@ L.Control.LokDialog = L.Control.extend({
|
|||
this._dialogs[e.id].cursorVisible = e.visible === 'true';
|
||||
if (this._dialogs[e.id].cursorVisible) {
|
||||
$('#' + strId + '-cursor').css({display: 'block'});
|
||||
this._map._onLostFocus();
|
||||
this._map.onEditorLostFocus(this);
|
||||
}
|
||||
else {
|
||||
$('#' + strId + '-cursor').css({display: 'none'});
|
||||
|
|
|
@ -2656,7 +2656,14 @@ L.TileLayer = L.GridLayer.extend({
|
|||
|
||||
_onPaste: function (e) {
|
||||
e = e.originalEvent;
|
||||
this._map._clip.paste(e);
|
||||
if (!this._map._activeDialog) {
|
||||
// Paste in document
|
||||
this._map._clip.paste(e);
|
||||
} else {
|
||||
// Paste in dialog
|
||||
e.usePasteKeyEvent = true;
|
||||
this._map._clip.paste(e);
|
||||
}
|
||||
},
|
||||
|
||||
_onDragOver: function (e) {
|
||||
|
|
|
@ -196,7 +196,7 @@ L.Clipboard = L.Class.extend({
|
|||
};
|
||||
},
|
||||
|
||||
dataTransferToDocument: function (dataTransfer, preferInternal, htmlText) {
|
||||
dataTransferToDocument: function (dataTransfer, preferInternal, htmlText, usePasteKeyEvent) {
|
||||
// Look for our HTML meta magic.
|
||||
// cf. ClientSession.cpp /textselectioncontent:/
|
||||
|
||||
|
@ -273,12 +273,19 @@ L.Clipboard = L.Class.extend({
|
|||
|
||||
var that = this;
|
||||
this._doAsyncDownload('POST', destination, formData,
|
||||
function() {
|
||||
console.log('Posted ' + content.size + ' bytes successfully');
|
||||
that._map._socket.sendMessage('uno .uno:Paste');
|
||||
},
|
||||
function(progress) { return progress; }
|
||||
);
|
||||
function() {
|
||||
console.log('Posted ' + content.size + ' bytes successfully');
|
||||
if (usePasteKeyEvent) {
|
||||
// paste into dialog
|
||||
var KEY_PASTE = 1299;
|
||||
that._map._clipboardContainer._sendKeyEvent(0, KEY_PASTE);
|
||||
} else {
|
||||
// paste into document
|
||||
that._map._socket.sendMessage('uno .uno:Paste');
|
||||
}
|
||||
},
|
||||
function(progress) { return progress; }
|
||||
);
|
||||
} else {
|
||||
console.log('Nothing we can paste on the clipboard');
|
||||
}
|
||||
|
@ -498,7 +505,8 @@ L.Clipboard = L.Class.extend({
|
|||
console.log('Paste');
|
||||
if (ev.clipboardData) { // Standard
|
||||
ev.preventDefault();
|
||||
this.dataTransferToDocument(ev.clipboardData, /* preferInternal = */ true);
|
||||
var usePasteKeyEvent = ev.usePasteKeyEvent;
|
||||
this.dataTransferToDocument(ev.clipboardData, /* preferInternal = */ true, null, usePasteKeyEvent);
|
||||
this._map._clipboardContainer._abortComposition();
|
||||
this._clipboardSerial++;
|
||||
}
|
||||
|
|
|
@ -1169,8 +1169,8 @@ L.Map = L.Evented.extend({
|
|||
}, map.options.outOfFocusTimeoutSecs * 1000);
|
||||
},
|
||||
|
||||
// The editor got focus (probably a dialog closed or user clicked to edit).
|
||||
_onEditorLostFocus: function() {
|
||||
// The editor lost focus (probably a dialog was created).
|
||||
onEditorLostFocus: function onEditorLostFocus(dialog) {
|
||||
if (!this._loaded) { return; }
|
||||
|
||||
var doclayer = this._docLayer;
|
||||
|
@ -1179,11 +1179,15 @@ L.Map = L.Evented.extend({
|
|||
doclayer._isFocused = false;
|
||||
doclayer._updateCursorAndOverlay();
|
||||
}
|
||||
|
||||
if (dialog) {
|
||||
this._activeDialog = dialog;
|
||||
}
|
||||
},
|
||||
|
||||
// Our browser tab lost focus.
|
||||
_onLostFocus: function () {
|
||||
this._onEditorLostFocus();
|
||||
this.onEditorLostFocus();
|
||||
this._deactivate();
|
||||
},
|
||||
|
||||
|
@ -1204,6 +1208,7 @@ L.Map = L.Evented.extend({
|
|||
}, 300);
|
||||
}
|
||||
|
||||
this._activeDialog = null;
|
||||
},
|
||||
|
||||
// Our browser tab lost focus.
|
||||
|
|
Loading…
Reference in a new issue