|
| 1 | +/// <reference path="./collectionSettings.d.ts" /> |
| 2 | + |
1 | 3 | import WebSocketManager, { |
2 | 4 | IBloomWebSocketEvent, |
3 | 5 | } from "../../utils/WebSocketManager"; |
4 | 6 | import { postJson } from "../../utils/bloomApi"; |
5 | 7 | import { showBookGridSetupDialog } from "../../react_components/BookGridSetup/BookGridSetupDialog"; |
6 | 8 | import { Link } from "../../react_components/BookGridSetup/BookLinkTypes"; |
7 | 9 |
|
| 10 | +function getLanguage1Font(): string { |
| 11 | + const settings = GetSettings() as ICollectionSettings; |
| 12 | + return settings.language1Font; |
| 13 | +} |
| 14 | + |
| 15 | +function applyLanguage1Font(element: HTMLElement) { |
| 16 | + const language1Font = getLanguage1Font(); |
| 17 | + if (!language1Font) { |
| 18 | + return; |
| 19 | + } |
| 20 | + |
| 21 | + Array.from(element.getElementsByTagName("p")).forEach((p) => { |
| 22 | + p.style.fontFamily = language1Font; |
| 23 | + }); |
| 24 | +} |
| 25 | + |
8 | 26 | export function setupBookLinkGrids(container: HTMLElement) { |
9 | 27 | // Add skeleton to empty grids on initial setup |
10 | 28 | const linkGrids = Array.from( |
11 | 29 | container.getElementsByClassName("bloom-link-grid"), |
12 | 30 | ) as HTMLElement[]; |
13 | 31 | for (const linkGrid of linkGrids) { |
| 32 | + applyLanguage1Font(linkGrid); |
14 | 33 | addSkeletonIfEmpty(linkGrid as HTMLElement); |
15 | 34 | // In case anyone wonders why this works here but will not on most canvas elements |
16 | 35 | // and their children...we put a rule in basepage.less that puts bloom-link-grid |
@@ -96,10 +115,13 @@ export function editLinkGrid(linkGrid: HTMLElement) { |
96 | 115 | const p = document.createElement("p"); |
97 | 116 | p.textContent = |
98 | 117 | link.book.title || link.book.folderName || ""; |
| 118 | + p.style.fontFamily = getLanguage1Font(); |
99 | 119 | button.appendChild(p); |
100 | 120 |
|
101 | 121 | linkGrid.appendChild(button); |
102 | 122 | }); |
| 123 | + |
| 124 | + applyLanguage1Font(linkGrid); |
103 | 125 | } |
104 | 126 | }, |
105 | 127 | ); |
|
0 commit comments