@tnotesjs/core 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -87
- package/dist/{chunk-4MO7F7Q4.js → chunk-BSTQOJVE.js} +1 -1
- package/dist/{chunk-SQVHJR2Z.js → chunk-O4DCXHOV.js} +0 -3
- package/dist/cli/index.js +2 -2
- package/dist/index.js +1 -1
- package/dist/vitepress/config/index.js +2 -2
- package/package.json +3 -4
- package/types/config.ts +60 -61
- package/types/index.ts +11 -11
- package/types/note.ts +33 -33
- package/vitepress/assets/icons/icon__check.svg +3 -3
- package/vitepress/assets/icons/icon__clipboard.svg +7 -7
- package/vitepress/assets/icons/icon__close.svg +1 -1
- package/vitepress/assets/icons/icon__collapse.svg +1 -1
- package/vitepress/assets/icons/icon__confirm.svg +1 -1
- package/vitepress/assets/icons/icon__copy.svg +4 -4
- package/vitepress/assets/icons/icon__focus.svg +1 -1
- package/vitepress/assets/icons/icon__fold.svg +3 -3
- package/vitepress/assets/icons/icon__folder.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
- package/vitepress/assets/icons/icon__github.svg +3 -3
- package/vitepress/assets/icons/icon__mindmap.svg +1 -1
- package/vitepress/assets/icons/icon__next.svg +1 -1
- package/vitepress/assets/icons/icon__number_gray.svg +1 -1
- package/vitepress/assets/icons/icon__number_purple.svg +1 -1
- package/vitepress/assets/icons/icon__prev.svg +1 -1
- package/vitepress/assets/icons/icon__restore.svg +1 -1
- package/vitepress/assets/icons/icon__rotate.svg +4 -4
- package/vitepress/assets/icons/icon__search.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
- package/vitepress/assets/icons/icon__totop.svg +5 -5
- package/vitepress/assets/icons/icon__vscode.svg +5 -5
- package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
- package/vitepress/assets/icons/index.ts +39 -39
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +369 -369
- package/vitepress/components/CodeBlockFullscreen/index.ts +209 -213
- package/vitepress/components/CodeBlockFullscreen/styles.css +126 -126
- package/vitepress/components/Discussions/Discussions.vue +244 -211
- package/vitepress/components/EnWordList/EnWordList.vue +663 -543
- package/vitepress/components/EnWordList/RightClickMenu.vue +89 -66
- package/vitepress/components/Footprints/Footprints.vue +472 -377
- package/vitepress/components/Layout/AboutModal.vue +331 -105
- package/vitepress/components/Layout/AboutPanel.vue +484 -270
- package/vitepress/components/Layout/ContentCollapse.vue +590 -603
- package/vitepress/components/Layout/CustomSidebar.vue +817 -817
- package/vitepress/components/Layout/DocBeforeControls.vue +351 -149
- package/vitepress/components/Layout/DocFooter.vue +233 -233
- package/vitepress/components/Layout/ImagePreview.vue +484 -281
- package/vitepress/components/Layout/Layout.vue +744 -621
- package/vitepress/components/Layout/NavBarSettingsTrigger.vue +0 -2
- package/vitepress/components/Layout/NoteStatus.vue +140 -140
- package/vitepress/components/Layout/SidebarItems.vue +1083 -1083
- package/vitepress/components/Layout/SidebarNavBefore.vue +170 -171
- package/vitepress/components/Layout/SidebarResizeHandle.vue +311 -319
- package/vitepress/components/Layout/Swiper.vue +167 -167
- package/vitepress/components/Layout/ToggleFullContent.vue +47 -35
- package/vitepress/components/Layout/ToggleSidebar.vue +37 -26
- package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
- package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -119
- package/vitepress/components/Layout/composables/useNoteSave.ts +178 -178
- package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
- package/vitepress/components/Layout/composables/useRedirect.ts +113 -113
- package/vitepress/components/Layout/composables/useSidebarLayout.ts +122 -122
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
- package/vitepress/components/Layout/homeReadme.data.ts +124 -124
- package/vitepress/components/LoadingPage/LoadingPage.vue +1 -6
- package/vitepress/components/MarkMap/MarkMap.vue +564 -405
- package/vitepress/components/Mermaid/Mermaid.vue +643 -365
- package/vitepress/components/NotesTable/NotesTable.vue +174 -98
- package/vitepress/components/NotesTable/README.md +67 -67
- package/vitepress/components/Settings/Settings.vue +711 -334
- package/vitepress/components/Settings/SettingsDialog.vue +1 -11
- package/vitepress/components/SidebarCard/MindMapView.vue +484 -484
- package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
- package/vitepress/components/SidebarCard/SidebarCard.vue +945 -946
- package/vitepress/components/Tooltip/Tooltip.vue +70 -70
- package/vitepress/components/constants.ts +109 -109
- package/vitepress/components/notesConfig.data.ts +73 -73
- package/vitepress/components/sidebar.data.ts +59 -59
- package/vitepress/components/tnotes-config.data.ts +21 -21
- package/vitepress/components/utils.ts +26 -26
- package/vitepress/config/index.ts +169 -169
- package/vitepress/configs/constants.ts +26 -26
- package/vitepress/configs/head.config.ts +25 -25
- package/vitepress/configs/index.ts +9 -9
- package/vitepress/configs/markdown-it.d.ts +23 -23
- package/vitepress/configs/markdown.config.ts +368 -367
- package/vitepress/configs/theme.config.ts +108 -108
- package/vitepress/plugins/buildProgressPlugin.ts +434 -434
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
- package/vitepress/plugins/renameNotePlugin.ts +68 -68
- package/vitepress/plugins/sidebarStructurePlugin.ts +260 -260
- package/vitepress/plugins/updateConfigPlugin.ts +63 -63
- package/vitepress/theme/index.ts +137 -137
- package/vitepress/theme/styles/base.scss +66 -64
- package/vitepress/theme/styles/components/404.scss +31 -31
- package/vitepress/theme/styles/components/collapse.scss +172 -172
- package/vitepress/theme/styles/components/markmap.scss +101 -101
- package/vitepress/theme/styles/components/swiper.scss +255 -255
- package/vitepress/theme/styles/index.scss +25 -25
- package/vitepress/theme/styles/layout.scss +78 -78
- package/vitepress/theme/styles/utilities.scss +39 -39
- package/vitepress/theme/styles/vitepress-override.scss +25 -25
- package/vitepress/components/Discussions/Discussions.module.scss +0 -32
- package/vitepress/components/EnWordList/EnWordList.module.scss +0 -124
- package/vitepress/components/EnWordList/RightClickMenu.module.scss +0 -22
- package/vitepress/components/Footprints/Footprints.module.scss +0 -93
- package/vitepress/components/Layout/AboutModal.module.scss +0 -233
- package/vitepress/components/Layout/ImagePreview.module.scss +0 -201
- package/vitepress/components/Layout/Layout.module.scss +0 -661
- package/vitepress/components/Layout/ToggleFullContent.module.scss +0 -11
- package/vitepress/components/Layout/ToggleSidebar.module.scss +0 -11
- package/vitepress/components/MarkMap/MarkMap.module.scss +0 -159
- package/vitepress/components/Mermaid/Mermaid.module.scss +0 -275
- package/vitepress/components/NotesTable/NotesTable.module.scss +0 -77
- package/vitepress/components/Settings/Settings.module.scss +0 -375
|
@@ -1,405 +1,564 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { scaleOrdinal, schemePastel2, schemeSet3, schemeTableau10 } from 'd3'
|
|
3
|
-
import { Transformer } from 'markmap-lib'
|
|
4
|
-
import { Toolbar } from 'markmap-toolbar'
|
|
5
|
-
import 'markmap-toolbar/dist/style.css'
|
|
6
|
-
import { Markmap, IMarkmapOptions } from 'markmap-view'
|
|
7
|
-
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
8
|
-
|
|
9
|
-
import { icon__fullscreen, icon__fullscreen_exit, icon__confirm } from '../../assets/icons'
|
|
10
|
-
import { MARKMAP_THEME_KEY, MARKMAP_EXPAND_LEVEL_KEY } from '../constants'
|
|
11
|
-
|
|
12
|
-
// doc: https://github.com/markmap/markmap/blob/205367a24603dc187f67da1658940c6cade20dce/packages/markmap-view/src/constants.ts#L15
|
|
13
|
-
|
|
14
|
-
const props = defineProps({
|
|
15
|
-
content: { type: String, default: '' },
|
|
16
|
-
duration: { type: Number, default: 100 },
|
|
17
|
-
spacingVertical: { type: Number, default: 10 },
|
|
18
|
-
spacingHorizontal: { type: Number, default: 20 },
|
|
19
|
-
nodeMinHeight: { type: Number, default: 24 },
|
|
20
|
-
initialExpandLevel: { type: Number, default: 5 },
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
const svgRef = ref<SVGSVGElement | null>(null)
|
|
24
|
-
const containerRef = ref<HTMLDivElement | null>(null)
|
|
25
|
-
|
|
26
|
-
let markmapInstance: Markmap | null = null
|
|
27
|
-
let observer: MutationObserver | null = null
|
|
28
|
-
let toolbarEl: HTMLElement | null = null
|
|
29
|
-
|
|
30
|
-
// 从 localStorage 读取配置,如果没有则使用 props 或默认值
|
|
31
|
-
const getInitialExpandLevel = () => {
|
|
32
|
-
if (typeof window !== 'undefined') {
|
|
33
|
-
const saved = localStorage.getItem(MARKMAP_EXPAND_LEVEL_KEY)
|
|
34
|
-
if (saved) return parseInt(saved)
|
|
35
|
-
}
|
|
36
|
-
return props.initialExpandLevel
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const getThemeColorFn = () => {
|
|
40
|
-
if (typeof window !== 'undefined') {
|
|
41
|
-
const theme = localStorage.getItem(MARKMAP_THEME_KEY) || 'default'
|
|
42
|
-
switch (theme) {
|
|
43
|
-
case 'colorful':
|
|
44
|
-
return scaleOrdinal(schemeTableau10)
|
|
45
|
-
case 'dark':
|
|
46
|
-
return scaleOrdinal(schemeSet3)
|
|
47
|
-
default:
|
|
48
|
-
return scaleOrdinal(schemePastel2)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return scaleOrdinal(schemePastel2)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 可由配置/props 初始化,也可以通过工具栏改动
|
|
55
|
-
const expandLevel = ref(getInitialExpandLevel())
|
|
56
|
-
const transformer = new Transformer()
|
|
57
|
-
const isFullscreen = ref(false)
|
|
58
|
-
|
|
59
|
-
// 保存工具栏中层级输入框的引用,方便同步显示与绑定事件
|
|
60
|
-
let toolbarLevelInput: HTMLInputElement | null = null
|
|
61
|
-
|
|
62
|
-
function renderMarkmap(content: string, level = expandLevel.value) {
|
|
63
|
-
if (!svgRef.value) return
|
|
64
|
-
|
|
65
|
-
nextTick().then(() => {
|
|
66
|
-
if (markmapInstance) {
|
|
67
|
-
try {
|
|
68
|
-
markmapInstance.destroy()
|
|
69
|
-
} catch {}
|
|
70
|
-
markmapInstance = null
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!content.trim()) {
|
|
74
|
-
svgRef.value!.innerHTML = '<text x="20" y="30" fill="#999">空内容</text>'
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
const { root } = transformer.transform(content)
|
|
80
|
-
const colorFn = getThemeColorFn()
|
|
81
|
-
const options: Partial<IMarkmapOptions> = {
|
|
82
|
-
// autoFit 会自动调整 scale 和 position 来适配当前容器大小,在阅读大量节点内容的时候,会放大某块区域阅读,每次展开节点或者收起节点,都会自动触发 autoFit,导致阅读体验不佳,因此不启用。
|
|
83
|
-
// autoFit: true,
|
|
84
|
-
initialExpandLevel: level,
|
|
85
|
-
duration: props.duration,
|
|
86
|
-
nodeMinHeight: props.nodeMinHeight,
|
|
87
|
-
spacingVertical: props.spacingVertical,
|
|
88
|
-
spacingHorizontal: props.spacingHorizontal,
|
|
89
|
-
maxInitialScale: 2,
|
|
90
|
-
maxWidth: 400,
|
|
91
|
-
// 使用配置的主题颜色
|
|
92
|
-
color: (node): string => colorFn(`${node.state?.path || ''}`),
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
markmapInstance = Markmap.create(svgRef.value!, options, root)
|
|
96
|
-
|
|
97
|
-
setTimeout(() => {
|
|
98
|
-
try {
|
|
99
|
-
markmapInstance?.fit() // 确保居中
|
|
100
|
-
} catch (e) {
|
|
101
|
-
console.warn('fit failed', e)
|
|
102
|
-
}
|
|
103
|
-
}, 0)
|
|
104
|
-
|
|
105
|
-
initToolbar()
|
|
106
|
-
setupObserver()
|
|
107
|
-
} catch (error: any) {
|
|
108
|
-
console.error('Markmap render error:', error)
|
|
109
|
-
svgRef.value!.innerHTML = `<text x="20" y="30" fill="red">Markmap 错误: ${error.message}</text>`
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function initToolbar() {
|
|
115
|
-
if (!markmapInstance || !containerRef.value) return
|
|
116
|
-
|
|
117
|
-
// 移除现有的工具栏
|
|
118
|
-
if (toolbarEl) {
|
|
119
|
-
toolbarEl.remove()
|
|
120
|
-
toolbarEl = null
|
|
121
|
-
toolbarLevelInput = null
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 创建新工具栏
|
|
125
|
-
const { el } = Toolbar.create(markmapInstance)
|
|
126
|
-
toolbarEl = el
|
|
127
|
-
toolbarEl.style.position = 'absolute'
|
|
128
|
-
toolbarEl.style.top = '1rem'
|
|
129
|
-
toolbarEl.style.right = '.5rem'
|
|
130
|
-
toolbarEl.style.scale = '.8'
|
|
131
|
-
const brand = toolbarEl.querySelector('.mm-toolbar-brand')
|
|
132
|
-
if (brand) toolbarEl.removeChild(brand)
|
|
133
|
-
containerRef.value.appendChild(toolbarEl)
|
|
134
|
-
|
|
135
|
-
// 添加自定义全屏按钮
|
|
136
|
-
addFullscreenButton(toolbarEl)
|
|
137
|
-
|
|
138
|
-
// 在工具栏中添加更新按钮 + 层级输入(并支持 Enter 键触发)
|
|
139
|
-
addUpdateButton(toolbarEl)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function addFullscreenButton(toolbar: HTMLElement) {
|
|
143
|
-
const fullscreenBtn = document.createElement('div')
|
|
144
|
-
fullscreenBtn.className = 'mm-toolbar-item'
|
|
145
|
-
fullscreenBtn.title = isFullscreen.value ? '退出全屏' : '全屏'
|
|
146
|
-
fullscreenBtn.innerHTML = isFullscreen.value
|
|
147
|
-
? `<img src="${icon__fullscreen_exit}" alt="退出全屏" style="width:18px;height:18px;display:block" />`
|
|
148
|
-
: `<img src="${icon__fullscreen}" alt="全屏" style="width:18px;height:18px;display:block" />`
|
|
149
|
-
fullscreenBtn.addEventListener('click', toggleFullscreen)
|
|
150
|
-
toolbar.appendChild(fullscreenBtn)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function addUpdateButton(toolbar: HTMLElement) {
|
|
154
|
-
// 创建更新按钮容器
|
|
155
|
-
const updateContainer = document.createElement('div')
|
|
156
|
-
updateContainer.style.display = 'flex'
|
|
157
|
-
updateContainer.style.alignItems = 'center'
|
|
158
|
-
updateContainer.style.gap = '8px'
|
|
159
|
-
updateContainer.style.marginRight = '5px'
|
|
160
|
-
|
|
161
|
-
// 创建输入框(确保具有 id/name,且样式能在工具栏中清晰可见)
|
|
162
|
-
const levelInput = document.createElement('input')
|
|
163
|
-
levelInput.type = 'number'
|
|
164
|
-
levelInput.id = 'markmap-expand-level'
|
|
165
|
-
levelInput.name = 'markmap-expand-level'
|
|
166
|
-
levelInput.min = '1'
|
|
167
|
-
levelInput.max = '100'
|
|
168
|
-
levelInput.value = expandLevel.value.toString()
|
|
169
|
-
levelInput.style.width = '2.4rem'
|
|
170
|
-
levelInput.style.height = '1.6rem'
|
|
171
|
-
levelInput.style.padding = '2px 6px'
|
|
172
|
-
levelInput.style.fontSize = '12px'
|
|
173
|
-
levelInput.style.lineHeight = '1.2'
|
|
174
|
-
levelInput.style.textAlign = 'center'
|
|
175
|
-
levelInput.style.boxSizing = 'border-box'
|
|
176
|
-
levelInput.style.borderBottom = '.5px solid var(--vp-c-tip-1)'
|
|
177
|
-
// levelInput.style.borderRadius = '4px'
|
|
178
|
-
// levelInput.style.background = 'var(--vp-c-bg)'
|
|
179
|
-
levelInput.style.color = 'var(--vp-c-tip-1)'
|
|
180
|
-
levelInput.title = '展开层级'
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
updateBtn.
|
|
233
|
-
updateBtn.
|
|
234
|
-
updateBtn.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
updateContainer.appendChild(
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
document.
|
|
275
|
-
(document as any).
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
() =>
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
() =>
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
document.addEventListener('
|
|
372
|
-
document.addEventListener('
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
observer
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
document.removeEventListener('
|
|
390
|
-
document.removeEventListener('
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
<
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { scaleOrdinal, schemePastel2, schemeSet3, schemeTableau10 } from 'd3'
|
|
3
|
+
import { Transformer } from 'markmap-lib'
|
|
4
|
+
import { Toolbar } from 'markmap-toolbar'
|
|
5
|
+
import 'markmap-toolbar/dist/style.css'
|
|
6
|
+
import { Markmap, IMarkmapOptions } from 'markmap-view'
|
|
7
|
+
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
8
|
+
|
|
9
|
+
import { icon__fullscreen, icon__fullscreen_exit, icon__confirm } from '../../assets/icons'
|
|
10
|
+
import { MARKMAP_THEME_KEY, MARKMAP_EXPAND_LEVEL_KEY } from '../constants'
|
|
11
|
+
|
|
12
|
+
// doc: https://github.com/markmap/markmap/blob/205367a24603dc187f67da1658940c6cade20dce/packages/markmap-view/src/constants.ts#L15
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
content: { type: String, default: '' },
|
|
16
|
+
duration: { type: Number, default: 100 },
|
|
17
|
+
spacingVertical: { type: Number, default: 10 },
|
|
18
|
+
spacingHorizontal: { type: Number, default: 20 },
|
|
19
|
+
nodeMinHeight: { type: Number, default: 24 },
|
|
20
|
+
initialExpandLevel: { type: Number, default: 5 },
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const svgRef = ref<SVGSVGElement | null>(null)
|
|
24
|
+
const containerRef = ref<HTMLDivElement | null>(null)
|
|
25
|
+
|
|
26
|
+
let markmapInstance: Markmap | null = null
|
|
27
|
+
let observer: MutationObserver | null = null
|
|
28
|
+
let toolbarEl: HTMLElement | null = null
|
|
29
|
+
|
|
30
|
+
// 从 localStorage 读取配置,如果没有则使用 props 或默认值
|
|
31
|
+
const getInitialExpandLevel = () => {
|
|
32
|
+
if (typeof window !== 'undefined') {
|
|
33
|
+
const saved = localStorage.getItem(MARKMAP_EXPAND_LEVEL_KEY)
|
|
34
|
+
if (saved) return parseInt(saved)
|
|
35
|
+
}
|
|
36
|
+
return props.initialExpandLevel
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const getThemeColorFn = () => {
|
|
40
|
+
if (typeof window !== 'undefined') {
|
|
41
|
+
const theme = localStorage.getItem(MARKMAP_THEME_KEY) || 'default'
|
|
42
|
+
switch (theme) {
|
|
43
|
+
case 'colorful':
|
|
44
|
+
return scaleOrdinal(schemeTableau10)
|
|
45
|
+
case 'dark':
|
|
46
|
+
return scaleOrdinal(schemeSet3)
|
|
47
|
+
default:
|
|
48
|
+
return scaleOrdinal(schemePastel2)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return scaleOrdinal(schemePastel2)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 可由配置/props 初始化,也可以通过工具栏改动
|
|
55
|
+
const expandLevel = ref(getInitialExpandLevel())
|
|
56
|
+
const transformer = new Transformer()
|
|
57
|
+
const isFullscreen = ref(false)
|
|
58
|
+
|
|
59
|
+
// 保存工具栏中层级输入框的引用,方便同步显示与绑定事件
|
|
60
|
+
let toolbarLevelInput: HTMLInputElement | null = null
|
|
61
|
+
|
|
62
|
+
function renderMarkmap(content: string, level = expandLevel.value) {
|
|
63
|
+
if (!svgRef.value) return
|
|
64
|
+
|
|
65
|
+
nextTick().then(() => {
|
|
66
|
+
if (markmapInstance) {
|
|
67
|
+
try {
|
|
68
|
+
markmapInstance.destroy()
|
|
69
|
+
} catch {}
|
|
70
|
+
markmapInstance = null
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!content.trim()) {
|
|
74
|
+
svgRef.value!.innerHTML = '<text x="20" y="30" fill="#999">空内容</text>'
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const { root } = transformer.transform(content)
|
|
80
|
+
const colorFn = getThemeColorFn()
|
|
81
|
+
const options: Partial<IMarkmapOptions> = {
|
|
82
|
+
// autoFit 会自动调整 scale 和 position 来适配当前容器大小,在阅读大量节点内容的时候,会放大某块区域阅读,每次展开节点或者收起节点,都会自动触发 autoFit,导致阅读体验不佳,因此不启用。
|
|
83
|
+
// autoFit: true,
|
|
84
|
+
initialExpandLevel: level,
|
|
85
|
+
duration: props.duration,
|
|
86
|
+
nodeMinHeight: props.nodeMinHeight,
|
|
87
|
+
spacingVertical: props.spacingVertical,
|
|
88
|
+
spacingHorizontal: props.spacingHorizontal,
|
|
89
|
+
maxInitialScale: 2,
|
|
90
|
+
maxWidth: 400,
|
|
91
|
+
// 使用配置的主题颜色
|
|
92
|
+
color: (node): string => colorFn(`${node.state?.path || ''}`),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
markmapInstance = Markmap.create(svgRef.value!, options, root)
|
|
96
|
+
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
try {
|
|
99
|
+
markmapInstance?.fit() // 确保居中
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.warn('fit failed', e)
|
|
102
|
+
}
|
|
103
|
+
}, 0)
|
|
104
|
+
|
|
105
|
+
initToolbar()
|
|
106
|
+
setupObserver()
|
|
107
|
+
} catch (error: any) {
|
|
108
|
+
console.error('Markmap render error:', error)
|
|
109
|
+
svgRef.value!.innerHTML = `<text x="20" y="30" fill="red">Markmap 错误: ${error.message}</text>`
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function initToolbar() {
|
|
115
|
+
if (!markmapInstance || !containerRef.value) return
|
|
116
|
+
|
|
117
|
+
// 移除现有的工具栏
|
|
118
|
+
if (toolbarEl) {
|
|
119
|
+
toolbarEl.remove()
|
|
120
|
+
toolbarEl = null
|
|
121
|
+
toolbarLevelInput = null
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 创建新工具栏
|
|
125
|
+
const { el } = Toolbar.create(markmapInstance)
|
|
126
|
+
toolbarEl = el
|
|
127
|
+
toolbarEl.style.position = 'absolute'
|
|
128
|
+
toolbarEl.style.top = '1rem'
|
|
129
|
+
toolbarEl.style.right = '.5rem'
|
|
130
|
+
toolbarEl.style.scale = '.8'
|
|
131
|
+
const brand = toolbarEl.querySelector('.mm-toolbar-brand')
|
|
132
|
+
if (brand) toolbarEl.removeChild(brand)
|
|
133
|
+
containerRef.value.appendChild(toolbarEl)
|
|
134
|
+
|
|
135
|
+
// 添加自定义全屏按钮
|
|
136
|
+
addFullscreenButton(toolbarEl)
|
|
137
|
+
|
|
138
|
+
// 在工具栏中添加更新按钮 + 层级输入(并支持 Enter 键触发)
|
|
139
|
+
addUpdateButton(toolbarEl)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function addFullscreenButton(toolbar: HTMLElement) {
|
|
143
|
+
const fullscreenBtn = document.createElement('div')
|
|
144
|
+
fullscreenBtn.className = 'mm-toolbar-item'
|
|
145
|
+
fullscreenBtn.title = isFullscreen.value ? '退出全屏' : '全屏'
|
|
146
|
+
fullscreenBtn.innerHTML = isFullscreen.value
|
|
147
|
+
? `<img src="${icon__fullscreen_exit}" alt="退出全屏" style="width:18px;height:18px;display:block" />`
|
|
148
|
+
: `<img src="${icon__fullscreen}" alt="全屏" style="width:18px;height:18px;display:block" />`
|
|
149
|
+
fullscreenBtn.addEventListener('click', toggleFullscreen)
|
|
150
|
+
toolbar.appendChild(fullscreenBtn)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function addUpdateButton(toolbar: HTMLElement) {
|
|
154
|
+
// 创建更新按钮容器
|
|
155
|
+
const updateContainer = document.createElement('div')
|
|
156
|
+
updateContainer.style.display = 'flex'
|
|
157
|
+
updateContainer.style.alignItems = 'center'
|
|
158
|
+
updateContainer.style.gap = '8px'
|
|
159
|
+
updateContainer.style.marginRight = '5px'
|
|
160
|
+
|
|
161
|
+
// 创建输入框(确保具有 id/name,且样式能在工具栏中清晰可见)
|
|
162
|
+
const levelInput = document.createElement('input')
|
|
163
|
+
levelInput.type = 'number'
|
|
164
|
+
levelInput.id = 'markmap-expand-level'
|
|
165
|
+
levelInput.name = 'markmap-expand-level'
|
|
166
|
+
levelInput.min = '1'
|
|
167
|
+
levelInput.max = '100'
|
|
168
|
+
levelInput.value = expandLevel.value.toString()
|
|
169
|
+
levelInput.style.width = '2.4rem'
|
|
170
|
+
levelInput.style.height = '1.6rem'
|
|
171
|
+
levelInput.style.padding = '2px 6px'
|
|
172
|
+
levelInput.style.fontSize = '12px'
|
|
173
|
+
levelInput.style.lineHeight = '1.2'
|
|
174
|
+
levelInput.style.textAlign = 'center'
|
|
175
|
+
levelInput.style.boxSizing = 'border-box'
|
|
176
|
+
levelInput.style.borderBottom = '.5px solid var(--vp-c-tip-1)'
|
|
177
|
+
// levelInput.style.borderRadius = '4px'
|
|
178
|
+
// levelInput.style.background = 'var(--vp-c-bg)'
|
|
179
|
+
levelInput.style.color = 'var(--vp-c-tip-1)'
|
|
180
|
+
levelInput.title = '展开层级'
|
|
181
|
+
|
|
182
|
+
// 保存引用,供外部(props 改变)同步输入值
|
|
183
|
+
toolbarLevelInput = levelInput
|
|
184
|
+
|
|
185
|
+
// 实时限制输入范围(1-100)
|
|
186
|
+
levelInput.addEventListener('input', (e) => {
|
|
187
|
+
const input = e.target as HTMLInputElement
|
|
188
|
+
let value = parseInt(input.value)
|
|
189
|
+
|
|
190
|
+
// 如果输入为空或非数字,不做处理
|
|
191
|
+
if (input.value === '' || isNaN(value)) return
|
|
192
|
+
|
|
193
|
+
// 限制范围:1-100
|
|
194
|
+
if (value < 1) {
|
|
195
|
+
input.value = '1'
|
|
196
|
+
value = 1
|
|
197
|
+
} else if (value > 100) {
|
|
198
|
+
input.value = '100'
|
|
199
|
+
value = 100
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
// 当输入框值变化时仅更新内部 expandLevel(不自动渲染)
|
|
204
|
+
levelInput.addEventListener('change', (e) => {
|
|
205
|
+
const value = parseInt((e.target as HTMLInputElement).value)
|
|
206
|
+
if (!isNaN(value) && value >= 1 && value <= 100) {
|
|
207
|
+
expandLevel.value = value
|
|
208
|
+
} else {
|
|
209
|
+
// 回退到之前的值(避免非法输入)
|
|
210
|
+
levelInput.value = expandLevel.value.toString()
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
// 按键监听:按 Enter 时触发更新(相当于点击确认按钮)
|
|
215
|
+
levelInput.addEventListener('keydown', (e) => {
|
|
216
|
+
if (e.key === 'Enter') {
|
|
217
|
+
// 同步输入框值到 expandLevel(防止未触发 change)
|
|
218
|
+
const val = parseInt((e.target as HTMLInputElement).value)
|
|
219
|
+
if (!isNaN(val) && val >= 1 && val <= 100) {
|
|
220
|
+
expandLevel.value = val
|
|
221
|
+
} else {
|
|
222
|
+
// 如果超出范围,重置为有效值
|
|
223
|
+
levelInput.value = expandLevel.value.toString()
|
|
224
|
+
}
|
|
225
|
+
onUpdateClick()
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
// 创建按钮
|
|
230
|
+
const updateBtn = document.createElement('button')
|
|
231
|
+
updateBtn.type = 'button'
|
|
232
|
+
updateBtn.title = '确定层级并更新'
|
|
233
|
+
updateBtn.innerHTML = `<img src="${icon__confirm}" alt="确定" style="width:16px;height:16px;display:block" />`
|
|
234
|
+
updateBtn.addEventListener('click', onUpdateClick)
|
|
235
|
+
|
|
236
|
+
updateContainer.appendChild(levelInput)
|
|
237
|
+
updateContainer.appendChild(updateBtn)
|
|
238
|
+
|
|
239
|
+
// 将更新按钮插入到工具栏开头
|
|
240
|
+
toolbar.insertBefore(updateContainer, toolbar.firstChild)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 切换全屏(保持原来的实现)
|
|
244
|
+
function toggleFullscreen() {
|
|
245
|
+
if (!containerRef.value) return
|
|
246
|
+
|
|
247
|
+
if (!isFullscreen.value) {
|
|
248
|
+
// 进入全屏
|
|
249
|
+
if (containerRef.value.requestFullscreen) {
|
|
250
|
+
containerRef.value.requestFullscreen().catch((err) => {
|
|
251
|
+
console.error('全屏请求失败:', err)
|
|
252
|
+
})
|
|
253
|
+
} else if ((containerRef.value as any).webkitRequestFullscreen) {
|
|
254
|
+
;(containerRef.value as any).webkitRequestFullscreen()
|
|
255
|
+
} else if ((containerRef.value as any).msRequestFullscreen) {
|
|
256
|
+
;(containerRef.value as any).msRequestFullscreen()
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
// 退出全屏
|
|
260
|
+
if (document.exitFullscreen) {
|
|
261
|
+
document.exitFullscreen()
|
|
262
|
+
} else if ((document as any).webkitExitFullscreen) {
|
|
263
|
+
;(document as any).webkitExitFullscreen()
|
|
264
|
+
} else if ((document as any).msExitFullscreen) {
|
|
265
|
+
;(document as any).msExitFullscreen()
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 监听全屏状态变化
|
|
271
|
+
function handleFullscreenChange() {
|
|
272
|
+
isFullscreen.value = !!(
|
|
273
|
+
document.fullscreenElement ||
|
|
274
|
+
(document as any).webkitFullscreenElement ||
|
|
275
|
+
(document as any).msFullscreenElement
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
// 更新工具栏中的全屏按钮(若存在)
|
|
279
|
+
if (toolbarEl) {
|
|
280
|
+
const fullscreenBtn = toolbarEl.querySelector(
|
|
281
|
+
'.mm-toolbar-item:last-child'
|
|
282
|
+
) as HTMLButtonElement
|
|
283
|
+
if (fullscreenBtn) {
|
|
284
|
+
fullscreenBtn.title = isFullscreen.value
|
|
285
|
+
? '退出全屏(Exit Fullscreen)'
|
|
286
|
+
: '全屏(Fullscreen)'
|
|
287
|
+
fullscreenBtn.innerHTML = isFullscreen.value
|
|
288
|
+
? `<img src="${icon__fullscreen_exit}" alt="退出全屏" style="width:18px;height:18px;display:block" />`
|
|
289
|
+
: `<img src="${icon__fullscreen}" alt="全屏" style="width:18px;height:18px;display:block" />`
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 全屏模式下调整SVG高度
|
|
294
|
+
if (svgRef.value) {
|
|
295
|
+
if (isFullscreen.value) {
|
|
296
|
+
svgRef.value.style.height = 'calc(100vh - 100px)'
|
|
297
|
+
} else {
|
|
298
|
+
svgRef.value.style.height = '400px'
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// 确保居中 - 无论进入还是退出全屏都执行居中
|
|
302
|
+
setTimeout(() => {
|
|
303
|
+
if (markmapInstance) {
|
|
304
|
+
try {
|
|
305
|
+
markmapInstance.fit()
|
|
306
|
+
} catch (e) {
|
|
307
|
+
console.warn('居中失败', e)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}, 300)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function setupObserver() {
|
|
315
|
+
if (!svgRef.value) return
|
|
316
|
+
if (observer !== null) {
|
|
317
|
+
observer.disconnect()
|
|
318
|
+
}
|
|
319
|
+
observer = new MutationObserver(() => {
|
|
320
|
+
// DOM 变动后处理(保留扩展点)
|
|
321
|
+
})
|
|
322
|
+
observer.observe(svgRef.value, {
|
|
323
|
+
childList: true,
|
|
324
|
+
subtree: true,
|
|
325
|
+
attributes: true,
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 只监听内容变化,expandLevel 改动不自动渲染(点击/Enter 确认渲染)
|
|
330
|
+
watch(
|
|
331
|
+
() => props.content,
|
|
332
|
+
(newVal) => {
|
|
333
|
+
renderMarkmap(decodeURIComponent(newVal || ''))
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
// 新增:当外部传入的 initialExpandLevel 改变时,组件应同步并重新渲染
|
|
338
|
+
watch(
|
|
339
|
+
() => props.initialExpandLevel,
|
|
340
|
+
(newVal) => {
|
|
341
|
+
if (typeof newVal === 'number' && !isNaN(newVal)) {
|
|
342
|
+
expandLevel.value = newVal
|
|
343
|
+
// 更新输入框显示(如果已创建)
|
|
344
|
+
if (toolbarLevelInput) toolbarLevelInput.value = newVal.toString()
|
|
345
|
+
// 重新渲染使用新的层级(保持对外部 prop 改动的即时响应)
|
|
346
|
+
renderMarkmap(decodeURIComponent(props.content || ''), newVal)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
// 同步:当内部 expandLevel 变更时(例如通过输入框 change 事件),更新工具栏输入显示
|
|
352
|
+
watch(expandLevel, (v) => {
|
|
353
|
+
if (toolbarLevelInput) {
|
|
354
|
+
const asStr = (v || 0).toString()
|
|
355
|
+
if (toolbarLevelInput.value !== asStr) {
|
|
356
|
+
toolbarLevelInput.value = asStr
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
// 点击更新按钮才用当前 expandLevel 渲染
|
|
362
|
+
function onUpdateClick() {
|
|
363
|
+
renderMarkmap(decodeURIComponent(props.content || ''), expandLevel.value)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
onMounted(() => {
|
|
367
|
+
renderMarkmap(decodeURIComponent(props.content || ''))
|
|
368
|
+
|
|
369
|
+
// 添加全屏事件监听
|
|
370
|
+
document.addEventListener('fullscreenchange', handleFullscreenChange)
|
|
371
|
+
document.addEventListener('webkitfullscreenchange', handleFullscreenChange)
|
|
372
|
+
document.addEventListener('MSFullscreenChange', handleFullscreenChange)
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
onBeforeUnmount(() => {
|
|
376
|
+
if (markmapInstance) {
|
|
377
|
+
try {
|
|
378
|
+
markmapInstance.destroy()
|
|
379
|
+
} catch {}
|
|
380
|
+
markmapInstance = null
|
|
381
|
+
}
|
|
382
|
+
if (observer !== null) {
|
|
383
|
+
observer.disconnect()
|
|
384
|
+
observer = null
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// 移除全屏事件监听
|
|
388
|
+
document.removeEventListener('fullscreenchange', handleFullscreenChange)
|
|
389
|
+
document.removeEventListener('webkitfullscreenchange', handleFullscreenChange)
|
|
390
|
+
document.removeEventListener('MSFullscreenChange', handleFullscreenChange)
|
|
391
|
+
})
|
|
392
|
+
</script>
|
|
393
|
+
|
|
394
|
+
<template>
|
|
395
|
+
<div
|
|
396
|
+
class="markmapContainer"
|
|
397
|
+
ref="containerRef"
|
|
398
|
+
style="position: relative"
|
|
399
|
+
>
|
|
400
|
+
<svg ref="svgRef" style="width: 100%; height: 400px"></svg>
|
|
401
|
+
</div>
|
|
402
|
+
</template>
|
|
403
|
+
|
|
404
|
+
<style scoped lang="scss">
|
|
405
|
+
/**
|
|
406
|
+
* MarkMap 组件样式
|
|
407
|
+
* 全局样式(.mm-toolbar, .mm-toolbar-item 等)已移至 global-components.css
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
.markmapContainer {
|
|
411
|
+
border-radius: 8px;
|
|
412
|
+
padding: 1rem;
|
|
413
|
+
overflow: auto;
|
|
414
|
+
position: relative;
|
|
415
|
+
margin: 1.5rem 0;
|
|
416
|
+
transition: all 0.3s ease;
|
|
417
|
+
background-color: #fff;
|
|
418
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
419
|
+
|
|
420
|
+
&:hover {
|
|
421
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
svg {
|
|
425
|
+
min-width: 100%;
|
|
426
|
+
display: block;
|
|
427
|
+
transition: height 0.3s ease;
|
|
428
|
+
|
|
429
|
+
text:empty {
|
|
430
|
+
animation: pulse 1.5s ease-in-out infinite;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/* 鼠标悬停显示 toolbar */
|
|
435
|
+
&:hover :global(.mm-toolbar) {
|
|
436
|
+
opacity: 1;
|
|
437
|
+
pointer-events: auto;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* dark background */
|
|
442
|
+
:global(.markmap-dark) .markmapContainer {
|
|
443
|
+
background-color: #1d1d1d;
|
|
444
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
|
|
445
|
+
|
|
446
|
+
&:hover {
|
|
447
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/* 按钮组样式 */
|
|
452
|
+
.btnGroup {
|
|
453
|
+
color: var(--vp-c-brand-1);
|
|
454
|
+
|
|
455
|
+
input {
|
|
456
|
+
display: inline-block;
|
|
457
|
+
width: 2rem;
|
|
458
|
+
text-align: center;
|
|
459
|
+
border: 1px solid var(--vp-c-divider);
|
|
460
|
+
border-radius: 4px;
|
|
461
|
+
padding: 2px 4px;
|
|
462
|
+
background: var(--vp-c-bg);
|
|
463
|
+
color: var(--vp-c-text-1);
|
|
464
|
+
transition: all 0.2s ease;
|
|
465
|
+
|
|
466
|
+
&:focus {
|
|
467
|
+
outline: none;
|
|
468
|
+
border-color: var(--vp-c-brand-1);
|
|
469
|
+
box-shadow: 0 0 0 2px rgba(var(--vp-c-brand-1), 0.1);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
&:hover {
|
|
473
|
+
border-color: var(--vp-c-brand-2);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
button {
|
|
478
|
+
outline: none;
|
|
479
|
+
border: none;
|
|
480
|
+
cursor: pointer;
|
|
481
|
+
padding: 4px 8px;
|
|
482
|
+
border-radius: 4px;
|
|
483
|
+
background-color: #f0f0f0;
|
|
484
|
+
transition: all 0.2s ease;
|
|
485
|
+
font-weight: 500;
|
|
486
|
+
|
|
487
|
+
&:hover {
|
|
488
|
+
background-color: #e0e0e0;
|
|
489
|
+
transform: translateY(-1px);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
&:active {
|
|
493
|
+
transform: translateY(0);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
:global(.markmap-dark) .btnGroup {
|
|
499
|
+
button {
|
|
500
|
+
background-color: #333;
|
|
501
|
+
color: #fff;
|
|
502
|
+
|
|
503
|
+
&:hover {
|
|
504
|
+
background-color: #444;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
input {
|
|
509
|
+
background-color: #2a2a2a;
|
|
510
|
+
border-color: #444;
|
|
511
|
+
color: #fff;
|
|
512
|
+
|
|
513
|
+
&:focus {
|
|
514
|
+
border-color: var(--vp-c-brand-1);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/* 全屏样式 */
|
|
520
|
+
.markmapContainer:fullscreen,
|
|
521
|
+
.markmapContainer:-ms-fullscreen,
|
|
522
|
+
.markmapContainer:-webkit-full-screen {
|
|
523
|
+
width: 100%;
|
|
524
|
+
height: 100%;
|
|
525
|
+
padding: 20px;
|
|
526
|
+
background: white;
|
|
527
|
+
display: flex;
|
|
528
|
+
flex-direction: column;
|
|
529
|
+
justify-content: center;
|
|
530
|
+
box-shadow: none;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
:global(.markmap-dark) .markmapContainer:fullscreen,
|
|
534
|
+
:global(.markmap-dark) .markmapContainer:-ms-fullscreen,
|
|
535
|
+
:global(.markmap-dark) .markmapContainer:-webkit-full-screen {
|
|
536
|
+
background: #1d1d1d;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/* 响应式设计 */
|
|
540
|
+
@media (max-width: 768px) {
|
|
541
|
+
.markmapContainer {
|
|
542
|
+
padding: 0.75rem;
|
|
543
|
+
margin: 1rem 0;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
@media (max-width: 480px) {
|
|
548
|
+
.markmapContainer {
|
|
549
|
+
padding: 0.5rem;
|
|
550
|
+
margin: 0.75rem 0;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/* 加载动画 */
|
|
555
|
+
@keyframes pulse {
|
|
556
|
+
0%,
|
|
557
|
+
100% {
|
|
558
|
+
opacity: 1;
|
|
559
|
+
}
|
|
560
|
+
50% {
|
|
561
|
+
opacity: 0.5;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
</style>
|