Skip to content

Commit 218d5d6

Browse files
authored
update
1 parent 1e8ae85 commit 218d5d6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

main.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
22
* Obsidian Plugin: SafeLearn Plugin
3-
* Provides visual and structural enhancements for SafeLearn-specific tags,
4-
* including highlighting of '##fragment', permission-based visibility blocks,
5-
* and Reveal.js features like side-by-side columns.
3+
* Provides visual and structural enhancements for SafeLearn-specific tags.
4+
* Compatible with plain JavaScript use (no bundler required).
65
*/
76

8-
export default class SafeLearnPlugin extends Plugin {
7+
class SafeLearnPlugin extends Plugin {
98
async onload() {
109
this.addStyles();
1110
this.registerDomEvent(document, "DOMContentLoaded", () => {
@@ -86,7 +85,7 @@ export default class SafeLearnPlugin extends Plugin {
8685
}
8786
}
8887

89-
highlightFragments(container: HTMLElement) {
88+
highlightFragments(container) {
9089
const walker = document.createTreeWalker(
9190
container,
9291
NodeFilter.SHOW_TEXT,
@@ -100,9 +99,9 @@ export default class SafeLearnPlugin extends Plugin {
10099
false
101100
);
102101

103-
const toHighlight: Text[] = [];
102+
const toHighlight = [];
104103
while (walker.nextNode()) {
105-
toHighlight.push(walker.currentNode as Text);
104+
toHighlight.push(walker.currentNode);
106105
}
107106

108107
for (const node of toHighlight) {
@@ -113,7 +112,7 @@ export default class SafeLearnPlugin extends Plugin {
113112
}
114113
}
115114

116-
markPermissionBlocks(container: HTMLElement) {
115+
markPermissionBlocks(container) {
117116
const blocks = container.innerHTML.match(/@@@[^@\n]+[\s\S]*?@@@/g);
118117
if (!blocks) return;
119118
for (const block of blocks) {
@@ -128,7 +127,7 @@ export default class SafeLearnPlugin extends Plugin {
128127
}
129128
}
130129

131-
convertSideBySide(container: HTMLElement) {
130+
convertSideBySide(container) {
132131
const pattern = /##side-by-side-start([\s\S]*?)##side-by-side-end/g;
133132
container.innerHTML = container.innerHTML.replace(pattern, (match, content) => {
134133
const parts = content.split(/##separator/g);
@@ -137,3 +136,5 @@ export default class SafeLearnPlugin extends Plugin {
137136
});
138137
}
139138
}
139+
140+
module.exports = SafeLearnPlugin;

0 commit comments

Comments
 (0)