Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow placing the annotation element after the selected text #232

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading