Skip to content

Commit 7f642a9

Browse files
committed
update blades
1 parent 56810e3 commit 7f642a9

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
[Token Note Hover](https://foundryvtt.com/packages/token-note-hover)
44

5+
## [4.0.3](https://github.com/jendave/token-note-hover/blob/main/CHANGELOG.md) (2026-01-29)
6+
7+
* [Blades in the Dark](https://foundryvtt.com/packages/blades-in-the-dark) improvements.
8+
* Fixed issue with formatting.
9+
* Added note for Factions.
10+
511
## [4.0.2](https://github.com/jendave/token-note-hover/blob/main/CHANGELOG.md) (2026-01-23)
612

713
* Added support for using a HotKey to show the hovered note.

src/scripts/systems/bladesInTheDark.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import CONSTANTS from '../constants.js';
22
import { processNotes } from "../textUtil.js";
3+
import { processRawNotes } from "../textUtil.js";
34

45
export async function bladesInTheDark(actor, displayImages) {
56
// Using a guard here looks cleaner
@@ -19,7 +20,11 @@ export async function bladesInTheDark(actor, displayImages) {
1920
return null;
2021
}
2122
case "factions":
22-
return null;
23+
if (game.settings.get(CONSTANTS.MODULE_ID, 'displayNPC')) {
24+
return await getFactionNotes(displayImages, actor, actorIsOwner);
25+
} else {
26+
return null;
27+
}
2328
case "character":
2429
if (game.settings.get(CONSTANTS.MODULE_ID, 'displayPC')) {
2530
return await getCharacterNotes(displayImages, actor, actorIsOwner);
@@ -38,13 +43,26 @@ export async function bladesInTheDark(actor, displayImages) {
3843
}
3944

4045
async function getClockNotes(displayImages, actor, actorIsOwner) {
41-
return await processNotes(actor.system?.value + " / " + actor.system?.type, actorIsOwner, displayImages);
46+
return await processRawNotes(actor.system?.value + " / " + actor.system?.type, actorIsOwner, displayImages);
4247
}
4348

4449
async function getCharacterNotes(displayImages, actor, actorIsOwner) {
45-
return await processNotes(actor.system?.description, actorIsOwner, displayImages);
50+
return await processRawNotes(actor.system?.description, actorIsOwner, displayImages);
4651
}
4752

4853
async function getNPCNotes(displayImages, actor, actorIsOwner) {
49-
return await processNotes(actor.system?.notes, actorIsOwner, displayImages);
54+
return await processRawNotes(actor.system?.notes, actorIsOwner, displayImages);
55+
}
56+
57+
async function getFactionNotes(displayImages, actor, actorIsOwner) {
58+
let factionNote = "";
59+
for (let i = 0; i < actor.items.contents.length; i += 1) {
60+
factionNote = factionNote.concat("<div class=\"token-note-hover-hud-h3\">");
61+
factionNote = factionNote.concat(actor.items.contents[i].name);
62+
factionNote = factionNote.concat("</div>");
63+
factionNote = factionNote.concat("<p>");
64+
factionNote = factionNote.concat(actor.items.contents[i].system.description);
65+
factionNote = factionNote.concat("</p>");
66+
}
67+
return await processNotes(factionNote, actorIsOwner, displayImages);
5068
}

src/scripts/textUtil.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,27 @@ async function getTextFromNote(notes, actorIsOwner) {
1919
async: true,
2020
});
2121
}
22+
23+
export async function processRawNotes(notes, actorIsOwner, displayImages) {
24+
const renderedNotes = await getTextFromRawNote(notes, actorIsOwner);
25+
26+
if (!renderedNotes) {
27+
return null;
28+
}
29+
30+
return displayImages ? renderedNotes : renderedNotes.replaceAll(/<img.*>/g, "");
31+
}
32+
33+
async function getTextFromRawNote(notes, actorIsOwner) {
34+
if (!notes || notes.length === 0) {
35+
return null;
36+
}
37+
38+
const updatedNotes = notes.replaceAll(/\n/g, "<br />");
39+
40+
return await foundry.applications.ux.TextEditor.enrichHTML(updatedNotes, {
41+
secrets: actorIsOwner,
42+
documents: true,
43+
async: true,
44+
});
45+
}

0 commit comments

Comments
 (0)