{"record":{"id":"066668641a6c21a1","repo":"toeverything/AFFiNE","slug":"missing-edgeless-selected-rect","errorCode":null,"errorMessage":"Missing edgeless selected rect","messagePattern":"Missing edgeless selected rect","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/blocksuite/view-extensions/editor-config/toolbar/copy-as-image.ts","lineNumber":34,"sourceCode":"import { CopyAsImgaeIcon } from '@blocksuite/icons/lit';\nimport type { FrameworkProvider } from '@toeverything/infra';\n\nconst snapshotStyle = `\n  affine-edgeless-root .widgets-container,\n  .copy-as-image-transparent {\n    opacity: 0;\n  }\n  .edgeless-background {\n    background-image: none;\n  }\n`;\n\nfunction getSelectedRect() {\n  const selected = document\n    .querySelector('edgeless-selected-rect')\n    ?.shadowRoot?.querySelector('.affine-edgeless-selected-rect');\n  if (!selected) {\n    throw new Error('Missing edgeless selected rect');\n  }\n  return selected.getBoundingClientRect();\n}\n\nfunction expandBound(bound: Bound, margin: number) {\n  const x = bound.x - margin;\n  const y = bound.y - margin;\n  const w = bound.w + margin * 2;\n  const h = bound.h + margin * 2;\n  return new Bound(x, y, w, h);\n}\n\nfunction isOverlap(target: Bound, source: Bound) {\n  const { x, y, w, h } = source;\n  const left = target.x;\n  const top = target.y;\n  const right = target.x + target.w;\n  const bottom = target.y + target.h;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/blocksuite/view-extensions/editor-config/toolbar/copy-as-image.ts#L16-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Make a selection in edgeless mode before invoking copy-as-image.","Disable the action when no selected rect is present."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}