From d86b04a321faaa828ba013ab1533f5af3c38b0cc Mon Sep 17 00:00:00 2001 From: 0xzion <0xyz.penx@gmail.com> Date: Tue, 19 Dec 2023 15:10:01 +0800 Subject: [PATCH] fix: fix titile ux --- README.md | 2 -- extensions/list/src/ui/Title/CommonTitle.tsx | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c6f62d4..66a64e03 100644 --- a/README.md +++ b/README.md @@ -52,5 +52,3 @@ yarn dev # start web service ## ⚖️ License AGPL 3.0 - -What Is Open Source Software? diff --git a/extensions/list/src/ui/Title/CommonTitle.tsx b/extensions/list/src/ui/Title/CommonTitle.tsx index 1b3d1fcb..26059f97 100644 --- a/extensions/list/src/ui/Title/CommonTitle.tsx +++ b/extensions/list/src/ui/Title/CommonTitle.tsx @@ -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) => { 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 (