@matfsw/docusaurus-plantuml-plugin 1.0.1 → 1.0.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
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.2]
11
+
12
+ ### Fixed
13
+
14
+ - The zoom buttons and keyboard shortcuts now zoom about the viewport's top-left corner rather
15
+ than its centre. A diagram that fits its viewport is left-aligned, so the empty space is to
16
+ its right and below; zooming about the centre scaled that empty space and pushed the diagram
17
+ off the top and left edges, most visibly on a maximized diagram. Wheel zoom continues to
18
+ track the pointer.
19
+
10
20
  ## [1.0.1]
11
21
 
12
22
  ### Fixed
@@ -86,7 +96,8 @@ Initial release.
86
96
  opt-out.
87
97
  - Plugin option validation that rejects unknown keys and out-of-range values at build time.
88
98
 
89
- [Unreleased]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.0.1...HEAD
99
+ [Unreleased]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.0.2...HEAD
100
+ [1.0.2]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.0.1...v1.0.2
90
101
  [1.0.1]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v1.0.0...v1.0.1
91
102
  [1.0.0]: https://github.com/matf/docusaurus-plantuml-plugin/compare/v0.1.0...v1.0.0
92
103
  [0.1.0]: https://github.com/matf/docusaurus-plantuml-plugin/releases/tag/v0.1.0
package/README.md CHANGED
@@ -277,6 +277,13 @@ The diagram viewport is focusable. Once focused:
277
277
  Keys with Ctrl, Cmd or Alt held are left to the browser, so shortcuts such as Ctrl + 0 keep
278
278
  working, and `Tab` always moves on — the diagram is never a keyboard trap.
279
279
 
280
+ The toolbar buttons and the keyboard zoom about the **top-left corner** of the viewport, while
281
+ the wheel zooms about the **pointer**. That difference is deliberate: a diagram rarely fills its
282
+ viewport, and one that fits is left-aligned, so the empty space sits to its right and below.
283
+ Zooming about the centre would scale that empty space and push the diagram off the top and left
284
+ edges — most visibly when maximized. Anchoring at the top-left grows the diagram into the empty
285
+ space instead and keeps it visible as long as possible.
286
+
280
287
  Scale is limited to 0.25×–8×, and the view resets to 100% whenever the diagram source or the
281
288
  site colour mode changes.
282
289
 
@@ -54,12 +54,19 @@ export function useZoomPan({ enabled, resetKey }) {
54
54
  const reset = useCallback(() => {
55
55
  apply(IDENTITY);
56
56
  }, [apply]);
57
- /** Zooms about the middle of the viewport, which is what buttons and keys should do. */
57
+ /**
58
+ * Zooms about the viewport's top-left corner.
59
+ *
60
+ * Not the centre: a diagram rarely fills its viewport, and a diagram that fits is
61
+ * left-aligned, so the empty space sits to its right and below. Zooming about the centre
62
+ * scales that empty space too and pushes the diagram off the top and left edges — most
63
+ * visibly when maximized. Anchoring at the top-left leaves a left-aligned diagram exactly
64
+ * where it is and grows it into the empty space, keeping it visible as long as possible.
65
+ *
66
+ * Wheel zoom still tracks the pointer, which is what direct manipulation should do.
67
+ */
58
68
  const zoomByStep = useCallback((factor) => {
59
- const viewport = viewportRef.current;
60
- const focalX = (viewport?.clientWidth ?? 0) / 2;
61
- const focalY = (viewport?.clientHeight ?? 0) / 2;
62
- apply(zoomAbout(transformRef.current, factor, focalX, focalY));
69
+ apply(zoomAbout(transformRef.current, factor, 0, 0));
63
70
  }, [apply]);
64
71
  const zoomIn = useCallback(() => zoomByStep(SCALE_STEP), [zoomByStep]);
65
72
  const zoomOut = useCallback(() => zoomByStep(1 / SCALE_STEP), [zoomByStep]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matfsw/docusaurus-plantuml-plugin",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Render PlantUML diagrams in Docusaurus 3 entirely in the browser - no Java, no PlantUML server, no CDN.",
5
5
  "keywords": [
6
6
  "docusaurus",