Skip to content

Commit

Permalink
Merge pull request #232 from daliboris/feature/annotations/empty-elem…
Browse files Browse the repository at this point in the history
…ent-place

Allow placing the annotation element after the selected text
  • Loading branch information
wolfgangmm authored Oct 10, 2024
2 parents 6e9b0c0 + 72b58bb commit 6ea6b9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions resources/scripts/annotations/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pb/>) or "after" (for <note>)
let text = "";
let enablePreview = true;
let currentEntityInfo = null;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -415,10 +417,15 @@ window.addEventListener("WebComponentsReady", () => {
query: selection
});
}
emptyElement = false;
elementPosition = "around";
if (button.classList.contains("after")) {
elementPosition = "after";
}
if (button.classList.contains("before")) {
emptyElement = true;
elementPosition = "before";
}
//if class contains 'before' or 'after' value, it's an empty element
emptyElement = (elementPosition != "around");
window.pbEvents.emit("show-annotation", "transcription", {});
showForm(type);
text = selection;
Expand Down Expand Up @@ -642,7 +649,8 @@ window.addEventListener("WebComponentsReady", () => {
if (trackHistory) {
document.dispatchEvent(new CustomEvent('pb-before-save', {
detail: {
user: currentUser
user: currentUser,
export: false
}
}));
} else {
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/annotate.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<paper-icon-button class="annotation-action" data-i18n="[title]annotations.app" title="Apparatus" data-type="app" icon="icons:visibility" data-shortcut="⌘+⇧+v,ctrl+⇧+v" disabled="disabled"></paper-icon-button>
<paper-icon-button class="annotation-action" data-i18n="[title]annotations.hi" title="Highlight" data-type="hi" icon="editor:format-bold" data-shortcut="⌘+⇧+h,ctrl+⇧+h" disabled="disabled"></paper-icon-button>
<paper-icon-button class="annotation-action before" data-i18n="[title]annotations.pb" title="Page break" data-type="pb" icon="editor:format-textdirection-r-to-l" data-shortcut="⌘+⇧+b,ctrl+⇧+b" disabled="disabled"></paper-icon-button>
<paper-icon-button class="annotation-action before" data-i18n="[title]annotations.note" title="Note" data-type="note" icon="icons:speaker-notes" data-shortcut="⌘+⇧+f,ctrl+⇧+f" disabled="disabled"></paper-icon-button>
<paper-icon-button class="annotation-action after" data-i18n="[title]annotations.note" title="Note" data-type="note" icon="icons:speaker-notes" data-shortcut="⌘+⇧+f,ctrl+⇧+f" disabled="disabled"></paper-icon-button>
<paper-icon-button class="annotation-action" data-i18n="[title]annotations.modify" title="Edit" data-type="edit" icon="editor:mode-edit" data-shortcut="⌘+⇧+m,ctrl+⇧+m" disabled="disabled"></paper-icon-button>
<paper-icon-button id="ner-action" icon="social:group-add" data-i18n="[title]annotations.ner.title"></paper-icon-button>
</span>
Expand Down

0 comments on commit 6ea6b9c

Please sign in to comment.