docblocks-react-ui 0.31.0 → 0.31.1

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,5 +1,21 @@
1
1
  # docblocks-react-ui
2
2
 
3
+ ## 0.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 0478534: The canvas world snaps to the device pixel grid: the container's centre (the
8
+ world transform's origin) gains a sub-device-pixel compensation, so strokes
9
+ sit on whole pixels instead of antialiasing across two rows at partial alpha.
10
+ An odd container size (an arbitrary consumer height), a fractional device
11
+ ratio, or a fractional pan no longer soften every figure's edge and every
12
+ connector line — the effect that read as a scaled raster at a high zoom.
13
+ - 6eec500: The orthogonal connector clears its own arrowhead before the first bend: the
14
+ stub along the port's normal now runs 18 canvas px (the arrow's 11 px body
15
+ plus 7 px of straight line), so a route that turns right at the figure no
16
+ longer reads as leaving the arrow's side corner — the line comes out of the
17
+ arrow's base centre and only then bends.
18
+
3
19
  ## 0.31.0
4
20
 
5
21
  ### Minor Changes
@@ -14801,12 +14801,12 @@ function connectorPathPoints(a, b, variant, obstacles) {
14801
14801
  const aAnchored = a.nx !== 0 || a.ny !== 0;
14802
14802
  const bAnchored = b.nx !== 0 || b.ny !== 0;
14803
14803
  const aOut = aAnchored ? {
14804
- x: a.x + a.nx * 12,
14805
- y: a.y + a.ny * 12
14804
+ x: a.x + a.nx * 18,
14805
+ y: a.y + a.ny * 18
14806
14806
  } : a;
14807
14807
  const bIn = bAnchored ? {
14808
- x: b.x + b.nx * 12,
14809
- y: b.y + b.ny * 12
14808
+ x: b.x + b.nx * 18,
14809
+ y: b.y + b.ny * 18
14810
14810
  } : b;
14811
14811
  const horizontal = Math.abs(dx) >= Math.abs(dy);
14812
14812
  const structures = [horizontal ? (t) => [{
@@ -33936,6 +33936,28 @@ function StandaloneBody({ id, block }) {
33936
33936
  function childrenSlot(_id, children) {
33937
33937
  if (children === void 0 || children.length === 0) return void 0;
33938
33938
  }
33939
+ // src/shared/hooks/use-device-pixel-ratio.ts
33940
+ /**
33941
+ * The display's device pixel ratio (the canvas world's raster-grid snap's
33942
+ * input): the value changes over a browser zoom, a monitor move, or an OS
33943
+ * scale change — each re-reads it on the window's resize (the ratio itself
33944
+ * never triggers a layout, so the read stands the render's own).
33945
+ */
33946
+ const FALLBACK_RATIO = 1;
33947
+ function readDevicePixelRatio() {
33948
+ if (typeof window === "undefined") return FALLBACK_RATIO;
33949
+ return window.devicePixelRatio > 0 ? window.devicePixelRatio : FALLBACK_RATIO;
33950
+ }
33951
+ function useDevicePixelRatio() {
33952
+ const [ratio, setRatio] = useState(readDevicePixelRatio);
33953
+ useEffect(() => {
33954
+ const read = () => setRatio(readDevicePixelRatio());
33955
+ read();
33956
+ window.addEventListener("resize", read);
33957
+ return () => window.removeEventListener("resize", read);
33958
+ }, []);
33959
+ return ratio;
33960
+ }
33939
33961
  // src/canvas/canvas-view/CanvasTextGhost.tsx
33940
33962
  /**
33941
33963
  * The canvas ghost text block (the double-click's empty-canvas entry): the
@@ -34807,6 +34829,20 @@ function ConnectorLabelEdit({ id, mid, stroke, width, lineStyle, label, onClose
34807
34829
  onKeyDown: onLabelKeyDown
34808
34830
  });
34809
34831
  }
34832
+ // src/canvas/canvas-view/world-snap.ts
34833
+ /** The world's translate compensation (screen px, the before-the-scale
34834
+ * translate's own space): zero over an unmeasured container. */
34835
+ function worldSnapOf(pan, container, devicePixelRatio) {
34836
+ const snapAxis = (offset, size) => {
34837
+ if (!(devicePixelRatio > 0) || !(size > 0)) return 0;
34838
+ const origin = size / 2 + offset;
34839
+ return Math.round(origin * devicePixelRatio) / devicePixelRatio - origin;
34840
+ };
34841
+ return {
34842
+ x: snapAxis(pan.x, container.width),
34843
+ y: snapAxis(pan.y, container.height)
34844
+ };
34845
+ }
34810
34846
  // src/canvas/canvas-view/CanvasSurface.tsx
34811
34847
  /** The canvas's surface assembly: the container (the pointer / key
34812
34848
  * sessions' host, the focus's park, the dot grid over the pan / zoom) and
@@ -34817,6 +34853,8 @@ function ConnectorLabelEdit({ id, mid, stroke, width, lineStyle, label, onClose
34817
34853
  * session's hooks + the target's reads; this component is the paint. */
34818
34854
  function CanvasSurface({ containerRef, containerSize, cursor, viewport, handlers, pageContext, pageChildren, pageCardSelected, pageCardDisplayStyle, surfaces, culling, storeSelection, blocks, viewMode, targets, beginEndpointDrag, beginWaypointDrag, addConnectorWaypoint, onResetZoom, onFit }) {
34819
34855
  const { t } = useTranslation("canvas");
34856
+ const devicePixelRatio = useDevicePixelRatio();
34857
+ const worldSnap = worldSnapOf(viewport.pan, containerSize, devicePixelRatio);
34820
34858
  const { handleTarget, displayBox, multiSelectionBox, shapeToolbarTarget, textToolbarTarget, arrangeToolbarTarget, connectorToolbarTarget, connectorLabelTarget, selectedConnectorHandles, previewFrom, previewSnap, previewEnd, hoverSnapPoint } = targets;
34821
34859
  return /* @__PURE__ */ jsxs("div", {
34822
34860
  "data-slot": "docblocks/canvas-view",
@@ -34847,7 +34885,7 @@ function CanvasSurface({ containerRef, containerSize, cursor, viewport, handlers
34847
34885
  "data-slot": "docblocks/canvas-world",
34848
34886
  className: cn("absolute inset-0", (viewport.moveSession || viewport.resizeSession || viewport.connectorEndpoint !== null) && "select-none"),
34849
34887
  style: {
34850
- transform: `translate(${viewport.pan.x}px, ${viewport.pan.y}px) scale(${viewport.zoom})`,
34888
+ transform: `translate(${viewport.pan.x + worldSnap.x}px, ${viewport.pan.y + worldSnap.y}px) scale(${viewport.zoom})`,
34851
34889
  transformOrigin: "center",
34852
34890
  "--docblocks-canvas-inv-zoom": 1 / viewport.zoom
34853
34891
  },
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as DropdownMenuShortcut, $t as useText, A as Select, At as columnAnnotation, B as Label, Bt as CardDescription, C as cellValueEqual, Ct as isBridgeErrorCode, D as filterIsComplete, Dt as conditionMatches, E as emptyFilter, Et as ENUM_OPTION_NAME_COLUMN, F as SelectScrollDownButton, Ft as BookOpen, G as DropdownMenuContent, Gt as badgeVariants, H as Input, Ht as CardHeader, I as SelectScrollUpButton, It as Skeleton, J as DropdownMenuLabel, Jt as useMeta, K as DropdownMenuGroup, Kt as useBlock, L as SelectSeparator, Lt as Card, M as SelectGroup, Mt as Pen, N as SelectItem, Nt as Eye, O as SegmentSelector, Ot as parseCellValue, P as SelectLabel, Q as DropdownMenuSeparator, Qt as useSelectionView, R as SelectTrigger, Rt as CardAction, S as useDatabaseTable, St as isBridgeError, T as FilterBuilder, Tt as ENUM_OPTION_COLOR_COLUMN, U as DropdownMenu, Ut as CardTitle, V as InlineEditInput, Vt as CardFooter, W as DropdownMenuCheckboxItem, Wt as Badge, X as DropdownMenuRadioGroup, Xt as usePresenceSharing, Y as DropdownMenuPortal, Yt as usePresence, Z as DropdownMenuRadioItem, Zt as useSelection, _ as mapFrontmatter, _t as PROTOCOL_VERSION, a as DEFAULT_EMBED_SANDBOX, at as Popover, b as renderRuns, bt as BRIDGE_ERROR_CODES, c as SHAPE_FONT_OPTIONS, ct as PopoverDescription, d as FORMAT_PALETTE, dt as PopoverTrigger, en as DocblocksI18nProvider, et as DropdownMenuSub, ft as Checkbox, g as parseFrontmatter, gt as BASELINE_CAPABILITIES, h as mdToBlocks, ht as AlertTitle, i as useEditorContext, in as buttonVariants, it as Separator, j as SelectContent, k as ScrollArea, kt as TEXT_TYPES, l as SHAPE_FONT_STACKS, lt as PopoverHeader, m as insertNative, mt as AlertDescription, n as useCoverAverageColor, nn as EditorErrorBoundary, nt as DropdownMenuSubTrigger, ot as PopoverAnchor, p as htmlToBlocks, pt as Alert, q as DropdownMenuItem, qt as useDoc, r as EditorProvider, rn as Button, rt as DropdownMenuTrigger, st as PopoverContent, t as Editor, tn as createMemoryBlobStore, tt as DropdownMenuSubContent, ut as PopoverTitle, v as markToggleAction, vt as isDatabaseBridge, w as newMutationContext, wt as toBridgeError, x as GridBody, xt as BridgeError, yt as validateProtocolDescriptor, z as SelectValue, zt as CardContent } from "./Editor-CAU0NkdR.mjs";
1
+ import { $ as DropdownMenuShortcut, $t as useText, A as Select, At as columnAnnotation, B as Label, Bt as CardDescription, C as cellValueEqual, Ct as isBridgeErrorCode, D as filterIsComplete, Dt as conditionMatches, E as emptyFilter, Et as ENUM_OPTION_NAME_COLUMN, F as SelectScrollDownButton, Ft as BookOpen, G as DropdownMenuContent, Gt as badgeVariants, H as Input, Ht as CardHeader, I as SelectScrollUpButton, It as Skeleton, J as DropdownMenuLabel, Jt as useMeta, K as DropdownMenuGroup, Kt as useBlock, L as SelectSeparator, Lt as Card, M as SelectGroup, Mt as Pen, N as SelectItem, Nt as Eye, O as SegmentSelector, Ot as parseCellValue, P as SelectLabel, Q as DropdownMenuSeparator, Qt as useSelectionView, R as SelectTrigger, Rt as CardAction, S as useDatabaseTable, St as isBridgeError, T as FilterBuilder, Tt as ENUM_OPTION_COLOR_COLUMN, U as DropdownMenu, Ut as CardTitle, V as InlineEditInput, Vt as CardFooter, W as DropdownMenuCheckboxItem, Wt as Badge, X as DropdownMenuRadioGroup, Xt as usePresenceSharing, Y as DropdownMenuPortal, Yt as usePresence, Z as DropdownMenuRadioItem, Zt as useSelection, _ as mapFrontmatter, _t as PROTOCOL_VERSION, a as DEFAULT_EMBED_SANDBOX, at as Popover, b as renderRuns, bt as BRIDGE_ERROR_CODES, c as SHAPE_FONT_OPTIONS, ct as PopoverDescription, d as FORMAT_PALETTE, dt as PopoverTrigger, en as DocblocksI18nProvider, et as DropdownMenuSub, ft as Checkbox, g as parseFrontmatter, gt as BASELINE_CAPABILITIES, h as mdToBlocks, ht as AlertTitle, i as useEditorContext, in as buttonVariants, it as Separator, j as SelectContent, k as ScrollArea, kt as TEXT_TYPES, l as SHAPE_FONT_STACKS, lt as PopoverHeader, m as insertNative, mt as AlertDescription, n as useCoverAverageColor, nn as EditorErrorBoundary, nt as DropdownMenuSubTrigger, ot as PopoverAnchor, p as htmlToBlocks, pt as Alert, q as DropdownMenuItem, qt as useDoc, r as EditorProvider, rn as Button, rt as DropdownMenuTrigger, st as PopoverContent, t as Editor, tn as createMemoryBlobStore, tt as DropdownMenuSubContent, ut as PopoverTitle, v as markToggleAction, vt as isDatabaseBridge, w as newMutationContext, wt as toBridgeError, x as GridBody, xt as BridgeError, yt as validateProtocolDescriptor, z as SelectValue, zt as CardContent } from "./Editor-NfJ_5Hyw.mjs";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { C as UnknownSlashCommandError, S as UnhandledValueError, _ as CanvasPasteError, b as HookMisuseError, g as BlobNotFoundError, s as preventDefault, v as DocBlocksUiError, w as cn, x as PdfFetchError, y as EditorProviderError } from "./constants-CBPODzZc.mjs";
@@ -1,4 +1,4 @@
1
- import { It as Skeleton, Nt as Eye, O as SegmentSelector, Pt as CodeXml, f as textOf, ht as AlertTitle, i as useEditorContext, jt as RotateCcw, mt as AlertDescription, o as childrenSlot, pt as Alert, rn as Button, s as CodeHeader, u as TextBlock, y as INLINE_CODE_CLASS } from "../Editor-CAU0NkdR.mjs";
1
+ import { It as Skeleton, Nt as Eye, O as SegmentSelector, Pt as CodeXml, f as textOf, ht as AlertTitle, i as useEditorContext, jt as RotateCcw, mt as AlertDescription, o as childrenSlot, pt as Alert, rn as Button, s as CodeHeader, u as TextBlock, y as INLINE_CODE_CLASS } from "../Editor-NfJ_5Hyw.mjs";
2
2
  import mermaid from "mermaid";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import { useEffect, useRef, useState } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docblocks-react-ui",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "React rendering + editing layer for docblocks: hooks, block renderers, caret/selection, keyboard, clipboard.",
5
5
  "type": "module",
6
6
  "license": "MIT",