|
@@ -31,6 +31,8 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
tooltipText = 'Initial';
|
|
|
|
|
|
+ public npcDescriptions: any = {};
|
|
|
+
|
|
|
editor: Editor = new Editor();
|
|
|
toolbar: any = [
|
|
|
// default value
|
|
@@ -149,7 +151,7 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
|
|
|
this.isInEditMode = false;
|
|
|
}
|
|
|
|
|
|
- deleteEntry(): void {
|
|
|
+ public deleteEntry(): void {
|
|
|
this.entries.splice(this.currentEntryIndex, 1);
|
|
|
if (this.entries.length === 0) {
|
|
|
this.currentEntryIndex = -1;
|
|
@@ -170,22 +172,28 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
|
|
+ /**
|
|
|
+ * Converts the content of the current entry to a tooltipified version.
|
|
|
+ * Is called on everyx refresh of an entry
|
|
|
+ */
|
|
|
tooltipify() {
|
|
|
let result: any = this.tooltipService.tooltipifyEntry(
|
|
|
JSON.parse(JSON.stringify(this.currentEntry.content)),
|
|
|
);
|
|
|
- // console.log(result);
|
|
|
+ console.log(result.npcDescriptions);
|
|
|
this.tooltipifiedEntry.content = result.content;
|
|
|
+ this.npcDescriptions = result.npcDescriptions;
|
|
|
+
|
|
|
+ console.log(this.npcDescriptions);
|
|
|
|
|
|
// 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);
|
|
|
+ }, 10);
|
|
|
|
|
|
// result.forEach((entry: any) => {
|
|
|
// entry.content = this.sanitizer.bypassSecurityTrustHtml(entry.content);
|
|
@@ -205,7 +213,7 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
/**
|
|
|
* Highlights and adds tooltips to the names that are mentioned in the current entry.
|
|
|
- * @param name The name of the person which mentionings are to be highlighted.
|
|
|
+ * @param name The name of the person which is currently highlighted.
|
|
|
*/
|
|
|
addHighlightsToText(name: string) {
|
|
|
console.log('Highlighting: ' + name);
|
|
@@ -222,10 +230,21 @@ export class JournalNotesComponent implements OnInit, OnDestroy {
|
|
|
componentRef.instance.tooltip = this.tooltip;
|
|
|
// Appends it at the right spot
|
|
|
this.renderer.appendChild(element, componentRef.location.nativeElement);
|
|
|
+ // add a mouseover event listener to the highlight component
|
|
|
+ this.renderer.listen(
|
|
|
+ componentRef.location.nativeElement,
|
|
|
+ 'mouseover',
|
|
|
+ () => {
|
|
|
+ console.log('Mouseover on: ' + name);
|
|
|
+ console.log(this.npcDescriptions);
|
|
|
+
|
|
|
+ this.tooltipText = this.npcDescriptions[name];
|
|
|
+ },
|
|
|
+ );
|
|
|
});
|
|
|
// Modufies the text inside the tooltip template
|
|
|
// Muss auf mouseover erfolgen
|
|
|
- this.tooltipText = 'Neuer Tooltip <b>text</b>';
|
|
|
+ // this.tooltipText = 'Neuer Tooltip <b>text</b>';
|
|
|
}
|
|
|
|
|
|
ngOnDestroy(): void {
|