save images drawn with whiteboard to your CryptDrive

pull/1/head
ansuz 7 years ago
parent fe826133b3
commit 8b0831ac5d

@ -254,6 +254,7 @@ define([
var createAreaHandlers = File.createDropArea = function ($area, $hoverArea) { var createAreaHandlers = File.createDropArea = function ($area, $hoverArea) {
var counter = 0; var counter = 0;
if (!$hoverArea) { $hoverArea = $area; } if (!$hoverArea) { $hoverArea = $area; }
if (!$area) { return; }
$hoverArea $hoverArea
.on('dragenter', function (e) { .on('dragenter', function (e) {
e.preventDefault(); e.preventDefault();

@ -1243,6 +1243,13 @@ define([
style: 'font:'+size+' FontAwesome' style: 'font:'+size+' FontAwesome'
}); });
break; break;
case 'savetodrive':
button = $('<button>', {
'class': 'fa fa-cloud-upload',
title: Messages.canvas_saveToDrive,
})
.click(prepareFeedback(type));
break;
default: default:
button = $('<button>', { button = $('<button>', {
'class': "fa fa-question", 'class': "fa fa-question",

@ -212,6 +212,18 @@ window.canvas = canvas;
}); });
}; };
module.FM = Cryptpad.createFileManager({});
module.upload = function (title) {
$canvas[0].toBlob(function (blob) {
blob.name = title;
var reader = new FileReader();
reader.onloadend = function () {
module.FM.handleFile(blob);
};
reader.readAsArrayBuffer(blob);
});
};
var initializing = true; var initializing = true;
var $bar = $('#toolbar'); var $bar = $('#toolbar');
@ -337,6 +349,15 @@ window.canvas = canvas;
var $export = Cryptpad.createButton('export', true, {}, saveImage); var $export = Cryptpad.createButton('export', true, {}, saveImage);
$rightside.append($export); $rightside.append($export);
Cryptpad.createButton('savetodrive', true, {}, function () {})
.click(function () {
Cryptpad.prompt(Messages.exportPrompt, document.title + '.png',
function (name) {
if (name === null || !name.trim()) { return; }
module.upload(name);
});
}).appendTo($rightside);
var $forget = Cryptpad.createButton('forget', true, {}, function (err) { var $forget = Cryptpad.createButton('forget', true, {}, function (err) {
if (err) { return; } if (err) { return; }
setEditable(false); setEditable(false);
@ -344,7 +365,6 @@ window.canvas = canvas;
}); });
$rightside.append($forget); $rightside.append($forget);
var editHash; var editHash;
if (!readOnly) { if (!readOnly) {

Loading…
Cancel
Save