From 461ba6e5d92122fbce6c0b1e59de2eef99deb9bd Mon Sep 17 00:00:00 2001 From: pavelteplitsky Date: Thu, 11 Apr 2019 09:16:05 +0300 Subject: [PATCH 1/3] Issue #52 | Fixed XLSX annotating Improved image rendering for Cells documents - made image wrapper fixed size for any image size --- packages/annotation/js/annotation.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/annotation/js/annotation.js b/packages/annotation/js/annotation.js index b044424..9ed9194 100644 --- a/packages/annotation/js/annotation.js +++ b/packages/annotation/js/annotation.js @@ -83,7 +83,7 @@ $(document).ready(function () { // set text rows data to null rows = null; // append svg element to each page, this is required to draw svg based annotations - addSvgContainer(); + addSvgContainer(documentData.pages); if (isMobile() || fitWidth) { setZoomLevel("Fit Width"); } @@ -1157,9 +1157,25 @@ function download(button) { /** * Append SVG container to each document page */ -function addSvgContainer() { +function addSvgContainer(pages) { $('div.gd-page').each(function (index, page) { $(page).css("zoom", "1"); + var width = page.offsetWidth; + var height = page.offsetHeight; + //Cells document pages size fix + if (getDocumentFormat(documentGuid).format == "Microsoft Excel") { + width = 500; + height = 300; + $(page).css("width", width); + $(page).css("height", height); + $(page).css("min-width", width); + $(page).css("min-height", height); + $(page).css("overflow", "scroll"); + $(page).find("img").css("width", pages[index].width); + width = pages[index].width; + height = pages[index].height; + } + // add svg object to the list for further use // initiate svg object if (svgList == null) { svgList = {}; @@ -1168,9 +1184,8 @@ function addSvgContainer() { return true; } else { if (!(page.id in svgList) && $(page).find("svg").length == 0) { - $(page).addClass("gd-disable-select"); - // add svg object to the list for further use - var draw = SVG(page.id).size(page.offsetWidth, page.offsetHeight); + $(page).addClass("gd-disable-select"); + var draw = SVG(page.id).size(width, height); svgList[page.id] = draw; draw = null; } else { From 9d984b389eda2537499d155bb4866230b8128dd1 Mon Sep 17 00:00:00 2001 From: pavelteplitsky Date: Mon, 22 Apr 2019 14:25:45 +0300 Subject: [PATCH 2/3] Fixed annotation resizing when mouse is out of the canvas --- packages/annotation/js/drawTextAnnotation.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/annotation/js/drawTextAnnotation.js b/packages/annotation/js/drawTextAnnotation.js index 3604c55..3dcfaf8 100644 --- a/packages/annotation/js/drawTextAnnotation.js +++ b/packages/annotation/js/drawTextAnnotation.js @@ -186,6 +186,9 @@ $(document).ready(function () { addComment(annotationsList[annotationsList.length - 1]); } } + if (!element) { + element = $(".gd-annotation")[0]; + } makeResizable(annotation, element); annotationInnerHtml = null; lineInnerHtml = null; @@ -209,6 +212,7 @@ $(document).ready(function () { if (element !== null) { var currentWidth = (isNaN(parseInt(element.style.width))) ? 0 : parseInt(element.style.width); var currentHeight = (isNaN(parseInt(element.style.height))) ? 0 : parseInt(element.style.height); + if (mouse.x != 0) { element.style.width = Math.abs(startX - mouse.x) + "px"; } From 23c5e0e775587bf1f5e52b36b47972172c01cc7f Mon Sep 17 00:00:00 2001 From: pavelteplitsky Date: Mon, 22 Apr 2019 14:29:18 +0300 Subject: [PATCH 3/3] Added improvement to stopImmediatePropagation --- packages/annotation/js/drawTextAnnotation.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/annotation/js/drawTextAnnotation.js b/packages/annotation/js/drawTextAnnotation.js index 3dcfaf8..b3787d0 100644 --- a/packages/annotation/js/drawTextAnnotation.js +++ b/packages/annotation/js/drawTextAnnotation.js @@ -173,6 +173,8 @@ $(document).ready(function () { // set mouse up event // this handler used to get annotation width and height after draw process $(canvas).on(userMouseUp, function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); if (['textField','watermark'].indexOf(currentPrefix) >= 0) { attachTextFieldBehaviour(element,annotation); }