Переглянути джерело

fix: redirect to whiteboard on edit

Konstantinos Kaloutas 2 роки тому
батько
коміт
05010d1c00

+ 10 - 0
tldraw/apps/tldraw-logseq/src/components/ContextBar/contextBarActionFactory.tsx

@@ -27,6 +27,7 @@ import {
   type ToggleGroupInputOption,
 } from '../inputs/ToggleGroupInput'
 import { ToggleInput } from '../inputs/ToggleInput'
+import { LogseqContext } from '../../lib/logseq-context'
 
 export const contextBarActionTypes = [
   // Order matters
@@ -85,8 +86,13 @@ function filterShapeByAction<S extends Shape>(shapes: Shape[], type: ContextBarA
 }
 
 const EditAction = observer(() => {
+  const {
+    handlers: { isWhiteboardPage, redirectToPage },
+  } = React.useContext(LogseqContext)
+
   const app = useApp<Shape>()
   const shape = filterShapeByAction(app.selectedShapesArray, 'Edit')[0]
+
   const iconName =
     ('label' in shape.props && shape.props.label) || ('text' in shape.props && shape.props.text)
       ? 'forms'
@@ -101,6 +107,10 @@ const EditAction = observer(() => {
         if (shape.props.type === 'logseq-portal') {
           let uuid = shape.props.pageId
           if (shape.props.blockType === 'P') {
+            if (isWhiteboardPage(uuid)) {
+              redirectToPage(uuid)
+            }
+
             const firstNonePropertyBlock = window.logseq?.api
               ?.get_page_blocks_tree?.(shape.props.pageId)
               .find(b => !('propertiesOrder' in b))