Skip to content

Commit 294c2d5

Browse files
committed
refactor: prevent interference with mounted target styles
1 parent b7490a5 commit 294c2d5

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/index.less

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.mind-elixir {
1+
.map-container {
22
// May overwrited by js
33
--gap: 30px; // child node horizontal gap
44
--root-radius: 30px;
@@ -17,17 +17,9 @@
1717
--panel-border-color: #eaeaea;
1818
// ---
1919

20-
position: relative;
2120
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
2221
font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans CJK SC,
2322
WenQuanYi Micro Hei, sans-serif;
24-
.hyper-link {
25-
text-decoration: none;
26-
margin-left: 0.3em;
27-
}
28-
}
29-
30-
.map-container {
3123
user-select: none;
3224
height: 100%;
3325
width: 100%;
@@ -44,6 +36,10 @@
4436
outline: 2px solid var(--selected);
4537
outline-offset: 1px;
4638
}
39+
.hyper-link {
40+
text-decoration: none;
41+
margin-left: 0.3em;
42+
}
4743
.lhs {
4844
direction: rtl;
4945
me-tpc {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function MindElixir(
4848
}
4949
if (!ele) throw new Error('MindElixir: el is not a valid element')
5050

51-
ele.className += ' mind-elixir'
51+
ele.style.position = 'relative'
5252
ele.innerHTML = ''
5353
this.mindElixirBox = ele as HTMLElement
5454
this.disposable = []

src/utils/generateBranch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function main({ pT, pL, pW, pH, cT, cL, cW, cH, direction, containerHeigh
5050
}
5151

5252
export function sub(this: MindElixirInstance, { pT, pL, pW, pH, cT, cL, cW, cH, direction, isFirst }: SubLineParams) {
53-
const GAP = parseInt(this.mindElixirBox.style.getPropertyValue('--gap')) // cache?
53+
const GAP = parseInt(this.container.style.getPropertyValue('--gap')) // cache?
5454
// const GAP = 30
5555
let y1 = 0
5656
let end = 0

src/utils/theme.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ const changeTheme = function (this: MindElixirInstance, theme: Theme, shouldRefr
55
this.theme = theme
66
const cssVar = this.theme.cssVar
77
const keys = Object.keys(cssVar)
8-
// TODO: clear all cssText is too aggressive
9-
this.mindElixirBox.style.cssText = ''
8+
this.container.style.cssText = ''
109
for (let i = 0; i < keys.length; i++) {
1110
const key = keys[i] as keyof typeof cssVar
12-
this.mindElixirBox.style.setProperty(key, cssVar[key] as string)
11+
this.container.style.setProperty(key, cssVar[key] as string)
1312
}
1413
if (!theme.cssVar['--gap']) {
15-
this.mindElixirBox.style.setProperty('--gap', '30px')
14+
this.container.style.setProperty('--gap', '30px')
1615
}
1716
shouldRefresh && this.refresh()
1817
}

0 commit comments

Comments
 (0)