-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathsettings.ts
More file actions
26 lines (22 loc) · 932 Bytes
/
settings.ts
File metadata and controls
26 lines (22 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// There are a bunch of legacy Roam42 features that uses this settings system - plan is to migrate those over time
// once I see which features actually get usage, then delete this file
import getBlockUidsAndTextsReferencingPage from "roamjs-components/queries/getBlockUidsAndTextsReferencingPage";
const normalizeSpaces = (value: string) =>
value.replace(/[\u200B\u200C\u200D\uFEFF]/gu, "").replace(/\s+/gu, " ");
export const get = (settingName: string) => {
let customTrigger = getBlockUidsAndTextsReferencingPage("42Setting");
let result = null;
for (let s of customTrigger) {
const normalizedText = normalizeSpaces(s.text);
if (normalizedText.includes(settingName)) {
result = normalizedText
.replace("#42Setting ", "")
.replace("#[[42Setting]] ", "")
.replace("[[42Setting]] ", "")
.replace(settingName, "")
.trim();
break;
}
}
return result;
};