From d686b1f0c5d54a7d2f716728c4b31acf56393373 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Wed, 26 Jun 2024 17:00:37 +0100 Subject: [PATCH] Fix `` (#4024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR: - fixes the placement of the InFrontOfTheCanvas component ### Change Type - [x] `sdk` — Changes the tldraw SDK - [x] `bugfix` — Bug fix ### Release Notes - Fixed placement of the InFrontOfTheCanvas component. --- packages/editor/editor.css | 15 +-- .../default-components/DefaultCanvas.tsx | 91 ++++++++++--------- packages/tldraw/src/lib/ui/TldrawUi.tsx | 13 +-- 3 files changed, 52 insertions(+), 67 deletions(-) diff --git a/packages/editor/editor.css b/packages/editor/editor.css index 2c668be97..3b25671f6 100644 --- a/packages/editor/editor.css +++ b/packages/editor/editor.css @@ -41,7 +41,6 @@ --layer-collaborator-cursor: 130; --layer-grid: 150; --layer-culled-shapes: 175; - --layer-canvas: 200; --layer-shapes: 300; --layer-overlays: 400; --layer-in-front-overlay: 500; @@ -257,7 +256,6 @@ input, height: 100%; width: 100%; color: var(--color-text); - z-index: var(--layer-canvas); cursor: var(--tl-cursor); overflow: clip; content-visibility: auto; @@ -313,17 +311,6 @@ input, pointer-events: none; } -.tl-front { - z-index: var(--layer-in-front); - position: absolute; - inset: 0px; - height: 100%; - width: 100%; - overflow: clip; - content-visibility: auto; - touch-action: none; - pointer-events: none; -} /* ------------------- Background ------------------- */ .tl-background__wrapper { @@ -1068,7 +1055,7 @@ input, display: flex; align-items: center; justify-content: center; - z-index: var(--layer-canvas); + z-index: 200; font-size: 12px; font-weight: 400; color: var(--color-text-1); diff --git a/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx b/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx index 99e650898..668abd686 100644 --- a/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx +++ b/packages/editor/src/lib/components/default-components/DefaultCanvas.tsx @@ -125,53 +125,62 @@ export function DefaultCanvas({ className }: TLCanvasComponentProps) { ) return ( -
- - - {shapeSvgDefs} - - - {SvgDefs && } - - - {Background && ( -
- + <> +
+ + + {shapeSvgDefs} + + + {SvgDefs && } + + + {Background && ( +
+ +
+ )} + +
+ + + {hideShapes ? null : debugSvg ? : }
- )} - -
- - - {hideShapes ? null : debugSvg ? : } -
-
-
- {debugGeometry ? : null} - - - - - - - - - +
+
+ {debugGeometry ? : null} + + + + + + + + + +
+
- -
+ + ) } +function InFrontOfTheCanvasWrapper() { + const { InFrontOfTheCanvas } = useEditorComponents() + if (!InFrontOfTheCanvas) return null + return +} + function GridWrapper() { const editor = useEditor() const gridSize = useValue('gridSize', () => editor.getDocumentSettings().gridSize, [editor]) diff --git a/packages/tldraw/src/lib/ui/TldrawUi.tsx b/packages/tldraw/src/lib/ui/TldrawUi.tsx index 637eb223b..37f42a4c1 100644 --- a/packages/tldraw/src/lib/ui/TldrawUi.tsx +++ b/packages/tldraw/src/lib/ui/TldrawUi.tsx @@ -1,4 +1,4 @@ -import { useEditor, useEditorComponents, useValue } from '@tldraw/editor' +import { useEditor, useValue } from '@tldraw/editor' import classNames from 'classnames' import React, { ReactNode } from 'react' import { TLUiAssetUrlOverrides } from './assetUrls' @@ -87,21 +87,10 @@ const TldrawUiInner = React.memo(function TldrawUiInner({ <> {children} {hideUi ? null : } - ) }) -function InFrontOfTheCanvasWrapper() { - const { InFrontOfTheCanvas } = useEditorComponents() - if (!InFrontOfTheCanvas) return null - return ( -
- -
- ) -} - const TldrawUiContent = React.memo(function TldrawUI() { const editor = useEditor() const msg = useTranslation()