{"record":{"id":"ee49801bf11f281b","repo":"toeverything/AFFiNE","slug":"edgelessexporterror","errorCode":"EdgelessExportError","errorMessage":"Could not find edgeless block component.","messagePattern":"Could not find edgeless block component\\.","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/affine/blocks/root/src/edgeless/clipboard/clipboard.ts","lineNumber":507,"sourceCode":"        boxShadowElements.forEach(function (element) {\n          if (element instanceof HTMLElement) {\n            element.style.setProperty('box-shadow', 'none');\n          }\n        });\n        await replaceImgSrcWithSvg?.(element);\n      },\n      backgroundColor: 'transparent',\n      useCORS: imageProxy ? false : true,\n      proxy: imageProxy,\n    };\n\n    const _drawTopLevelBlock = async (\n      block: GfxBlockElementModel,\n      isInFrame = false\n    ) => {\n      const blockComponent = this.std.view.getBlock(block.id);\n      if (!blockComponent) {\n        throw new BlockSuiteError(\n          ErrorCode.EdgelessExportError,\n          'Could not find edgeless block component.'\n        );\n      }\n\n      const blockBound = Bound.deserialize(block.xywh);\n      const canvasData = await html2canvas(\n        blockComponent as HTMLElement,\n        html2canvasOption\n      );\n      ctx.drawImage(\n        canvasData,\n        blockBound.x - bound.x + padding,\n        blockBound.y - bound.y + padding,\n        blockBound.w,\n        isInFrame\n          ? (blockBound.w / canvasData.width) * canvasData.height\n          : blockBound.h","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/26c515e050211269e911f7d9cfe162a26c83ed98/blocksuite/affine/blocks/root/src/edgeless/clipboard/clipboard.ts#L489-L525","documentation":"Thrown during edgeless-to-canvas export by _drawTopLevelBlock when std.view.getBlock(block.id) returns null/undefined for a block model being rendered to the canvas. html2canvas needs the live DOM component; if it is not mounted/registered in the view layer the export cannot proceed. Error code EdgelessExportError.","triggerScenarios":"Exporting an edgeless canvas to an image while one of the blocks in the export bound has no rendered component — e.g. it is lazy-loaded/virtualised off-screen, was just deleted, belongs to an unregistered flavour, or the view layer has not yet mounted it.","commonSituations":"Virtualised/lazy-rendered blocks not yet in the DOM at export time; exporting immediately after adding blocks before React mounts them; exporting a selection that includes a block whose flavour component is not registered; race after block deletion where the model lingers but the component is gone.","solutions":["Ensure all blocks in the export bound are mounted before exporting — scroll them into view or disable virtualisation during export.","Confirm all referenced block flavours have their components registered with the editor host.","Filter the node list passed to _edgelessToCanvas to blocks whose std.view.getBlock(id) is non-null, skipping unmounted ones."],"exampleFix":"// before\n// export selection includes a not-yet-mounted block -> throws\n\n// after\n// wait one frame / use the readiness check before exporting\nawait exportManager.docToCanvas(); // runs after _checkReady confirms mount","handlingStrategy":"validation","validationCode":"const mounted = nodes.filter(b => !!std.view.getBlock(b.id));\n// pass only mounted blocks to the export\nawait edgelessToCanvas(bound, mounted, canvasElements, opts);","typeGuard":"function isBlockMounted(std, id) {\n  return !!std.view.getBlock(id);\n}","tryCatchPattern":"import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';\ntry { await edgelessToCanvas(...); }\ncatch (e) {\n  if (e instanceof BlockSuiteError && e.code === ErrorCode.EdgelessExportError) {\n    // retry after ensuring mount, or skip missing blocks\n  } else throw e;\n}","preventionTips":["Ensure all blocks in the export bound are mounted (scroll into view / disable virtualisation) before exporting.","Register all block flavour components with the host.","Filter the node list to mounted components before exporting."],"tags":["edgeless","export","component-missing","edgeless-export-error"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}