tiptap: add default title when empty and can't editable

This commit is contained in:
fantasticit 2022-06-05 19:03:17 +08:00
parent 28fe0c361a
commit 698680455e
2 changed files with 7 additions and 14 deletions

View File

@ -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;
}
}

View File

@ -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 }) => {
</ButtonGroup>
</div>
) : null}
{!isEditable && !hasTitleContent && <span className={styles.emptyTitle}></span>}
<NodeViewContent></NodeViewContent>
</NodeViewWrapper>
);