From 698680455e492927b4ee63db30a13754af0b382b Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sun, 5 Jun 2022 19:03:17 +0800 Subject: [PATCH] tiptap: add default title when empty and can't editable --- .../core/wrappers/title/index.module.scss | 19 +++++-------------- .../src/tiptap/core/wrappers/title/index.tsx | 2 ++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/client/src/tiptap/core/wrappers/title/index.module.scss b/packages/client/src/tiptap/core/wrappers/title/index.module.scss index 28808a69..f6f25f25 100644 --- a/packages/client/src/tiptap/core/wrappers/title/index.module.scss +++ b/packages/client/src/tiptap/core/wrappers/title/index.module.scss @@ -1,4 +1,5 @@ .wrap { + position: relative; overflow: auto; .coverWrap { @@ -27,19 +28,9 @@ } } - .emoji { - display: inline-block; - width: 78px; - height: 78px; - font-size: 78px; - font-weight: normal; - line-height: 78px; - cursor: pointer; - - &:hover, - &:focus, - &:focus-within { - background-color: var(--semi-color-fill-1); - } + .emptyTitle { + position: absolute; + height: 0; + pointer-events: none; } } diff --git a/packages/client/src/tiptap/core/wrappers/title/index.tsx b/packages/client/src/tiptap/core/wrappers/title/index.tsx index b05fba2d..41830b1c 100644 --- a/packages/client/src/tiptap/core/wrappers/title/index.tsx +++ b/packages/client/src/tiptap/core/wrappers/title/index.tsx @@ -19,6 +19,7 @@ const images = [ export const TitleWrapper = ({ editor, node }) => { const isEditable = editor.isEditable; const { cover } = node.attrs; + const hasTitleContent = node.content.size > 0; const setCover = useCallback( (cover) => { @@ -62,6 +63,7 @@ export const TitleWrapper = ({ editor, node }) => { ) : null} + {!isEditable && !hasTitleContent && 未命名文档} );