@r74tech/docusaurus-plugin-panzoom 2.1.0 → 2.3.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/.prettierrc ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "semi": true,
3
+ "tabWidth": 2,
4
+ "printWidth": 120,
5
+ "singleQuote": true,
6
+ "trailingComma": "all",
7
+ "jsxSingleQuote": true,
8
+ "bracketSpacing": true,
9
+ "bracketSameLine": false,
10
+ "endOfLine": "lf",
11
+ "proseWrap": "always"
12
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [2.3.0](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.2.0...v2.3.0) (2025-07-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * add toolbar to control zooming (zoom in, zoom out, reset) ([a170e52](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/a170e5253e2bf5b1ddb12bf7b0e648722b053bcb))
7
+ * merge all toolbar props into a single object ([0c32e6c](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/0c32e6c361563ad81517818c99693a9de717f33f))
8
+
9
+ # [2.2.0](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.1.0...v2.2.0) (2025-07-12)
10
+
11
+
12
+ ### Features
13
+
14
+ * add Prettier and ESLint to documentation website ([33dd381](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/33dd381ae478260cade8f15e8c69670c75628905))
15
+
1
16
  # [2.1.0](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.0.0...v2.1.0) (2025-04-14)
2
17
 
3
18
 
package/dist/PanZoom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { ClientModule } from '@docusaurus/types';
2
+ import './styles/panzoom.css';
2
3
  /**
3
4
  * Client module implementation. Wait a bit before trying this, some components like mermaid take a second to process / render
4
5
  */
package/dist/PanZoom.js CHANGED
@@ -4,10 +4,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const panzoom_1 = __importDefault(require("@panzoom/panzoom"));
7
+ const PanzoomPluginOptions_1 = require("./PanzoomPluginOptions");
8
+ const zoom_in_1 = __importDefault(require("./img/zoom-in"));
9
+ const zoom_out_1 = __importDefault(require("./img/zoom-out"));
10
+ const zoom_reset_1 = __importDefault(require("./img/zoom-reset"));
11
+ require("./styles/panzoom.css");
7
12
  const config = require('@generated/docusaurus.config').default;
8
13
  const { themeConfig } = config;
9
14
  const { zoom } = themeConfig;
10
- const { selectors = ['div.mermaid[data-processed="true"]', 'div.docusaurus-mermaid-container', '.drawio'], wrap = true, timeout = 1000, excludeClass = 'panzoom-exclude', ...panZoomConfig } = zoom;
15
+ const { selectors = ['div.mermaid[data-processed="true"]', 'div.docusaurus-mermaid-container', '.drawio'], wrap = true, timeout = 1000, excludeClass = 'panzoom-exclude', toolbar: { enabled = false, position = PanzoomPluginOptions_1.PanZoomPluginToolbarPosition.TopRight, opacity = 0 } = {}, ...panZoomConfig } = zoom;
16
+ /**
17
+ * Creates a toolbar with zoom controls for a panzoom instance
18
+ * @param container The container element to append the toolbar to
19
+ * @param instance The panzoom instance to control
20
+ * @param position The position of the toolbar
21
+ */
22
+ const createToolbar = (container, instance, position) => {
23
+ const toolbar = document.createElement('div');
24
+ toolbar.className = `panzoom-toolbar panzoom-toolbar-${position} ${excludeClass}`;
25
+ // Apply custom opacity from configuration
26
+ toolbar.style.opacity = opacity.toString();
27
+ // Prevent double-click events from bubbling up to the container
28
+ // By default the panzoom library will reset on double click
29
+ toolbar.addEventListener('dblclick', (e) => {
30
+ e.stopPropagation();
31
+ });
32
+ // Helper function to create toolbar buttons
33
+ const createButton = (svg, title, action) => {
34
+ const button = document.createElement('button');
35
+ button.innerHTML = svg;
36
+ button.title = title;
37
+ button.className = excludeClass;
38
+ button.addEventListener('click', (e) => {
39
+ e.preventDefault();
40
+ e.stopPropagation();
41
+ action();
42
+ });
43
+ return button;
44
+ };
45
+ // Create and append all buttons
46
+ const buttons = [
47
+ createButton(zoom_in_1.default, 'Zoom in', () => instance.zoomIn()),
48
+ createButton(zoom_out_1.default, 'Zoom out', () => instance.zoomOut()),
49
+ createButton(zoom_reset_1.default, 'Reset zoom', () => instance.reset()),
50
+ ];
51
+ buttons.forEach((button) => toolbar.appendChild(button));
52
+ container.appendChild(toolbar);
53
+ };
11
54
  /**
12
55
  * Main work method to zoom the set of elements. You can pass in global options to the pan zoom component
13
56
  * as well as control whether the items will be wrapped.
@@ -20,25 +63,33 @@ const zoomElements = (selectors) => {
20
63
  });
21
64
  foundElements.forEach((element) => {
22
65
  const instance = (0, panzoom_1.default)(element, { excludeClass, ...panZoomConfig });
66
+ let container;
23
67
  if (wrap) {
24
68
  const wrapper = document.createElement('div');
25
- wrapper.setAttribute('style', "overflow: hidden");
69
+ wrapper.setAttribute('style', 'overflow: hidden; position: relative;');
26
70
  element.parentElement?.insertBefore(wrapper, element);
27
71
  wrapper.appendChild(element);
28
72
  wrapper.addEventListener('wheel', (event) => {
29
73
  instance.zoomWithWheel(event);
30
74
  });
31
- wrapper.addEventListener('dblclick', (event) => {
75
+ wrapper.addEventListener('dblclick', () => {
32
76
  instance.reset();
33
77
  });
78
+ container = wrapper;
34
79
  }
35
- if (!wrap) {
80
+ else {
81
+ element.style.position = 'relative';
36
82
  element.addEventListener('wheel', (event) => {
37
83
  instance.zoomWithWheel(event);
38
84
  });
39
- element.addEventListener('dblclick', (event) => {
85
+ element.addEventListener('dblclick', () => {
40
86
  instance.reset();
41
87
  });
88
+ container = element;
89
+ }
90
+ // Add toolbar if enabled
91
+ if (enabled) {
92
+ createToolbar(container, instance, position);
42
93
  }
43
94
  });
44
95
  };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatedThemeConfig = exports.PanZoomPlugin = void 0;
4
4
  const utils_validation_1 = require("@docusaurus/utils-validation");
5
+ const PanzoomPluginOptions_1 = require("./PanzoomPluginOptions");
5
6
  const path_1 = require("path");
6
7
  /**
7
8
  * Main module for the PanZoom plugin
@@ -11,15 +12,15 @@ const path_1 = require("path");
11
12
  */
12
13
  const PanZoomPlugin = (context, options) => {
13
14
  return {
14
- name: "docusaurus-plugin-panzoom",
15
+ name: 'docusaurus-plugin-panzoom',
15
16
  getClientModules() {
16
- return [
17
- (0, path_1.resolve)(__dirname, "./PanZoom")
18
- ];
19
- }
17
+ return [(0, path_1.resolve)(__dirname, './PanZoom'), (0, path_1.resolve)(__dirname, './styles/panzoom.css')];
18
+ },
20
19
  };
21
20
  };
