From 10708c97b4143bce6ab6ef3ed65b09d00c4a3513 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Tue, 29 Apr 2025 20:24:57 +0800 Subject: [PATCH] feat(plugin-md-power): add diff syntax in file-tree container, close #577 (#578) * feat(plugin-md-power): add diff syntax in file-tree container, close #577 * chore: tweak --- docs/notes/theme/guide/markdown/file-tree.md | 12 ++-- .../__snapshots__/fileTreePlugin.spec.ts.snap | 70 +++++++++++-------- .../__test__/fileTreePlugin.spec.ts | 8 +++ .../src/client/components/FileTreeNode.vue | 45 ++++++++---- .../src/node/container/fileTree.ts | 30 ++++++-- 5 files changed, 114 insertions(+), 51 deletions(-) diff --git a/docs/notes/theme/guide/markdown/file-tree.md b/docs/notes/theme/guide/markdown/file-tree.md index 142bbae9..59241d38 100644 --- a/docs/notes/theme/guide/markdown/file-tree.md +++ b/docs/notes/theme/guide/markdown/file-tree.md @@ -18,18 +18,20 @@ permalink: /guide/markdown/file-tree/ - 通过加粗文件名或目录名来突出显示,例如 `**README.md**` - 通过在名称后添加更多文本来为文件或目录添加注释 +- 通过在名称前添加 `++` 或 `--` 来标记文件或目录为 **新增** 或 **删除** - 使用 `...` 或 `…` 作为名称来添加占位符文件和目录。 - 在 `:::file-tree` 后添加 `icon="simple"` 或 添加 `icon="colored"` 可以切换为简单图标或彩色图标,默认为彩色图标。 +- 在 `:::file-tree` 后添加 `title="xxxx"` 可以为文件树添加标题。 **输入:** -```md +```md /++/ /--/ ::: file-tree - docs - .vuepress - - config.ts - - page1.md + - ++ config.ts + - -- page1.md - README.md - theme 一个 **主题** 目录 - client @@ -55,8 +57,8 @@ permalink: /guide/markdown/file-tree/ - docs - .vuepress - - config.ts - - page1.md + - ++ config.ts + - -- page1.md - README.md - theme 一个 **主题** 目录 - client diff --git a/plugins/plugin-md-power/__test__/__snapshots__/fileTreePlugin.spec.ts.snap b/plugins/plugin-md-power/__test__/__snapshots__/fileTreePlugin.spec.ts.snap index 272b81d5..fe41c4d8 100644 --- a/plugins/plugin-md-power/__test__/__snapshots__/fileTreePlugin.spec.ts.snap +++ b/plugins/plugin-md-power/__test__/__snapshots__/fileTreePlugin.spec.ts.snap @@ -71,79 +71,93 @@ exports[`fileTree > parseFileTreeRawContent > should work 1`] = ` `; exports[`fileTreePlugin > should work with default options 1`] = ` -"
- +"
+ - + - - - - + + + + - + - - + + - + - +
-

files

- - +

files

+ + - - + + - - + + - +
-
+
- - + + - + - +
-
+
- - + +
+
+ + + + + + + + + + + + +
" `; diff --git a/plugins/plugin-md-power/__test__/fileTreePlugin.spec.ts b/plugins/plugin-md-power/__test__/fileTreePlugin.spec.ts index 9084c4dc..41ab21b8 100644 --- a/plugins/plugin-md-power/__test__/fileTreePlugin.spec.ts +++ b/plugins/plugin-md-power/__test__/fileTreePlugin.spec.ts @@ -99,6 +99,14 @@ describe('fileTreePlugin', () => { - ::: +::: file-tree +- docs + - ++ added.md + - -- remove.md +- ++ src +- -- source +::: + ::: file-tree ::: ` diff --git a/plugins/plugin-md-power/src/client/components/FileTreeNode.vue b/plugins/plugin-md-power/src/client/components/FileTreeNode.vue index a82f040b..331d708d 100644 --- a/plugins/plugin-md-power/src/client/components/FileTreeNode.vue +++ b/plugins/plugin-md-power/src/client/components/FileTreeNode.vue @@ -1,13 +1,12 @@