toeverything/AFFiNE · error
Missing edgeless selected rect
Error message
Missing edgeless selected rect
What it means
getSelectedRect queries the DOM for the edgeless-selected-rect element and its shadow-root rect; the error fires when that element is absent (e.g. copy-as-image triggered while no edgeless selection UI is rendered), so no bounding rect can be computed.
Source
Thrown at packages/frontend/core/src/blocksuite/view-extensions/editor-config/toolbar/copy-as-image.ts:34
import { CopyAsImgaeIcon } from '@blocksuite/icons/lit';
import type { FrameworkProvider } from '@toeverything/infra';
const snapshotStyle = `
affine-edgeless-root .widgets-container,
.copy-as-image-transparent {
opacity: 0;
}
.edgeless-background {
background-image: none;
}
`;
function getSelectedRect() {
const selected = document
.querySelector('edgeless-selected-rect')
?.shadowRoot?.querySelector('.affine-edgeless-selected-rect');
if (!selected) {
throw new Error('Missing edgeless selected rect');
}
return selected.getBoundingClientRect();
}
function expandBound(bound: Bound, margin: number) {
const x = bound.x - margin;
const y = bound.y - margin;
const w = bound.w + margin * 2;
const h = bound.h + margin * 2;
return new Bound(x, y, w, h);
}
function isOverlap(target: Bound, source: Bound) {
const { x, y, w, h } = source;
const left = target.x;
const top = target.y;
const right = target.x + target.w;
const bottom = target.y + target.h;View on GitHub (pinned to b4c8548c09)
Solutions
- Make a selection in edgeless mode before invoking copy-as-image.
- Disable the action when no selected rect is present.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown in getSelectedRect during copy-as-image when the edgeless-selected-rect element or its inner .affine-edgeless-selected-rect is not found in the DOM.
Common situations: Occurs when invoking Copy as image with no active canvas selection or before the selection UI has rendered. Select elements on the whiteboard first, then retry.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/066668641a6c21a1.
Report an issue: GitHub.