Skip to content

Commit

Permalink
Annotations: add annotation for notes
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangmm committed Jan 22, 2024
1 parent 2181493 commit d9a56ef
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
23 changes: 20 additions & 3 deletions modules/annotation-config.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ declare function anno:annotations($type as xs:string, $properties as map(*)?, $c
<choice xmlns="http://www.tei-c.org/ns/1.0"><sic>{$content()}</sic><corr>{$properties?corr}</corr></choice>
case "reg" return
<choice xmlns="http://www.tei-c.org/ns/1.0"><orig>{$content()}</orig><reg>{$properties?reg}</reg></choice>
case "note" return
<seg xmlns="http://www.tei-c.org/ns/1.0" type="annotated">{$content()}
<note xmlns="http://www.tei-c.org/ns/1.0" type="annotation">{$properties?note}</note></seg>
case "note" return
let $parsed := parse-xml-fragment($properties?content) => anno:fix-namespaces()
return (
$content(),
<note xmlns="http://www.tei-c.org/ns/1.0">{$parsed}</note>
)
case "date" return
<date xmlns="http://www.tei-c.org/ns/1.0">
{
Expand Down Expand Up @@ -120,4 +123,18 @@ declare function anno:occurrences($type as xs:string, $key as xs:string) {
case "organization" return
collection($config:data-default)//tei:orgName[@ref = $key]
default return ()
};

declare %private function anno:fix-namespaces($nodes as item()*) {
for $node in $nodes
return
typeswitch ($node)
case document-node() return
anno:fix-namespaces($node/node())
case element() return
element { QName("http://www.tei-c.org/ns/1.0", local-name($node)) } {
$node/@*, for $child in $node/node() return anno:fix-namespaces($child)
}
default return
$node
};
2 changes: 1 addition & 1 deletion modules/config.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ declare variable $config:enable-proxy-caching :=
: In this case, change $config:webcomponents-cdn to point to http://localhost:port
: (default: 8000, but check where your server is running).
:)
declare variable $config:webcomponents := "2.18.3";
declare variable $config:webcomponents := "2.18.4";

(:~
: CDN URL to use for loading webcomponents. Could be changed if you created your
Expand Down
6 changes: 6 additions & 0 deletions resources/scripts/annotations/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ window.addEventListener("WebComponentsReady", () => {
function save() {
view.saveHistory();
const data = form.serializeForm();
form.querySelectorAll(`.annotation-form.${type} jinn-xml-editor`).forEach((editor) => {
const value = editor.content;
if (value) {
data[editor.getAttribute('name')] = value;
}
});
if (!autoSave) {
hideForm();
}
Expand Down
12 changes: 12 additions & 0 deletions templates/pages/annotate.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<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" 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 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 id="ner-action" icon="social:group-add" data-i18n="[title]annotations.ner.title"></paper-icon-button>
</span>
<span class="icon-group">
Expand Down Expand Up @@ -154,6 +155,17 @@
<paper-input name="n" data-i18n="[label]annotations.pagenum"></paper-input>
<paper-input name="facs" data-i18n="[label]annotations.facs"></paper-input>
</div>
<div class="annotation-form note">
<jinn-xml-editor name="content" placeholder="[Inline text/markup or sequence of paragraphs]" schema="resources/scripts/tei.json" schema-root="note" namespace="http://www.tei-c.org/ns/1.0">
<div slot="toolbar">
<button data-command="selectElement" title="Select element around current cursor position">&lt;|&gt;</button>
<button data-command="encloseWith" title="Enclose selection in new element">&lt;...&gt;</button>
<button data-command="removeEnclosing" title="Remove enclosing tags" class="sep">&lt;X&gt;</button>
<button data-command="snippet" data-params="&lt;placeName key=&#34;$|1|&#34;&gt;$|_|&lt;/placeName&gt;" title="Insert placeName">&lt;placeName&gt;</button>
<button data-command="snippet" data-params="&lt;persName key=&#34;$|1|&#34;&gt;$|_|&lt;/persName&gt;" title="Insert persName">&lt;persName&gt;</button>
</div>
</jinn-xml-editor>
</div>
<div class="annotation-form edit">
<p><pb-i18n key="annotations.modify-info"></pb-i18n></p>
<paper-input name="content" data-i18n="[label]annotations.correction" label="Correction"></paper-input>
Expand Down

0 comments on commit d9a56ef

Please sign in to comment.