From d393fcbe8362533f73e3fad0e443d2014f14a0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Lehe=C4=8Dka?= Date: Sat, 10 Aug 2024 15:37:51 +0200 Subject: [PATCH 1/3] elementPosition property (for annotation element) --- resources/scripts/annotations/annotations.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/scripts/annotations/annotations.js b/resources/scripts/annotations/annotations.js index f683458c..53d5e729 100644 --- a/resources/scripts/annotations/annotations.js +++ b/resources/scripts/annotations/annotations.js @@ -91,6 +91,7 @@ window.addEventListener("WebComponentsReady", () => { let autoSave = false; let type = ""; let emptyElement = false; + let elementPosition = "around"; //default position of the annotation element to be inserted; can be also "before" (for ) or "after" (for ) let text = ""; let enablePreview = true; let currentEntityInfo = null; @@ -304,7 +305,8 @@ window.addEventListener("WebComponentsReady", () => { view.addAnnotation({ type, properties: data, - before: emptyElement + before: emptyElement, + position : elementPosition }); } catch (e) { document.getElementById('runtime-error-dialog').show('Error', e); @@ -416,7 +418,14 @@ window.addEventListener("WebComponentsReady", () => { }); } emptyElement = false; + if (button.classList.contains("after")) { + elementPosition = "after"; + } if (button.classList.contains("before")) { + elementPosition = "before"; + } + //if class contains 'before' or 'after' value, it's an empty element + if (elementPosition != "around") { emptyElement = true; } window.pbEvents.emit("show-annotation", "transcription", {}); From 7b9cda35c08c5342457479111096aae39172ba61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Lehe=C4=8Dka?= Date: Sat, 10 Aug 2024 15:39:15 +0200 Subject: [PATCH 2/3] specify position after (selected text) for annotation element --- templates/pages/annotate.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/pages/annotate.html b/templates/pages/annotate.html index 152caa54..cd3aa4de 100644 --- a/templates/pages/annotate.html +++ b/templates/pages/annotate.html @@ -58,7 +58,7 @@ - + From 72b58bbea5a3bcdf448c5f5aaf620d61e961966d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Lehe=C4=8Dka?= Date: Sat, 10 Aug 2024 20:12:52 +0200 Subject: [PATCH 3/3] avoid elementPosition variable to be undefined --- resources/scripts/annotations/annotations.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/scripts/annotations/annotations.js b/resources/scripts/annotations/annotations.js index 53d5e729..890c017e 100644 --- a/resources/scripts/annotations/annotations.js +++ b/resources/scripts/annotations/annotations.js @@ -417,7 +417,7 @@ window.addEventListener("WebComponentsReady", () => { query: selection }); } - emptyElement = false; + elementPosition = "around"; if (button.classList.contains("after")) { elementPosition = "after"; } @@ -425,9 +425,7 @@ window.addEventListener("WebComponentsReady", () => { elementPosition = "before"; } //if class contains 'before' or 'after' value, it's an empty element - if (elementPosition != "around") { - emptyElement = true; - } + emptyElement = (elementPosition != "around"); window.pbEvents.emit("show-annotation", "transcription", {}); showForm(type); text = selection; @@ -651,7 +649,8 @@ window.addEventListener("WebComponentsReady", () => { if (trackHistory) { document.dispatchEvent(new CustomEvent('pb-before-save', { detail: { - user: currentUser + user: currentUser, + export: false } })); } else {