diff --git a/apps/roam/src/components/canvas/Tldraw.tsx b/apps/roam/src/components/canvas/Tldraw.tsx index 5413fb186..4ac11d5a4 100644 --- a/apps/roam/src/components/canvas/Tldraw.tsx +++ b/apps/roam/src/components/canvas/Tldraw.tsx @@ -936,6 +936,7 @@ const renderTldrawCanvasHelper = ({ childFromRoot.parentElement && !childFromRoot.hasAttribute(TLDRAW_DATA_ATTRIBUTE) ) { + rootElement.setAttribute(TLDRAW_DATA_ATTRIBUTE, "true"); childFromRoot.setAttribute(TLDRAW_DATA_ATTRIBUTE, "true"); const parentEl = childFromRoot.parentElement; parentEl.appendChild(canvasWrapperEl); @@ -943,15 +944,6 @@ const renderTldrawCanvasHelper = ({ canvasWrapperEl.style.height = height; } - // console.log( - // "blockChildrenContainer.parentElement", - // articleChildren.parentElement, - // ); - // articleChildren.parentElement?.insertBefore( - // canvasWrapperEl, - // articleChildren.nextSibling, - // ); - const unmount = renderWithUnmount( @@ -963,6 +955,7 @@ const renderTldrawCanvasHelper = ({ return () => { originalUnmount(); childFromRoot.removeAttribute(TLDRAW_DATA_ATTRIBUTE); + rootElement.removeAttribute(TLDRAW_DATA_ATTRIBUTE); canvasWrapperEl.remove(); }; }; diff --git a/apps/roam/src/components/canvas/tldrawStyles.ts b/apps/roam/src/components/canvas/tldrawStyles.ts index 14f004e5a..46acf3621 100644 --- a/apps/roam/src/components/canvas/tldrawStyles.ts +++ b/apps/roam/src/components/canvas/tldrawStyles.ts @@ -2,12 +2,12 @@ export const TLDRAW_DATA_ATTRIBUTE = "dg-tldraw-canvas-wrapper"; export default ` /* Hide Roam Blocks only when canvas is present */ - .roam-article .rm-block-children[${TLDRAW_DATA_ATTRIBUTE}="true"] { + .roam-article[${TLDRAW_DATA_ATTRIBUTE}="true"] .rm-block-children { display: none; } /* Hide Roam Blocks in sidebar when canvas is present */ - .rm-sidebar-outline .rm-block-children[${TLDRAW_DATA_ATTRIBUTE}="true"] { + .rm-sidebar-outline[${TLDRAW_DATA_ATTRIBUTE}="true"] .rm-block-children { display: none; }