vitepress-component-medium-zoom 1.0.1 → 1.1.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/README.md CHANGED
@@ -52,13 +52,23 @@ const { Layout } = DefaultTheme;
52
52
 
53
53
  <template>
54
54
  <Layout>...</Layout>
55
- <!-- Import here -->
55
+ <!-- Use here -->
56
56
  <MediumZoom />
57
57
  </template>
58
58
  ```
59
59
 
60
60
  **Note:** The component doesn't render any visible content, so you can place it anywhere in your layout. It will automatically handle image zooming for all images matching the selector.
61
61
 
62
+ ⚠️ **Important:** You need to add the following configuration to `.vitepress/config.ts`, otherwise the build will fail:
63
+
64
+ ```js
65
+ vite: {
66
+ ssr: {
67
+ noExternal: ['vitepress-component-medium-zoom'];
68
+ }
69
+ }
70
+ ```
71
+
62
72
  ## Props
63
73
 
64
74
  ### selector
@@ -74,6 +84,24 @@ Customize the image selector. This follows the [medium-zoom](https://github.com/
74
84
  <MediumZoom selector=".vp-doc img" />
75
85
  ```
76
86
 
87
+ If you want to exclude certain images from zooming, you can use a custom data attribute and exclude them from the selector.
88
+
89
+ ```vue
90
+ <MediumZoom selector=".vp-doc img:not([data-disable-zoom])" />
91
+ ```
92
+
93
+ **Example:**
94
+
95
+ ```md
96
+ ![foo](./assets/foo.png){data-disable-zoom}
97
+ ```
98
+
99
+ or
100
+
101
+ ```vue
102
+ <img src="image.png" data-disable-zoom />
103
+ ```
104
+
77
105
  ### options
78
106
 
79
107
  - **Type**: `ZoomOptions`
