From 152048f7ea03868f640da39e3bc3b625a92d047b Mon Sep 17 00:00:00 2001 From: Timo Wagner Date: Sat, 18 Oct 2025 20:15:11 +0200 Subject: [PATCH] Add simple sizeInfo to context menu for single selected images and texts --- locales/de/translation.json | 3 ++- locales/en/translation.json | 3 ++- locales/fi/translation.json | 3 ++- public/js/edit.js | 18 +++++++++++++++++- views/admin/editSlide.twig | 3 +++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/locales/de/translation.json b/locales/de/translation.json index 03d029c..1243edb 100644 --- a/locales/de/translation.json +++ b/locales/de/translation.json @@ -31,7 +31,8 @@ "addVideo": "Video hinzufügen", "addWebPage": "Webseite hinzufügen", "announce": "Sofort anzeigen", - "announceAll": "Global sofort anzeigen" + "announceAll": "Global sofort anzeigen", + "sizeInfo": "Größe" }, "navs": { "bundle": "Pakete", diff --git a/locales/en/translation.json b/locales/en/translation.json index 403ded0..d5ff6b5 100644 --- a/locales/en/translation.json +++ b/locales/en/translation.json @@ -31,7 +31,8 @@ "addVideo": "Add Video", "addWebPage": "Add Web page", "announce": "Fast Announce", - "announceAll": "Global Announce" + "announceAll": "Global Announce", + "sizeInfo": "Size" }, "navs": { "bundle": "bundle", diff --git a/locales/fi/translation.json b/locales/fi/translation.json index 295e82f..ec05260 100644 --- a/locales/fi/translation.json +++ b/locales/fi/translation.json @@ -31,7 +31,8 @@ "addVideo": "Lisää Video", "addWebPage": "Lisää Web-sivu", "announce": "Ilmoita", - "announceAll": "Ilmoita Kaikille" + "announceAll": "Ilmoita Kaikille", + "sizeInfo": "Koko" }, "navs": { "bundle": "DiaPaketti", diff --git a/public/js/edit.js b/public/js/edit.js index 746106c..38efbf4 100644 --- a/public/js/edit.js +++ b/public/js/edit.js @@ -144,12 +144,28 @@ $(document).bind("contextmenu", function (event) { var objects = canvas.getActiveObjects(); if (objects.length > 0) { - // Show contextmenu + // Show contextmenu and hide size info to avoid laggy oppening + const sizeInfo = $('[data-action="sizeInfo"]') + sizeInfo.hide() $("#contextmenu").finish().toggle(100).// In the right position (the mouse) css({ top: event.pageY + "px", left: event.pageX + "px" }); + // only show the size info in case a single object is selected + if (objects.length === 1) { + const prevText = sizeInfo.text() + const labelPart = prevText.split(':')[0] + let sizePart = "" + if (objects[0].type === "image") { + sizePart = Math.round(objects[0].width*objects[0].scaleX) + sizePart += ' x ' + Math.round(objects[0].height*objects[0].scaleY) + } else if (objects[0].type === "i-text") { + sizePart = objects[0].fontSize + } + sizeInfo.text(labelPart+ ': ' + sizePart) + sizeInfo.show() + } } }); diff --git a/views/admin/editSlide.twig b/views/admin/editSlide.twig index ae8db93..2428fee 100644 --- a/views/admin/editSlide.twig +++ b/views/admin/editSlide.twig @@ -285,6 +285,9 @@ {{ t("actions.delete") }} + + {{ t("actions.sizeInfo") }}: +