Skip to content

Commit

Permalink
fix: redirect to whiteboard on edit
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc authored and tiensonqin committed Dec 28, 2022
1 parent ac1b535 commit 05010d1
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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))
Expand Down

0 comments on commit 05010d1

Please sign in to comment.