@r74tech/docusaurus-plugin-panzoom 2.3.0 → 2.4.2

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 CHANGED
@@ -1,3 +1,25 @@
1
+ ## [2.4.2](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.4.1...v2.4.2) (2026-02-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * npm CLIを最新版に更新(OIDC trusted publishing対応) ([93e241b](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/93e241b8113ce187ac6ec5f4ccf196844b2ac1b5))
7
+
8
+ ## [2.4.1](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.4.0...v2.4.1) (2026-02-08)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * CIのNode.jsバージョンを22に更新 ([21d9a57](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/21d9a57a26716a4e07e994fbbbdb74e2044d0e08))
14
+ * OIDC trusted publishingの設定を修正 ([31764e1](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/31764e10638d9b89715cadf173ba90f7f18d50c2))
15
+
16
+ # [2.4.0](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.3.0...v2.4.0) (2025-07-19)
17
+
18
+
19
+ ### Features
20
+
21
+ * add options to better control the zoom ([#7](https://github.com/r74tech/docusaurus-plugin-panzoom/issues/7)) ([4dc537c](https://github.com/r74tech/docusaurus-plugin-panzoom/commit/4dc537c8e059908cc2cae407fc78ae93de34c6dd))
22
+
1
23
  # [2.3.0](https://github.com/r74tech/docusaurus-plugin-panzoom/compare/v2.2.0...v2.3.0) (2025-07-17)
2
24
 
3
25
 
package/dist/PanZoom.js CHANGED
@@ -9,12 +9,14 @@ const zoom_in_1 = __importDefault(require("./img/zoom-in"));
9
9
  const zoom_out_1 = __importDefault(require("./img/zoom-out"));
10
10
  const zoom_reset_1 = __importDefault(require("./img/zoom-reset"));
11
11
  require("./styles/panzoom.css");
12
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
12
13
  const config = require('@generated/docusaurus.config').default;
13
14
  const { themeConfig } = config;
14
15
  const { zoom } = themeConfig;
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
+ 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 } = {}, enableWheelZoom = true, enableWheelZoomWithShift = false, enableDoubleClickResetZoom = true, restrictZoomOutBeyondOrigin = false, ...panZoomConfig } = zoom;
16
17
  /**
17
18
  * Creates a toolbar with zoom controls for a panzoom instance
19
+ *
18
20
  * @param container The container element to append the toolbar to
19
21
  * @param instance The panzoom instance to control
20
22
  * @param position The position of the toolbar
@@ -44,16 +46,72 @@ const createToolbar = (container, instance, position) => {
44
46
  };
45
47
  // Create and append all buttons
46
48
  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()),
49
+ // Zoom in
50
+ createButton(zoom_in_1.default, 'Zoom in', () => {
51
+ instance.zoomIn();
52
+ }),
53
+ // Zoom out
54
+ createButton(zoom_out_1.default, 'Zoom out', () => {
55
+ if (!restrictZoomOutBeyondOrigin) {
56
+ instance.zoomOut();
57
+ return;
58
+ }
59
+ if (instance.getScale() > 1) {
60
+ instance.zoomOut();
61
+ }
62
+ }),
63
+ // Reset zoom
64
+ createButton(zoom_reset_1.default, 'Reset zoom', () => {
65
+ instance.reset();
66
+ }),
50
67
  ];
51
68
  buttons.forEach((button) => toolbar.appendChild(button));
52
69
  container.appendChild(toolbar);
53
70
  };
71
+ /**
72
+ * Attach event listeners to the element where panzoom is applied.
73
+ * The listeners to add are based on the configuration options provided.
74
+ *
75
+ * @param element The element to add event listeners to
76
+ * @param instance The panzoom instance to control
77
+ */
78
+ const addEventListeners = (element, instance) => {
79
+ const handleZoomWithWheel = (event) => {
80
+ if (restrictZoomOutBeyondOrigin) {
81
+ // Allow zooming in or zooming out only to the original size
82
+ if (event.deltaY < 0 || (event.deltaY > 0 && instance.getScale() > 1)) {
83
+ instance.zoomWithWheel(event);
84
+ }
85
+ }
86
+ else {
87
+ instance.zoomWithWheel(event);
88
+ }
89
+ };
90
+ // Handle the wheel zoom functionality if at least one of the options is enabled
91
+ if (enableWheelZoom || enableWheelZoomWithShift) {
92
+ element.addEventListener('wheel', (event) => {
93
+ // Handle zoom with shift key
94
+ if (enableWheelZoomWithShift && event.shiftKey) {
95
+ handleZoomWithWheel(event);
96
+ return;
97
+ }
98
+ // Handle regular zoom
99
+ if (enableWheelZoom && !event.shiftKey) {
100
+ handleZoomWithWheel(event);
101
+ }
102
+ });
103
+ }
104
+ // Handle double-click reset zoom
105
+ if (enableDoubleClickResetZoom) {
106
+ element.addEventListener('dblclick', () => {
107
+ instance.reset();
108
+ });
109
+ }
110
+ };
54
111
  /**
55
112
  * Main work method to zoom the set of elements. You can pass in global options to the pan zoom component
56
113
  * as well as control whether the items will be wrapped.
114
+ *
57
115
  * @param selectors
58
116
  */
