mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-22 16:28:36 +02:00
chore: editor focus between title and content
This commit is contained in:
@@ -224,8 +224,14 @@ const DetailPageForm = React.memo(({ page }: { page: PersonalPage }) => {
|
|||||||
handleKeyDown: handleTitleKeyDown,
|
handleKeyDown: handleTitleKeyDown,
|
||||||
},
|
},
|
||||||
onCreate: ({ editor }) => {
|
onCreate: ({ editor }) => {
|
||||||
if (page.title) editor.commands.setContent(`<p>${page.title}</p>`)
|
if (page.title) {
|
||||||
|
editor.commands.setContent(`<p>${page.title}</p>`)
|
||||||
|
}
|
||||||
titleEditorRef.current = editor
|
titleEditorRef.current = editor
|
||||||
|
|
||||||
|
if (!page.title) {
|
||||||
|
editor.commands.focus()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onBlur: ({ editor }) => handleUpdateTitle(editor),
|
onBlur: ({ editor }) => handleUpdateTitle(editor),
|
||||||
onUpdate: ({ editor }) => handleUpdateTitle(editor),
|
onUpdate: ({ editor }) => handleUpdateTitle(editor),
|
||||||
@@ -237,8 +243,12 @@ const DetailPageForm = React.memo(({ page }: { page: PersonalPage }) => {
|
|||||||
editor.commands.setContent(page.content as Content)
|
editor.commands.setContent(page.content as Content)
|
||||||
}
|
}
|
||||||
contentEditorRef.current = editor
|
contentEditorRef.current = editor
|
||||||
|
|
||||||
|
if (page.title) {
|
||||||
|
editor.commands.focus()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[page.content],
|
[page.content, page.title],
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user