diff --git a/package.json b/package.json index 3c83e385..fb1396f1 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "dependencies": { "@types/smoothscroll-polyfill": "^0.3.0", "mitt": "^1.1.3", - "rrweb-snapshot": "^0.7.9", + "rrweb-snapshot": "^0.7.10", "smoothscroll-polyfill": "^0.4.3" } } diff --git a/src/record/index.ts b/src/record/index.ts index abff9f30..6c299ec2 100644 --- a/src/record/index.ts +++ b/src/record/index.ts @@ -24,6 +24,7 @@ function record(options: recordOptions = {}): listenerHandler | undefined { checkoutEveryNth, blockClass = 'rr-block', ignoreClass = 'rr-ignore', + inlineStylesheet = true, } = options; // runtime checks for user options if (!emit) { @@ -62,7 +63,7 @@ function record(options: recordOptions = {}): listenerHandler | undefined { }), isCheckout, ); - const [node, idNodeMap] = snapshot(document, blockClass); + const [node, idNodeMap] = snapshot(document, blockClass, inlineStylesheet); if (!node) { return console.warn('Failed to snapshot the document'); } @@ -160,6 +161,7 @@ function record(options: recordOptions = {}): listenerHandler | undefined { ), blockClass, ignoreClass, + inlineStylesheet, }), ); }; diff --git a/src/record/observer.ts b/src/record/observer.ts index 86be84bd..51484073 100644 --- a/src/record/observer.ts +++ b/src/record/observer.ts @@ -50,6 +50,7 @@ import { deepDelete, isParentRemoved, isParentDropped } from './collection'; function initMutationObserver( cb: mutationCallBack, blockClass: blockClass, + inlineStylesheet: boolean, ): MutationObserver { const observer = new MutationObserver(mutations => { const texts: textCursor[] = []; @@ -407,7 +408,11 @@ function initInputObserver( } export default function initObservers(o: observerParam): listenerHandler { - const mutationObserver = initMutationObserver(o.mutationCb, o.blockClass); + const mutationObserver = initMutationObserver( + o.mutationCb, + o.blockClass, + o.inlineStylesheet, + ); const mousemoveHandler = initMousemoveObserver(o.mousemoveCb); const mouseInteractionHandler = initMouseInteractionObserver( o.mouseInteractionCb, diff --git a/src/replay/styles/style.css b/src/replay/styles/style.css index f362740a..d21e1eb7 100644 --- a/src/replay/styles/style.css +++ b/src/replay/styles/style.css @@ -1,3 +1,6 @@ +body { + margin: 0; +} .replayer-wrapper { position: relative; } diff --git a/src/types.ts b/src/types.ts index a17c3986..14c043fe 100644 --- a/src/types.ts +++ b/src/types.ts @@ -106,6 +106,7 @@ export type recordOptions = { checkoutEveryNms?: number; blockClass?: blockClass; ignoreClass?: string; + inlineStylesheet?: boolean; }; export type observerParam = { @@ -117,6 +118,7 @@ export type observerParam = { inputCb: inputCallback; blockClass: blockClass; ignoreClass: string; + inlineStylesheet: boolean; }; export type textCursor = {