[Libreoffice-commits] online.git: loleaflet/src

Jan Holesovsky kendy at collabora.com
Fri Jan 15 02:12:08 PST 2016


 loleaflet/src/layer/tile/TileLayer.js |   34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

New commits:
commit be46817a6fc6dec229180cd933a6f715e93f3a74
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Fri Jan 15 11:08:57 2016 +0100

    loleaflet: JS part of the HTML and images dropping.
    
    So far it is commented out, as it needs improvements on the loolwsd side too.

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index c68287b..ee1df4a 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -943,7 +943,39 @@ L.TileLayer = L.GridLayer.extend({
 	_onDrop: function (e) {
 		e = e.originalEvent;
 		e.preventDefault();
-		this._map._socket.sendMessage('paste mimetype=text/plain;charset=utf-8 data=' + e.dataTransfer.getData("text/plain"));
+
+		// handle content
+		var types = e.dataTransfer.types;
+		var handled = false;
+		for (var t = 0; !handled && t < types.length; t++) {
+			var type = types[t];
+			if (type === 'text/html') {
+				// TODO this needs loolwsd fixing, to support multiline data (blob)
+				// this._map._socket.sendMessage('paste mimetype=text/html data=' + e.dataTransfer.getData(type));
+				// handled = true;
+			}
+			else if (type === 'text/plain') {
+				this._map._socket.sendMessage('paste mimetype=text/plain;charset=utf-8 data=' + e.dataTransfer.getData(type));
+				handled = true;
+			}
+			else if (type === 'Files') {
+				var files = e.dataTransfer.files;
+				for (var i = 0; i < files.length; ++i) {
+					var file = files[i];
+					if (file.type.match(/image.*/)) {
+						// TODO this needs loolwsd fixing, to support multiline data (blob)
+						// var reader = new FileReader();
+						// reader.onload = (function(aImg) { return function(e) {
+						//     this._map._socket.sendMessageWithData('paste mimetype=' + file.type + 'length=' + ..., e.target.result);
+						// }; })(img);
+						//
+						// reader.readAsArrayBuffer();
+						//
+						// handled = true;
+					}
+				}
+			}
+		}
 	},
 
 	_onDragStart: function () {


More information about the Libreoffice-commits mailing list