@rspress/plugin-medium-zoom 0.0.0-next-20230815052558

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Rspress
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ <p align="center">
2
+ <a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
3
+ </p>
4
+
5
+ <h1 align="center">Modern.js Doc</h1>
6
+
7
+ <p align="center">
8
+ The Documentation Framework of Modern.js.
9
+ </p>
10
+
11
+ ## Getting Started
12
+
13
+ Please follow [Quick Start](https://modernjs.dev/doc-tools/guide/getting-started.html) to get started with Modern.js Doc.
14
+
15
+ ## Documentation
16
+
17
+ - [English Documentation](https://modernjs.dev/doc-tools/)
18
+ - [中文文档](https://modernjs.dev/doc-tools/zh/)
19
+
20
+ ## Contributing
21
+
22
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
23
+
24
+ ## License
25
+
26
+ Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
@@ -0,0 +1,8 @@
1
+ import { RspressPlugin } from '@rspress/shared';
2
+
3
+ /**
4
+ * The plugin is used to add medium-zoom to the doc site.
5
+ */
6
+ declare function pluginMediumZoom(): RspressPlugin;
7
+
8
+ export { pluginMediumZoom };
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ // src/index.ts
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ function pluginMediumZoom() {
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url)).replace(/\\/g, "/");
6
+ return {
7
+ name: "@rspress/plugin-medium-zoom",
8
+ globalUIComponents: [
9
+ path.posix.join(__dirname, "../src/components/MediumZoom.tsx")
10
+ ]
11
+ };
12
+ }
13
+ export {
14
+ pluginMediumZoom
15
+ };
16
+
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"mappings":";AAAA,OAAOA,UAAU;AACjB,SAASC,qBAAqB;AAMvB,SAASC;AACd,QAAMC,YAAYH,KACfI,QAAQH,cAAc,YAAYI,GAAG,GAErCC,QAAQ,OAAO;AAClB,SAAO;IACLC,MAAM;IACNC,oBAAoB;MAClBR,KAAKS,MAAMC,KAAKP,WAAW;;EAE/B;AACF;","names":["path","fileURLToPath","pluginMediumZoom","__dirname","dirname","url","replace","name","globalUIComponents","posix","join"],"sources":["../src/home/runner/work/rspress/rspress/packages/plugin-medium-zoom/src/index.ts"],"sourcesContent":["import path from 'path';\nimport { fileURLToPath } from 'url';\nimport type { RspressPlugin } from '@rspress/shared';\n\n/**\n * The plugin is used to add medium-zoom to the doc site.\n */\nexport function pluginMediumZoom(): RspressPlugin {\n const __dirname = path\n .dirname(fileURLToPath(import.meta.url))\n // Fix: adapt windows\n .replace(/\\\\/g, '/');\n return {\n name: '@rspress/plugin-medium-zoom',\n globalUIComponents: [\n path.posix.join(__dirname, '../src/components/MediumZoom.tsx'),\n ],\n };\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@rspress/plugin-medium-zoom",
3
+ "version": "0.0.0-next-20230815052558",
4
+ "description": "A plugin for rspress to zoom images in docs.",
5
+ "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/web-infra-dev/rspress",
9
+ "directory": "packages/plugin-medium-zoom"
10
+ },
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "jsnext:source": "./src/index.ts",
14
+ "types": "./dist/index.d.ts",
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/node/index.js",
17
+ "engines": {
18
+ "node": ">=14.17.6"
19
+ },
20
+ "eslintIgnore": [
21
+ "node_modules/",
22
+ "dist/"
23
+ ],
24
+ "devDependencies": {
25
+ "@modern-js/tsconfig": "2.30.0",
26
+ "@types/node": "^18.11.17",
27
+ "@types/react": "^18",
28
+ "@types/react-dom": "^18",
29
+ "typescript": "^5",
30
+ "vitest": "0.33.0",
31
+ "react": "^17",
32
+ "@rspress/shared": "0.0.0-next-20230815052558"
33
+ },
34
+ "peerDependencies": {
35
+ "rspress": "0.0.0-next-20230815052558"
36
+ },
37
+ "sideEffects": [
38
+ "*.css",
39
+ "*.less",
40
+ "*.sass",
41
+ "*.scss"
42
+ ],
43
+ "files": [
44
+ "dist",
45
+ "src"
46
+ ],
47
+ "publishConfig": {
48
+ "access": "public",
49
+ "provenance": true,
50
+ "registry": "https://registry.npmjs.org/"
51
+ },
52
+ "dependencies": {
53
+ "medium-zoom": "1.0.8"
54
+ },
55
+ "scripts": {
56
+ "dev": "modern dev",
57
+ "build": "modern build",
58
+ "reset": "rimraf ./**/node_modules",
59
+ "lint": "modern lint",
60
+ "change": "modern change",
61
+ "bump": "modern bump",
62
+ "pre": "modern pre",
63
+ "change-status": "modern change-status",
64
+ "gen-release-note": "modern gen-release-note",
65
+ "release": "modern release",
66
+ "new": "modern new",
67
+ "test": "vitest run --passWithNoTests",
68
+ "upgrade": "modern upgrade"
69
+ }
70
+ }
@@ -0,0 +1,10 @@
1
+ // eslint-disable-next-line import/no-commonjs
2
+ module.exports = {
3
+ root: true,
4
+ extends: ['@modern-js-app'],
5
+ ignorePatterns: ['components/MediumZoom.tsx'],
6
+ parserOptions: {
7
+ tsconfigRootDir: __dirname,
8
+ project: ['../tsconfig.json'],
9
+ },
10
+ };
@@ -0,0 +1,5 @@
1
+ /* https://github.com/francoischalifour/medium-zoom#debugging */
2
+ .medium-zoom-overlay,
3
+ .medium-zoom-image--opened {
4
+ z-index: 999;
5
+ }
@@ -0,0 +1,19 @@
1
+ import { useLocation } from 'rspress/runtime';
2
+ import mediumZoom from 'medium-zoom';
3
+ import { useEffect } from 'react';
4
+ import './MediumZoom.css';
5
+
6
+ interface Props {
7
+ selector?: string;
8
+ }
9
+
10
+ export default function MediumZoom(props: Props) {
11
+ const { pathname } = useLocation();
12
+ const { selector = '.modern-doc img' } = props;
13
+
14
+ useEffect(() => {
15
+ const images = document.querySelectorAll(selector);
16
+ mediumZoom(images);
17
+ }, [pathname]);
18
+ return null;
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import type { RspressPlugin } from '@rspress/shared';
4
+
5
+ /**
6
+ * The plugin is used to add medium-zoom to the doc site.
7
+ */
8
+ export function pluginMediumZoom(): RspressPlugin {
9
+ const __dirname = path
10
+ .dirname(fileURLToPath(import.meta.url))
11
+ // Fix: adapt windows
12
+ .replace(/\\/g, '/');
13
+ return {
14
+ name: '@rspress/plugin-medium-zoom',
15
+ globalUIComponents: [
16
+ path.posix.join(__dirname, '../src/components/MediumZoom.tsx'),
17
+ ],
18
+ };
19
+ }
@@ -0,0 +1,2 @@
1
+ /// <reference types='@modern-js/module-tools/types' />
2
+ /// <reference types='@modern-js/plugin-testing/types' />