add an option to enable/disable take canvas snapshot
This commit is contained in:
@@ -167,6 +167,7 @@ function serializeNode(
|
|||||||
blockClass: string | RegExp,
|
blockClass: string | RegExp,
|
||||||
inlineStylesheet: boolean,
|
inlineStylesheet: boolean,
|
||||||
maskInputOptions: MaskInputOptions = {},
|
maskInputOptions: MaskInputOptions = {},
|
||||||
|
recordCanvas: boolean,
|
||||||
): serializedNode | false {
|
): serializedNode | false {
|
||||||
switch (n.nodeType) {
|
switch (n.nodeType) {
|
||||||
case n.DOCUMENT_NODE:
|
case n.DOCUMENT_NODE:
|
||||||
@@ -260,7 +261,7 @@ function serializeNode(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// canvas image data
|
// canvas image data
|
||||||
if (tagName === 'canvas') {
|
if (tagName === 'canvas' && recordCanvas) {
|
||||||
attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL();
|
attributes.rr_dataURL = (n as HTMLCanvasElement).toDataURL();
|
||||||
}
|
}
|
||||||
// media elements
|
// media elements
|
||||||
@@ -330,6 +331,7 @@ export function serializeNodeWithId(
|
|||||||
skipChild = false,
|
skipChild = false,
|
||||||
inlineStylesheet = true,
|
inlineStylesheet = true,
|
||||||
maskInputOptions?: MaskInputOptions,
|
maskInputOptions?: MaskInputOptions,
|
||||||
|
recordCanvas?: boolean,
|
||||||
): serializedNodeWithId | null {
|
): serializedNodeWithId | null {
|
||||||
const _serializedNode = serializeNode(
|
const _serializedNode = serializeNode(
|
||||||
n,
|
n,
|
||||||
@@ -337,6 +339,7 @@ export function serializeNodeWithId(
|
|||||||
blockClass,
|
blockClass,
|
||||||
inlineStylesheet,
|
inlineStylesheet,
|
||||||
maskInputOptions,
|
maskInputOptions,
|
||||||
|
recordCanvas || false,
|
||||||
);
|
);
|
||||||
if (!_serializedNode) {
|
if (!_serializedNode) {
|
||||||
// TODO: dev only
|
// TODO: dev only
|
||||||
@@ -373,6 +376,7 @@ export function serializeNodeWithId(
|
|||||||
skipChild,
|
skipChild,
|
||||||
inlineStylesheet,
|
inlineStylesheet,
|
||||||
maskInputOptions,
|
maskInputOptions,
|
||||||
|
recordCanvas,
|
||||||
);
|
);
|
||||||
if (serializedChildNode) {
|
if (serializedChildNode) {
|
||||||
serializedNode.childNodes.push(serializedChildNode);
|
serializedNode.childNodes.push(serializedChildNode);
|
||||||
@@ -387,6 +391,7 @@ function snapshot(
|
|||||||
blockClass: string | RegExp = 'rr-block',
|
blockClass: string | RegExp = 'rr-block',
|
||||||
inlineStylesheet = true,
|
inlineStylesheet = true,
|
||||||
maskAllInputsOrOptions: boolean | MaskInputOptions,
|
maskAllInputsOrOptions: boolean | MaskInputOptions,
|
||||||
|
recordCanvas?: boolean,
|
||||||
): [serializedNodeWithId | null, idNodeMap] {
|
): [serializedNodeWithId | null, idNodeMap] {
|
||||||
const idNodeMap: idNodeMap = {};
|
const idNodeMap: idNodeMap = {};
|
||||||
const maskInputOptions: MaskInputOptions =
|
const maskInputOptions: MaskInputOptions =
|
||||||
@@ -420,6 +425,7 @@ function snapshot(
|
|||||||
false,
|
false,
|
||||||
inlineStylesheet,
|
inlineStylesheet,
|
||||||
maskInputOptions,
|
maskInputOptions,
|
||||||
|
recordCanvas,
|
||||||
),
|
),
|
||||||
idNodeMap,
|
idNodeMap,
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user