fix: fix titile ux

This commit is contained in:
0xzion
2023-12-19 15:10:01 +08:00
parent d4f53b55d6
commit d86b04a321
2 changed files with 19 additions and 3 deletions

View File

@@ -52,5 +52,3 @@ yarn dev # start web service
## ⚖️ License
AGPL 3.0
What Is Open Source Software?

View File

@@ -1,6 +1,14 @@
import { useEffect } from 'react'
import { Box } from '@fower/react'
import { Node } from 'slate'
import {
ELEMENT_H1,
ELEMENT_H2,
ELEMENT_H3,
ELEMENT_H4,
ELEMENT_H5,
ELEMENT_H6,
} from '@penx/constants'
import { useEditor, useEditorStatic } from '@penx/editor-common'
import { useCompositionData } from '@penx/editor-composition'
import { ElementProps } from '@penx/extension-typings'
@@ -11,8 +19,18 @@ export const CommonTitle = ({
children,
}: ElementProps<TitleElement>) => {
const titleStr = Node.string(element)
const isHeading = [
ELEMENT_H1,
ELEMENT_H2,
ELEMENT_H3,
ELEMENT_H4,
ELEMENT_H5,
ELEMENT_H6,
].includes((element.children as any)?.[0]?.type || '')
const { compositionData } = useCompositionData(element.id)
const isPlaceholderShow = !titleStr?.length && !compositionData
const isPlaceholderShow = !titleStr?.length && !compositionData && !isHeading
return (
<Box