1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-10-09 22:22:31 +02:00

Desktop: Fixes #11662: Prevent the default note title from being " " (#11785)

This commit is contained in:
Henry Heino
2025-02-06 10:00:40 -08:00
committed by GitHub
parent c7031568a8
commit c55c8d62ec
2 changed files with 22 additions and 21 deletions

View File

@@ -216,12 +216,19 @@ const markdownUtils = {
titleFromBody(body: string) {
if (!body) return '';
const spaceEntities = / /g;
body = body.replace(spaceEntities, ' ');
const lines = body.trim().split('\n');
const title = lines[0].trim();
const mdLinkRegex = /!?\[([^\]]+?)\]\(.+?\)/g;
const emptyMdLinkRegex = /!?\[\]\((.+?)\)/g;
const filterRegex = /^[# \n\t*`-]*/;
const lines = body.trim().split('\n');
const title = lines[0].trim();
return title.replace(filterRegex, '').replace(mdLinkRegex, '$1').replace(emptyMdLinkRegex, '$1').substring(0, 80);
return title
.replace(filterRegex, '')
.replace(mdLinkRegex, '$1')
.replace(emptyMdLinkRegex, '$1')
.substring(0, 80);
},
};