Fixed placeholder text when adding formatting items
This commit is contained in:
@@ -29,7 +29,13 @@ export const TaskEditor: Component<TaskEditorProps> = (props) => {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Placeholder.configure({
|
Placeholder.configure({
|
||||||
placeholder: "Type '/' for commands or start writing...",
|
placeholder: ({ editor }) => {
|
||||||
|
// Only show placeholder if first node is a paragraph and doc is empty/short
|
||||||
|
if (editor.state.doc.childCount > 1 || (editor.state.doc.firstChild && editor.state.doc.firstChild.type.name !== 'paragraph')) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "Type '/' for commands or start writing...";
|
||||||
|
},
|
||||||
emptyEditorClass: "is-editor-empty before:content-[attr(data-placeholder)] before:text-muted-foreground before:float-left before:pointer-events-none before:h-0",
|
emptyEditorClass: "is-editor-empty before:content-[attr(data-placeholder)] before:text-muted-foreground before:float-left before:pointer-events-none before:h-0",
|
||||||
}),
|
}),
|
||||||
TaskList.configure({
|
TaskList.configure({
|
||||||
@@ -65,7 +71,7 @@ export const TaskEditor: Component<TaskEditorProps> = (props) => {
|
|||||||
"[&_ul[data-type='taskList']]:list-none [&_ul[data-type='taskList']]:p-0",
|
"[&_ul[data-type='taskList']]:list-none [&_ul[data-type='taskList']]:p-0",
|
||||||
"[&_li[data-type='taskItem']]:flex [&_li[data-type='taskItem']]:items-start",
|
"[&_li[data-type='taskItem']]:flex [&_li[data-type='taskItem']]:items-start",
|
||||||
"[&_li[data-type='taskItem']>label]:mr-2 [&_li[data-type='taskItem']>label]:mt-0.5 [&_li[data-type='taskItem']>label]:select-none",
|
"[&_li[data-type='taskItem']>label]:mr-2 [&_li[data-type='taskItem']>label]:mt-0.5 [&_li[data-type='taskItem']>label]:select-none",
|
||||||
"[&_li[data-type='taskItem']>div]:flex-1",
|
"[&_li[data-type='taskItem']>div]:flex-1 [&_li[data-type='taskItem']>div]:min-h-[1.5rem]",
|
||||||
props.class
|
props.class
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user