vitepress-plugin-code-collapse 0.3.0 → 0.4.0
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/dist/client/browser/index.d.ts +18 -0
- package/dist/client/browser/index.js +18 -0
- package/dist/client/ssr/index.d.ts +18 -0
- package/dist/client/ssr/index.js +18 -0
- package/dist/node/index.d.ts +29 -4
- package/dist/node/index.js +29 -4
- package/package.json +7 -3
|
@@ -26,6 +26,24 @@ declare function setupCollapsedLines({
|
|
|
26
26
|
}): void;
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/client/index.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Enhances the VitePress app with collapsed lines functionality.
|
|
31
|
+
*
|
|
32
|
+
* This function is automatically invoked by the `virtual:enhance-app` module
|
|
33
|
+
* when the plugin is registered. It sets up the click event listener that
|
|
34
|
+
* toggles the collapsed state of code blocks.
|
|
35
|
+
*
|
|
36
|
+
* 为 VitePress 应用增强折叠行功能。
|
|
37
|
+
*
|
|
38
|
+
* 此函数在插件注册时由 `virtual:enhance-app` 模块自动调用。
|
|
39
|
+
* 它设置点击事件监听器,用于切换代码块的折叠状态。
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Usually called automatically via `virtual:enhance-app`.
|
|
43
|
+
* // To invoke manually:
|
|
44
|
+
* import { enhanceAppWithCollapsedLines } from 'vitepress-plugin-code-collapse/client'
|
|
45
|
+
* enhanceAppWithCollapsedLines()
|
|
46
|
+
*/
|
|
29
47
|
declare function enhanceAppWithCollapsedLines(): void;
|
|
30
48
|
//#endregion
|
|
31
49
|
export { enhanceAppWithCollapsedLines, setupCollapsedLines };
|
|
@@ -35,6 +35,24 @@ function setupCollapsedLines({ selector = "div[class*=\"language-\"].has-collaps
|
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/client/index.ts
|
|
38
|
+
/**
|
|
39
|
+
* Enhances the VitePress app with collapsed lines functionality.
|
|
40
|
+
*
|
|
41
|
+
* This function is automatically invoked by the `virtual:enhance-app` module
|
|
42
|
+
* when the plugin is registered. It sets up the click event listener that
|
|
43
|
+
* toggles the collapsed state of code blocks.
|
|
44
|
+
*
|
|
45
|
+
* 为 VitePress 应用增强折叠行功能。
|
|
46
|
+
*
|
|
47
|
+
* 此函数在插件注册时由 `virtual:enhance-app` 模块自动调用。
|
|
48
|
+
* 它设置点击事件监听器,用于切换代码块的折叠状态。
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Usually called automatically via `virtual:enhance-app`.
|
|
52
|
+
* // To invoke manually:
|
|
53
|
+
* import { enhanceAppWithCollapsedLines } from 'vitepress-plugin-code-collapse/client'
|
|
54
|
+
* enhanceAppWithCollapsedLines()
|
|
55
|
+
*/
|
|
38
56
|
function enhanceAppWithCollapsedLines() {
|
|
39
57
|
setupCollapsedLines();
|
|
40
58
|
}
|
|
@@ -26,6 +26,24 @@ declare function setupCollapsedLines({
|
|
|
26
26
|
}): void;
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/client/index.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Enhances the VitePress app with collapsed lines functionality.
|
|
31
|
+
*
|
|
32
|
+
* This function is automatically invoked by the `virtual:enhance-app` module
|
|
33
|
+
* when the plugin is registered. It sets up the click event listener that
|
|
34
|
+
* toggles the collapsed state of code blocks.
|
|
35
|
+
*
|
|
36
|
+
* 为 VitePress 应用增强折叠行功能。
|
|
37
|
+
*
|
|
38
|
+
* 此函数在插件注册时由 `virtual:enhance-app` 模块自动调用。
|
|
39
|
+
* 它设置点击事件监听器,用于切换代码块的折叠状态。
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Usually called automatically via `virtual:enhance-app`.
|
|
43
|
+
* // To invoke manually:
|
|
44
|
+
* import { enhanceAppWithCollapsedLines } from 'vitepress-plugin-code-collapse/client'
|
|
45
|
+
* enhanceAppWithCollapsedLines()
|
|
46
|
+
*/
|
|
29
47
|
declare function enhanceAppWithCollapsedLines(): void;
|
|
30
48
|
//#endregion
|
|
31
49
|
export { enhanceAppWithCollapsedLines, setupCollapsedLines };
|
package/dist/client/ssr/index.js
CHANGED
|
@@ -34,6 +34,24 @@ function setupCollapsedLines({ selector = "div[class*=\"language-\"].has-collaps
|
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/client/index.ts
|
|
37
|
+
/**
|
|
38
|
+
* Enhances the VitePress app with collapsed lines functionality.
|
|
39
|
+
*
|
|
40
|
+
* This function is automatically invoked by the `virtual:enhance-app` module
|
|
41
|
+
* when the plugin is registered. It sets up the click event listener that
|
|
42
|
+
* toggles the collapsed state of code blocks.
|
|
43
|
+
*
|
|
44
|
+
* 为 VitePress 应用增强折叠行功能。
|
|
45
|
+
*
|
|
46
|
+
* 此函数在插件注册时由 `virtual:enhance-app` 模块自动调用。
|
|
47
|
+
* 它设置点击事件监听器,用于切换代码块的折叠状态。
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Usually called automatically via `virtual:enhance-app`.
|
|
51
|
+
* // To invoke manually:
|
|
52
|
+
* import { enhanceAppWithCollapsedLines } from 'vitepress-plugin-code-collapse/client'
|
|
53
|
+
* enhanceAppWithCollapsedLines()
|
|
54
|
+
*/
|
|
37
55
|
function enhanceAppWithCollapsedLines() {
|
|
38
56
|
setupCollapsedLines();
|
|
39
57
|
}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2,6 +2,19 @@ import { PluginWithOptions } from "markdown-it";
|
|
|
2
2
|
|
|
3
3
|
//#region src/node/plugin.d.ts
|
|
4
4
|
/**
|
|
5
|
+
* VitePress plugin for collapsing code blocks that exceed a specified line count.
|
|
6
|
+
*
|
|
7
|
+
* Integrates markdown-it rendering (to inject collapse markers and CSS variables)
|
|
8
|
+
* with client-side setup (to handle click interactions for expanding/collapsing).
|
|
9
|
+
* Code blocks can be configured globally via plugin options or individually via
|
|
10
|
+
* `:collapsed-lines` directives in the code fence info string.
|
|
11
|
+
*
|
|
12
|
+
* VitePress 插件,用于折叠超过指定行数的代码块。
|
|
13
|
+
*
|
|
14
|
+
* 将 markdown-it 渲染(注入折叠标记和 CSS 变量)与客户端设置(处理展开/折叠的
|
|
15
|
+
* 点击交互)集成在一起。代码块可通过插件选项全局配置,或通过代码围栏信息字符串
|
|
16
|
+
* 中的 `:collapsed-lines` 指令单独配置。
|
|
17
|
+
*
|
|
5
18
|
* @example
|
|
6
19
|
* ```ts
|
|
7
20
|
* import collapsedLines from 'vitepress-code-collapse'
|
|
@@ -37,13 +50,25 @@ type CollapsedLinesOptions = boolean | number | 'disable';
|
|
|
37
50
|
//#endregion
|
|
38
51
|
//#region src/node/markdown.d.ts
|
|
39
52
|
/**
|
|
40
|
-
*
|
|
53
|
+
* Adds collapsed lines functionality to code blocks in markdown-it.
|
|
41
54
|
*
|
|
42
|
-
*
|
|
55
|
+
* Wraps the default fence renderer to inject collapse markers and CSS variables
|
|
56
|
+
* when code blocks exceed a specified line count. The collapse behavior can be
|
|
57
|
+
* controlled globally via plugin options or per code block via `:collapsed-lines`
|
|
58
|
+
* directives in the code fence info string.
|
|
43
59
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
60
|
+
* 为 markdown-it 中的代码块添加折叠行功能。
|
|
61
|
+
*
|
|
62
|
+
* 包装默认的 fence 渲染器,当代码块超过指定行数时注入折叠标记和 CSS 变量。
|
|
63
|
+
* 折叠行为可通过插件选项全局控制,或通过代码围栏信息字符串中的
|
|
64
|
+
* `:collapsed-lines` 指令对单个代码块进行控制。
|
|
46
65
|
*
|
|
66
|
+
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
67
|
+
* @param options - Plugin options, can be:
|
|
68
|
+
* - `false`: Do not enable globally (default) / 不全局启用(默认)
|
|
69
|
+
* - `true`: Enable with default 15 lines / 启用,默认 15 行起折叠
|
|
70
|
+
* - `number`: Enable with custom starting line count / 启用,自定义起始折叠行数
|
|
71
|
+
* - `'disable'`: Completely disable the plugin / 完全禁用插件
|
|
47
72
|
* @example
|
|
48
73
|
* ```ts
|
|
49
74
|
* import { collapsedLinesMarkdownPlugin } from 'vitepress-code-collapse'
|
package/dist/node/index.js
CHANGED
|
@@ -51,13 +51,25 @@ function resolveCollapsedLines(info) {
|
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/node/markdown.ts
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Adds collapsed lines functionality to code blocks in markdown-it.
|
|
55
55
|
*
|
|
56
|
-
*
|
|
56
|
+
* Wraps the default fence renderer to inject collapse markers and CSS variables
|
|
57
|
+
* when code blocks exceed a specified line count. The collapse behavior can be
|
|
58
|
+
* controlled globally via plugin options or per code block via `:collapsed-lines`
|
|
59
|
+
* directives in the code fence info string.
|
|
57
60
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
61
|
+
* 为 markdown-it 中的代码块添加折叠行功能。
|
|
62
|
+
*
|
|
63
|
+
* 包装默认的 fence 渲染器,当代码块超过指定行数时注入折叠标记和 CSS 变量。
|
|
64
|
+
* 折叠行为可通过插件选项全局控制,或通过代码围栏信息字符串中的
|
|
65
|
+
* `:collapsed-lines` 指令对单个代码块进行控制。
|
|
60
66
|
*
|
|
67
|
+
* @param md - MarkdownIt instance / MarkdownIt 实例
|
|
68
|
+
* @param options - Plugin options, can be:
|
|
69
|
+
* - `false`: Do not enable globally (default) / 不全局启用(默认)
|
|
70
|
+
* - `true`: Enable with default 15 lines / 启用,默认 15 行起折叠
|
|
71
|
+
* - `number`: Enable with custom starting line count / 启用,自定义起始折叠行数
|
|
72
|
+
* - `'disable'`: Completely disable the plugin / 完全禁用插件
|
|
61
73
|
* @example
|
|
62
74
|
* ```ts
|
|
63
75
|
* import { collapsedLinesMarkdownPlugin } from 'vitepress-code-collapse'
|
|
@@ -95,6 +107,19 @@ const collapsedLinesMarkdownPlugin = (md, options = false) => {
|
|
|
95
107
|
//#endregion
|
|
96
108
|
//#region src/node/plugin.ts
|
|
97
109
|
/**
|
|
110
|
+
* VitePress plugin for collapsing code blocks that exceed a specified line count.
|
|
111
|
+
*
|
|
112
|
+
* Integrates markdown-it rendering (to inject collapse markers and CSS variables)
|
|
113
|
+
* with client-side setup (to handle click interactions for expanding/collapsing).
|
|
114
|
+
* Code blocks can be configured globally via plugin options or individually via
|
|
115
|
+
* `:collapsed-lines` directives in the code fence info string.
|
|
116
|
+
*
|
|
117
|
+
* VitePress 插件,用于折叠超过指定行数的代码块。
|
|
118
|
+
*
|
|
119
|
+
* 将 markdown-it 渲染(注入折叠标记和 CSS 变量)与客户端设置(处理展开/折叠的
|
|
120
|
+
* 点击交互)集成在一起。代码块可通过插件选项全局配置,或通过代码围栏信息字符串
|
|
121
|
+
* 中的 `:collapsed-lines` 指令单独配置。
|
|
122
|
+
*
|
|
98
123
|
* @example
|
|
99
124
|
* ```ts
|
|
100
125
|
* import collapsedLines from 'vitepress-code-collapse'
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-code-collapse",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "provide code block collapsed lines feature",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo/)",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://tuck.pengzhanbo.cn/plugins/code-collapse",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/pengzhanbo/vitepress-tuck.git",
|
|
11
12
|
"directory": "packages/plugin-code-collapse"
|
|
12
13
|
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/pengzhanbo/vitepress-tuck/issues"
|
|
16
|
+
},
|
|
13
17
|
"keywords": [
|
|
14
18
|
"vitepress",
|
|
15
19
|
"vitepress-plugin",
|
|
@@ -35,8 +39,8 @@
|
|
|
35
39
|
},
|
|
36
40
|
"dependencies": {
|
|
37
41
|
"@vueuse/core": "^14.3.0",
|
|
38
|
-
"vitepress-plugin-toolkit": "0.
|
|
39
|
-
"vitepress-tuck": "0.
|
|
42
|
+
"vitepress-plugin-toolkit": "0.4.0",
|
|
43
|
+
"vitepress-tuck": "0.4.0"
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
42
46
|
"access": "public",
|