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:
parent
0ddf5732a8
commit
4223864302
@ -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) {
|
||||
|
@ -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 = {}) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user