diff --git a/nietzsche-beta-app/src/app/page-view/models.ts b/nietzsche-beta-app/src/app/page-view/models.ts index 23608f4..ba33dac 100644 --- a/nietzsche-beta-app/src/app/page-view/models.ts +++ b/nietzsche-beta-app/src/app/page-view/models.ts @@ -1,290 +1,294 @@ /** * This interface specifies a function that returns a style class string (e.g. 'textfield unhighlighted') * that can be passed to [ngClass]. **/ export interface externalAssignClass { (currentWord: Word, hoveredWord: Word, hoveredLine: Line): string; } /** * This interface specifies a function that returns a style Object (e.g. { fill: red }) * that can be passed to [ngStyle]. **/ export interface externalAssignStyle { (currentItem: Line | Word, hoveredWord: Word, hoveredLine: Line, hoverStatus: string): Object; } /** * This interface specifies a configuration * */ export interface Configuration { [name: string]: any; } /** * a text continuation **/ export interface Continuation extends Interactable { reference: Reference; source: Reference; show?: string; } /** * Copyright information **/ export interface Copyright { text: string; licenseTextUrl?: string; license: string; originalUrl?: string; } /** * This interface specifies an object that can interact with {@link /injectables/PageViewService.html|PageViewService}. **/ export interface Interactable { /** * the string representation of the Interactable's interface type * ({@link /interfaces/Word.html|Word}|{@link /interfaces/Line.html|Line}|{@link /interfaces/TextByForeignHand.html|TextByForeignHand}). **/ datatype?: string; /** * the identity of the textfield to which this Interactable belongs. **/ textfield_identity?: string; /** * is Interactable top object **/ is_top_object?: boolean; } /** * This interface specifies the image that will be displayed by {@link /components/TextFieldComponent.html|TextFieldComponent}. **/ export interface Image { /** x coordinate of image **/ x: number; /** y coordinate of image **/ y: number; /** width of image **/ width: number; /** height of image **/ height: number; /** filename of image **/ filename: string; /** primary URL of image **/ URL: string; /** secondary URL of image **/ secondaryURL?: string; /** displayable area of image **/ text_field: TextField; /** matrix transformation string **/ transform?: string; /** * copyright information **/ copyright?: Copyright; } /** * This interface specifies a line that will be displayed by {@link /components/MarginFieldComponent.html|MarginFieldComponent}. **/ export interface LineStub extends Interactable { /** the line number **/ number: number; /** the (optional) IRI of this line **/ id: Identifier; } /** * This interface specifies a line that will be displayed by {@link /components/MarginFieldComponent.html|MarginFieldComponent}. **/ export interface Line extends LineStub { /** geometrical bottom position of this line **/ bottom: number; /** geometrical top position of this line **/ top: number; /** * reference to the line from which this line continues **/ continuesFrom?: Reference; /** * reference to the line on which this line continues **/ continuesTo?: Reference; source?: Reference; } /** * This interface specifies the area of an image that will be displayed by {@link /components/TextFieldComponent.html|TextFieldComponent}. **/ export interface TextField { /** the width of this textfield **/ width: number; /** the height of this textfield **/ height: number; /** the geometrical left position of this textfield **/ left: number; /** the geometrical top position of this textfield **/ top: number; } /** * This type specifies an identifier for words/lines (by its IRI string or its id number) **/ export type Identifier = string | number; /** * This interface specifies a page. **/ export interface Page { id: Identifier; number: string; } /** * Any svg path with an optional type. **/ export interface Path { id: Identifier; d: string; type?: string; } /** * geometrical Point **/ export interface Point { visible: boolean clientX: number; clientY: number; layerX: number; layerY: number; } /** * simple x,y-position **/ export interface Position { x: number; y: number; } /** * This interface specifies a postional object that can be displayed as a rect on the image by {@link /components/TextFieldComponent.html|TextFieldComponent}. **/ export interface PositionalObject extends Interactable { /** the identifier of a positional object (i.e. 'IRI' (string) or 'id' (number)) **/ id: Identifier; /** the geometrical left position of this word's rect. **/ left: number; /** the geometrical top position of this word's rect. **/ top: number; /** the width of this word's rect. **/ width: number; /** the height of this word's rect. **/ height: number; /** the matrix transformation string of the geometrical position of this word's rect. **/ transform?: string; } /** * This interface specifies a Line Reference that can be routed to. **/ export interface LineReference { /** * the title of the reference **/ manuscript?: Manuscript; /** * the page number of the reference **/ page?: string; /** * the line number of the reference **/ line_number?: number; /** * the line identifiaction of the reference **/ id: Identifier; } export interface Reference { /** * reference to the manuscript **/ manuscript?: Manuscript; /** * reference to the page **/ page?: Page; /** * reference to the line **/ line?: LineStub; /** * reference to the word **/ //word?: WordStub; } /** * This interface specifies a manuscript **/ export interface Manuscript { id: Identifier; title: string; type?: string; } /** * This interface specifies a text written by a foreign hand. **/ export interface TextByForeignHand extends PositionalObject { /** * pen used for writing text **/ pen: string; /** * text by foreign hand **/ text: string; /** * resolution of the abbrevation. **/ resolution?: string; /** * editor's comment about this text of foreign hand **/ comment?: string; + /** + * overwritten text by foreign hand + **/ + overwrittenTextByForeignHand?: TextByForeignHand; } /** * This interface specifies a word that can be displayed as a rect on the image by {@link /components/TextFieldComponent.html|TextFieldComponent}. **/ export interface Word extends PositionalObject { /** the (raw) text of this word. **/ text: string; /** the text of this word as it has been edited by the editors. **/ edited_text?: string; /** the identification of the line to which this word belongs (iri or id). **/ line: string | number; /** the number of the line to which this word belongs. **/ line_number: number; /** is this word deleted. **/ deleted: boolean; /** a deletion path **/ deletion_path?: string; } export const USE_EXTERNAL_TOOLTIP: string = 'UseExternalTooltip'; diff --git a/nietzsche-beta-app/src/app/tln-edition/datatypes/foreign_text.ts b/nietzsche-beta-app/src/app/tln-edition/datatypes/foreign_text.ts index d734a19..8caac92 100644 --- a/nietzsche-beta-app/src/app/tln-edition/datatypes/foreign_text.ts +++ b/nietzsche-beta-app/src/app/tln-edition/datatypes/foreign_text.ts @@ -1,110 +1,157 @@ import { FusekiResults, BasicResultBindingElement } from './basic_datatype'; import { TlnPositionalObject } from './positional_object'; import { TextByForeignHand } from '../models'; import { TlnPositionalStyleMarkup } from './positional-markup'; /** * This is the 'text by foreign hand' instantiation of an element of {@link /interfaces/FusekiResults.html|FusekiResults}. * It extends {@link /classes/BasicResultBindingElement.html|BasicResultBindingElement}. **/ export class TlnTextByForeignHand extends TlnPositionalObject implements TextByForeignHand { /** * the SPARQL-query of this datatype. **/ static readonly query: string = ` PREFIX tln: <http://www.nie.org/ontology/nietzsche#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - SELECT ?id ?text ?pen ?left ?top ?width ?height ?resolution ?comment ?transform ?markup ?sStyle ?start ?end WHERE { + SELECT ?id ?text ?pen ?left ?top ?width ?height ?resolution ?comment ?transform ?markup ?sStyle ?start ?end + ?idOFH ?textOFH ?penOFH ?markupOFH ?startOFH ?endOFH ?sStyleOFH + WHERE { ?page tln:hasMarkForeignHands/rdf:rest*/rdf:first ?id. ?id tln:textOfForeignHands ?textOfForeignHands; tln:penOfForeignHands ?pen; tln:hasTranskriptionPosition ?tp. ?textOfForeignHands tln:textHasContent ?text. ?tp tln:hasLeft ?left; tln:hasTop ?top; tln:hasWidth ?width; tln:hasHeight ?height. OPTIONAl { ?id tln:resolutionOfAbbreviation ?resolution.} OPTIONAl { ?id tln:foreignHandHasCommentByEditors ?comment.} OPTIONAl { ?textOfForeignHands tln:textHasMarkup ?markup. ?markup tln:standoffTagHasEndIndex ?end; tln:standoffTagHasStartIndex ?start; tln:standoffTagHasCSS ?sStyle. } OPTIONAl { ?tp tln:hasTransform ?transform.} + OPTIONAL { ?id tln:foreignHandOverwritesForeignHand ?idOFH. + ?idOFH tln:textOfForeignHands ?textOfForeignHandsOFH; + tln:penOfForeignHands ?penOFH. + ?textOfForeignHandsOFH tln:textHasContent ?textOFH. + OPTIONAL { + ?textOfForeignHandsOFH tln:textHasMarkup ?markupOFH. + ?markupOFH tln:standoffTagHasEndIndex ?endOFH; + tln:standoffTagHasStartIndex ?startOFH; + tln:standoffTagHasCSS ?sStyleOFH. + } + } } `; /** * the text of this word **/ text: string; /** * the text of this word as it has been edited by the editors. **/ pen: string; /** * resolution of the abbrevation **/ resolution?: string; /** * editor's comment about this text of foreign hand **/ comment?: string; markups: TlnPositionalStyleMarkup[] = []; + /** + * overwritten text by foreign hand + **/ + overwrittenTextByForeignHand?: TextByForeignHand; /** * The constructor creates a datatype from the data. * * @param id if omitted the id will be retrieved from data **/ constructor(data: any, id?: string, service?: any){ super(data, id, service) this.text = this.getData4Key('text'); this.pen = this.getData4Key('pen'); this.resolution = this.getData4Key('resolution'); this.comment = this.getData4Key('comment'); } public static convertData<T extends typeof BasicResultBindingElement>(this: T, data: FusekiResults, id?: string, service?: any): Array<InstanceType<T>> { let elements = []; let content = this.getContent(data); for (var i = 0; i < content.length; i++){ let element = new TlnTextByForeignHand(content[i], id, service); if (content[i]['markup'] != undefined && content[i]['markup']['value'] != null){ element.markups = TlnPositionalStyleMarkup.convertData({ head: { vars: []}, results: { bindings: <any>[ content[i] ] } }, content[i]['markup']['value']) } + if (content[i]['idOFH'] != undefined && content[i]['idOFH']['value'] != null){ + //let results = Object.fromEntries(Object.entries(content[i]).filter(key_value =>key_value[0].endsWith('OFH'))) + let contentObject = Object.fromEntries( + Object.entries(content[i]).filter(key_value =>key_value[0].endsWith('OFH')).map(key_value =>[ key_value[0].replace('OFH', ''), key_value[1]]) + ); + let overwritten_mark = TlnTextByForeignHand.convertData({ head: { vars: []}, results: { bindings: <any>[ contentObject ] }}, content[i]['idOFH']['value'])[0] + if (elements.length > 0 && elements[elements.length-1].id == element.id + && elements[elements.length-1].overwrittenTextByForeignHand != undefined && elements[elements.length-1].overwrittenTextByForeignHand != null){ + overwritten_mark.markups.forEach(markup =>{elements[elements.length-1].overwrittenTextByForeignHand.markups.push(markup) }); + } else { + element.overwrittenTextByForeignHand = overwritten_mark + } + } if (elements.length > 0 && elements[elements.length-1].id == element.id){ element.markups.forEach(markup =>{elements[elements.length-1].markups.push(markup)}); + if (element.overwrittenTextByForeignHand != undefined && element.overwrittenTextByForeignHand != null){ + elements[elements.length-1].overwrittenTextByForeignHand = element.overwrittenTextByForeignHand + } } else { elements.push(element) } } //console.log(elements) return elements; } } /** * This is the faksimile text by foreign hand instantiation of an element of {@link /interfaces/FusekiResults.html|FusekiResults}. * It extends {@link /classes/BasicResultBindingElement.html|BasicResultBindingElement}. **/ export class FaksimileTextByForeignHand extends TlnTextByForeignHand { /** * the SPARQL-query of this datatype. **/ static readonly query: string = ` PREFIX tln: <http://www.nie.org/ontology/nietzsche#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - SELECT ?id ?text ?pen ?left ?top ?width ?height ?resolution ?comment ?transform ?markup ?sStyle ?start ?end WHERE { + SELECT ?id ?text ?pen ?left ?top ?width ?height ?resolution ?comment ?transform ?markup ?sStyle ?start ?end + ?idOFH ?textOFH ?penOFH ?markupOFH ?startOFH ?endOFH ?sStyleOFH + WHERE { ?page tln:hasMarkForeignHands/rdf:rest*/rdf:first ?id. ?id tln:textOfForeignHands ?textOfForeignHands; tln:penOfForeignHands ?pen; tln:hasFaksimilePosition ?fp. ?textOfForeignHands tln:textHasContent ?text. ?fp tln:hasLeft ?left; tln:hasTop ?top; tln:hasWidth ?width; tln:hasHeight ?height. OPTIONAl { ?id tln:resolutionOfAbbreviation ?resolution.} OPTIONAl { ?id tln:foreignHandHasCommentByEditors ?comment.} OPTIONAl { ?textOfForeignHands tln:textHasMarkup ?markup. ?markup tln:standoffTagHasEndIndex ?end; tln:standoffTagHasStartIndex ?start; tln:standoffTagHasCSS ?sStyle. } OPTIONAl { ?fp tln:hasTransform ?transform.} + OPTIONAL { ?id tln:foreignHandOverwritesForeignHand ?idOFH. + ?idOFH tln:textOfForeignHands ?textOfForeignHandsOFH; + tln:penOfForeignHands ?penOFH. + ?textOfForeignHandsOFH tln:textHasContent ?textOFH. + OPTIONAL { + ?textOfForeignHandsOFH tln:textHasMarkup ?markupOFH. + ?markupOFH tln:standoffTagHasEndIndex ?endOFH; + tln:standoffTagHasStartIndex ?startOFH; + tln:standoffTagHasCSS ?sStyleOFH. + } + } + } `; } diff --git a/nietzsche-beta-app/src/app/tln-edition/tooltip/tool-tip.component.html b/nietzsche-beta-app/src/app/tln-edition/tooltip/tool-tip.component.html index f09dcab..11baa42 100644 --- a/nietzsche-beta-app/src/app/tln-edition/tooltip/tool-tip.component.html +++ b/nietzsche-beta-app/src/app/tln-edition/tooltip/tool-tip.component.html @@ -1,57 +1,65 @@ <div #myElement *ngIf="useExtendedTooltip && tooltipPosition.visible && hasAnyContent()" [ngClass]="[ 'tooltip', currentKey ]" [style.top.px]="getTop(currentKey)" [style.left.px]="getLeft(myElement.offsetWidth)"> <div *ngIf="word"> <div *ngIf="debug"> {{tooltipPosition.clientY+yOffset}}, {{topOffset}} <!--<div *ngFor="let markup of positionalStyleMarkups"> <div ><span>{{markup.startIndex}} </span><span>{{markup.endIndex}} </span><span>{{markup.cssStyleTag}}</span></div> </div>--> </div> <div class="earlier-version" *ngFor="let earlier_version of earlier_version_list; let i = index"> <span><i>{{i}}:</i> </span> <span *ngIf="!earlier_version.markups || earlier_version.markups.length == 0">{{earlier_version.text}}</span> <ngx-mat-standoffMarkup-component *ngIf="earlier_version.markups && earlier_version.markups.length > 0" [text]="earlier_version.text" [standOffMarkup]="earlier_version.markups" [settings]="mySettings"></ngx-mat-standoffMarkup-component> </div> <div class="text" > <span *ngIf="earlier_version_list.length"><i>{{earlier_version_list.length}}:</i> </span> <span *ngIf="!positionalStyleMarkups || positionalStyleMarkups.length == 0" [ngClass]="{'deleted': word.deleted}">{{word.text}}</span> <ngx-mat-standoffMarkup-component *ngIf="positionalStyleMarkups && positionalStyleMarkups.length > 0" [text]="word.text" [standOffMarkup]="positionalStyleMarkups" [settings]="mySettings"></ngx-mat-standoffMarkup-component> </div> <span class="edited_text" *ngIf="word.edited_text">>{{word.edited_text}}</span> <div class="overwritten" *ngIf="overwrittenWord"> <overwritten [word]="word"></overwritten><i>überschreibt: </i> <span [ngClass]="{'deleted': overwrittenWord.deleted}">{{overwrittenWord.text}}</span> <span *ngIf="overwrittenWord.uncertain_decipherment">] <i>?</i></span> </div> <editor-comment *ngFor="let editor_comment of editor_comments | mergeEditorComment" [editor_comment]="editor_comment"></editor-comment> </div> <div *ngIf="foreignHand"> <span *ngIf="!foreignHand.markups || foreignHand.markups.length == 0">{{foreignHand.text}}</span> <ngx-mat-standoffMarkup-component *ngIf="foreignHand.markups && foreignHand.markups.length > 0" [text]="foreignHand.text" [standOffMarkup]="foreignHand.markups" [settings]="mySettings"></ngx-mat-standoffMarkup-component> <i> <span *ngIf="foreignHand.resolution"> (={{foreignHand.resolution}})</span> <span *ngIf="foreignHand.comment"> {{foreignHand.comment}}</span>, {{foreignHand.pen}} </i> + <div *ngIf="foreignHand.overwrittenTextByForeignHand"><i>überschreibt: </i> + <span *ngIf="!foreignHand.overwrittenTextByForeignHand.markups || foreignHand.overwrittenTextByForeignHand.markups.length == 0">{{foreignHand.overwrittenTextByForeignHand.text}} + </span> + <ngx-mat-standoffMarkup-component *ngIf="foreignHand.overwrittenTextByForeignHand.markups && foreignHand.overwrittenTextByForeignHand.markups.length > 0" + [text]="foreignHand.overwrittenTextByForeignHand.text" [standOffMarkup]="foreignHand.overwrittenTextByForeignHand.markups" [settings]="mySettings"> + </ngx-mat-standoffMarkup-component> + <i>, {{foreignHand.overwrittenTextByForeignHand.pen}}</i> + </div> </div> <div *ngIf="continuation"> <span *ngIf="continuation.show == 'to'"><i>{{continuation.source.line.number}}</i> nach </span> <i> <span *ngIf="continuation.source.manuscript">{{continuation.reference.manuscript.title}} </span> <span *ngIf="continuation.source.page">{{continuation.reference.page.number}}, </span> {{continuation.reference.line.number}} </i> <span *ngIf="continuation.show != 'to'"> nach <i>{{continuation.source.line.number}}</i></span> </div> <div *ngIf="continuation && continuation_words.length > 0"> <span *ngIf="continuation.show == 'to'">→ </span> <span *ngFor="let word of continuation_words"> {{ (word.earlier_version) ? '[0:' + word.earlier_version + '|1:' : ''}} <ngx-mat-standoffMarkup-component [text]="word.text" [standOffMarkup]="word.markups" [settings]="mySettings"></ngx-mat-standoffMarkup-component> {{ (word.earlier_version) ? ']' : ''}}</span> <span *ngIf="continuation.show != 'to'">→ </span> </div> </div> diff --git a/nietzsche-beta-app/tsconfig.json b/nietzsche-beta-app/tsconfig.json index 62fde20..62a93ea 100644 --- a/nietzsche-beta-app/tsconfig.json +++ b/nietzsche-beta-app/tsconfig.json @@ -1,27 +1,28 @@ { "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true, "skipLibCheck": true, "declaration": false, "downlevelIteration": true, "experimentalDecorators": true, "module": "esnext", "moduleResolution": "node", "importHelpers": true, "target": "es2015", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2018", + "es2020", "dom" ] }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true } }