update create new note

This commit is contained in:
duanfuxiang 2025-03-31 18:50:47 +08:00
parent d88e78c4ab
commit c415175de8

View File

@ -46,9 +46,10 @@ function CreateNewFileButton({ message }: { message: string }) {
const [created, setCreated] = useState(false)
const handleCreate = async () => {
const firstLine = message.split('\n')[0].trim().replace(/[\\\/:]/g, '');
const firstLine = message.trimStart().split('\n')[0].trim().replace(/[\\\/:]/g, '');
const filename = firstLine.slice(0, 200) + (firstLine.length > 200 ? '...' : '') || 'untitled';
await app.vault.create(`/${filename}.md`, message)
await app.workspace.openLinkText(filename, 'split', true)
setCreated(true)
setTimeout(() => {
setCreated(false)