@tnotesjs/core 0.1.28 → 0.2.1
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 +2 -1
- package/dist/{chunk-4KG6RXFS.js → chunk-5QN44ES5.js} +2946 -1533
- package/dist/{chunk-AGSL3VZE.js → chunk-5Y5IYS6C.js} +7 -0
- package/dist/cli/index.js +343 -40
- package/dist/index.js +1 -1
- package/dist/vitepress/config/index.js +573 -65
- package/package.json +4 -1
- package/templates/sub-repo/.gitattributes +30 -0
- package/templates/sub-repo/.github/workflows/deploy.yml +87 -0
- package/templates/sub-repo/.vitepress/config.mts +12 -0
- package/templates/sub-repo/.vitepress/env.d.ts +10 -0
- package/templates/sub-repo/.vitepress/theme/index.ts +12 -0
- package/templates/sub-repo/.vscode/settings.json +330 -0
- package/templates/sub-repo/.vscode/tnotes.code-snippets +110 -0
- package/templates/sub-repo/public/favicon.ico +0 -0
- package/templates/sub-repo/public/logo.png +0 -0
- package/templates/sub-repo/tsconfig.json +45 -0
- package/vitepress/assets/icons/icon__setting_dark.svg +4 -0
- package/vitepress/assets/icons/icon__setting_light.svg +4 -0
- package/vitepress/assets/icons/index.ts +2 -2
- package/vitepress/client/localSearchIndexBridge.ts +24 -0
- package/vitepress/components/Discussions/Discussions.vue +1 -1
- package/vitepress/components/Footprints/Footprints.vue +90 -25
- package/vitepress/components/Layout/CustomSidebar.vue +489 -117
- package/vitepress/components/Layout/Layout.vue +5 -0
- package/vitepress/components/Layout/NavBarSettingsTrigger.vue +10 -2
- package/vitepress/components/Layout/SidebarItems.vue +517 -342
- package/vitepress/components/Layout/SidebarNavBefore.vue +1 -50
- package/vitepress/components/Layout/SidebarResizeHandle.vue +6 -23
- package/vitepress/components/Layout/composables/docLayoutLogic.ts +59 -0
- package/vitepress/components/Layout/composables/useDocLayout.test.ts +69 -0
- package/vitepress/components/Layout/composables/useDocLayout.ts +128 -0
- package/vitepress/components/Layout/composables/useSidebarDrag.ts +514 -0
- package/vitepress/components/Layout/composables/useSidebarLayout.ts +25 -8
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +8 -3
- package/vitepress/components/Layout/sidebarCollapsedState.test.ts +183 -0
- package/vitepress/components/Layout/sidebarCollapsedState.ts +241 -0
- package/vitepress/components/Layout/sidebarDragLogic.test.ts +1146 -0
- package/vitepress/components/Layout/sidebarDragLogic.ts +1307 -0
- package/vitepress/components/Layout/sidebarHitTest.test.ts +572 -0
- package/vitepress/components/Layout/sidebarHitTest.ts +801 -0
- package/vitepress/components/Layout/sidebarItemRenderLogic.test.ts +53 -0
- package/vitepress/components/Layout/sidebarItemRenderLogic.ts +50 -0
- package/vitepress/components/MarkMap/MarkMap.vue +67 -10
- package/vitepress/components/Settings/Settings.vue +78 -74
- package/vitepress/components/SidebarCard/FolderTreeItems.vue +268 -0
- package/vitepress/components/SidebarCard/SidebarCard.vue +125 -274
- package/vitepress/components/constants.ts +18 -6
- package/vitepress/components/sidebar.data.ts +13 -11
- package/vitepress/components/sidebarTreeHelpers.test.ts +142 -0
- package/vitepress/components/sidebarTreeHelpers.ts +168 -0
- package/vitepress/components/utils/vscodePaths.test.ts +41 -0
- package/vitepress/components/utils/vscodePaths.ts +52 -0
- package/vitepress/config/index.ts +2 -0
- package/vitepress/plugins/localSearchIndexBuilder.ts +209 -0
- package/vitepress/plugins/localSearchReindex.test.ts +46 -0
- package/vitepress/plugins/localSearchReindexLogic.ts +50 -0
- package/vitepress/plugins/localSearchReindexPatch.test.ts +30 -0
- package/vitepress/plugins/localSearchReindexPatch.ts +37 -0
- package/vitepress/plugins/localSearchReindexPlugin.ts +318 -0
- package/vitepress/plugins/sidebarStructurePlugin.ts +209 -63
- package/vitepress/theme/index.ts +8 -0
- package/vitepress/theme/styles/base.scss +0 -8
- package/vitepress/theme/styles/components/markmap.scss +23 -2
- package/vitepress/theme/styles/components/swiper.scss +1 -1
- package/vitepress/theme/styles/doc-layout.scss +212 -0
- package/vitepress/theme/styles/index.scss +3 -0
- package/vitepress/theme/styles/layout.scss +60 -10
- package/vitepress/assets/icons/icon__mindmap.svg +0 -1
- package/vitepress/assets/icons/icon__setting.svg +0 -1
- package/vitepress/components/SidebarCard/MindMapView.vue +0 -488
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
vitepress/components/SidebarCard/FolderTreeItems.vue
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import {
|
|
7
|
+
icon__sidebar_collapsed,
|
|
8
|
+
icon__sidebar_opened,
|
|
9
|
+
icon__vscode,
|
|
10
|
+
} from '../../assets/icons'
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
nodes: {
|
|
14
|
+
type: Array,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
depth: {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: 0,
|
|
20
|
+
},
|
|
21
|
+
showNumber: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false,
|
|
24
|
+
},
|
|
25
|
+
expandedKeys: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits(['toggle-node', 'open-vscode'])
|
|
32
|
+
|
|
33
|
+
function hasChildren(node) {
|
|
34
|
+
return node.children?.length > 0
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isExpanded(node) {
|
|
38
|
+
return props.expandedKeys.has(node.key)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getNodeKey(node) {
|
|
42
|
+
return node.key
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getDisplayTitle(node) {
|
|
46
|
+
if (props.showNumber && node.realNumber) {
|
|
47
|
+
return `${node.realNumber}. ${node.text}`
|
|
48
|
+
}
|
|
49
|
+
return node.text
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getStatusEmoji(status) {
|
|
53
|
+
if (status === 'done') return '✅'
|
|
54
|
+
if (status === 'pending') return '⏰'
|
|
55
|
+
return '📄'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onToggle(node) {
|
|
59
|
+
emit('toggle-node', node.key)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function onOpenVscode(node, event) {
|
|
63
|
+
event.preventDefault()
|
|
64
|
+
event.stopPropagation()
|
|
65
|
+
emit('open-vscode', node)
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<div
|
|
71
|
+
v-for="node in nodes"
|
|
72
|
+
:key="getNodeKey(node)"
|
|
73
|
+
class="tree-node"
|
|
74
|
+
:style="{ paddingLeft: `${depth * 16}px` }"
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
class="tree-row"
|
|
78
|
+
:class="{ 'tree-row-parent': hasChildren(node) }"
|
|
79
|
+
>
|
|
80
|
+
<button
|
|
81
|
+
v-if="hasChildren(node)"
|
|
82
|
+
class="tree-arrow-btn"
|
|
83
|
+
type="button"
|
|
84
|
+
:title="isExpanded(node) ? '折叠' : '展开'"
|
|
85
|
+
@click.stop="onToggle(node)"
|
|
86
|
+
>
|
|
87
|
+
<span class="tree-arrow" :class="{ collapsed: !isExpanded(node) }">
|
|
88
|
+
<img
|
|
89
|
+
:src="
|
|
90
|
+
isExpanded(node)
|
|
91
|
+
? icon__sidebar_opened
|
|
92
|
+
: icon__sidebar_collapsed
|
|
93
|
+
"
|
|
94
|
+
alt=""
|
|
95
|
+
/>
|
|
96
|
+
</span>
|
|
97
|
+
</button>
|
|
98
|
+
<span v-else class="tree-arrow-placeholder" aria-hidden="true" />
|
|
99
|
+
|
|
100
|
+
<a
|
|
101
|
+
v-if="node.fullLink"
|
|
102
|
+
:href="node.fullLink"
|
|
103
|
+
class="tree-link"
|
|
104
|
+
:class="{ 'tree-link-leaf': !hasChildren(node) }"
|
|
105
|
+
>
|
|
106
|
+
<span class="tree-status" :class="`status-${node.status}`">
|
|
107
|
+
{{ getStatusEmoji(node.status) }}
|
|
108
|
+
</span>
|
|
109
|
+
<span class="tree-title">{{ getDisplayTitle(node) }}</span>
|
|
110
|
+
</a>
|
|
111
|
+
|
|
112
|
+
<span
|
|
113
|
+
v-else-if="hasChildren(node)"
|
|
114
|
+
class="tree-link tree-link-folder"
|
|
115
|
+
>
|
|
116
|
+
<span class="tree-title">{{ getDisplayTitle(node) }}</span>
|
|
117
|
+
</span>
|
|
118
|
+
|
|
119
|
+
<button
|
|
120
|
+
v-if="node.relativePath"
|
|
121
|
+
class="vscode-article"
|
|
122
|
+
type="button"
|
|
123
|
+
title="在 VS Code 中打开笔记目录"
|
|
124
|
+
@click="onOpenVscode(node, $event)"
|
|
125
|
+
>
|
|
126
|
+
<img :src="icon__vscode" alt="打开笔记目录" />
|
|
127
|
+
</button>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<FolderTreeItems
|
|
131
|
+
v-if="hasChildren(node) && isExpanded(node)"
|
|
132
|
+
:nodes="node.children"
|
|
133
|
+
:depth="depth + 1"
|
|
134
|
+
:show-number="showNumber"
|
|
135
|
+
:expanded-keys="expandedKeys"
|
|
136
|
+
@toggle-node="emit('toggle-node', $event)"
|
|
137
|
+
@open-vscode="emit('open-vscode', $event)"
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
</template>
|
|
141
|
+
|
|
142
|
+
<script>
|
|
143
|
+
export default {
|
|
144
|
+
name: 'FolderTreeItems',
|
|
145
|
+
}
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<style scoped lang="scss">
|
|
149
|
+
.tree-node {
|
|
150
|
+
margin-bottom: 3px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.tree-row {
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
gap: 6px;
|
|
157
|
+
min-height: 48px;
|
|
158
|
+
padding: 3px 9px;
|
|
159
|
+
border-radius: 6px;
|
|
160
|
+
transition: background-color 0.2s;
|
|
161
|
+
|
|
162
|
+
&:hover {
|
|
163
|
+
background-color: var(--vp-c-default-soft);
|
|
164
|
+
|
|
165
|
+
.tree-link {
|
|
166
|
+
color: var(--vp-c-brand-1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.tree-arrow-btn {
|
|
172
|
+
display: inline-flex;
|
|
173
|
+
align-items: center;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
flex: 0 0 20px;
|
|
176
|
+
width: 20px;
|
|
177
|
+
height: 20px;
|
|
178
|
+
padding: 0;
|
|
179
|
+
border: none;
|
|
180
|
+
background: none;
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.tree-arrow-placeholder {
|
|
185
|
+
flex: 0 0 20px;
|
|
186
|
+
width: 20px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.tree-arrow {
|
|
190
|
+
display: inline-flex;
|
|
191
|
+
width: 14px;
|
|
192
|
+
height: 14px;
|
|
193
|
+
transition: transform 0.25s;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.tree-arrow:not(.collapsed) {
|
|
197
|
+
transform: rotate(90deg);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.tree-arrow img {
|
|
201
|
+
width: 14px;
|
|
202
|
+
height: 14px;
|
|
203
|
+
display: block;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.tree-link {
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
flex: 1;
|
|
210
|
+
min-width: 0;
|
|
211
|
+
color: var(--vp-c-text-2);
|
|
212
|
+
text-decoration: none;
|
|
213
|
+
font-size: 0.9rem;
|
|
214
|
+
overflow: hidden;
|
|
215
|
+
transition: color 0.2s;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.tree-link-leaf .tree-title {
|
|
219
|
+
font-weight: 400;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.tree-row-parent .tree-link {
|
|
223
|
+
font-weight: 600;
|
|
224
|
+
color: var(--vp-c-text-1);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.tree-link-folder {
|
|
228
|
+
cursor: default;
|
|
229
|
+
font-weight: 600;
|
|
230
|
+
color: var(--vp-c-text-1);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.tree-status {
|
|
234
|
+
flex-shrink: 0;
|
|
235
|
+
width: 1.4rem;
|
|
236
|
+
margin-right: 0.4rem;
|
|
237
|
+
text-align: center;
|
|
238
|
+
font-size: 0.85rem;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.tree-title {
|
|
242
|
+
overflow: hidden;
|
|
243
|
+
text-overflow: ellipsis;
|
|
244
|
+
white-space: nowrap;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.vscode-article {
|
|
248
|
+
background: none;
|
|
249
|
+
border: none;
|
|
250
|
+
padding: 0.3rem;
|
|
251
|
+
cursor: pointer;
|
|
252
|
+
border-radius: 4px;
|
|
253
|
+
flex-shrink: 0;
|
|
254
|
+
opacity: 0.5;
|
|
255
|
+
transition: opacity 0.2s ease;
|
|
256
|
+
|
|
257
|
+
&:hover {
|
|
258
|
+
opacity: 1;
|
|
259
|
+
background-color: var(--vp-c-bg-soft-down);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
img {
|
|
263
|
+
display: block;
|
|
264
|
+
height: 1rem;
|
|
265
|
+
width: 1rem;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
</style>
|