22
21
  exports.PanZoomPlugin = PanZoomPlugin;
22
+ // Extract the valid toolbar position values from the enum
23
+ const validToolbarPositions = Object.values(PanzoomPluginOptions_1.PanZoomPluginToolbarPosition);
23
24
  /**
24
25
  * Theme validation rules for this plugin
25
26
  */
@@ -29,7 +30,12 @@ const panZoomValidator = utils_validation_1.Joi.object({
29
30
  wrap: utils_validation_1.Joi.boolean(),
30
31
  timeout: utils_validation_1.Joi.number(),
31
32
  excludeClass: utils_validation_1.Joi.string(),
32
- })
33
+ toolbar: utils_validation_1.Joi.object({
34
+ enabled: utils_validation_1.Joi.boolean(),
35
+ position: utils_validation_1.Joi.string().valid(...validToolbarPositions),
36
+ opacity: utils_validation_1.Joi.number().min(0).max(1),
37
+ }),
38
+ }),
33
39
  });
34
40
  /**
35
41
  * Add a validation for the theme configuration
@@ -1,4 +1,10 @@
1
1
  import type { PanzoomOptions } from '@panzoom/panzoom';
2
+ export declare enum PanZoomPluginToolbarPosition {
3
+ TopRight = "top-right",
4
+ TopLeft = "top-left",
5
+ BottomRight = "bottom-right",
6
+ BottomLeft = "bottom-left"
7
+ }
2
8
  export type PanZoomPluginOptions = PanzoomOptions & {
3
9
  /**
4
10
  * A list of selectors to look for elements to enable pan and zoom
@@ -28,4 +34,29 @@ export type PanZoomPluginOptions = PanzoomOptions & {
28
34
  * default: 'panzoom-exclude'
29
35
  */
30
36
  excludeClass?: string;
37
+ /**
38
+ * Toolbar options for the Panzoom plugin.
39
+ */
40
+ toolbar?: {
41
+ /**
42
+ * Whether to enable and show a control toolbar with buttons for zoom in, zoom out, and reset.
43
+ *
44
+ * default: false
45
+ */
46
+ enabled?: boolean;
47
+ /**
48
+ * The toolbar position (top-right, top-left, bottom-right, bottom-left)
49
+ *
50
+ * default: 'top-right'
51
+ */
52
+ position?: PanZoomPluginToolbarPosition;
53
+ /**
54
+ * The toolbar opacity when not hovered (value between 0 and 1)
55
+ * The toolbar will become fully opaque (opacity: 1) when hovered.
56
+ *
57
+ * example: 0.5
58
+ * default: 0
59
+ */
60
+ opacity?: number;
61
+ };
31
62
  };
