@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.
Files changed (122) hide show
  1. package/README.md +87 -87
  2. package/dist/{chunk-4MO7F7Q4.js → chunk-BSTQOJVE.js} +1 -1
  3. package/dist/{chunk-SQVHJR2Z.js → chunk-O4DCXHOV.js} +0 -3
  4. package/dist/cli/index.js +2 -2
  5. package/dist/index.js +1 -1
  6. package/dist/vitepress/config/index.js +2 -2
  7. package/package.json +3 -4
  8. package/types/config.ts +60 -61
  9. package/types/index.ts +11 -11
  10. package/types/note.ts +33 -33
  11. package/vitepress/assets/icons/icon__check.svg +3 -3
  12. package/vitepress/assets/icons/icon__clipboard.svg +7 -7
  13. package/vitepress/assets/icons/icon__close.svg +1 -1
  14. package/vitepress/assets/icons/icon__collapse.svg +1 -1
  15. package/vitepress/assets/icons/icon__confirm.svg +1 -1
  16. package/vitepress/assets/icons/icon__copy.svg +4 -4
  17. package/vitepress/assets/icons/icon__focus.svg +1 -1
  18. package/vitepress/assets/icons/icon__fold.svg +3 -3
  19. package/vitepress/assets/icons/icon__folder.svg +1 -1
  20. package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
  21. package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
  22. package/vitepress/assets/icons/icon__github.svg +3 -3
  23. package/vitepress/assets/icons/icon__mindmap.svg +1 -1
  24. package/vitepress/assets/icons/icon__next.svg +1 -1
  25. package/vitepress/assets/icons/icon__number_gray.svg +1 -1
  26. package/vitepress/assets/icons/icon__number_purple.svg +1 -1
  27. package/vitepress/assets/icons/icon__prev.svg +1 -1
  28. package/vitepress/assets/icons/icon__restore.svg +1 -1
  29. package/vitepress/assets/icons/icon__rotate.svg +4 -4
  30. package/vitepress/assets/icons/icon__search.svg +1 -1
  31. package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
  32. package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
  33. package/vitepress/assets/icons/icon__totop.svg +5 -5
  34. package/vitepress/assets/icons/icon__vscode.svg +5 -5
  35. package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
  36. package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
  37. package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
  38. package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
  39. package/vitepress/assets/icons/index.ts +39 -39
  40. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
  41. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +369 -369
  42. package/vitepress/components/CodeBlockFullscreen/index.ts +209 -213
  43. package/vitepress/components/CodeBlockFullscreen/styles.css +126 -126
  44. package/vitepress/components/Discussions/Discussions.vue +244 -211
  45. package/vitepress/components/EnWordList/EnWordList.vue +663 -543
  46. package/vitepress/components/EnWordList/RightClickMenu.vue +89 -66
  47. package/vitepress/components/Footprints/Footprints.vue +472 -377
  48. package/vitepress/components/Layout/AboutModal.vue +331 -105
  49. package/vitepress/components/Layout/AboutPanel.vue +484 -270
  50. package/vitepress/components/Layout/ContentCollapse.vue +590 -603
  51. package/vitepress/components/Layout/CustomSidebar.vue +817 -817
  52. package/vitepress/components/Layout/DocBeforeControls.vue +351 -149
  53. package/vitepress/components/Layout/DocFooter.vue +233 -233
  54. package/vitepress/components/Layout/ImagePreview.vue +484 -281
  55. package/vitepress/components/Layout/Layout.vue +744 -621
  56. package/vitepress/components/Layout/NavBarSettingsTrigger.vue +0 -2
  57. package/vitepress/components/Layout/NoteStatus.vue +140 -140
  58. package/vitepress/components/Layout/SidebarItems.vue +1083 -1083
  59. package/vitepress/components/Layout/SidebarNavBefore.vue +170 -171
  60. package/vitepress/components/Layout/SidebarResizeHandle.vue +311 -319
  61. package/vitepress/components/Layout/Swiper.vue +167 -167
  62. package/vitepress/components/Layout/ToggleFullContent.vue +47 -35
  63. package/vitepress/components/Layout/ToggleSidebar.vue +37 -26
  64. package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
  65. package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -119
  66. package/vitepress/components/Layout/composables/useNoteSave.ts +178 -178
  67. package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
  68. package/vitepress/components/Layout/composables/useRedirect.ts +113 -113
  69. package/vitepress/components/Layout/composables/useSidebarLayout.ts +122 -122
  70. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
  71. package/vitepress/components/Layout/homeReadme.data.ts +124 -124
  72. package/vitepress/components/LoadingPage/LoadingPage.vue +1 -6
  73. package/vitepress/components/MarkMap/MarkMap.vue +564 -405
  74. package/vitepress/components/Mermaid/Mermaid.vue +643 -365
  75. package/vitepress/components/NotesTable/NotesTable.vue +174 -98
  76. package/vitepress/components/NotesTable/README.md +67 -67
  77. package/vitepress/components/Settings/Settings.vue +711 -334
  78. package/vitepress/components/Settings/SettingsDialog.vue +1 -11
  79. package/vitepress/components/SidebarCard/MindMapView.vue +484 -484
  80. package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
  81. package/vitepress/components/SidebarCard/SidebarCard.vue +945 -946
  82. package/vitepress/components/Tooltip/Tooltip.vue +70 -70
  83. package/vitepress/components/constants.ts +109 -109
  84. package/vitepress/components/notesConfig.data.ts +73 -73
  85. package/vitepress/components/sidebar.data.ts +59 -59
  86. package/vitepress/components/tnotes-config.data.ts +21 -21
  87. package/vitepress/components/utils.ts +26 -26
  88. package/vitepress/config/index.ts +169 -169
  89. package/vitepress/configs/constants.ts +26 -26
  90. package/vitepress/configs/head.config.ts +25 -25
  91. package/vitepress/configs/index.ts +9 -9
  92. package/vitepress/configs/markdown-it.d.ts +23 -23
  93. package/vitepress/configs/markdown.config.ts +368 -367
  94. package/vitepress/configs/theme.config.ts +108 -108
  95. package/vitepress/plugins/buildProgressPlugin.ts +434 -434
  96. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
  97. package/vitepress/plugins/renameNotePlugin.ts +68 -68
  98. package/vitepress/plugins/sidebarStructurePlugin.ts +260 -260
  99. package/vitepress/plugins/updateConfigPlugin.ts +63 -63
  100. package/vitepress/theme/index.ts +137 -137
  101. package/vitepress/theme/styles/base.scss +66 -64
  102. package/vitepress/theme/styles/components/404.scss +31 -31
  103. package/vitepress/theme/styles/components/collapse.scss +172 -172
  104. package/vitepress/theme/styles/components/markmap.scss +101 -101
  105. package/vitepress/theme/styles/components/swiper.scss +255 -255
  106. package/vitepress/theme/styles/index.scss +25 -25
  107. package/vitepress/theme/styles/layout.scss +78 -78
  108. package/vitepress/theme/styles/utilities.scss +39 -39
  109. package/vitepress/theme/styles/vitepress-override.scss +25 -25
  110. package/vitepress/components/Discussions/Discussions.module.scss +0 -32
  111. package/vitepress/components/EnWordList/EnWordList.module.scss +0 -124
  112. package/vitepress/components/EnWordList/RightClickMenu.module.scss +0 -22
  113. package/vitepress/components/Footprints/Footprints.module.scss +0 -93
  114. package/vitepress/components/Layout/AboutModal.module.scss +0 -233
  115. package/vitepress/components/Layout/ImagePreview.module.scss +0 -201
  116. package/vitepress/components/Layout/Layout.module.scss +0 -661
  117. package/vitepress/components/Layout/ToggleFullContent.module.scss +0 -11
  118. package/vitepress/components/Layout/ToggleSidebar.module.scss +0 -11
  119. package/vitepress/components/MarkMap/MarkMap.module.scss +0 -159
  120. package/vitepress/components/Mermaid/Mermaid.module.scss +0 -275
  121. package/vitepress/components/NotesTable/NotesTable.module.scss +0 -77
  122. package/vitepress/components/Settings/Settings.module.scss +0 -375
