Skip to content

Build your personal knowledge base with Trilium Notes

refactor(mermaid): fit and zoom the SVG preview without svg-pan-zoom

Elian Dorand2143f95d9ce
diff --git a/apps/client/package.json b/apps/client/package.json
index d541f4d82e..e06631bbe3 100644
--- a/apps/client/package.json
+++ b/apps/client/package.json
@@ -67,7 +67,6 @@
"react-zoom-pan-pinch": "4.2.0",
"reveal.js": "6.0.2",
"rrule": "2.8.1",
- "svg-pan-zoom": "3.6.2",
"tabulator-tables": "6.5.2",
"temporal-polyfill": "1.0.5",
"terra-draw": "1.33.0",
diff --git a/apps/client/src/widgets/type_widgets/helpers/SplitEditor.css b/apps/client/src/widgets/type_widgets/helpers/SplitEditor.css
index cffdf1d22b..e71940c802 100644
--- a/apps/client/src/widgets/type_widgets/helpers/SplitEditor.css
+++ b/apps/client/src/widgets/type_widgets/helpers/SplitEditor.css
@@ -157,7 +157,16 @@ body.desktop .note-detail-split .note-detail-code-editor {
}
/* #region SVG */
+/* react-zoom-pan-pinch sizes both of its boxes as `fit-content`, which leaves the percentage heights
+ below nothing to resolve against. Stretch them to the pane so the SVG fits it at a scale of 1. */
+.note-detail-split.svg-editor .svg-preview-viewport,
+.note-detail-split.svg-editor .svg-preview-content {
+ width: 100%;
+ height: 100%;
+}
+
.note-detail-split.svg-editor .render-container {
+ width: 100%;
height: 100%;
}
@@ -166,10 +175,4 @@ body.desktop .note-detail-split .note-detail-code-editor {
height: 100%;
max-width: 100% !important;
}
-
-/* Pinned by the corner it names (see `placement` on OverlayControlGroup); left here is only what it
- stands above, which is the error card the preview may be dimmed behind. */
-.note-detail-split.svg-editor .svg-preview-controls {
- z-index: 10;
-}
/* #endregion */
diff --git a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.spec.tsx b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.spec.tsx
index 6befe1b422..5abbb55153 100644
--- a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.spec.tsx
@@ -1,131 +1,71 @@
-import { render } from "preact";
+import { type ComponentChildren, render } from "preact";
import { useEffect } from "preact/hooks";
import { act } from "preact/test-utils";
-import { describe, expect, it, vi } from "vitest";
+import { beforeEach, describe, expect, it, vi } from "vitest";
-import SvgSplitEditor from "./SvgSplitEditor";
import type { SplitEditorProps } from "./SplitEditor";
+import SvgSplitEditor from "./SvgSplitEditor";
-// svg-pan-zoom strips the SVG's `viewBox` attribute as soon as it initializes (it caches the
-// original value internally and works off pan/zoom transforms afterwards) and its `destroy()`
-// never puts it back. `useResizer` (SvgSplitEditor.tsx) is responsible for restoring it itself;
-// this fake reproduces exactly that stripping-without-restoring behavior so the test exercises
-// the real bug shape rather than a strawman.
-//
-// It also keeps a scale, the way the library does: a step multiplies it by the library's own
-// sensitivity and is clamped to the same bounds, a fit takes it back to the view it opened at, and
-// every change is told to whoever asked to be told (`setOnZoom`) — which is what the readout follows.
-vi.mock("svg-pan-zoom", () => ({
- default: vi.fn((svgEl: SVGElement) => {
- svgEl.removeAttribute("viewBox");
- let zoom = 1;
- let onZoom: ((zoom: number) => void) | undefined;
- const setZoom = (value: number) => {
- zoom = Math.min(10, Math.max(0.5, value));
- onZoom?.(zoom);
- return instance;
- };
- const instance = {
- resize: () => instance,
- center: () => instance,
- fit: () => setZoom(1),
- zoom: (value: number) => setZoom(value),
- zoomIn: () => setZoom(zoom * 1.2),
- zoomOut: () => setZoom(zoom / 1.2),
- pan: () => instance,
- getPan: () => ({ x: 0, y: 0 }),
- getZoom: () => zoom,
- setOnZoom: (fn: (zoom: number) => void) => { onZoom = fn; return instance; },
- destroy: () => {}
- };
- return instance;
- })
+// react-zoom-pan-pinch measures its boxes, which happy-dom cannot do. Render the children in place
+// and capture the props so the bounds handed to the library can still be asserted.
+const { transformWrapperSpy } = vi.hoisted(() => ({ transformWrapperSpy: vi.fn() }));
+
+vi.mock("react-zoom-pan-pinch", () => ({
+ TransformWrapper: (props: { children?: ComponentChildren }) => {
+ transformWrapperSpy(props);
+ return props.children;
+ },
+ TransformComponent: (props: { children?: ComponentChildren; wrapperClass?: string }) => (
+ <div className={props.wrapperClass}>{props.children}</div>
+ )
}));
// SplitEditor pulls in CodeMirror, Split.js and a Bootstrap ribbon that have nothing to do with
-// the pan/zoom behavior under test; stub it down to just the preview pane and the controls over it,
-// and fire the same `onContentChanged` callback the real editor would once content arrives.
+// the pan/zoom behavior under test; stub it down to just the preview pane, and fire the same
+// `onContentChanged` callback the real editor would once content arrives.
vi.mock("./SplitEditor", () => ({
- default: ({ previewContent, previewButtons, onContentChanged }: SplitEditorProps) => {
+ default: ({ previewContent, onContentChanged }: SplitEditorProps) => {
useEffect(() => {
onContentChanged?.("gantt\nsection Test\nTask: 2024-01-01, 1d");
}, []);
- return <div>{previewContent}{previewButtons}</div>;
+ return <div>{previewContent}</div>;
}
}));
-// The bootstrap tooltip the control buttons wear needs real layout, which happy-dom hasn't.
-vi.mock("../../react/hooks", async (importOriginal) => ({
- ...(await importOriginal<object>()),
- useStaticTooltip: () => {}
-}));
-
const ORIGINAL_VIEW_BOX = "0 0 1234 56";
const SVG_MARKUP = `<svg viewBox="${ORIGINAL_VIEW_BOX}" xmlns="http://www.w3.org/2000/svg">`
+ `<rect width="10" height="10"/></svg>`;
-const SVG_MARKUP_WITHOUT_VIEW_BOX = `<svg xmlns="http://www.w3.org/2000/svg">`
- + `<rect width="10" height="10"/></svg>`;
describe("SvgSplitEditor", () => {
- it("restores the viewBox on cleanup, undoing what svg-pan-zoom stripped on init", async () => {
- const svgEl = await mountAndUnmount(SVG_MARKUP, (el) => {
- // Sanity check that the mocked library actually ran and stripped the attribute, so a
- // passing assertion below reflects the restore and not an untouched attribute.
- expect(el.getAttribute("viewBox")).toBeNull();
- });
-
- expect(svgEl.getAttribute("viewBox")).toBe(ORIGINAL_VIEW_BOX);
- });
-
- it("does not invent a viewBox for an SVG that never had one", async () => {
- const svgEl = await mountAndUnmount(SVG_MARKUP_WITHOUT_VIEW_BOX);
-
- expect(svgEl.getAttribute("viewBox")).toBeNull();
- });
-
- it("says the scale the diagram is drawn at, and fits it back to the pane when the readout is pressed", async () => {
- const { container, controls, unmount } = await mountControls();
+ beforeEach(() => transformWrapperSpy.mockClear());
- expect(controls().readout.textContent).toBe("100%");
+ it("renders the diagram inside the pan/zoom viewport, with its viewBox untouched", async () => {
+ const { container, unmount } = await mount();
- act(() => controls().zoomIn.click());
- expect(controls().readout.textContent).toBe("120%");
-
- act(() => controls().readout.click());
- expect(controls().readout.textContent).toBe("100%");
+ const svgEl = container.querySelector(".svg-preview-viewport .render-container svg");
+ expect(svgEl).not.toBeNull();
+ // The fit comes from the viewBox rather than from a measured scale, so nothing may strip it
+ // — svg-pan-zoom used to, which shrank gantt charts to invisibility on a re-fit (#9749).
+ expect(svgEl?.getAttribute("viewBox")).toBe(ORIGINAL_VIEW_BOX);
unmount();
container.remove();
});
- it("leaves a step with no room left to it disabled", async () => {
- const { container, controls, unmount } = await mountControls();
-
- expect(controls().zoomOut.disabled).toBe(false);
+ it("bounds the zoom as a multiple of the fitted view", async () => {
+ const { container, unmount } = await mount();
- // Far enough to be clamped at either end, so the readout sits exactly on the limit — which
- // is where the rounding the tolerance covers would otherwise leave the button live.
- for (let i = 0; i < 20; i++) act(() => controls().zoomOut.click());
- expect(controls().readout.textContent).toBe("50%");
- expect(controls().zoomOut.disabled).toBe(true);
- expect(controls().zoomIn.disabled).toBe(false);
-
- for (let i = 0; i < 20; i++) act(() => controls().zoomIn.click());
- expect(controls().readout.textContent).toBe("1000%");
- expect(controls().zoomIn.disabled).toBe(true);
- expect(controls().zoomOut.disabled).toBe(false);
+ expect(transformWrapperSpy).toHaveBeenCalledWith(
+ expect.objectContaining({ minScale: 0.5, maxScale: 10 })
+ );
unmount();
container.remove();
});
});
-/**
- * Mounts `SvgSplitEditor` and waits for the controls over the rendered diagram to appear, handing
- * back a reader for the three buttons. They are read afresh on every call, the group being drawn
- * anew whenever the scale changes.
- */
-async function mountControls() {
+/** Mounts `SvgSplitEditor` and waits for the rendered diagram to appear. */
+async function mount() {
const container = document.createElement("div");
document.body.appendChild(container);
@@ -133,42 +73,9 @@ async function mountControls() {
render(<SvgSplitEditor {...svgSplitEditorProps(SVG_MARKUP)} />, container);
});
- await vi.waitFor(() => expect(container.querySelectorAll(".tn-overlay-control-group button")).toHaveLength(3));
-
- const controls = () => {
- const [ zoomOut, readout, zoomIn ] = container.querySelectorAll<HTMLButtonElement>(".svg-preview-controls button");
- return { zoomOut, readout, zoomIn };
- };
-
- return { container, controls, unmount: () => act(() => render(null, container)) };
-}
-
-/**
- * Mounts `SvgSplitEditor` around the given SVG markup, waits for the SVG to render, runs the
- * optional pre-unmount assertion, then unmounts to trigger the effect cleanup under test and
- * returns the (now detached) SVG element for post-cleanup assertions.
- */
-async function mountAndUnmount(svgMarkup: string, beforeUnmount?: (svgEl: SVGElement) => void) {
- const container = document.createElement("div");
- document.body.appendChild(container);
-
- await act(async () => {
- render(<SvgSplitEditor {...svgSplitEditorProps(svgMarkup)} />, container);
- });
-
await vi.waitFor(() => expect(container.querySelector("svg")).not.toBeNull());
- const svgEl = container.querySelector("svg");
- if (!svgEl) {
- throw new Error("Expected the rendered SVG to be present after waiting for it.");
- }
-
- beforeUnmount?.(svgEl);
-
- // Unmounting tears the effect down (its only cleanup), which is where the fix lives.
- act(() => render(null, container));
- container.remove();
- return svgEl;
+ return { container, unmount: () => act(() => render(null, container)) };
}
/**
diff --git a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx
index cdc3da1aeb..581f80743a 100644
--- a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx
+++ b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx
@@ -1,13 +1,11 @@
-import { RefObject } from "preact";
-import { useCallback, useEffect, useRef, useState } from "preact/hooks";
-import svgPanZoom from "svg-pan-zoom";
+import { useCallback, useEffect, useState } from "preact/hooks";
+import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
import { t } from "../../../services/i18n";
import server from "../../../services/server";
import toast from "../../../services/toast";
import utils from "../../../services/utils";
-import { useElementSize, useTriliumEvent } from "../../react/hooks";
-import OverlayControlGroup, { OverlayControlButton } from "../../react/OverlayControlGroup";
+import { useTriliumEvent } from "../../react/hooks";
import { RawHtmlBlock } from "../../react/RawHtml";
import SplitEditor, { SplitEditorProps } from "./SplitEditor";
@@ -41,7 +39,6 @@ interface SvgSplitEditorProps extends Omit<SplitEditorProps, "previewContent"> {
export default function SvgSplitEditor({ ntxId, note, attachmentTitle, renderSvg, ...props }: SvgSplitEditorProps) {
const [ svg, setSvg ] = useState<string>();
const [ error, setError ] = useState<string | null | undefined>();
- const containerRef = useRef<HTMLDivElement>(null);
// Reset the render state when switching notes so a previous note's render (and the
// "showing last valid render" badge) can't briefly carry over to a different note.
@@ -90,8 +87,8 @@ export default function SvgSplitEditor({ ntxId, note, attachmentTitle, renderSvg
}).catch(e => console.error("Failed to get attachments for SVGSplitEditor", e));
}, [ note, svg, attachmentTitle, onSave ]);
- // Import/export. The renderer's `svg` string is exported rather than the on-screen element,
- // which svg-pan-zoom has wrapped in a viewport transform reflecting the current pan/zoom.
+ // Import/export. The renderer's `svg` string is exported rather than the on-screen element, so
+ // the export never carries what the preview did to fit the diagram into its pane.
useTriliumEvent("exportSvg", ({ ntxId: eventNtxId }) => {
if (eventNtxId !== ntxId || !svg) return;
@@ -113,9 +110,6 @@ export default function SvgSplitEditor({ ntxId, note, attachmentTitle, renderSvg
}
});
- // Pan & zoom.
- const panZoom = useResizer(containerRef, note.noteId, svg);
-
return (
<SplitEditor
className="svg-editor"
@@ -126,168 +120,32 @@ export default function SvgSplitEditor({ ntxId, note, attachmentTitle, renderSvg
dataSaved={onSave}
placeholder={t("mermaid.placeholder")}
previewContent={(
- <RawHtmlBlock
- className="render-container"
- containerRef={containerRef}
- html={svg}
- />
+ <TransformWrapper
+ // The transform sits on an ancestor of the diagram, so it survives a re-render
+ // of the same note. Keying it on the note drops it when a different one opens.
+ key={note.noteId}
+ minScale={MIN_ZOOM}
+ maxScale={MAX_ZOOM}
+ centerOnInit
+ centerZoomedOut
+ doubleClick={{ mode: "reset" }}
+ >
+ <TransformComponent wrapperClass="svg-preview-viewport" contentClass="svg-preview-content">
+ <RawHtmlBlock className="render-container" html={svg} />
+ </TransformComponent>
+ </TransformWrapper>
)}
- previewButtons={<PreviewControls panZoom={panZoom} />}
{...props}
/>
);
}
/**
- * How far in and out the rendered diagram may be taken, as a multiple of the view it opened at —
- * svg-pan-zoom's own defaults, said here so that the steps and the library agree on where the ends
- * are rather than one of them finding out by being clamped.
+ * How far in and out the diagram can be taken, as a multiple of the view it opened at.
+ *
+ * CSS fits the SVG to the preview pane through its `viewBox` and `preserveAspectRatio` (see the SVG
+ * section of SplitEditor.css), so a scale of 1 already is that fitted view and these bounds need no
+ * measurement of their own.
*/
const MIN_ZOOM = 0.5;
const MAX_ZOOM = 10;
-/**
- * How near an end counts as being at it: the library clamps a step to the limit as an absolute scale,
- * and the trip back through the fitted scale can leave the readout a hair short of the round number.
- */
-const ZOOM_LIMIT_TOLERANCE = 1e-6;
-
-/**
- * The controls standing in the corner of a rendered diagram: how close in it is drawn, and the way
- * back to the view it opened at.
- *
- * They stand on the {@link OverlayControlGroup} the image viewer's zoom buttons stand on (see
- * {@link ImageViewer}), as the two maps' controls do, in place of the three floating buttons that
- * were here before. The readout between the steps says the scale the way the image viewer's does — a
- * hundred being the diagram at the size it was fitted to the pane at — and pressed, fits and centers
- * it there again, which is all the button wearing a crop mark used to do.
- *
- * Kept on mobile, unlike the image viewer's and the maps' steps: a pinch does nothing here — the
- * library follows a finger for panning and takes a double tap for a zoom in, and knows no pinch at
- * all — so the steps are the only way to settle on a scale. Absent until there is something to zoom,
- * an empty or not-yet-rendered diagram having no view to speak of.
- */
-function PreviewControls({ panZoom }: { panZoom: SvgPanZoom.Instance | undefined }) {
- const zoom = usePanZoomScale(panZoom);
-
- if (!panZoom) return null;
-
- return (
- <OverlayControlGroup className="svg-preview-controls" placement="bottom-end">
- <OverlayControlButton
- title={t("svg.zoom_out")}
- icon="bx-minus-circle"
- disabled={zoom <= MIN_ZOOM * (1 + ZOOM_LIMIT_TOLERANCE)}
- onClick={() => panZoom.zoomOut()}
- />
- <OverlayControlButton
- title={t("svg.reset_zoom")}
- text={`${Math.round(zoom * 100)}%`}
- onClick={() => panZoom.fit().center()}
- />
- <OverlayControlButton
- title={t("svg.zoom_in")}
- icon="bx-plus-circle"
- disabled={zoom >= MAX_ZOOM * (1 - ZOOM_LIMIT_TOLERANCE)}
- onClick={() => panZoom.zoomIn()}
- />
- </OverlayControlGroup>
- );
-}
-
-/**
- * The scale the diagram is drawn at, followed as it changes — by these buttons, by the wheel, or by
- * the diagram being fitted afresh. It is told as a multiple of the fitted view rather than of the
- * diagram's own coordinates, which is what makes a hundred mean the view the pane opened at.
- *
- * Nothing is unsubscribed on the way out: what stops the reports is the instance being destroyed by
- * the hook that made it, which drops the callback along with the rest of its options.
- */
-function usePanZoomScale(panZoom: SvgPanZoom.Instance | undefined) {
- const [ zoom, setZoom ] = useState(1);
-
- useEffect(() => {
- if (!panZoom) return;
-
- // It is fitted as it is built, and may have been moved again before being listened to.
- setZoom(panZoom.getZoom());
- panZoom.setOnZoom(setZoom);
- }, [ panZoom ]);
-
- return zoom;
-}
-
-/**
- * Sets the rendered diagram up to be panned and zoomed, and hands the instance driving it back so
- * that the controls over it can drive it too — as state rather than as the ref the effects here
- * keep, so that the controls are drawn afresh when the diagram is fitted anew under a different
- * instance.
- */
-function useResizer(containerRef: RefObject<HTMLDivElement>, noteId: string, svg: string | undefined) {
- const lastPanZoom = useRef<{ pan: SvgPanZoom.Point, zoom: number }>();
- const lastNoteId = useRef<string>();
- const wasEmpty = useRef<boolean>(false);
- const zoomRef = useRef<SvgPanZoom.Instance>();
- const [ panZoom, setPanZoom ] = useState<SvgPanZoom.Instance>();
- const width = useElementSize(containerRef);
-
- // Set up pan & zoom.
- useEffect(() => {
- if (zoomRef.current || width?.width === 0) return;
-
- const shouldPreservePanZoom = (lastNoteId.current === noteId) && !wasEmpty.current;
- const svgEl = containerRef.current?.querySelector("svg");
- if (!svgEl) {
- if (svg?.trim().length === 0) {
- wasEmpty.current = true;
- }
- return;
- };
-
- // svg-pan-zoom strips the SVG's viewBox attribute on init and never restores it on
- // destroy(), so a re-init (e.g. triggered by a `width` change below) would otherwise
- // fit from `getBBox()` instead. For mermaid gantt diagrams the bounding box is inflated
- // by an off-screen "today" marker, which makes the re-fit shrink the chart to invisibility
- // (issue #9749). Save it here and restore it in the cleanup below.
- const viewBox = svgEl.getAttribute("viewBox");
-
- const zoomInstance = svgPanZoom(svgEl, {
- zoomEnabled: true,
- controlIconsEnabled: false,
- minZoom: MIN_ZOOM,
- maxZoom: MAX_ZOOM
- });
-
- // Restore the previous pan/zoom if the user updates same note.
- if (shouldPreservePanZoom && lastPanZoom.current) {
- zoomInstance.zoom(lastPanZoom.current.zoom);
- zoomInstance.pan(lastPanZoom.current.pan);
- } else {
- zoomInstance.resize().center().fit();
- }
-
- lastNoteId.current = noteId;
- zoomRef.current = zoomInstance;
- setPanZoom(zoomInstance);
-
- return () => {
- lastPanZoom.current = {
- pan: zoomInstance.getPan(),
- zoom: zoomInstance.getZoom()
- };
- zoomRef.current = undefined;
- setPanZoom(undefined);
- zoomInstance.destroy();
- if (viewBox !== null) {
- svgEl.setAttribute("viewBox", viewBox);
- }
- };
- }, [ containerRef, noteId, svg, width ]);
-
- // React to container changes.
- useEffect(() => {
- if (!zoomRef.current || (width?.width ?? 0) < 1) return;
- zoomRef.current.resize().fit().center();
- }, [ width ]);
-
- return panZoom;
-}
diff --git a/apps/standalone/package.json b/apps/standalone/package.json
index 072270d050..1a61a4f3b0 100644
--- a/apps/standalone/package.json
+++ b/apps/standalone/package.json
@@ -59,7 +59,6 @@
"react-window": "2.3.1",
"react-zoom-pan-pinch": "4.2.0",
"reveal.js": "6.0.2",
- "svg-pan-zoom": "3.6.2",
"tabulator-tables": "6.5.2",
"temporal-polyfill": "1.0.5"
},
diff --git a/packages/trilium-e2e/src/note_types/mermaid.spec.ts b/packages/trilium-e2e/src/note_types/mermaid.spec.ts
index 269d8c0076..2105fdbef6 100644
--- a/packages/trilium-e2e/src/note_types/mermaid.spec.ts
+++ b/packages/trilium-e2e/src/note_types/mermaid.spec.ts
@@ -101,10 +101,9 @@ interface DividerDragTestOpts {
/**
* Regression test for issue #9749: mermaid gantt-based diagrams (which mermaid renders with a
* SVG `viewBox` inflated far beyond the visible chart, because of an off-screen "today" marker)
- * would collapse to a sub-pixel sliver after the split divider was dragged. The root cause was
- * that `svg-pan-zoom` strips the SVG's `viewBox` attribute on init and never restores it on
- * `destroy()`, so every divider-drag-triggered resize re-initialized pan/zoom by fitting from
- * `getBBox()` instead of the original `viewBox`, each time shrinking the effective scale further.
+ * would collapse to a sub-pixel sliver after the split divider was dragged, because the pan/zoom
+ * library re-fitted the diagram on every resize from a `viewBox` it had itself stripped. The
+ * preview now fits through the `viewBox` in CSS, so a resize re-fits nothing.
*
* The regression only shows up once the divider returns to (approximately) its original position:
* a one-directional drag legitimately shrinks the rendered diagram proportionally to the smaller
@@ -120,15 +119,16 @@ async function testDividerDragSurvival({ page, context, noteTitle }: DividerDrag
const svgData = app.currentNoteSplit.locator(".render-container svg");
await expect(svgData).toBeVisible();
- const viewport = app.currentNoteSplit.locator(".render-container svg .svg-pan-zoom_viewport");
- await expect(viewport).toBeVisible();
+ // The SVG itself always measures as the whole pane, so read the on-screen height of what it
+ // actually draws: its bounding box in user units, scaled by the CTM that puts it on the screen.
+ const drawnHeight = () => svgData.evaluate((svg: SVGSVGElement) =>
+ svg.getBBox().height * (svg.getScreenCTM()?.d ?? 0));
- // Let the initial pan/zoom fit settle (mounting can itself trigger one resize-driven re-init
- // as the ResizeObserver reports the container's real size shortly after mount).
+ // Let the layout settle, mermaid sizing the diagram shortly after it mounts.
await page.waitForTimeout(500);
- const beforeBox = requireBoundingBox(await viewport.boundingBox(), "viewport (before drag)");
- expect(beforeBox.height).toBeGreaterThan(0);
+ const beforeHeight = await drawnHeight();
+ expect(beforeHeight).toBeGreaterThan(0);
const gutter = app.currentNoteSplit.locator(".gutter");
await expect(gutter).toHaveCount(1);
@@ -153,12 +153,12 @@ async function testDividerDragSurvival({ page, context, noteTitle }: DividerDrag
await page.waitForTimeout(500);
- const afterBox = requireBoundingBox(await viewport.boundingBox(), "viewport (after drag)");
+ const afterHeight = await drawnHeight();
// With the bug, this collapses to a sub-pixel sliver (observed ratio ~0.001 or less) even
- // though the container returned to its original size. A healthy re-fit reproduces (close to)
+ // though the container returned to its original size. A healthy fit reproduces (close to)
// the original height.
- expect(afterBox.height).toBeGreaterThan(beforeBox.height * 0.5);
+ expect(afterHeight).toBeGreaterThan(beforeHeight * 0.5);
}
/**
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3d4173c8dc..b988ed16f7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -353,9 +353,6 @@ importers:
rrule:
specifier: 2.8.1
version: 2.8.1
- svg-pan-zoom:
- specifier: 3.6.2
- version: 3.6.2
tabulator-tables:
specifier: 6.5.2
version: 6.5.2
@@ -961,9 +958,6 @@ importers:
scrypt-js:
specifier: 3.0.1
version: 3.0.1
- svg-pan-zoom:
- specifier: 3.6.2
- version: 3.6.2
tabulator-tables:
specifier: 6.5.2
version: 6.5.2
@@ -10713,9 +10707,6 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
- resolution: {integrity: sha512-JwnvRWfVKw/Xzfe6jriFyfey/lWJLq4bUh2jwoR5ChWQuQoOH8FEh1l/bEp46iHHKHEJWIyFJETbazraxNWECg==}
-
resolution: {integrity: sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==}
@@ -23548,8 +23539,6 @@ snapshots:
-