Add canvas image content support (#20)

* Add canvas image content support

* use rr_dataURL as the key so we know its a rrweb-added attribute.

* fix canvas rr_dataURL rebuild
This commit is contained in:
吴泽康
2026-04-01 12:00:00 +08:00
committed by yz-yu
parent 5c214f42b8
commit 94d64e3424
2 changed files with 24 additions and 8 deletions

View File

@@ -224,6 +224,10 @@ function serializeNode(
attributes.selected = (n as HTMLOptionElement).selected;
}
}
// canvas image data
if (tagName === 'canvas') {
attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL()
}
if (needBlock) {
const { width, height } = (n as HTMLElement).getBoundingClientRect();
attributes.rr_width = `${width}px`;