1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-17 20:48:11 +02:00

Desktop, Mobile: Do not add double newlines around attached files (#11690)

This commit is contained in:
Laurent Cozic 2025-01-21 10:25:28 +00:00 committed by GitHub
parent 0ddf5732a8
commit 4223864302
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -51,6 +51,7 @@ export async function commandAttachFileToBody(body: string, filePaths: string[]
createFileURL: options.createFileURL,
resizeLargeImages: Setting.value('imageResizing'),
markupLanguage: options.markupLanguage,
resourceSuffix: i > 0 ? ' ' : '',
});
if (!newBody) {

View File

@ -391,7 +391,13 @@ function shimInit(options: ShimInitOptions = null) {
};
shim.attachFileToNoteBody = async function(noteBody, filePath, position = null, options = null) {
options = { createFileURL: false, markupLanguage: 1, ...options };
options = {
createFileURL: false,
markupLanguage: 1,
resourcePrefix: '',
resourceSuffix: '',
...options,
};
const { basename } = require('path');
const { escapeTitleText } = require('./markdownUtils').default;
@ -412,16 +418,16 @@ function shimInit(options: ShimInitOptions = null) {
if (noteBody && position) newBody.push(noteBody.substr(0, position));
if (!options.createFileURL) {
newBody.push(Resource.markupTag(resource, options.markupLanguage));
newBody.push(options.resourcePrefix + Resource.markupTag(resource, options.markupLanguage) + options.resourceSuffix);
} else {
const filename = escapeTitleText(basename(filePath)); // to get same filename as standard drag and drop
const fileURL = `[${filename}](${toFileProtocolPath(filePath)})`;
newBody.push(fileURL);
newBody.push(options.resourcePrefix + fileURL + options.resourceSuffix);
}
if (noteBody) newBody.push(noteBody.substr(position));
return newBody.join('\n\n');
return newBody.join('');
};
shim.attachFileToNote = async function(note, filePath, options = {}) {