From 5e7bf0cfb861ab062fafdaf3b575d9b12a568e70 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 9 Oct 2017 10:32:24 +0200 Subject: [PATCH] Embed an image in whiteboard --- customize.dist/pages.js | 1 + www/common/sframe-chainpad-netflux-inner.js | 2 +- www/whiteboard/app-whiteboard.less | 4 + www/whiteboard/inner.js | 99 ++++++++++++++++----- 4 files changed, 85 insertions(+), 21 deletions(-) diff --git a/customize.dist/pages.js b/customize.dist/pages.js index 5fac0939b..733a4e062 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -630,6 +630,7 @@ define([ } }), h('div#cp-app-whiteboard-pickers'), + h('div#cp-app-whiteboard-media-hidden') ]; }; diff --git a/www/common/sframe-chainpad-netflux-inner.js b/www/common/sframe-chainpad-netflux-inner.js index 7e0eb2a57..66fd3fc50 100644 --- a/www/common/sframe-chainpad-netflux-inner.js +++ b/www/common/sframe-chainpad-netflux-inner.js @@ -136,4 +136,4 @@ define([ }); }; return Object.freeze(module.exports); -}); \ No newline at end of file +}); diff --git a/www/whiteboard/app-whiteboard.less b/www/whiteboard/app-whiteboard.less index b2bd789fc..59888a5f3 100644 --- a/www/whiteboard/app-whiteboard.less +++ b/www/whiteboard/app-whiteboard.less @@ -25,6 +25,10 @@ display: none; } + #cp-app-whiteboard-media-hidden { + display: none; + } + // created in the html #cp-app-whiteboard-canvas-area { flex: 1; diff --git a/www/whiteboard/inner.js b/www/whiteboard/inner.js index f0c0c609a..165de6b5d 100644 --- a/www/whiteboard/inner.js +++ b/www/whiteboard/inner.js @@ -178,6 +178,7 @@ define([ APP.draw = true; var toggleDrawMode = function () { + canvas.deactivateAll().renderAll(); APP.draw = !APP.draw; canvas.isDrawingMode = APP.draw; $toggle.text(APP.draw ? Messages.canvas_disable : Messages.canvas_enable); @@ -353,6 +354,7 @@ define([ var onLocal = config.onLocal = function () { if (initializing) { return; } if (readOnly) { return; } + console.error('local'); var content = stringifyInner(canvas.toDatalessJSON()); @@ -413,6 +415,58 @@ define([ if (!readOnly) { makeColorButton($rightside); + + // Embed image + var onUpload = function (e) { + var file = e.target.files[0]; + var reader = new FileReader(); + reader.onload = function () { + var img = new Image(); + img.onload = function () { + var w = img.width; + var h = img.height; + if (w', {type:'file'}).on('change', onUpload).click(); + }).appendTo($rightside); + var fileDialogCfg = { + onSelect: function (data) { + if (data.type === 'file') { + var $block = $('#cp-app-whiteboard-media-hidden'); + var mt = ''; + $block.append(mt); + return; + } + } + }; + common.initFilePicker(fileDialogCfg); + APP.$mediaTagButton = $('