diff --git a/config.default.yml b/config.default.yml index 27745d8..9f1226b 100644 --- a/config.default.yml +++ b/config.default.yml @@ -31,6 +31,9 @@ frontend: # Image download format, can be "png", "jpeg" (or "webp" -> only working on chrome) -- string imageDownloadFormat: "png" + # if it is blank, images will use relative path, for example "/uploads/.png" + imageURL : "" + # draw the background grid to images on download ? (If True, even PNGs are also not transparent anymore) -- boolean drawBackgroundGrid: false diff --git a/scripts/config/config-schema.json b/scripts/config/config-schema.json index 52a88c9..e386f4f 100644 --- a/scripts/config/config-schema.json +++ b/scripts/config/config-schema.json @@ -54,6 +54,9 @@ "imageDownloadFormat": { "type": "string" }, + "imageURL": { + "type": "string" + }, "drawBackgroundGrid": { "type": "boolean" }, diff --git a/src/js/whiteboard.js b/src/js/whiteboard.js index ef7ad14..70a2971 100644 --- a/src/js/whiteboard.js +++ b/src/js/whiteboard.js @@ -777,13 +777,20 @@ const whiteboard = { addImgToCanvasByUrl: function (url) { var _this = this; var oldTool = _this.tool; + + const { imageURL } = ConfigService; + var finalURL = url; + if (imageURL && url.startsWith("/uploads/")) { + finalURL = imageURL + url; + } + _this.setTool("mouse"); //Set to mouse tool while dropping to prevent errors _this.imgDragActive = true; _this.mouseOverlay.css({ cursor: "default" }); var imgDiv = $( '
' + '' + '
' + ' ' + @@ -821,15 +828,15 @@ const whiteboard = { if (draw == "1") { //draw image to canvas - _this.drawImgToCanvas(url, width, height, left, top, rotationAngle); + _this.drawImgToCanvas(finalURL, width, height, left, top, rotationAngle); } else { //Add image to background - _this.drawImgToBackground(url, width, height, left, top, rotationAngle); + _this.drawImgToBackground(finalURL, width, height, left, top, rotationAngle); } _this.sendFunction({ t: "addImgBG", draw: draw, - url: url, + url: finalURL, d: [width, height, left, top, rotationAngle], }); _this.drawId++; @@ -1184,6 +1191,7 @@ const whiteboard = { var color = content["c"]; var username = content["username"]; var thickness = content["th"]; + window.requestAnimationFrame(function () { if (tool === "line" || tool === "pen") { if (data.length == 4) {