59
117
  const zoomElements = (selectors) => {
@@ -69,24 +127,14 @@ const zoomElements = (selectors) => {
69
127
  wrapper.setAttribute('style', 'overflow: hidden; position: relative;');
70
128
  element.parentElement?.insertBefore(wrapper, element);
71
129
  wrapper.appendChild(element);
72
- wrapper.addEventListener('wheel', (event) => {
73
- instance.zoomWithWheel(event);
74
- });
75
- wrapper.addEventListener('dblclick', () => {
76
- instance.reset();
77
- });
78
130
  container = wrapper;
79
131
  }
80
132
  else {
81
- element.style.position = 'relative';
82
- element.addEventListener('wheel', (event) => {
83
- instance.zoomWithWheel(event);
84
- });
85
- element.addEventListener('dblclick', () => {
86
- instance.reset();
87
- });
88
- container = element;
133
+ const htmlElement = element;
134
+ htmlElement.style.position = 'relative';
135
+ container = htmlElement;
89
136
  }
137
+ addEventListeners(container, instance);
90
138
  // Add toolbar if enabled
91
139
  if (enabled) {
92
140
  createToolbar(container, instance, position);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validatedThemeConfig = exports.PanZoomPlugin = void 0;
3
+ exports.PanZoomPlugin = void 0;
4
+ exports.validatedThemeConfig = validatedThemeConfig;
4
5
  const utils_validation_1 = require("@docusaurus/utils-validation");
5
6
  const PanzoomPluginOptions_1 = require("./PanzoomPluginOptions");
6
7
  const path_1 = require("path");
@@ -10,7 +11,7 @@ const path_1 = require("path");
10
11
  * @param options
11
12
  * @returns
12
13
  */
13
- const PanZoomPlugin = (context, options) => {
14
+ const PanZoomPlugin = (_context, _options) => {
14
15
  return {
15
16
  name: 'docusaurus-plugin-panzoom',
16
17
  getClientModules() {
@@ -47,4 +48,3 @@ function validatedThemeConfig(data) {
47
48
  const validated = validate(panZoomValidator, themeConfig);
48
49
  return validated;
49
50
  }
50
- exports.validatedThemeConfig = validatedThemeConfig;
@@ -59,4 +59,35 @@ export type PanZoomPluginOptions = PanzoomOptions & {
59
59
  */
60
60
  opacity?: number;
61
61
  };
62
+ /**
63
+ * Whether to enable zooming with the mouse wheel.
64
+ * If true, the user can zoom in and out using the mouse wheel.
65
+ *
66
+ * default: true
67
+ */
68
+ enableWheelZoom?: boolean;
69
+ /**
70
+ * Whether to enable zooming with the mouse wheel while holding the shift key.
71
+ * If true, the user can zoom in and out using the mouse wheel while holding the shift key.
72
+ *
73
+ * This option is independent of `enableWheelZoom`. Meaning, even if `enableWheelZoom` is false,
74
+ * and `enableWheelZoomWithShift` is true, the user can still zoom using shift + mouse whee.
75
+ * Also, `enableWheelZoom` and `enableWheelZoomWithShift` can be used together.
76
+ *
77
+ * default: false
78
+ */
79
+ enableWheelZoomWithShift?: boolean;
80
+ /**
81
+ * Whether to enable double-click to reset zoom.
82
+ * If true, double-clicking on the panzoom element will reset the zoom level.
83
+ *
84
+ * default: true
85
+ */
86
+ enableDoubleClickResetZoom?: boolean;
87
+ /**
88
+ * Whether to restrict zooming out beyond the original size of the element.
89
+ *
90
+ * default: false
91
+ */
92
+ restrictZoomOutBeyondOrigin?: boolean;
62
93
  };
@@ -7,4 +7,4 @@ var PanZoomPluginToolbarPosition;
7
7
  PanZoomPluginToolbarPosition["TopLeft"] = "top-left";
8
8
  PanZoomPluginToolbarPosition["BottomRight"] = "bottom-right";
9
9
  PanZoomPluginToolbarPosition["BottomLeft"] = "bottom-left";
10
- })(PanZoomPluginToolbarPosition = exports.PanZoomPluginToolbarPosition || (exports.PanZoomPluginToolbarPosition = {}));
10
+ })(PanZoomPluginToolbarPosition || (exports.PanZoomPluginToolbarPosition = PanZoomPluginToolbarPosition = {}));
package/eslint.config.mjs CHANGED
@@ -6,7 +6,7 @@ import prettierPlugin from 'eslint-plugin-prettier';
6
6
 
7
7
  export default [
8
8
  {
9
- files: ['src/**/*.{ts,css}'],
9
+ files: ['src/**/*.ts'],
10
10
  ignores: ['**/dist/**', '**/node_modules/**'],
11
11
  languageOptions: {
12
12
  ecmaVersion: 2020,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r74tech/docusaurus-plugin-panzoom",
3
- "version": "2.3.0",
3
+ "version": "2.4.2",
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",
@@ -10,7 +10,8 @@
10
10
  "PanZoom"
11
11
  ],
12
12
  "publishConfig": {
13
- "access": "public"
13
+ "access": "public",
14
+ "provenance": true
14
15
  },
15
16
  "author": "r74tech",
16
17
  "license": "MIT",
@@ -23,34 +24,34 @@
23
24
  "format": "prettier --write --no-error-on-unmatched-pattern 'src/**/*.{ts,css}' --config ./.prettierrc"
24
25
  },
25
26
  "dependencies": {
26
- "@docusaurus/utils-validation": "^3.7.0",
27
- "@panzoom/panzoom": "^4.6.0"
27
+ "@docusaurus/utils-validation": "^3.9.2",
28
+ "@panzoom/panzoom": "^4.6.1"
28
29
  },
29
30
  "devDependencies": {
30
- "@docusaurus/types": "^3.7.0",
31
- "@eslint/compat": "^1.2.3",
32
- "@eslint/js": "^9.14.0",
31
+ "@docusaurus/types": "^3.9.2",
32
+ "@eslint/compat": "^1.4.1",
33
+ "@eslint/js": "^9.39.2",
33
34
  "@semantic-release/changelog": "^6.0.3",
34
- "@semantic-release/commit-analyzer": "^9.0.2",
35
+ "@semantic-release/commit-analyzer": "^13.0.1",
35
36
  "@semantic-release/git": "^10.0.1",
36
- "@semantic-release/github": "^11.0.1",
37
- "@semantic-release/npm": "^12.0.1",
38
- "@semantic-release/release-notes-generator": "^10.0.3",
39
- "@tsconfig/docusaurus": "^1.0.7",
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",
37
+ "@semantic-release/github": "^12.0.5",
38
+ "@semantic-release/npm": "^13.1.0",
39
+ "@semantic-release/release-notes-generator": "^14.1.0",
40
+ "@tsconfig/docusaurus": "^2.0.8",
41
+ "@types/node": "^25.2.2",
42
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
43
+ "@typescript-eslint/parser": "^8.54.0",
44
+ "eslint": "^9.39.2",
45
+ "eslint-config-prettier": "^10.1.8",
46
+ "eslint-plugin-prettier": "^5.5.5",
47
+ "globals": "^15.15.0",
48
+ "lint-staged": "^16.2.7",
49
+ "prettier": "^3.8.1",
49
50
  "react": "^18.3.1",
50
51
  "react-dom": "^18.3.1",
51
- "semantic-release": "^24.2.3",
52
- "typescript": "^4.9.5",
53
- "typescript-eslint": "^8.13.0"
52
+ "semantic-release": "^25.0.3",
53
+ "typescript": "^5.9.3",
54
+ "typescript-eslint": "^8.54.0"
54
55
  },
55
56
  "release": {
56
57
  "plugins": [
@@ -71,7 +72,7 @@
71
72
  "assets": [
72
73
  "CHANGELOG.md",
73
74
  "package.json",
74
- "package-lock.json"
75
+ "pnpm-lock.yaml"
75
76
  ],
76
77
  "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
77
78
  }