@tnotesjs/core 0.1.18 → 0.1.20

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 (114) hide show
  1. package/README.md +87 -87
  2. package/package.json +1 -1
  3. package/types/config.ts +61 -61
  4. package/types/index.ts +11 -11
  5. package/types/note.ts +33 -33
  6. package/vitepress/assets/icons/icon__check.svg +3 -3
  7. package/vitepress/assets/icons/icon__clipboard.svg +7 -7
  8. package/vitepress/assets/icons/icon__close.svg +1 -1
  9. package/vitepress/assets/icons/icon__collapse.svg +1 -1
  10. package/vitepress/assets/icons/icon__confirm.svg +1 -1
  11. package/vitepress/assets/icons/icon__copy.svg +4 -4
  12. package/vitepress/assets/icons/icon__focus.svg +1 -1
  13. package/vitepress/assets/icons/icon__fold.svg +3 -3
  14. package/vitepress/assets/icons/icon__folder.svg +1 -1
  15. package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
  16. package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
  17. package/vitepress/assets/icons/icon__github.svg +3 -3
  18. package/vitepress/assets/icons/icon__mindmap.svg +1 -1
  19. package/vitepress/assets/icons/icon__next.svg +1 -1
  20. package/vitepress/assets/icons/icon__number_gray.svg +1 -1
  21. package/vitepress/assets/icons/icon__number_purple.svg +1 -1
  22. package/vitepress/assets/icons/icon__prev.svg +1 -1
  23. package/vitepress/assets/icons/icon__restore.svg +1 -1
  24. package/vitepress/assets/icons/icon__rotate.svg +4 -4
  25. package/vitepress/assets/icons/icon__search.svg +1 -1
  26. package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
  27. package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
  28. package/vitepress/assets/icons/icon__totop.svg +5 -5
  29. package/vitepress/assets/icons/icon__vscode.svg +5 -5
  30. package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
  31. package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
  32. package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
  33. package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
  34. package/vitepress/assets/icons/index.ts +39 -39
  35. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
  36. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +369 -369
  37. package/vitepress/components/CodeBlockFullscreen/index.ts +213 -213
  38. package/vitepress/components/CodeBlockFullscreen/styles.css +126 -126
  39. package/vitepress/components/Discussions/Discussions.module.scss +32 -32
  40. package/vitepress/components/Discussions/Discussions.vue +211 -211
  41. package/vitepress/components/EnWordList/EnWordList.module.scss +124 -124
  42. package/vitepress/components/EnWordList/EnWordList.vue +543 -543
  43. package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -22
  44. package/vitepress/components/EnWordList/RightClickMenu.vue +66 -66
  45. package/vitepress/components/Footprints/Footprints.module.scss +93 -93
  46. package/vitepress/components/Footprints/Footprints.vue +377 -377
  47. package/vitepress/components/Layout/AboutModal.module.scss +233 -233
  48. package/vitepress/components/Layout/AboutModal.vue +105 -105
  49. package/vitepress/components/Layout/AboutPanel.vue +270 -270
  50. package/vitepress/components/Layout/ContentCollapse.vue +603 -603
  51. package/vitepress/components/Layout/CustomSidebar.vue +817 -817
  52. package/vitepress/components/Layout/DocBeforeControls.vue +149 -149
  53. package/vitepress/components/Layout/DocFooter.vue +233 -233
  54. package/vitepress/components/Layout/ImagePreview.module.scss +201 -201
  55. package/vitepress/components/Layout/ImagePreview.vue +281 -281
  56. package/vitepress/components/Layout/Layout.module.scss +661 -661
  57. package/vitepress/components/Layout/Layout.vue +621 -621
  58. package/vitepress/components/Layout/NoteStatus.vue +140 -140
  59. package/vitepress/components/Layout/SidebarItems.vue +1083 -1083
  60. package/vitepress/components/Layout/SidebarNavBefore.vue +171 -171
  61. package/vitepress/components/Layout/SidebarResizeHandle.vue +319 -319
  62. package/vitepress/components/Layout/Swiper.vue +167 -167
  63. package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -11
  64. package/vitepress/components/Layout/ToggleFullContent.vue +35 -35
  65. package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -11
  66. package/vitepress/components/Layout/ToggleSidebar.vue +26 -26
  67. package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
  68. package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -119
  69. package/vitepress/components/Layout/composables/useNoteSave.ts +178 -178
  70. package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
  71. package/vitepress/components/Layout/composables/useRedirect.ts +113 -113
  72. package/vitepress/components/Layout/composables/useSidebarLayout.ts +122 -122
  73. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
  74. package/vitepress/components/Layout/homeReadme.data.ts +124 -124
  75. package/vitepress/components/MarkMap/MarkMap.module.scss +159 -159
  76. package/vitepress/components/MarkMap/MarkMap.vue +405 -405
  77. package/vitepress/components/Mermaid/Mermaid.module.scss +275 -275
  78. package/vitepress/components/Mermaid/Mermaid.vue +365 -365
  79. package/vitepress/components/NotesTable/NotesTable.module.scss +77 -77
  80. package/vitepress/components/NotesTable/NotesTable.vue +98 -98
  81. package/vitepress/components/NotesTable/README.md +67 -67
  82. package/vitepress/components/Settings/Settings.module.scss +375 -375
  83. package/vitepress/components/Settings/Settings.vue +334 -334
  84. package/vitepress/components/SidebarCard/MindMapView.vue +484 -484
  85. package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
  86. package/vitepress/components/SidebarCard/SidebarCard.vue +946 -946
  87. package/vitepress/components/Tooltip/Tooltip.vue +70 -70
  88. package/vitepress/components/constants.ts +109 -109
  89. package/vitepress/components/notesConfig.data.ts +73 -73
  90. package/vitepress/components/sidebar.data.ts +59 -59
  91. package/vitepress/components/tnotes-config.data.ts +21 -21
  92. package/vitepress/components/utils.ts +26 -26
  93. package/vitepress/config/index.ts +169 -169
  94. package/vitepress/configs/constants.ts +26 -26
  95. package/vitepress/configs/head.config.ts +25 -25
  96. package/vitepress/configs/index.ts +9 -9
  97. package/vitepress/configs/markdown-it.d.ts +23 -23
  98. package/vitepress/configs/markdown.config.ts +366 -366
  99. package/vitepress/configs/theme.config.ts +108 -108
  100. package/vitepress/plugins/buildProgressPlugin.ts +434 -434
  101. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
  102. package/vitepress/plugins/renameNotePlugin.ts +68 -68
  103. package/vitepress/plugins/sidebarStructurePlugin.ts +260 -260
  104. package/vitepress/plugins/updateConfigPlugin.ts +63 -63
  105. package/vitepress/theme/index.ts +137 -137
  106. package/vitepress/theme/styles/base.scss +64 -59
  107. package/vitepress/theme/styles/components/404.scss +31 -31
  108. package/vitepress/theme/styles/components/collapse.scss +172 -185
  109. package/vitepress/theme/styles/components/markmap.scss +101 -101
  110. package/vitepress/theme/styles/components/swiper.scss +255 -255
  111. package/vitepress/theme/styles/index.scss +25 -25
  112. package/vitepress/theme/styles/layout.scss +78 -78
  113. package/vitepress/theme/styles/utilities.scss +39 -39
  114. package/vitepress/theme/styles/vitepress-override.scss +25 -25
@@ -1,213 +1,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 = 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 = 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,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: calc(100% + 6px);
80
- right: 0;
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(-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(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: calc(100% + 6px);
80
+ right: 0;
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(-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(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
+ }