Skip to content

Commit 94ea611

Browse files
committed
add an option to enable/disable take canvas snapshot
1 parent 3c406bd commit 94ea611

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/snapshot.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ function serializeNode(
167167
blockClass: string | RegExp,
168168
inlineStylesheet: boolean,
169169
maskInputOptions: MaskInputOptions = {},
170+
recordCanvas: boolean,
170171
): serializedNode | false {
171172
switch (n.nodeType) {
172173
case n.DOCUMENT_NODE:
@@ -260,7 +261,7 @@ function serializeNode(
260261
}
261262
}
262263
// canvas image data
263-
if (tagName === 'canvas') {
264+
if (tagName === 'canvas' && recordCanvas) {
264265
attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL();
265266
}
266267
// media elements
@@ -330,13 +331,15 @@ export function serializeNodeWithId(
330331
skipChild = false,
331332
inlineStylesheet = true,
332333
maskInputOptions?: MaskInputOptions,
334+
recordCanvas?: boolean,
333335
): serializedNodeWithId | null {
334336
const _serializedNode = serializeNode(
335337
n,
336338
doc,
337339
blockClass,
338340
inlineStylesheet,
339341
maskInputOptions,
342+
recordCanvas || false,
340343
);
341344
if (!_serializedNode) {
342345
// TODO: dev only
@@ -373,6 +376,7 @@ export function serializeNodeWithId(
373376
skipChild,
374377
inlineStylesheet,
375378
maskInputOptions,
379+
recordCanvas,
376380
);
377381
if (serializedChildNode) {
378382
serializedNode.childNodes.push(serializedChildNode);
@@ -387,6 +391,7 @@ function snapshot(
387391
blockClass: string | RegExp = 'rr-block',
388392
inlineStylesheet = true,
389393
maskAllInputsOrOptions: boolean | MaskInputOptions,
394+
recordCanvas?: boolean,
390395
): [serializedNodeWithId | null, idNodeMap] {
391396
const idNodeMap: idNodeMap = {};
392397
const maskInputOptions: MaskInputOptions =
@@ -420,6 +425,7 @@ function snapshot(
420425
false,
421426
inlineStylesheet,
422427
maskInputOptions,
428+
recordCanvas,
423429
),
424430
idNodeMap,
425431
];

0 commit comments

Comments
 (0)