فهرست منبع

highlighting and tooltips are added now

Warafear 6 ماه پیش
والد
کامیت
9e5067875c

+ 2 - 5
src/app/journal/journal-notes/journal-notes.component.html

@@ -104,17 +104,14 @@
     } @else {
       <div class="read-container">
         <div class="title-row">
-          <div class="title-read">{{ entries[currentEntryIndex].title }}</div>
+          <div class="title-read">{{ currentEntry.title }}</div>
           <div class="date-read">
             {{ currentEntry.created | date: "longDate" : "" : "de" }}
           </div>
         </div>
         <divider appearance="gold-2"></divider>
         <!-- <div class="content-read" [innerHTML]="currentEntry.content"></div> -->
-        <div
-          class="content-read"
-          [innerHTML]="tooltipifiedEntries[currentEntryIndex].content"
-        ></div>
+        <div class="content-read" [innerHTML]="tooltipifiedEntry.content"></div>
       </div>
     }
     <div class="button-row">

+ 17 - 13
src/app/journal/journal-notes/journal-notes.component.ts

@@ -85,6 +85,7 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
       this.currentEntryIndex = -1;
     } else {
       this.currentEntry = this.entries[0];
+      this.tooltipifiedEntry = JSON.parse(JSON.stringify(this.currentEntry));
     }
     this.tooltipify();
   }
@@ -173,20 +174,19 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
     let result: any = this.tooltipService.tooltipifyEntry(
       JSON.parse(JSON.stringify(this.currentEntry.content)),
     );
-    console.log(result);
-    this.tooltipifiedEntry = result.content;
-    result.npcs.forEach((name: string) => {
-      this.addHighlightsToText(name);
-    });
+    // console.log(result);
+    this.tooltipifiedEntry.content = result.content;
+
+    // console.log(result.content);
+    // console.log(this.tooltipifiedEntry);
+
+    // TODO: AB hier funktioniert es noch nicht.
+    setTimeout(() => {
+      result.npcs.forEach((name: string) => {
+        this.addHighlightsToText(name);
+      });
+    }, 1000);
 
-    // result = {
-    //   enntryContent: string;
-    //   npcs: string[] = [xyz];
-    //   npcDescriptions: {
-    //     name1: 'description1',
-    //     name2: 'description2',
-    //   }
-    //   }
     // result.forEach((entry: any) => {
     //   entry.content = this.sanitizer.bypassSecurityTrustHtml(entry.content);
     // });
@@ -208,8 +208,12 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
    * @param name The name of the person which mentionings are to be highlighted.
    */
   addHighlightsToText(name: string) {
+    console.log('Highlighting: ' + name);
+
     // Target the correct containers
     const parent = this.el.nativeElement.querySelectorAll('.' + name);
+    console.log(parent);
+
     parent.forEach((element: any) => {
       const componentRef = this.test.createComponent(HighlightComponent);
       // The name