You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Desktop, Mobile: Do not add double newlines around attached files (#11690)
This commit is contained in:
@@ -51,6 +51,7 @@ export async function commandAttachFileToBody(body: string, filePaths: string[]
|
|||||||
createFileURL: options.createFileURL,
|
createFileURL: options.createFileURL,
|
||||||
resizeLargeImages: Setting.value('imageResizing'),
|
resizeLargeImages: Setting.value('imageResizing'),
|
||||||
markupLanguage: options.markupLanguage,
|
markupLanguage: options.markupLanguage,
|
||||||
|
resourceSuffix: i > 0 ? ' ' : '',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!newBody) {
|
if (!newBody) {
|
||||||
|
|||||||
@@ -391,7 +391,13 @@ function shimInit(options: ShimInitOptions = null) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
shim.attachFileToNoteBody = async function(noteBody, filePath, position = null, options = 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 { basename } = require('path');
|
||||||
const { escapeTitleText } = require('./markdownUtils').default;
|
const { escapeTitleText } = require('./markdownUtils').default;
|
||||||
@@ -412,16 +418,16 @@ function shimInit(options: ShimInitOptions = null) {
|
|||||||
if (noteBody && position) newBody.push(noteBody.substr(0, position));
|
if (noteBody && position) newBody.push(noteBody.substr(0, position));
|
||||||
|
|
||||||
if (!options.createFileURL) {
|
if (!options.createFileURL) {
|
||||||
newBody.push(Resource.markupTag(resource, options.markupLanguage));
|
newBody.push(options.resourcePrefix + Resource.markupTag(resource, options.markupLanguage) + options.resourceSuffix);
|
||||||
} else {
|
} else {
|
||||||
const filename = escapeTitleText(basename(filePath)); // to get same filename as standard drag and drop
|
const filename = escapeTitleText(basename(filePath)); // to get same filename as standard drag and drop
|
||||||
const fileURL = `[${filename}](${toFileProtocolPath(filePath)})`;
|
const fileURL = `[${filename}](${toFileProtocolPath(filePath)})`;
|
||||||
newBody.push(fileURL);
|
newBody.push(options.resourcePrefix + fileURL + options.resourceSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noteBody) newBody.push(noteBody.substr(position));
|
if (noteBody) newBody.push(noteBody.substr(position));
|
||||||
|
|
||||||
return newBody.join('\n\n');
|
return newBody.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
shim.attachFileToNote = async function(note, filePath, options = {}) {
|
shim.attachFileToNote = async function(note, filePath, options = {}) {
|
||||||
|
|||||||
Reference in New Issue
Block a user