Skip to content

Commit 6fb5e1a

Browse files
authored
update
1 parent 218d5d6 commit 6fb5e1a

File tree

2 files changed

+48
-68
lines changed

2 files changed

+48
-68
lines changed

main.js

Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,19 @@
44
* Compatible with plain JavaScript use (no bundler required).
55
*/
66

7-
class SafeLearnPlugin extends Plugin {
7+
module.exports = class SafeLearnPlugin extends Plugin {
88
async onload() {
9-
this.addStyles();
10-
this.registerDomEvent(document, "DOMContentLoaded", () => {
11-
this.processAll();
12-
});
13-
this.registerEvent(
14-
this.app.workspace.on("layout-change", () => this.processAll())
15-
);
9+
console.log("✅ SafeLearn Plugin loaded");
10+
this.registerEvent(this.app.workspace.on("layout-change", () => this.processAll()));
1611
}
1712

1813
onunload() {
14+
console.log("❎ SafeLearn Plugin unloaded");
1915
document.querySelectorAll(".fragment-highlight, .permission-block, .side-by-side").forEach(el => {
2016
el.classList.remove("fragment-highlight", "permission-block", "side-by-side");
2117
});
2218
}
2319

24-
addStyles() {
25-
const style = document.createElement("style");
26-
style.id = "safelearn-style";
27-
style.textContent = `
28-
.fragment-highlight {
29-
background-color: var(--fragment-bg);
30-
color: var(--fragment-fg);
31-
border: 2px solid var(--fragment-border);
32-
border-radius: 8px;
33-
padding: 2px 6px;
34-
margin: 1px;
35-
display: inline-block;
36-
font-weight: 500;
37-
}
38-
.fragment-highlight::before {
39-
content: "🔀 ";
40-
opacity: 0.6;
41-
}
42-
.permission-block {
43-
background-color: var(--permission-bg, #eef7ff);
44-
border-left: 4px solid var(--permission-border, #3399ff);
45-
padding: 4px 8px;
46-
margin: 8px 0;
47-
}
48-
.permission-block .perm-label,
49-
.permission-block .perm-end {
50-
font-family: monospace;
51-
font-size: 0.8em;
52-
background: #ddeeff;
53-
color: #225577;
54-
padding: 2px 4px;
55-
border-radius: 4px;
56-
display: inline-block;
57-
margin-bottom: 4px;
58-
}
59-
.side-by-side {
60-
display: flex;
61-
gap: 20px;
62-
margin: 1em 0;
63-
border: 1px dashed #bbb;
64-
padding: 8px;
65-
}
66-
.side-by-side > div {
67-
flex: 1;
68-
padding: 0 10px;
69-
border-left: 2px dashed #ccc;
70-
}
71-
`;
72-
document.head.appendChild(style);
73-
}
74-
7520
processAll() {
7621
const leaves = this.app.workspace.getLeavesOfType("markdown");
7722
for (const leaf of leaves) {
@@ -135,6 +80,4 @@ class SafeLearnPlugin extends Plugin {
13580
return `<div class="side-by-side">${columns}</div>`;
13681
});
13782
}
138-
}
139-
140-
module.exports = SafeLearnPlugin;
83+
};

styles.css

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,45 @@
1-
:root {
2-
--fragment-bg: #f3e6ff;
3-
--fragment-fg: #4b0082;
4-
--fragment-border: #4b0082;
1+
.fragment-highlight {
2+
background-color: var(--fragment-bg);
3+
color: var(--fragment-fg);
4+
border: 2px solid var(--fragment-border);
5+
border-radius: 8px;
6+
padding: 2px 6px;
7+
margin: 1px;
8+
display: inline-block;
9+
font-weight: 500;
10+
}
11+
.fragment-highlight::before {
12+
content: "🔀 ";
13+
opacity: 0.6;
14+
}
15+
16+
.permission-block {
17+
background-color: var(--permission-bg, #eef7ff);
18+
border-left: 4px solid var(--permission-border, #3399ff);
19+
padding: 4px 8px;
20+
margin: 8px 0;
21+
}
22+
.permission-block .perm-label,
23+
.permission-block .perm-end {
24+
font-family: monospace;
25+
font-size: 0.8em;
26+
background: #ddeeff;
27+
color: #225577;
28+
padding: 2px 4px;
29+
border-radius: 4px;
30+
display: inline-block;
31+
margin-bottom: 4px;
32+
}
533

6-
--permission-bg: #eef7ff;
7-
--permission-border: #3399ff;
34+
.side-by-side {
35+
display: flex;
36+
gap: 20px;
37+
margin: 1em 0;
38+
border: 1px dashed #bbb;
39+
padding: 8px;
40+
}
41+
.side-by-side > div {
42+
flex: 1;
43+
padding: 0 10px;
44+
border-left: 2px dashed #ccc;
845
}

0 commit comments

Comments
 (0)