@@ -1,213 +1,209 @@
1
- import { createApp, onMounted, onUnmounted } from 'vue'
2
-
3
- import CodeBlockFullscreen from './CodeBlockFullscreen.vue'
4
- import { icon__check, icon__clipboard, icon__fullscreen } from '../../assets/icons'
5
-
6
- type CopyState = 'idle' | 'copied' | 'failed'
7
-
8
- const CODE_BLOCK_SELECTOR = 'div[class*="language-"]'
9
- const CODE_ACTIONS_CLASS = 'tn-code-actions'
10
- const COPY_RESET_DELAY = 2000
11
-
12
- export function useCodeBlockFullscreen() {
13
- let fullscreenApp: any = null
14
- let fullscreenContainer: HTMLElement | null = null
15
- const copyResetTimers = new WeakMap<HTMLElement, number>()
16
-
17
- function addCodeActions() {
18
- // 找到所有代码块
19
- const codeBlocks = document.querySelectorAll(CODE_BLOCK_SELECTOR)
20
-
21
- codeBlocks.forEach((block) => {
22
- if (!(block instanceof HTMLElement)) return
23
- if (!block.querySelector('pre code')) return
24
- block.querySelectorAll('.fullscreen-btn').forEach((button) => {
25
- button.remove()
26
- })
27
- if (block.querySelector(`.${CODE_ACTIONS_CLASS}`)) return
28
-
29
- const actions = document.createElement('div')
30
- actions.className = CODE_ACTIONS_CLASS
31
- actions.setAttribute('aria-label', '代码块操作')
32
-
33
- const fullscreenButton = createActionButton({
34
- className: 'tn-code-action-fullscreen',
35
- title: '全屏查看代码',
36
- icon: icon__fullscreen,
37
- alt: '全屏',
38
- })
39
- fullscreenButton.addEventListener('click', () => {
40
- openFullscreen(block)
41
- })
42
-
43
- const copyButton = createActionButton({
44
- className: 'tn-code-action-copy',
45
- title: '复制代码',
46
- icon: icon__clipboard,
47
- alt: '复制',
48
- })
49
- copyButton.addEventListener('click', () => {
50
- void copyCode(block, copyButton)
51
- })
52
-
53
- actions.append(fullscreenButton, copyButton)
54
- block.appendChild(actions)
55
- })
56
- }
57
-
58
- function createActionButton(options: {
59
- className: string
60
- title: string
61
- icon: string
62
- alt: string
63
- }) {
64
- const button = document.createElement('button')
65
- button.className = `tn-code-action ${options.className}`
66
- button.type = 'button'
67
- button.title = options.title
68
- button.setAttribute('aria-label', options.title)
69
- button.innerHTML = `<img src="${options.icon}" alt="${options.alt}" />`
70
-
71
- return button
72
- }
73
-
74
- async function copyCode(codeBlock: HTMLElement, button: HTMLElement) {
75
- const codeElement = codeBlock.querySelector('pre code')
76
- const text = codeElement?.textContent ?? ''
77
- if (!text) {
78
- setCopyState(button, 'failed')
79
- return
80
- }
81
-
82
- try {
83
- await navigator.clipboard.writeText(text)
84
- setCopyState(button, 'copied')
85
- } catch {
86
- setCopyState(button, 'failed')
87
- }
88
- }
89
-
90
- function setCopyState(button: HTMLElement, state: CopyState) {
91
- const currentTimer = copyResetTimers.get(button)
92
- if (currentTimer) {
93
- window.clearTimeout(currentTimer)
94
- }
95
-
96
- button.dataset.copyState = state
97
- if (button.parentElement) {
98
- button.parentElement.dataset.copyState = state
99
- }
100
- button.title = getCopyTitle(state)
101
- button.setAttribute('aria-label', getCopyTitle(state))
102
-
103
- const icon = button.querySelector('img')
104
- if (icon) {
105
- icon.setAttribute('src', state === 'copied' ? icon__check : icon__clipboard)
106
- icon.setAttribute('alt', state === 'copied' ? '已复制' : '复制')
107
- }
108
-
109
- const timer = window.setTimeout(() => {
110
- button.dataset.copyState = 'idle'
111
- if (button.parentElement) {
112
- button.parentElement.dataset.copyState = 'idle'
113
- }
114
- button.title = getCopyTitle('idle')
115
- button.setAttribute('aria-label', getCopyTitle('idle'))
116
- icon?.setAttribute('src', icon__clipboard)
117
- icon?.setAttribute('alt', '复制')
118
- copyResetTimers.delete(button)
119
- }, COPY_RESET_DELAY)
120
-
121
- copyResetTimers.set(button, timer)
122
- }
123
-
124
- function getCopyTitle(state: CopyState): string {
125
- if (state === 'copied') return '已复制'
126
- if (state === 'failed') return '复制失败'
127
-
128
- return '复制代码'
129
- }
130
-
131
- function openFullscreen(codeBlock: HTMLElement) {
132
- // 获取代码内容
133
- const pre = codeBlock.querySelector('pre')
134
- if (!pre) return
135
-
136
- const codeHtml = pre.outerHTML
137
-
138
- // 提取语言
139
- const classList = Array.from(codeBlock.classList)
140
- const languageClass = classList.find((c) => c.startsWith('language-'))
141
- const language = languageClass
142
- ? languageClass.replace('language-', '').toUpperCase()
143
- : undefined
144
-
145
- // 提取文件名(如果有)
146
- const filenameSpan = codeBlock.querySelector('.lang')
147
- const filename = filenameSpan?.textContent?.trim()
148
-
149
- // 创建全屏组件容器
150
- if (!fullscreenContainer) {
151
- fullscreenContainer = document.createElement('div')
152
- document.body.appendChild(fullscreenContainer)
153
- }
154
-
155
- // 创建 Vue 应用
156
- fullscreenApp = createApp(CodeBlockFullscreen, {
157
- isFullscreen: true,
158
- codeHtml,
159
- language,
160
- filename,
161
- 'onUpdate:isFullscreen': (value: boolean) => {
162
- if (!value) {
163
- closeFullscreen()
164
- }
165
- },
166
- })
167
-
168
- fullscreenApp.mount(fullscreenContainer)
169
- }
170
-
171
- function closeFullscreen() {
172
- if (fullscreenApp) {
173
- fullscreenApp.unmount()
174
- fullscreenApp = null
175
- }
176
- if (fullscreenContainer && fullscreenContainer.parentNode) {
177
- fullscreenContainer.parentNode.removeChild(fullscreenContainer)
178
- fullscreenContainer = null
179
- }
180
- }
181
-
182
- function cleanup() {
183
- closeFullscreen()
184
- document.querySelectorAll(`.${CODE_ACTIONS_CLASS}`).forEach((actions) => {
185
- actions.remove()
186
- })
187
- document.querySelectorAll('.fullscreen-btn').forEach((button) => {
188
- button.remove()
189
- })
190
- }
191
-
192
- onMounted(() => {
193
- // 初始化
194
- setTimeout(() => {
195
- addCodeActions()
196
- }, 100)
197
-
198
- // 监听路由变化
199
- const observer = new MutationObserver(() => {
200
- addCodeActions()
201
- })
202
-
203
- observer.observe(document.body, {
204
- childList: true,
205
- subtree: true,
206
- })
207
-
208
- onUnmounted(() => {
209
- observer.disconnect()
210
- cleanup()
211
- })
212
- })
213
- }
1
+ import { createApp, onMounted, onUnmounted } from 'vue'
2
+
3
+ import CodeBlockFullscreen from './CodeBlockFullscreen.vue'
4
+ import { icon__check, icon__clipboard, icon__fullscreen } from '../../assets/icons'
5
+
6
+ type CopyState = 'idle' | 'copied' | 'failed'
7
+
8
+ const CODE_BLOCK_SELECTOR = 'div[class*="language-"]'
9
+ const CODE_ACTIONS_CLASS = 'tn-code-actions'
10
+ const COPY_RESET_DELAY = 1000
11
+
12
+ export function useCodeBlockFullscreen() {
13
+ let fullscreenApp: any = null
14
+ let fullscreenContainer: HTMLElement | null = null
15
+ const copyResetTimers = new WeakMap<HTMLElement, number>()
16
+
17
+ function addCodeActions() {
18
+ // 找到所有代码块
19
+ const codeBlocks = document.querySelectorAll(CODE_BLOCK_SELECTOR)
20
+
21
+ codeBlocks.forEach((block) => {
22
+ if (!(block instanceof HTMLElement)) return
23
+ if (!block.querySelector('pre code')) return
24
+ block.querySelectorAll('.fullscreen-btn').forEach((button) => {
25
+ button.remove()
26
+ })
27
+ if (block.querySelector(`.${CODE_ACTIONS_CLASS}`)) return
28
+
29
+ const actions = document.createElement('div')
30
+ actions.className = CODE_ACTIONS_CLASS
31
+
32
+ const fullscreenButton = createActionButton({
33
+ className: 'tn-code-action-fullscreen',
34
+ title: '全屏查看代码',
35
+ icon: icon__fullscreen,
36
+ alt: '全屏',
37
+ })
38
+ fullscreenButton.addEventListener('click', () => {
39
+ openFullscreen(block)
40
+ })
41
+
42
+ const copyButton = createActionButton({
43
+ className: 'tn-code-action-copy',
44
+ title: '复制代码',
45
+ icon: icon__clipboard,
46
+ alt: '复制',
47
+ })
48
+ copyButton.addEventListener('click', () => {
49
+ void copyCode(block, copyButton)
50
+ })
51
+
52
+ actions.append(fullscreenButton, copyButton)
53
+ block.appendChild(actions)
54
+ })
55
+ }
56
+
57
+ function createActionButton(options: {
58
+ className: string
59
+ title: string
60
+ icon: string
61
+ alt: string
62
+ }) {
63
+ const button = document.createElement('button')
64
+ button.className = `tn-code-action ${options.className}`
65
+ button.type = 'button'
66
+ button.title = options.title
67
+ button.innerHTML = `<img src="${options.icon}" alt="${options.alt}" />`
68
+
69
+ return button
70
+ }
71
+
72
+ async function copyCode(codeBlock: HTMLElement, button: HTMLElement) {
73
+ const codeElement = codeBlock.querySelector('pre code')
74
+ const text = codeElement?.textContent ?? ''
75
+ if (!text) {
76
+ setCopyState(button, 'failed')
77
+ return
78
+ }
79
+
80
+ try {
81
+ await navigator.clipboard.writeText(text)
82
+ setCopyState(button, 'copied')
83
+ } catch {
84
+ setCopyState(button, 'failed')
85
+ }
86
+ }
87
+
88
+ function setCopyState(button: HTMLElement, state: CopyState) {
89
+ const currentTimer = copyResetTimers.get(button)
90
+ if (currentTimer) {
91
+ window.clearTimeout(currentTimer)
92
+ }
93
+
94
+ button.dataset.copyState = state
95
+ if (button.parentElement) {
96
+ button.parentElement.dataset.copyState = state
97
+ }
98
+ button.title = getCopyTitle(state)
99
+
100
+ const icon = button.querySelector('img')
101
+ if (icon) {
102
+ icon.setAttribute('src', state === 'copied' ? icon__check : icon__clipboard)
103
+ icon.setAttribute('alt', state === 'copied' ? '已复制' : '复制')
104
+ }
105
+
106
+ const timer = window.setTimeout(() => {
107
+ button.dataset.copyState = 'idle'
108
+ if (button.parentElement) {
109
+ button.parentElement.dataset.copyState = 'idle'
110
+ }
111
+ button.title = getCopyTitle('idle')
112
+ icon?.setAttribute('src', icon__clipboard)
113
+ icon?.setAttribute('alt', '复制')
114
+ copyResetTimers.delete(button)
115
+ }, COPY_RESET_DELAY)
116
+
117
+ copyResetTimers.set(button, timer)
118
+ }
119
+
120
+ function getCopyTitle(state: CopyState): string {
121
+ if (state === 'copied') return '已复制'
122
+ if (state === 'failed') return '复制失败'
123
+
124
+ return '复制代码'
125
+ }
126
+
127
+ function openFullscreen(codeBlock: HTMLElement) {
128
+ // 获取代码内容
129
+ const pre = codeBlock.querySelector('pre')
130
+ if (!pre) return
131
+
132
+ const codeHtml = pre.outerHTML
133
+
134
+ // 提取语言
135
+ const classList = Array.from(codeBlock.classList)
136
+ const languageClass = classList.find((c) => c.startsWith('language-'))
137
+ const language = languageClass
138
+ ? languageClass.replace('language-', '').toUpperCase()
139
+ : undefined
140
+
141
+ // 提取文件名(如果有)
142
+ const filenameSpan = codeBlock.querySelector('.lang')
143
+ const filename = filenameSpan?.textContent?.trim()
144
+
145
+ // 创建全屏组件容器
146
+ if (!fullscreenContainer) {
147
+ fullscreenContainer = document.createElement('div')
148
+ document.body.appendChild(fullscreenContainer)
149
+ }
150
+
151
+ // 创建 Vue 应用
152
+ fullscreenApp = createApp(CodeBlockFullscreen, {
153
+ isFullscreen: true,
154
+ codeHtml,
155
+ language,
156
+ filename,
157
+ 'onUpdate:isFullscreen': (value: boolean) => {
158
+ if (!value) {
159
+ closeFullscreen()
160
+ }
161
+ },
162
+ })
163
+
164
+ fullscreenApp.mount(fullscreenContainer)
165
+ }
166
+
167
+ function closeFullscreen() {
168
+ if (fullscreenApp) {
169
+ fullscreenApp.unmount()
170
+ fullscreenApp = null
171
+ }
172
+ if (fullscreenContainer && fullscreenContainer.parentNode) {
173
+ fullscreenContainer.parentNode.removeChild(fullscreenContainer)
174
+ fullscreenContainer = null
175
+ }
176
+ }
177
+
178
+ function cleanup() {
179
+ closeFullscreen()
180
+ document.querySelectorAll(`.${CODE_ACTIONS_CLASS}`).forEach((actions) => {
181
+ actions.remove()
182
+ })
183
+ document.querySelectorAll('.fullscreen-btn').forEach((button) => {
184
+ button.remove()
185
+ })
186
+ }
187
+
188
+ onMounted(() => {
189
+ // 初始化
190
+ setTimeout(() => {
191
+ addCodeActions()
192
+ }, 100)
193
+
194
+ // 监听路由变化
195
+ const observer = new MutationObserver(() => {
196
+ addCodeActions()
197
+ })
198
+
199
+ observer.observe(document.body, {
200
+ childList: true,
201
+ subtree: true,
202
+ })
203
+
204
+ onUnmounted(() => {
205
+ observer.disconnect()
206
+ cleanup()
207
+ })
208
+ })
209
+ }
@@ -1,126 +1,126 @@
1
- /* 代码块操作按钮样式 */
2
- div[class*='language-'] {
3
- position: relative;
4
- }
5
-
6
- div[class*='language-'] button.copy {
7
- display: none !important;
8
- }
9
-
10
- .tn-code-actions {
11
- position: absolute;
12
- top: 8px;
13
- right: 8px;
14
- z-index: 10;
15
- display: flex;
16
- align-items: center;
17
- justify-content: center;
18
- gap: 4px;
19
- padding: 2px;
20
- background-color: color-mix(in srgb, var(--vp-code-block-bg) 92%, transparent);
21
- border: .1px solid var(--vp-c-divider);
22
- border-radius: 7px;
23
- opacity: 0;
24
- transition: opacity 0.2s;
25
- }
26
-
27
- .tn-code-action {
28
- display: inline-flex;
29
- align-items: center;
30
- justify-content: center;
31
- width: 32px;
32
- height: 32px;
33
- padding: 0;
34
- border: none;
35
- background-color: transparent;
36
- color: var(--vp-c-text-2);
37
- border-radius: 6px;
38
- cursor: pointer;
39
- transition: all 0.2s;
40
- }
41
-
42
- .tn-code-action img {
43
- width: 16px;
44
- height: 16px;
45
- filter: var(--vp-icon-filter, none);
46
- }
47
-
48
- div[class*='language-']:hover .tn-code-actions,
49
- .tn-code-actions:focus-within,
50
- .tn-code-actions[data-copy-state='copied'],
51
- .tn-code-actions[data-copy-state='failed'] {
52
- opacity: 1;
53
- }
54
-
55
- .tn-code-action:hover {
56
- background-color: var(--vp-c-default-soft);
57
- color: var(--vp-c-brand-1);
58
- transform: scale(1.05);
59
- }
60
-
61
- .tn-code-action:active {
62
- transform: scale(0.95);
63
- }
64
-
65
- .tn-code-action-copy {
66
- position: relative;
67
- }
68
-
69
- .tn-code-action-copy[data-copy-state='copied'] {
70
- background-color: var(--vp-c-green-soft);
71
- }
72
-
73
- .tn-code-action-copy[data-copy-state='failed'] {
74
- background-color: var(--vp-c-danger-soft);
75
- }
76
-
77
- .tn-code-action-copy::after {
78
- position: absolute;
79
- top: 50%;
80
- right: calc(100% + 6px);
81
- padding: 4px 7px;
82
- color: var(--vp-c-text-1);
83
- background: var(--vp-c-bg-elv);
84
- border: 1px solid var(--vp-c-divider);
85
- border-radius: 6px;
86
- box-shadow: var(--vp-shadow-2);
87
- content: attr(title);
88
- font-size: 12px;
89
- line-height: 18px;
90
- opacity: 0;
91
- pointer-events: none;
92
- transform: translateY(-50%) translateX(2px);
93
- transition:
94
- opacity 0.16s ease,
95
- transform 0.16s ease;
96
- white-space: nowrap;
97
- }
98
-
99
- .tn-code-action-copy[data-copy-state='copied']::after,
100
- .tn-code-action-copy[data-copy-state='failed']::after {
101
- opacity: 1;
102
- transform: translateY(-50%) translateX(0);
103
- }
104
-
105
- /* .dark .tn-code-action-copy img {
106
- filter: invert(1);
107
- } */
108
-
109
- /* 移动端始终显示按钮 */
110
- @media (max-width: 768px) {
111
- .tn-code-actions {
112
- /* opacity: 0.8; */
113
- top: 6px;
114
- right: 6px;
115
- }
116
-
117
- .tn-code-action {
118
- width: 28px;
119
- height: 28px;
120
- }
121
-
122
- .tn-code-action img {
123
- width: 14px;
124
- height: 14px;
125
- }
126
- }
1
+ /* 代码块操作按钮样式 */
2
+ div[class*='language-'] {
3
+ position: relative;
4
+ }
5
+
6
+ div[class*='language-'] button.copy {
7
+ display: none !important;
8
+ }
9
+
10
+ .tn-code-actions {
11
+ position: absolute;
12
+ top: 8px;
13
+ right: 8px;
14
+ z-index: 10;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ gap: 4px;
19
+ padding: 2px;
20
+ background-color: color-mix(in srgb, var(--vp-code-block-bg) 92%, transparent);
21
+ border: .1px solid var(--vp-c-divider);
22
+ border-radius: 7px;
23
+ opacity: 0;
24
+ transition: opacity 0.2s;
25
+ }
26
+
27
+ .tn-code-action {
28
+ display: inline-flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ width: 32px;
32
+ height: 32px;
33
+ padding: 0;
34
+ border: none;
35
+ background-color: transparent;
36
+ color: var(--vp-c-text-2);
37
+ border-radius: 6px;
38
+ cursor: pointer;
39
+ transition: all 0.2s;
40
+ }
41
+
42
+ .tn-code-action img {
43
+ width: 16px;
44
+ height: 16px;
45
+ filter: var(--vp-icon-filter, none);
46
+ }
47
+
48
+ div[class*='language-']:hover .tn-code-actions,
49
+ .tn-code-actions:focus-within,
50
+ .tn-code-actions[data-copy-state='copied'],
51
+ .tn-code-actions[data-copy-state='failed'] {
52
+ opacity: 1;
53
+ }
54
+
55
+ .tn-code-action:hover {
56
+ background-color: var(--vp-c-default-soft);
57
+ color: var(--vp-c-brand-1);
58
+ transform: scale(1.05);
59
+ }
60
+
61
+ .tn-code-action:active {
62
+ transform: scale(0.95);
63
+ }
64
+
65
+ .tn-code-action-copy {
66
+ position: relative;
67
+ }
68
+
69
+ .tn-code-action-copy[data-copy-state='copied'] {
70
+ background-color: var(--vp-c-green-soft);
71
+ }
72
+
73
+ .tn-code-action-copy[data-copy-state='failed'] {
74
+ background-color: var(--vp-c-danger-soft);
75
+ }
76
+
77
+ .tn-code-action-copy::after {
78
+ position: absolute;
79
+ top: 50%;
80
+ right: calc(100% + 6px);
81
+ padding: 4px 7px;
82
+ color: var(--vp-c-text-1);
83
+ background: var(--vp-c-bg-elv);
84
+ border: 1px solid var(--vp-c-divider);
85
+ border-radius: 6px;
86
+ box-shadow: var(--vp-shadow-2);
87
+ content: attr(title);
88
+ font-size: 12px;
89
+ line-height: 18px;
90
+ opacity: 0;
91
+ pointer-events: none;
92
+ transform: translateY(-50%) translateX(2px);
93
+ transition:
94
+ opacity 0.16s ease,
95
+ transform 0.16s ease;
96
+ white-space: nowrap;
97
+ }
98
+
99
+ .tn-code-action-copy[data-copy-state='copied']::after,
100
+ .tn-code-action-copy[data-copy-state='failed']::after {
101
+ opacity: 1;
102
+ transform: translateY(-50%) translateX(0);
103
+ }
104
+
105
+ /* .dark .tn-code-action-copy img {
106
+ filter: invert(1);
107
+ } */
108
+
109
+ /* 移动端始终显示按钮 */
110
+ @media (max-width: 768px) {
111
+ .tn-code-actions {
112
+ /* opacity: 0.8; */
113
+ top: 6px;
114
+ right: 6px;
115
+ }
116
+
117
+ .tn-code-action {
118
+ width: 28px;
119
+ height: 28px;
120
+ }
121
+
122
+ .tn-code-action img {
123
+ width: 14px;
124
+ height: 14px;
125
+ }
126
+ }