@@ -1,2 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PanZoomPluginToolbarPosition = void 0;
4
+ var PanZoomPluginToolbarPosition;
5
+ (function (PanZoomPluginToolbarPosition) {
6
+ PanZoomPluginToolbarPosition["TopRight"] = "top-right";
7
+ PanZoomPluginToolbarPosition["TopLeft"] = "top-left";
8
+ PanZoomPluginToolbarPosition["BottomRight"] = "bottom-right";
9
+ PanZoomPluginToolbarPosition["BottomLeft"] = "bottom-left";
10
+ })(PanZoomPluginToolbarPosition = exports.PanZoomPluginToolbarPosition || (exports.PanZoomPluginToolbarPosition = {}));
@@ -0,0 +1,2 @@
1
+ declare const _default: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#000\"><path d=\"M450-450H220v-60h230v-230h60v230h230v60H510v230h-60v-230Z\"/></svg>";
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000"><path d="M450-450H220v-60h230v-230h60v230h230v60H510v230h-60v-230Z"/></svg>';
@@ -0,0 +1,2 @@
1
+ declare const _default: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#000\"><path d=\"M220-450v-60h520v60H220Z\"/></svg>";
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000"><path d="M220-450v-60h520v60H220Z"/></svg>';
@@ -0,0 +1,2 @@
1
+ declare const _default: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#000\"><path d=\"M480-333.85v-91.92q0-22.6 15.82-38.41Q511.63-480 534.23-480h91.92v47.69h-98.46v98.46H480ZM534.23-100q-22.6 0-38.41-15.82Q480-131.64 480-154.23v-91.92h47.69v98.46h98.46V-100h-91.92Zm278.08-233.85v-98.46h-98.46V-480h91.92q22.59 0 38.41 15.82Q860-448.37 860-425.77v91.92h-47.69ZM713.85-100v-47.69h98.46v-98.46H860v91.92q0 22.59-15.82 38.41Q828.36-100 805.77-100h-91.92Zm94.07-467.69h-62.23q-27.54-84.54-99.57-138.43Q574.08-760 480-760q-117 0-198.5 81.5T200-480q0 78.15 38.46 141.81 38.46 63.65 101.54 99.34V-360h60v220H180v-60h113.23q-69.3-45-111.27-118.27Q140-391.54 140-480q0-70.8 26.77-132.63t72.77-107.83q46-46 107.83-72.77Q409.2-820 480-820q118.61 0 208.81 71.42Q779-677.15 807.92-567.69Z\"/></svg>";
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000"><path d="M480-333.85v-91.92q0-22.6 15.82-38.41Q511.63-480 534.23-480h91.92v47.69h-98.46v98.46H480ZM534.23-100q-22.6 0-38.41-15.82Q480-131.64 480-154.23v-91.92h47.69v98.46h98.46V-100h-91.92Zm278.08-233.85v-98.46h-98.46V-480h91.92q22.59 0 38.41 15.82Q860-448.37 860-425.77v91.92h-47.69ZM713.85-100v-47.69h98.46v-98.46H860v91.92q0 22.59-15.82 38.41Q828.36-100 805.77-100h-91.92Zm94.07-467.69h-62.23q-27.54-84.54-99.57-138.43Q574.08-760 480-760q-117 0-198.5 81.5T200-480q0 78.15 38.46 141.81 38.46 63.65 101.54 99.34V-360h60v220H180v-60h113.23q-69.3-45-111.27-118.27Q140-391.54 140-480q0-70.8 26.77-132.63t72.77-107.83q46-46 107.83-72.77Q409.2-820 480-820q118.61 0 208.81 71.42Q779-677.15 807.92-567.69Z"/></svg>';
@@ -0,0 +1,48 @@
1
+ .panzoom-toolbar {
2
+ position: absolute;
3
+ z-index: 10;
4
+ display: flex;
5
+ gap: 5px;
6
+ padding: 5px;
7
+ background: rgba(255, 255, 255, 0.5);
8
+ border-radius: 4px;
9
+ transition: opacity 0.2s ease-in-out;
10
+ }
11
+
12
+ *:hover > .panzoom-toolbar {
13
+ opacity: 1 !important;
14
+ }
15
+
16
+ .panzoom-toolbar-top-right {
17
+ top: 10px;
18
+ right: 10px;
19
+ }
20
+
21
+ .panzoom-toolbar-top-left {
22
+ top: 10px;
23
+ left: 10px;
24
+ }
25
+
26
+ .panzoom-toolbar-bottom-right {
27
+ bottom: 10px;
28
+ right: 10px;
29
+ }
30
+
31
+ .panzoom-toolbar-bottom-left {
32
+ bottom: 10px;
33
+ left: 10px;
34
+ }
35
+
36
+ .panzoom-toolbar button {
37
+ width: 30px;
38
+ height: 30px;
39
+ cursor: pointer;
40
+ border: 1px solid #ddd;
41
+ border-radius: 3px;
42
+ background-color: #fff;
43
+ padding: 0;
44
+ margin: 0;
45
+ display: flex;
46
+ justify-content: center;
47
+ align-items: center;
48
+ }
@@ -0,0 +1,32 @@
1
+ import js from '@eslint/js';
2
+ import tsParser from '@typescript-eslint/parser';
3
+ import tseslint from '@typescript-eslint/eslint-plugin';
4
+ import globals from 'globals';
5
+ import prettierPlugin from 'eslint-plugin-prettier';
6
+
7
+ export default [
8
+ {
9
+ files: ['src/**/*.{ts,css}'],
10
+ ignores: ['**/dist/**', '**/node_modules/**'],
11
+ languageOptions: {
12
+ ecmaVersion: 2020,
13
+ sourceType: 'module',
14
+ globals: {
15
+ ...globals.node,
16
+ ...globals.browser,
17
+ },
18
+ parser: tsParser,
19
+ },
20
+ plugins: {
21
+ '@typescript-eslint': tseslint,
22
+ prettier: prettierPlugin,
23
+ },
24
+ rules: {
25
+ ...js.configs.recommended.rules,
26
+ ...tseslint.configs.recommended.rules,
27
+ 'prettier/prettier': 'error',
28
+ '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
29
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
30
+ },
31
+ },
32
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r74tech/docusaurus-plugin-panzoom",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "A plugin to enable the panzoom component on SVG and other elements",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,8 +15,12 @@
15
15
  "author": "r74tech",
16
16
  "license": "MIT",
17
17
  "scripts": {
18
- "build": "tsc",
19
- "prepublishOnly": "npm run build"
18
+ "build": "tsc && npm run copy-assets",
19
+ "copy-assets": "mkdir -p dist/styles && cp -r src/styles/* dist/styles/",
20
+ "prepublishOnly": "npm run build",
21
+ "lint": "eslint 'src/**/*.{ts,css}' --report-unused-disable-directives --max-warnings 0",
22
+ "lint:fix": "eslint --fix 'src/**/*.{ts,css}'",
23
+ "format": "prettier --write --no-error-on-unmatched-pattern 'src/**/*.{ts,css}' --config ./.prettierrc"
20
24
  },
21
25
  "dependencies": {
22
26
  "@docusaurus/utils-validation": "^3.7.0",
@@ -24,6 +28,8 @@
24
28
  },
25
29
  "devDependencies": {
26
30
  "@docusaurus/types": "^3.7.0",
31
+ "@eslint/compat": "^1.2.3",
32
+ "@eslint/js": "^9.14.0",
27
33
  "@semantic-release/changelog": "^6.0.3",
28
34
  "@semantic-release/commit-analyzer": "^9.0.2",
29
35
  "@semantic-release/git": "^10.0.1",
@@ -32,10 +38,19 @@
32
38
  "@semantic-release/release-notes-generator": "^10.0.3",
33
39
  "@tsconfig/docusaurus": "^1.0.7",
34
40
  "@types/node": "^22.14.0",
41
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
42
+ "@typescript-eslint/parser": "^8.13.0",
43
+ "eslint": "^9.14.0",
44
+ "eslint-config-prettier": "^9.1.0",
45
+ "eslint-plugin-prettier": "^5.5.1",
46
+ "globals": "^15.12.0",
47
+ "lint-staged": "^15.2.10",
48
+ "prettier": "^3.3.3",
35
49
  "react": "^18.3.1",
36
50
  "react-dom": "^18.3.1",
37
51
  "semantic-release": "^24.2.3",
38
- "typescript": "^4.9.5"
52
+ "typescript": "^4.9.5",
53
+ "typescript-eslint": "^8.13.0"
39
54
  },
40
55
  "release": {
41
56
  "plugins": [
@@ -79,5 +94,10 @@
79
94
  "type": "git",
80
95
  "url": "git+https://github.com/r74tech/docusaurus-plugin-panzoom.git"
81
96
  },
82
- "sideEffects": false
97
+ "sideEffects": false,
98
+ "lint-staged": {
99
+ "src/**/*.{ts,css}": [
100
+ "prettier --write --no-error-on-unmatched-pattern --config ./.prettierrc"
101
+ ]
102
+ }
83
103
  }
package/docs/README.md DELETED
@@ -1,56 +0,0 @@
1
- # Docusaurus Plugin PanZoom Documentation
2
-
3
- This is the documentation website for the [@r74tech/docusaurus-plugin-panzoom](https://github.com/r74tech/docusaurus-plugin-panzoom) package. The site is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4
-
5
- ## Getting Started
6
-
7
- ### Prerequisites
8
-
9
- - Node.js 20.0 or higher
10
- - pnpm (recommended) or npm
11
-
12
- ### Installation
13
-
14
- ```bash
15
- # Install dependencies
16
- pnpm install
17
- ```
18
-
19
- ### Local Development
20
-
21
- To start the local development server:
22
-
23
- ```bash
24
- # Start the development server
25
- pnpm start
26
- ```
27
-
28
- This command starts a local development server and opens a browser window. Most changes are reflected live without having to restart the server.
29
-
30
- ### Building the Documentation
31
-
32
- To build the static website:
33
-
34
- ```bash
35
- # Build the static site
36
- pnpm build
37
- ```
38
-
39
- This command generates static content in the `build` directory, which can be served using any static content hosting service.
40
-
41
- ## Project Structure
42
-
43
- - `/docs` - Documentation content in Markdown format
44
- - `/static` - Static assets like images and favicon
45
-
46
- ## Deployment
47
-
48
- The documentation is automatically deployed to GitHub Pages using GitHub Actions whenever changes are pushed to the main branch.
49
-
50
- ## Contributing
51
-
52
- Contributions to improve the documentation are welcome! Please feel free to submit a pull request.
53
-
54
- ## License
55
-
56
- This documentation is licensed under the same [MIT License](https://github.com/r74tech/docusaurus-plugin-panzoom/blob/main/LICENSE) as the main project.
@@ -1,35 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- title: Examples
4
- description: Examples of docusaurus-plugin-panzoom in action
5
- ---
6
-
7
- # Pan and Zoom Examples
8
-
9
- This page demonstrates the pan and zoom functionality provided by the docusaurus-plugin-panzoom plugin.
10
- Try dragging to pan, using the mouse wheel to zoom, and double-clicking to reset.
11
-
12
- ## Basic Example
13
-
14
- A simple div with the panzoom-example class:
15
-
16
- <div className="panzoom-example">
17
- Drag here, use wheel to zoom, double-click to reset
18
- </div>
19
-
20
- ## Image Example
21
-
22
- An image with pan and zoom functionality:
23
-
24
- <div className="panzoom-example">
25
- <img src="https://picsum.photos/400/300" alt="Scenic landscape" style={{ width: '100%', height: 'auto' }} />
26
- </div>
27
-
28
- ## Placeholder Example
29
-
30
- A placeholder image with pan and zoom functionality:
31
-
32
- <div className="panzoom-example">
33
- <img src="https://placeholder.pics/svg/400x300" alt="Placeholder graphic" style={{ width: '100%', height: 'auto' }} />
34
- </div>
35
-
@@ -1,57 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # Introduction
6
-
7
- **docusaurus-plugin-panzoom** is a plugin that adds pan and zoom functionality to images and SVG images in Docusaurus websites.
8
-
9
- ## Overview
10
-
11
- Complex diagrams and charts, especially those generated with mermaid.js, can be difficult to examine in detail in a browser. This plugin allows users to drag to move (pan) and zoom in or out of diagrams for better visibility.
12
-
13
- This plugin implements the excellent [@panzoom/panzoom](https://www.npmjs.com/package/@panzoom/panzoom) library.
14
-
15
- ## Key Features
16
-
17
- - Adds pan and zoom functionality to images and SVG elements
18
- - Works with mermaid.js generated diagrams
19
- - Customizable selectors to target specific elements
20
- - Option to wrap elements to contain them within their original container
21
- - Wheel zoom and double-click reset functionality
22
-
23
- ## Demo
24
-
25
- Here's an example of an element with pan and zoom functionality enabled. Try dragging to pan, using the mouse wheel to zoom, and double-clicking to reset.
26
-
27
- <div class="panzoom-example">
28
- Drag here, use wheel to zoom, double-click to reset
29
- </div>
30
-
31
- ## Installation
32
-
33
- ```bash
34
- npm install @r74tech/docusaurus-plugin-panzoom
35
- ```
36
-
37
- ```javascript
38
- // Add to docusaurus.config.js
39
- // ...
40
- plugins: ['@r74tech/docusaurus-plugin-panzoom'],
41
- // or
42
- plugins: [['@r74tech/docusaurus-plugin-panzoom', {} /* options */]],
43
- ```
44
-
45
- ## Next Steps
46
-
47
- - Check out the [Basic Usage](usage/basic)
48
- - See [Examples](example)
49
-
50
- ## License
51
-
52
- MIT, see [LICENSE](https://github.com/r74tech/docusaurus-plugin-panzoom/blob/main/LICENSE) for more details.
53
-
54
- > [!NOTE]
55
- > This package is a fork of [act-org/docusaurus-plugin-panzoom](https://github.com/act-org/docusaurus-plugin-panzoom) under the MIT license. It was forked because the original package was not being actively maintained.
56
- >
57
- > If the original package is updated and maintained again, we recommend migrating back to the original package. This fork will continue to be maintained until then.
@@ -1,120 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # Basic Usage
6
-
7
- This page explains the basic usage of docusaurus-plugin-panzoom.
8
-
9
- ## Installation
10
-
11
- First, install the plugin using npm:
12
-
13
- ```bash
14
- npm install @r74tech/docusaurus-plugin-panzoom
15
- ```
16
-
17
- ## Configuration
18
-
19
- ### Adding the Plugin
20
-
21
- Add the plugin to your Docusaurus configuration file (`docusaurus.config.js` or `docusaurus.config.ts`):
22
-
23
- ```javascript
24
- // Add to docusaurus.config.js
25
- module.exports = {
26
- // ...
27
- plugins: ['@r74tech/docusaurus-plugin-panzoom'],
28
- // ...
29
- };
30
- ```
31
-
32
- Or, if you want to specify options:
33
-
34
- ```javascript
35
- // Add to docusaurus.config.js
36
- module.exports = {
37
- // ...
38
- plugins: [
39
- [
40
- '@r74tech/docusaurus-plugin-panzoom',
41
- {
42
- // Options can be specified here (currently not used)
43
- }
44
- ]
45
- ],
46
- // ...
47
- };
48
- ```
49
-
50
- ### Theme Configuration
51
-
52
- To customize the plugin's behavior, add a `zoom` object to the `themeConfig` section:
53
-
54
- ```javascript
55
- // Add to docusaurus.config.js
56
- module.exports = {
57
- // ...
58
- themeConfig: {
59
- // ...
60
- zoom: {
61
- // A list of selectors to look for elements to enable pan and zoom
62
- // Default: ['div.mermaid[data-processed="true"]', 'div.docusaurus-mermaid-container', '.drawio']
63
- selectors: ['div.mermaid[data-processed="true"]', '.drawio'],
64
-
65
- // Whether to wrap the panzoom items in a div with overflow:hidden
66
- // This constrains the pan zoom detail into the original container
67
- // Default: true
68
- wrap: true,
69
-
70
- // The amount of time to wait in MS before the plugin client module tries to look for
71
- // and alter pan zoom elements. Some renders take a little bit before they appear in the
72
- // dom to find.
73
- // Default: 1000
74
- timeout: 1000,
75
-
76
- // You can also pass any options supported by @panzoom/panzoom
77
- // See: https://github.com/timmywil/panzoom for available options
78
- }
79
- },
80
- // ...
81
- };
82
- ```
83
-
84
- ## Basic Usage
85
-
86
- Once you've installed and configured the plugin, pan and zoom functionality will be automatically added to elements matching the specified selectors.
87
-
88
- ### Default Behavior
89
-
90
- By default, pan and zoom functionality is added to the following elements:
91
-
92
- 1. `div.mermaid[data-processed="true"]` - Processed mermaid.js diagrams
93
- 2. `div.docusaurus-mermaid-container` - Docusaurus mermaid containers
94
- 3. `.drawio` - Diagrams created with draw.io
95
-
96
- ### User Interactions
97
-
98
- For elements with pan and zoom functionality enabled, users can:
99
-
100
- - **Pan**: Click and drag the element to move the view area
101
- - **Zoom**: Use the mouse wheel to zoom in and out of the element
102
- - **Reset**: Double-click the element to reset to the original view state
103
-
104
- ## Adding Custom Selectors
105
-
106
- If you want to add pan and zoom functionality to specific elements, add custom selectors to the `selectors` array:
107
-
108
- ```javascript
109
- zoom: {
110
- selectors: [
111
- 'div.mermaid[data-processed="true"]',
112
- '.drawio',
113
- '.my-custom-diagram', // Add a custom selector
114
- '#specific-image' // Add a specific ID element
115
- ],
116
- // Other options...
117
- }
118
- ```
119
-
120
- Check out the [Examples](../example) page for demonstrations.
@@ -1,123 +0,0 @@
1
- import {themes as prismThemes} from 'prism-react-renderer';
2
- import type {Config} from '@docusaurus/types';
3
- import type * as Preset from '@docusaurus/preset-classic';
4
-
5
- // This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
6
-
7
- const config: Config = {
8
- title: 'Docusaurus Plugin PanZoom',
9
- tagline: 'Add pan and zoom functionality to images and SVGs in your Docusaurus site',
10
- favicon: 'img/favicon.ico',
11
-
12
- // Set the production url of your site here
13
- url: 'https://r74tech.github.io',
14
- // Set the /<baseUrl>/ pathname under which your site is served
15
- // For GitHub pages deployment, it is often '/<projectName>/'
16
- baseUrl: '/docusaurus-plugin-panzoom/',
17
-
18
- // GitHub pages deployment config.
19
- // If you aren't using GitHub pages, you don't need these.
20
- organizationName: 'r74tech', // Usually your GitHub org/user name.
21
- projectName: 'docusaurus-plugin-panzoom', // Usually your repo name.
22
-
23
- onBrokenLinks: 'throw',
24
- onBrokenMarkdownLinks: 'warn',
25
-
26
- // Even if you don't use internationalization, you can use this field to set
27
- // useful metadata like html lang. For example, if your site is Chinese, you
28
- // may want to replace "en" with "zh-Hans".
29
- i18n: {
30
- defaultLocale: 'en',
31
- locales: ['en'],
32
- },
33
-
34
- presets: [
35
- [
36
- 'classic',
37
- {
38
- docs: {
39
- sidebarPath: './sidebars.ts',
40
- // Please change this to your repo.
41
- // Remove this to remove the "edit this page" links.
42
- editUrl:
43
- 'https://github.com/r74tech/docusaurus-plugin-panzoom/tree/main/docs/',
44
- routeBasePath: '/', // Changed from 'docs' to '/' to make docs the main route
45
- },
46
- blog: false, // Disable the blog feature
47
- } satisfies Preset.Options,
48
- ],
49
- ],
50
-
51
- plugins: [
52
- '@r74tech/docusaurus-plugin-panzoom'
53
- ],
54
-
55
- themeConfig: {
56
- // Replace with your project's social card
57
- image: 'img/docusaurus-social-card.jpg',
58
- navbar: {
59
- title: 'Docusaurus Plugin PanZoom',
60
- logo: {
61
- alt: 'Docusaurus Plugin PanZoom Logo',
62
- src: 'img/logo.svg',
63
- },
64
- items: [
65
- {
66
- type: 'docSidebar',
67
- sidebarId: 'tutorialSidebar',
68
- position: 'left',
69
- label: 'Docs',
70
- },
71
- {
72
- type: 'doc',
73
- docId: 'example/index',
74
- position: 'left',
75
- label: 'Example',
76
- },
77
- {
78
- href: 'https://github.com/r74tech/docusaurus-plugin-panzoom',
79
- label: 'GitHub',
80
- position: 'right',
81
- },
82
- ],
83
- },
84
- footer: {
85
- style: 'dark',
86
- links: [
87
- {
88
- title: 'Links',
89
- items: [
90
- {
91
- label: 'Docs',
92
- to: '/',
93
- },
94
- {
95
- label: 'Example',
96
- to: '/example/',
97
- },
98
- {
99
- label: 'GitHub',
100
- href: 'https://github.com/r74tech/docusaurus-plugin-panzoom',
101
- },
102
- {
103
- label: 'npm',
104
- href: 'https://www.npmjs.com/package/@r74tech/docusaurus-plugin-panzoom',
105
- },
106
- ],
107
- },
108
- ],
109
- copyright: `Copyright © ${new Date().getFullYear()} r74tech. Built with Docusaurus.`,
110
- },
111
- prism: {
112
- theme: prismThemes.github,
113
- darkTheme: prismThemes.dracula,
114
- },
115
- zoom: {
116
- selectors: ['div.mermaid[data-processed="true"]', 'div.docusaurus-mermaid-container', '.drawio', '.panzoom-example'],
117
- wrap: true,
118
- timeout: 1000,
119
- },
120
- } satisfies Preset.ThemeConfig,
121
- };
122
-
123
- export default config;
package/docs/package.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "name": "docs",
3
- "version": "0.0.0",
4
- "private": true,
5
- "scripts": {
6
- "docusaurus": "docusaurus",
7
- "start": "docusaurus start",
8
- "build": "docusaurus build",
9
- "swizzle": "docusaurus swizzle",
10
- "deploy": "docusaurus deploy",
11
- "clear": "docusaurus clear",
12
- "serve": "docusaurus serve",
13
- "write-translations": "docusaurus write-translations",
14
- "write-heading-ids": "docusaurus write-heading-ids",
15
- "typecheck": "tsc"
16
- },
17
- "dependencies": {
18
- "@docusaurus/core": "3.7.0",
19
- "@docusaurus/preset-classic": "3.7.0",
20
- "@mdx-js/react": "^3.0.0",
21
- "@r74tech/docusaurus-plugin-panzoom": "file:..",
22
- "clsx": "^2.0.0",
23
- "prism-react-renderer": "^2.3.0",
24
- "react": "^19.0.0",
25
- "react-dom": "^19.0.0"
26
- },
27
- "devDependencies": {
28
- "@docusaurus/module-type-aliases": "3.7.0",
29
- "@docusaurus/tsconfig": "3.7.0",
30
- "@docusaurus/types": "3.7.0",
31
- "typescript": "~5.6.2"
32
- },
33
- "browserslist": {
34
- "production": [
35
- ">0.5%",
36
- "not dead",
37
- "not op_mini all"
38
- ],
39
- "development": [
40
- "last 3 chrome version",
41
- "last 3 firefox version",
42
- "last 5 safari version"
43
- ]
44
- },
45
- "engines": {
46
- "node": ">=20.0"
47
- }
48
- }
package/docs/sidebars.ts DELETED
@@ -1,22 +0,0 @@
1
- import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
2
-
3
- /**
4
- * Creating a sidebar enables you to:
5
- - create an ordered group of docs
6
- - render a sidebar for each doc of that group
7
- - provide next/previous navigation
8
-
9
- The sidebars can be generated from the filesystem, or explicitly defined here.
10
-
11
- Create as many sidebars as you want.
12
- */
13
- const sidebars: SidebarsConfig = {
14
- // Manually defined sidebar with specific items
15
- tutorialSidebar: [
16
- 'index', // Main documentation page (docs/index.md)
17
- 'usage/basic', // Basic usage guide
18
- 'example/index', // Examples page
19
- ],
20
- };
21
-
22
- export default sidebars;
Binary file
@@ -1 +0,0 @@
1
- <svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path fill="#FFF" d="M99 52h84v34H99z"/><path d="M23 163c-7.398 0-13.843-4.027-17.303-10A19.886 19.886 0 0 0 3 163c0 11.046 8.954 20 20 20h20v-20H23z" fill="#3ECC5F"/><path d="M112.98 57.376L183 53V43c0-11.046-8.954-20-20-20H73l-2.5-4.33c-1.112-1.925-3.889-1.925-5 0L63 23l-2.5-4.33c-1.111-1.925-3.889-1.925-5 0L53 23l-2.5-4.33c-1.111-1.925-3.889-1.925-5 0L43 23c-.022 0-.042.003-.065.003l-4.142-4.141c-1.57-1.571-4.252-.853-4.828 1.294l-1.369 5.104-5.192-1.392c-2.148-.575-4.111 1.389-3.535 3.536l1.39 5.193-5.102 1.367c-2.148.576-2.867 3.259-1.296 4.83l4.142 4.142c0 .021-.003.042-.003.064l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 53l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 63l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 73l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 83l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 93l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 103l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 113l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 123l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 133l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 143l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 153l-4.33 2.5c-1.925 1.111-1.925 3.889 0 5L23 163c0 11.046 8.954 20 20 20h120c11.046 0 20-8.954 20-20V83l-70.02-4.376A10.645 10.645 0 0 1 103 68c0-5.621 4.37-10.273 9.98-10.624" fill="#3ECC5F"/><path fill="#3ECC5F" d="M143 183h30v-40h-30z"/><path d="M193 158c-.219 0-.428.037-.639.064-.038-.15-.074-.301-.116-.451A5 5 0 0 0 190.32 148a4.96 4.96 0 0 0-3.016 1.036 26.531 26.531 0 0 0-.335-.336 4.955 4.955 0 0 0 1.011-2.987 5 5 0 0 0-9.599-1.959c-.148-.042-.297-.077-.445-.115.027-.211.064-.42.064-.639a5 5 0 0 0-5-5 5 5 0 0 0-5 5c0 .219.037.428.064.639-.148.038-.297.073-.445.115a4.998 4.998 0 0 0-9.599 1.959c0 1.125.384 2.151 1.011 2.987-3.717 3.632-6.031 8.693-6.031 14.3 0 11.046 8.954 20 20 20 9.339 0 17.16-6.41 19.361-15.064.211.027.42.064.639.064a5 5 0 0 0 5-5 5 5 0 0 0-5-5" fill="#44D860"/><path fill="#3ECC5F" d="M153 123h30v-20h-30z"/><path d="M193 115.5a2.5 2.5 0 1 0 0-5c-.109 0-.214.019-.319.032-.02-.075-.037-.15-.058-.225a2.501 2.501 0 0 0-.963-4.807c-.569 0-1.088.197-1.508.518a6.653 6.653 0 0 0-.168-.168c.314-.417.506-.931.506-1.494a2.5 2.5 0 0 0-4.8-.979A9.987 9.987 0 0 0 183 103c-5.522 0-10 4.478-10 10s4.478 10 10 10c.934 0 1.833-.138 2.69-.377a2.5 2.5 0 0 0 4.8-.979c0-.563-.192-1.077-.506-1.494.057-.055.113-.111.168-.168.42.321.939.518 1.508.518a2.5 2.5 0 0 0 .963-4.807c.021-.074.038-.15.058-.225.105.013.21.032.319.032" fill="#44D860"/><path d="M63 55.5a2.5 2.5 0 0 1-2.5-2.5c0-4.136-3.364-7.5-7.5-7.5s-7.5 3.364-7.5 7.5a2.5 2.5 0 1 1-5 0c0-6.893 5.607-12.5 12.5-12.5S65.5 46.107 65.5 53a2.5 2.5 0 0 1-2.5 2.5" fill="#000"/><path d="M103 183h60c11.046 0 20-8.954 20-20V93h-60c-11.046 0-20 8.954-20 20v70z" fill="#FFFF50"/><path d="M168.02 124h-50.04a1 1 0 1 1 0-2h50.04a1 1 0 1 1 0 2m0 20h-50.04a1 1 0 1 1 0-2h50.04a1 1 0 1 1 0 2m0 20h-50.04a1 1 0 1 1 0-2h50.04a1 1 0 1 1 0 2m0-49.814h-50.04a1 1 0 1 1 0-2h50.04a1 1 0 1 1 0 2m0 19.814h-50.04a1 1 0 1 1 0-2h50.04a1 1 0 1 1 0 2m0 20h-50.04a1 1 0 1 1 0-2h50.04a1 1 0 1 1 0 2M183 61.611c-.012 0-.022-.006-.034-.005-3.09.105-4.552 3.196-5.842 5.923-1.346 2.85-2.387 4.703-4.093 4.647-1.889-.068-2.969-2.202-4.113-4.46-1.314-2.594-2.814-5.536-5.963-5.426-3.046.104-4.513 2.794-5.807 5.167-1.377 2.528-2.314 4.065-4.121 3.994-1.927-.07-2.951-1.805-4.136-3.813-1.321-2.236-2.848-4.75-5.936-4.664-2.994.103-4.465 2.385-5.763 4.4-1.373 2.13-2.335 3.428-4.165 3.351-1.973-.07-2.992-1.51-4.171-3.177-1.324-1.873-2.816-3.993-5.895-3.89-2.928.1-4.399 1.97-5.696 3.618-1.232 1.564-2.194 2.802-4.229 2.724a1 1 0 0 0-.072 2c3.017.101 4.545-1.8 5.872-3.487 1.177-1.496 2.193-2.787 4.193-2.855 1.926-.082 2.829 1.115 4.195 3.045 1.297 1.834 2.769 3.914 5.731 4.021 3.103.104 4.596-2.215 5.918-4.267 1.182-1.834 2.202-3.417 4.15-3.484 1.793-.067 2.769 1.35 4.145 3.681 1.297 2.197 2.766 4.686 5.787 4.796 3.125.108 4.634-2.62 5.949-5.035 1.139-2.088 2.214-4.06 4.119-4.126 1.793-.042 2.728 1.595 4.111 4.33 1.292 2.553 2.757 5.445 5.825 5.556l.169.003c3.064 0 4.518-3.075 5.805-5.794 1.139-2.41 2.217-4.68 4.067-4.773v-2z" fill="#000"/><path fill="#3ECC5F" d="M83 183h40v-40H83z"/><path d="M143 158c-.219 0-.428.037-.639.064-.038-.15-.074-.301-.116-.451A5 5 0 0 0 140.32 148a4.96 4.96 0 0 0-3.016 1.036 26.531 26.531 0 0 0-.335-.336 4.955 4.955 0 0 0 1.011-2.987 5 5 0 0 0-9.599-1.959c-.148-.042-.297-.077-.445-.115.027-.211.064-.42.064-.639a5 5 0 0 0-5-5 5 5 0 0 0-5 5c0 .219.037.428.064.639-.148.038-.297.073-.445.115a4.998 4.998 0 0 0-9.599 1.959c0 1.125.384 2.151 1.011 2.987-3.717 3.632-6.031 8.693-6.031 14.3 0 11.046 8.954 20 20 20 9.339 0 17.16-6.41 19.361-15.064.211.027.42.064.639.064a5 5 0 0 0 5-5 5 5 0 0 0-5-5" fill="#44D860"/><path fill="#3ECC5F" d="M83 123h40v-20H83z"/><path d="M133 115.5a2.5 2.5 0 1 0 0-5c-.109 0-.214.019-.319.032-.02-.075-.037-.15-.058-.225a2.501 2.501 0 0 0-.963-4.807c-.569 0-1.088.197-1.508.518a6.653 6.653 0 0 0-.168-.168c.314-.417.506-.931.506-1.494a2.5 2.5 0 0 0-4.8-.979A9.987 9.987 0 0 0 123 103c-5.522 0-10 4.478-10 10s4.478 10 10 10c.934 0 1.833-.138 2.69-.377a2.5 2.5 0 0 0 4.8-.979c0-.563-.192-1.077-.506-1.494.057-.055.113-.111.168-.168.42.321.939.518 1.508.518a2.5 2.5 0 0 0 .963-4.807c.021-.074.038-.15.058-.225.105.013.21.032.319.032" fill="#44D860"/><path d="M143 41.75c-.16 0-.33-.02-.49-.05a2.52 2.52 0 0 1-.47-.14c-.15-.06-.29-.14-.431-.23-.13-.09-.259-.2-.38-.31-.109-.12-.219-.24-.309-.38s-.17-.28-.231-.43a2.619 2.619 0 0 1-.189-.96c0-.16.02-.33.05-.49.03-.16.08-.31.139-.47.061-.15.141-.29.231-.43.09-.13.2-.26.309-.38.121-.11.25-.22.38-.31.141-.09.281-.17.431-.23.149-.06.31-.11.47-.14.32-.07.65-.07.98 0 .159.03.32.08.47.14.149.06.29.14.43.23.13.09.259.2.38.31.11.12.22.25.31.38.09.14.17.28.23.43.06.16.11.31.14.47.029.16.05.33.05.49 0 .66-.271 1.31-.73 1.77-.121.11-.25.22-.38.31-.14.09-.281.17-.43.23a2.565 2.565 0 0 1-.96.19m20-1.25c-.66 0-1.3-.27-1.771-.73a3.802 3.802 0 0 1-.309-.38c-.09-.14-.17-.28-.231-.43a2.619 2.619 0 0 1-.189-.96c0-.66.27-1.3.729-1.77.121-.11.25-.22.38-.31.141-.09.281-.17.431-.23.149-.06.31-.11.47-.14.32-.07.66-.07.98 0 .159.03.32.08.47.14.149.06.29.14.43.23.13.09.259.2.38.31.459.47.73 1.11.73 1.77 0 .16-.021.33-.05.49-.03.16-.08.32-.14.47-.07.15-.14.29-.23.43-.09.13-.2.26-.31.38-.121.11-.25.22-.38.31-.14.09-.281.17-.43.23a2.565 2.565 0 0 1-.96.19" fill="#000"/></g></svg>