@@ -93,16 +121,17 @@ Configuration options for medium-zoom. See the [medium-zoom documentation](https
93
121
  />
94
122
  ```
95
123
 
96
- If you want to exclude certain images from zooming, you can use a custom data attribute and exclude them from the selector.
124
+ ### zIndex
97
125
 
98
- ```vue
99
- <MediumZoom selector=".vp-doc img:not([data-disable-zoom])" />
100
- ```
126
+ - **Type**: `number`
127
+ - **Default**: `999`
128
+
129
+ Customize the z-index value for the overlay and zoomed image.
101
130
 
102
131
  **Example:**
103
132
 
104
133
  ```vue
105
- <img src="image.png" data-disable-zoom />
134
+ <MediumZoom :z-index="2000" />
106
135
  ```
107
136
 
108
137
  ## How It Works
package/README.zh-CN.md CHANGED
@@ -21,7 +21,7 @@ pnpm add vitepress-component-medium-zoom
21
21
  yarn add vitepress-component-medium-zoom
22
22
  ```
23
23
 
24
- ## 使用方法
24
+ ## 使用
25
25
 
26
26
  参考 [VitePress Layout Slots](https://vitepress.dev/guide/extending-default-theme#layout-slots),在布局中直接引入组件。
27
27
 
@@ -52,13 +52,23 @@ const { Layout } = DefaultTheme;
52
52
 
53
53
  <template>
54
54
  <Layout>...</Layout>
55
- <!-- 在这里引入 -->
55
+ <!-- 在这里使用 -->
56
56
  <MediumZoom />
57
57
  </template>
58
58
  ```
59
59
 
60
60
  **注意:** 该组件不会渲染任何可见内容,因此可以将其放置在布局的任何位置。它会自动处理所有匹配选择器的图片缩放功能。
61
61
 
62
+ ⚠️ **重要:** 需要把下面这个配置添加到 `.vitepress/config.ts` 中,否则构建会报错:
63
+
64
+ ```js
65
+ vite: {
66
+ ssr: {
67
+ noExternal: ['vitepress-component-medium-zoom'];
68
+ }
69
+ }
70
+ ```
71
+
62
72
  ## Props
63
73
 
64
74
  ### selector
@@ -74,6 +84,24 @@ const { Layout } = DefaultTheme;
74
84
  <MediumZoom selector=".vp-doc img" />
75
85
  ```
76
86
 
87
+ 如果某些图像不要 zoom,可以自定义一个 data 值,然后从 selector 中排除掉。
88
+
89
+ ```vue
90
+ <MediumZoom selector=".vp-doc img:not([data-disable-zoom])" />
91
+ ```
92
+
93
+ **示例:**
94
+
95
+ ```md
96
+ ![foo](./assets/foo.png){data-disable-zoom}
97
+ ```
98
+
99
+
100
+
101
+ ```vue
102
+ <img src="image.png" data-disable-zoom />
103
+ ```
104
+
77
105
  ### options
78
106
 
79
107
  - **类型**: `ZoomOptions`
@@ -93,16 +121,17 @@ medium-zoom 的配置选项。查看 [medium-zoom 文档](https://github.com/fra
93
121
  />
94
122
  ```
95
123
 
96
- 如果某些图像不要 zoom,可以自定义一个 data 值,然后从 selector 中排除掉。
124
+ ### zIndex
97
125
 
98
- ```vue
99
- <MediumZoom selector=".vp-doc img:not([data-disable-zoom])" />
100
- ```
126
+ - **类型**: `number`
127
+ - **默认值**: `999`
128
+
129
+ 自定义遮罩层和放大图片的 z-index 值。
101
130
 
102
131
  **示例:**
103
132
 
104
133
  ```vue
105
- <img src="image.png" data-disable-zoom />
134
+ <MediumZoom :z-index="2000" />
106
135
  ```
107
136
 
108
137
  ## 工作原理
package/dist/index.css CHANGED
@@ -2,6 +2,6 @@
2
2
  /* https://github.com/francoischalifour/medium-zoom#debugging */
3
3
  .medium-zoom-overlay,
4
4
  .medium-zoom-image--opened {
5
- z-index: 999;
5
+ z-index: var(--7055c699-zIndex);
6
6
  }
7
7
 
package/dist/index.d.ts CHANGED
@@ -5,10 +5,12 @@ import { ZoomOptions, ZoomSelector } from "medium-zoom";
5
5
  type __VLS_Props = {
6
6
  selector?: ZoomSelector;
7
7
  options?: ZoomOptions;
8
+ zIndex?: number;
8
9
  };
9
10
  declare const __VLS_export: vue0.DefineComponent<__VLS_Props, {}, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
11
  selector: ZoomSelector;
11
12
  options: ZoomOptions;
13
+ zIndex: number;
12
14
  }, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
13
15
  declare const _default: typeof __VLS_export;
14
16
  //#endregion
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{defineComponent as e,nextTick as t,onBeforeUnmount as n,onMounted as r}from"vue";import{useRouter as i}from"vitepress";import a from"medium-zoom";var o=e({__name:`MediumZoom`,props:{selector:{type:null,required:!1,default:`.vp-doc img`},options:{type:Object,required:!1,default:()=>({})}},setup(e){let o=e,s,c,l=i();l.onAfterRouteChange=u,r(u),n(()=>{clearTimeout(c),s&&(s.detach(),s.close())});function u(){t(()=>{s&&=(s.detach(),s.close(),void 0),clearTimeout(c),c=setTimeout(()=>{s=a(o.selector,{background:`var(--vp-c-bg)`,...o.options})},100)})}return()=>{}}});export{o as MediumZoom};
1
+ import{defineComponent as e,nextTick as t,onBeforeUnmount as n,onMounted as r,useCssVars as i}from"vue";import{useRouter as a}from"vitepress";import o from"medium-zoom";var s=e({__name:`MediumZoom`,props:{selector:{type:null,required:!1,default:`.vp-doc img`},options:{type:Object,required:!1,default:()=>({})},zIndex:{type:Number,required:!1,default:999}},setup(e){i(e=>({"7055c699-zIndex":e.zIndex}));let s=e,c,l,u=a();u.onAfterRouteChange=d,r(d),n(()=>{clearTimeout(l),c&&(c.detach(),c.close())});function d(){t(()=>{c&&=(c.detach(),c.close(),void 0),clearTimeout(l),l=setTimeout(()=>{c=o(s.selector,{background:`var(--vp-c-bg)`,...s.options})},100)})}return()=>{}}});export{s as MediumZoom};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitepress-component-medium-zoom",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "VitePress image preview component with medium-zoom support",
5
5
  "keywords": [
6
6
  "vitepress",