[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src

Jan Holesovsky kendy at collabora.com
Thu Jan 21 01:55:10 PST 2016


 loleaflet/src/layer/tile/TileLayer.js     |   10 ++++++++++
 loleaflet/src/map/Map.js                  |    4 ++--
 loleaflet/src/map/handler/Map.Keyboard.js |   10 ++++++----
 3 files changed, 18 insertions(+), 6 deletions(-)

New commits:
commit e11e112411ee600e6bdd3da009b0d8e870d0a418
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Jan 21 10:53:37 2016 +0100

    loleaflet: Implement the 'cut' functionality.

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 16106ff..dcef8c7 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -124,6 +124,7 @@ L.TileLayer = L.GridLayer.extend({
 		map.on('drag resize zoomend', this._updateScrollOffset, this);
 
 		map.on('copy', this._onCopy, this);
+		map.on('cut', this._onCut, this);
 		map.on('paste', this._onPaste, this);
 		map.on('dragover', this._onDragOver, this);
 		map.on('drop', this._onDrop, this);
@@ -995,6 +996,15 @@ L.TileLayer = L.GridLayer.extend({
 		}
 	},
 
+	_onCut: function (e) {
+		e = e.originalEvent;
+		e.preventDefault();
+		if (this._selectionTextContent) {
+			e.clipboardData.setData('text/plain', this._selectionTextContent);
+			this._map._socket.sendMessage('uno .uno:Cut');
+		}
+	},
+
 	_onPaste: function (e) {
 		e = e.originalEvent;
 		e.preventDefault();
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index e5749f6..a2f9e06 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -600,7 +600,7 @@ L.Map = L.Evented.extend({
 		L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
 			'mouseover mouseout mousemove contextmenu dragover drop ' +
 			'keydown keypress keyup trplclick qdrplclick', this._handleDOMEvent, this);
-		L.DomEvent[onOff](this._textArea, 'copy paste keydown keypress keyup', this._handleDOMEvent, this);
+		L.DomEvent[onOff](this._textArea, 'copy cut paste keydown keypress keyup', this._handleDOMEvent, this);
 
 		if (this.options.trackResize && this._resizeDetector.contentWindow) {
 			L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
@@ -653,7 +653,7 @@ L.Map = L.Evented.extend({
 		var data = {
 			originalEvent: e
 		};
-		if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' && e.type !== 'copy' && e.type !== 'paste') {
+		if (e.type !== 'keypress' && e.type !== 'keyup' && e.type !== 'keydown' && e.type !== 'copy' && e.type !== 'cut' && e.type !== 'paste') {
 			data.containerPoint = target instanceof L.Marker ?
 					this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e);
 			data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index cac51b9..956b118 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -321,12 +321,13 @@ L.Map.Keyboard = L.Handler.extend({
 	},
 
 	_handleCtrlCommand: function (e) {
-		if (e.type !== 'keydown' && e.originalEvent.key !== 'c' && e.originalEvent.key !== 'v') {
+		if (e.type !== 'keydown' && e.originalEvent.key !== 'c' && e.originalEvent.key !== 'v' && e.originalEvent.key !== 'x') {
 			e.originalEvent.preventDefault();
 			return true;
 		}
 
-		if (e.originalEvent.keyCode !== 67 && e.originalEvent.keyCode !== 86 && e.originalEvent.key !== 'c' && e.originalEvent.key !== 'v') {
+		if (e.originalEvent.keyCode !== 67 && e.originalEvent.keyCode !== 86 && e.originalEvent.keyCode !== 88 &&
+				e.originalEvent.key !== 'c' && e.originalEvent.key !== 'v' && e.originalEvent.key !== 'x') {
 			// not copy or paste
 			e.originalEvent.preventDefault();
 		}
@@ -376,7 +377,8 @@ L.Map.Keyboard = L.Handler.extend({
 				}
 				return false;
 			case 67: // c
-				// we prepare for a copy event
+			case 88: // x
+				// we prepare for a copy or cut event
 				this._map._docLayer._textArea.value = 'dummy text';
 				this._map._docLayer._textArea.focus();
 				this._map._docLayer._textArea.select();
@@ -396,7 +398,7 @@ L.Map.Keyboard = L.Handler.extend({
 				this._map._socket.sendMessage('uno .uno:SuperScript');
 				return true;
 		}
-		if (e.type === 'keypress' && e.originalEvent.ctrlKey && (e.originalEvent.key === 'c' || e.originalEvent.key === 'v')) {
+		if (e.type === 'keypress' && e.originalEvent.ctrlKey && (e.originalEvent.key === 'c' || e.originalEvent.key === 'v' || e.originalEvent.key === 'x')) {
 			// need to handle this separately for Firefox
 			return true;
 		}


More information about the Libreoffice-commits mailing list