fix(editor): placeholder showing or not showing
This commit is contained in:
parent
2f3196ef86
commit
c61f1a45fb
@ -319,16 +319,18 @@ const editor = useEditor({
|
|||||||
Text,
|
Text,
|
||||||
|
|
||||||
Placeholder.configure({
|
Placeholder.configure({
|
||||||
placeholder: () => {
|
placeholder: ({editor}) => {
|
||||||
if (!isEditEnabled) {
|
if (!isEditEnabled) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placeholder !== '') {
|
if (editor.getText() !== '' && !editor.isFocused) {
|
||||||
return placeholder
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return t('input.editor.placeholder')
|
return placeholder !== ''
|
||||||
|
? placeholder
|
||||||
|
: t('input.editor.placeholder')
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Typography,
|
Typography,
|
||||||
@ -499,16 +501,9 @@ function setFocusToEditor(event) {
|
|||||||
&:focus-within, &:focus {
|
&:focus-within, &:focus {
|
||||||
box-shadow: 0 0 0 2px hsla(var(--primary-hsl), 0.5);
|
box-shadow: 0 0 0 2px hsla(var(--primary-hsl), 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-within, &:focus, &.tiptap__editor-is-empty {
|
|
||||||
.tiptap p.is-empty::before {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tiptap p.is-empty::before {
|
.tiptap p.is-empty::before {
|
||||||
display: none;
|
|
||||||
content: attr(data-placeholder);
|
content: attr(data-placeholder);
|
||||||
color: var(--grey-400);
|
color: var(--grey-400);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user