@r74tech/docusaurus-plugin-panzoom 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # [2.0.0](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v1.0.1...v2.0.0) (2025-04-09)
2
+
3
+
4
+ * feat!: migrate package from [@actinc](https://github.com/actinc) to [@r74tech](https://github.com/r74tech) namespace ([ed56447](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/ed56447becf424c44f0d91badd6209d246b5f401))
5
+
6
+
7
+ ### BREAKING CHANGES
8
+
9
+ * Package has been renamed from @actinc/docusaurus-plugin-panzoom to @r74tech/docusaurus-plugin-panzoom. This requires users to update their import statements and configuration.
10
+
11
+ - Updated dependencies to support Docusaurus v3
12
+ - Changed author information
13
+ - Updated repository URLs
14
+ - Added proper build scripts
15
+ - Enhanced documentation
16
+
17
+ ## [1.0.1](https://github.com/act-org/docusaurus-plugin-panzoom/compare/v1.0.0...v1.0.1) (2023-03-02)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Add theme-mermaid class naming convention as a default selector ([9543aee](https://github.com/act-org/docusaurus-plugin-panzoom/commit/9543aee990c3d70daf7f7a231c7e5ec214c95334))
23
+
24
+ # 1.0.0 (2023-03-02)
25
+
26
+
27
+ ### Features
28
+
29
+ * Initial release of module ([7fe5711](https://github.com/act-org/docusaurus-plugin-panzoom/commit/7fe571118dc286791d608489b6eb59f1b8b27a86))
@@ -0,0 +1,110 @@
1
+ # Contributing to docusaurus-plugin-panzoom
2
+
3
+ I appreciate your consideration to contribute to this project! This document is a guide to help make your contribution easier and more effective.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - [Node.js](https://nodejs.org) (v20 or later recommended)
10
+
11
+ ### Installation
12
+
13
+ 1. Clone the repository
14
+
15
+ ```bash
16
+ git clone https://github.com/r74tech/docusaurus-plugin-panzoom.git
17
+ ```
18
+
19
+ 2. Move to the directory and install dependencies
20
+
21
+ ```bash
22
+ cd docusaurus-plugin-panzoom
23
+ npm install
24
+ ```
25
+
26
+ ### Development
27
+
28
+ The main scripts used during development are:
29
+
30
+ - `npm run build`: Builds the TypeScript code.
31
+ - `npm run prepublishOnly`: Runs the build script before publishing.
32
+
33
+ ## How to Contribute
34
+
35
+ ### Reporting Issues
36
+
37
+ If you find a bug or have a feature request, please open an issue on GitHub.
38
+
39
+ 1. Check [the Issue Tracker](https://github.com/r74tech/docusaurus-plugin-panzoom/issues) for existing issues.
40
+ 2. When requesting a new issue or feature, please provide as much detail as possible.
41
+
42
+ ### Development
43
+
44
+ 1. Check [the Issue Tracker](https://github.com/r74tech/docusaurus-plugin-panzoom/issues), make sure if there is anything relevant to the problem you are trying to solve.
45
+ 2. Keep the repository you did folk up to date.
46
+
47
+ ```bash
48
+ git fetch upstream
49
+ git rebase upstream/main
50
+ ```
51
+
52
+ 3. Create a new branch.
53
+
54
+ ```bash
55
+ git switch -c feature/your-feature-name
56
+ ```
57
+
58
+ 4. Make changes to the code and run tests to make sure everything is working properly.
59
+ 5. Write a clear commit message following the Conventional Commits style.
60
+
61
+ ### Commit Messages
62
+
63
+ - Commit messages should concisely describe the changes you made.
64
+ - Commits should be split into appropriate chunks, and we recommend using [the Conventional Commits](https://www.conventionalcommits.org/) style. Below are the available Conventional Commits types:
65
+ - `feat`: a commit that adds new functionality (triggers a MINOR version bump).
66
+ - `fix`: a commit that fixes a bug (triggers a PATCH version bump).
67
+ - `docs`: a commit that adds or improves documentation.
68
+ - `style`: changes that do not affect the meaning of the code.
69
+ - `refactor`: a code change that neither fixes a bug nor adds a feature.
70
+ - `perf`: a commit that improves performance, without functional changes.
71
+ - `test`: adding missing tests or correcting existing tests.
72
+ - `build`: changes that affect the build system or external dependencies.
73
+ - `ci`: changes to our CI configuration files and scripts.
74
+ - `chore`: other changes that don't modify src or test files.
75
+ - `revert`: reverts a previous commit.
76
+
77
+ > [!NOTE]
78
+ > If there is a single commit in the pull request, the commit message must be the same as a pull request title. Because the merge strategy in this repository is "Squash and merge". When you "Squash and merge" a pull request on a branch that has only one commit, the default commit message will be the commit message in that branch.
79
+ >
80
+ > cf. [About pull request merges - GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#merge-message-for-a-squash-merge)
81
+
82
+ ### Breaking Changes
83
+
84
+ For commits that introduce breaking changes, add an exclamation mark after the type and include a "BREAKING CHANGE:" section in the commit body:
85
+
86
+ ```
87
+ feat!: completely revamp the API
88
+
89
+ BREAKING CHANGE: The new API is not compatible with previous versions
90
+ ```
91
+
92
+ ### Pull Requests
93
+
94
+ 1. Write the title of pull request in the [the Conventional Commits](https://www.conventionalcommits.org/) style.
95
+ 2. Create a pull request and include the following information:
96
+ - Description of the change
97
+ - Purpose of the change
98
+ - Relevant issue number (if any)
99
+
100
+ ## Automated Releases
101
+
102
+ This project uses [semantic-release](https://github.com/semantic-release/semantic-release) for automated version management and package publishing. The release process is triggered automatically when changes are merged into the main branch.
103
+
104
+ - `fix:` commits trigger a PATCH version bump (e.g., 1.0.0 → 1.0.1)
105
+ - `feat:` commits trigger a MINOR version bump (e.g., 1.0.0 → 1.1.0)
106
+ - Commits with `BREAKING CHANGE:` trigger a MAJOR version bump (e.g., 1.0.0 → 2.0.0)
107
+
108
+ ## License
109
+
110
+ This project is based on [MIT License](/LICENSE).
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) ACT, Inc. and its affiliates.
4
+ Copyright (c) 2025 r74tech.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # docusaurus-plugin-panzoom
2
+
3
+ This plugin adds the ability to pan and zoom images and SVG images inside of a docusaurus website. This is useful for embedding diagrams or
4
+ complex mermaid.js renders around models and object schemas. The normal theme doesn't scale tremendously well in a browser so some augmentation
5
+ for complex diagrams is necessary.
6
+
7
+ This implements the excellent [@panzoom/panzoom](https://www.npmjs.com/package/@panzoom/panzoom) plugin
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @r74tech/docusaurus-plugin-panzoom
13
+ ```
14
+
15
+ ```javascript
16
+ // In docusaurus.config.js
17
+ // ...
18
+ plugins: ['@r74tech/docusaurus-plugin-panzoom'],
19
+ // or
20
+ plugins: [['@r74tech/docusaurus-plugin-panzoom', {} /* options */]],
21
+ ```
22
+
23
+ ## Configuration
24
+
25
+ The plugin accepts the following configuration options:
26
+
27
+ ```javascript
28
+ // In docusaurus.config.js
29
+ // ...
30
+ themeConfig: {
31
+ zoom: {
32
+ // A list of selectors to look for elements to enable pan and zoom
33
+ // Default: ['div.mermaid[data-processed="true"]', 'div.docusaurus-mermaid-container', '.drawio']
34
+ selectors: ['div.mermaid[data-processed="true"]', '.drawio'],
35
+
36
+ // Whether to wrap the panzoom items in a div with overflow:hidden
37
+ // This constrains the pan zoom detail into the original container
38
+ // Default: true
39
+ wrap: true,
40
+
41
+ // The amount of time to wait in MS before the plugin client module tries to look for
42
+ // and alter pan zoom elements. Some renders take a little bit before they appear in the
43
+ // dom to find.
44
+ // Default: 1000
45
+ timeout: 1000,
46
+
47
+ // You can also pass any options supported by @panzoom/panzoom
48
+ // See: https://github.com/timmywil/panzoom for available options
49
+ }
50
+ }
51
+ ```
52
+
53
+ > [!NOTE]
54
+ > 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.
55
+ >
56
+ > 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.
57
+
58
+ ## License
59
+
60
+ MIT, see [LICENSE](LICENSE) for more details.
@@ -0,0 +1,6 @@
1
+ import type { ClientModule } from '@docusaurus/types';
2
+ /**
3
+ * Client module implementation. Wait a bit before trying this, some components like mermaid take a second to process / render
4
+ */
5
+ declare const ZoomModule: ClientModule;
6
+ export default ZoomModule;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const panzoom_1 = __importDefault(require("@panzoom/panzoom"));
7
+ const config = require('@generated/docusaurus.config').default;
8
+ const { themeConfig } = config;
9
+ const { zoom } = themeConfig;
10
+ const { selectors = ['div.mermaid[data-processed="true"]', 'div.docusaurus-mermaid-container', '.drawio'], wrap = true, timeout = 1000, ...panZoomConfig } = zoom;
11
+ /**
12
+ * Main work method to zoom the set of elements. You can pass in global options to the pan zoom component
13
+ * as well as control whether the items will be wrapped.
14
+ * @param selectors
15
+ */
16
+ const zoomElements = (selectors) => {
17
+ const foundElements = [];
18
+ selectors.forEach((selector) => {
19
+ foundElements.push(...document.querySelectorAll(selector));
20
+ });
21
+ foundElements.forEach((element) => {
22
+ const instance = (0, panzoom_1.default)(element, panZoomConfig);
23
+ if (wrap) {
24
+ const wrapper = document.createElement('div');
25
+ wrapper.setAttribute('style', "overflow: hidden");
26
+ element.parentElement?.insertBefore(wrapper, element);
27
+ wrapper.appendChild(element);
28
+ wrapper.addEventListener('wheel', (event) => {
29
+ instance.zoomWithWheel(event);
30
+ });
31
+ wrapper.addEventListener('dblclick', (event) => {
32
+ instance.reset();
33
+ });
34
+ }
35
+ if (!wrap) {
36
+ element.addEventListener('wheel', (event) => {
37
+ instance.zoomWithWheel(event);
38
+ });
39
+ element.addEventListener('dblclick', (event) => {
40
+ instance.reset();
41
+ });
42
+ }
43
+ });
44
+ };
45
+ /**
46
+ * Client module implementation. Wait a bit before trying this, some components like mermaid take a second to process / render
47
+ */
48
+ const ZoomModule = {
49
+ onRouteDidUpdate() {
50
+ setTimeout(() => {
51
+ zoomElements(selectors);
52
+ }, timeout);
53
+ },
54
+ };
55
+ exports.default = ZoomModule;
@@ -0,0 +1,15 @@
1
+ import type { PluginModule, ThemeConfigValidationContext } from '@docusaurus/types';
2
+ import { PanZoomPluginOptions } from './PanzoomPluginOptions';
3
+ /**
4
+ * Main module for the PanZoom plugin
5
+ * @param context
6
+ * @param options
7
+ * @returns
8
+ */
9
+ export declare const PanZoomPlugin: PluginModule;
10
+ /**
11
+ * Add a validation for the theme configuration
12
+ * @param data
13
+ * @returns
14
+ */
15
+ export declare function validatedThemeConfig(data: ThemeConfigValidationContext<PanZoomPluginOptions>): PanZoomPluginOptions;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatedThemeConfig = exports.PanZoomPlugin = void 0;
4
+ const utils_validation_1 = require("@docusaurus/utils-validation");
5
+ const path_1 = require("path");
6
+ /**
7
+ * Main module for the PanZoom plugin
8
+ * @param context
9
+ * @param options
10
+ * @returns
11
+ */
12
+ const PanZoomPlugin = (context, options) => {
13
+ return {
14
+ name: "docusaurus-plugin-panzoom",
15
+ getClientModules() {
16
+ return [
17
+ (0, path_1.resolve)(__dirname, "./PanZoom")
18
+ ];
19
+ }
20
+ };
21
+ };
22
+ exports.PanZoomPlugin = PanZoomPlugin;
23
+ /**
24
+ * Theme validation rules for this plugin
25
+ */
26
+ const panZoomValidator = utils_validation_1.Joi.object({
27
+ zoom: utils_validation_1.Joi.object({
28
+ selectors: utils_validation_1.Joi.array(),
29
+ wrap: utils_validation_1.Joi.boolean(),
30
+ timeout: utils_validation_1.Joi.number(),
31
+ })
32
+ });
33
+ /**
34
+ * Add a validation for the theme configuration
35
+ * @param data
36
+ * @returns
37
+ */
38
+ function validatedThemeConfig(data) {
39
+ const { themeConfig, validate } = data;
40
+ const validated = validate(panZoomValidator, themeConfig);
41
+ return validated;
42
+ }
43
+ exports.validatedThemeConfig = validatedThemeConfig;
@@ -0,0 +1,24 @@
1
+ import type { PanzoomOptions } from '@panzoom/panzoom';
2
+ export type PanZoomPluginOptions = PanzoomOptions & {
3
+ /**
4
+ * A list of selectors to look for elements to enable pan and zoom
5
+ *
6
+ * The default value is ['div.mermaid[data-processed="true"]', '.drawio']
7
+ */
8
+ selectors?: string[];
9
+ /**
10
+ * Whether to wrap the panzoom items in a div with overflow:hidden. This constrains
11
+ * the pan zoom detail into the original container.
12
+ *
13
+ * default: true
14
+ */
15
+ wrap?: boolean;
16
+ /**
17
+ * The amount of time to wait in MS before the plugin client module tries to look for
18
+ * and alter pan zoom elements. Some renders take a little bit before they appear in the
19
+ * dom to find.
20
+ *
21
+ * The default is 1000
22
+ */
23
+ timeout?: number;
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { PanZoomPlugin as default, validatedThemeConfig } from './PanZoomPlugin';
2
+ export type { PanZoomPluginOptions } from './PanzoomPluginOptions';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatedThemeConfig = exports.default = void 0;
4
+ var PanZoomPlugin_1 = require("./PanZoomPlugin");
5
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return PanZoomPlugin_1.PanZoomPlugin; } });
6
+ Object.defineProperty(exports, "validatedThemeConfig", { enumerable: true, get: function () { return PanZoomPlugin_1.validatedThemeConfig; } });
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@r74tech/docusaurus-plugin-panzoom",
3
+ "version": "2.0.0",
4
+ "description": "A plugin to enable the panzoom component on SVG and other elements",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "keywords": [
8
+ "Docusaurus",
9
+ "Plugin",
10
+ "PanZoom"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "author": "r74tech",
16
+ "license": "MIT",
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "dependencies": {
22
+ "@docusaurus/utils-validation": "^3.7.0",
23
+ "@panzoom/panzoom": "^4.6.0"
24
+ },
25
+ "devDependencies": {
26
+ "@docusaurus/types": "^3.7.0",
27
+ "@semantic-release/changelog": "^6.0.3",
28
+ "@semantic-release/commit-analyzer": "^9.0.2",
29
+ "@semantic-release/git": "^10.0.1",
30
+ "@semantic-release/github": "^11.0.1",
31
+ "@semantic-release/npm": "^12.0.1",
32
+ "@semantic-release/release-notes-generator": "^10.0.3",
33
+ "@tsconfig/docusaurus": "^1.0.7",
34
+ "@types/node": "^22.14.0",
35
+ "react": "^18.3.1",
36
+ "react-dom": "^18.3.1",
37
+ "semantic-release": "^24.2.3",
38
+ "typescript": "^4.9.5"
39
+ },
40
+ "release": {
41
+ "plugins": [
42
+ "@semantic-release/commit-analyzer",
43
+ "@semantic-release/release-notes-generator",
44
+ [
45
+ "@semantic-release/changelog",
46
+ {
47
+ "changelogFile": "CHANGELOG.md",
48
+ "changeLogTitle": "# Changelog"
49
+ }
50
+ ],
51
+ "@semantic-release/npm",
52
+ "@semantic-release/github",
53
+ [
54
+ "@semantic-release/git",
55
+ {
56
+ "assets": [
57
+ "CHANGELOG.md",
58
+ "package.json",
59
+ "package-lock.json"
60
+ ],
61
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
62
+ }
63
+ ]
64
+ ],
65
+ "repositoryUrl": "git@github.com:r74tech/docusaurus-plugin-panzoom.git",
66
+ "branches": [
67
+ {
68
+ "name": "main",
69
+ "prerelease": false
70
+ },
71
+ {
72
+ "name": "next",
73
+ "prerelease": true
74
+ }
75
+ ],
76
+ "initialVersion": "2.0.0"
77
+ },
78
+ "repository": {
79
+ "type": "git",
80
+ "url": "git+https://github.com/r74tech/docusaurus-plugin-panzoom.git"
81
+ },
82
+ "sideEffects": false
83
+ }