1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Desktop: Allow attaching a file from the Markdown editor for HTML notes

This commit is contained in:
Laurent Cozic
2023-10-31 16:53:47 +00:00
parent a95a66104d
commit a7dddaf2c4
13 changed files with 73 additions and 21 deletions

View File

@@ -332,7 +332,7 @@ function shimInit(options = null) {
};
shim.attachFileToNoteBody = async function(noteBody, filePath, position = null, options = null) {
options = { createFileURL: false, ...options };
options = { createFileURL: false, markupLanguage: 1, ...options };
const { basename } = require('path');
const { escapeTitleText } = require('./markdownUtils').default;
@@ -353,7 +353,7 @@ function shimInit(options = null) {
if (noteBody && position) newBody.push(noteBody.substr(0, position));
if (!options.createFileURL) {
newBody.push(Resource.markdownTag(resource));
newBody.push(Resource.markupTag(resource, options.markupLanguage));
} else {
const filename = escapeTitleText(basename(filePath)); // to get same filename as standard drag and drop
const fileURL = `[${filename}](${toFileProtocolPath(filePath)})`;
@@ -366,6 +366,7 @@ function shimInit(options = null) {
};
shim.attachFileToNote = async function(note, filePath, position = null, options = null) {
if (note.markup_language) options.markupLanguage = note.markup_language;
const newBody = await shim.attachFileToNoteBody(note.body, filePath, position, options);
if (!newBody) return null;