Skip to content

Commit

Permalink
Desktop: Fixes #9607: Copied and pasted text from Firefox to RTE does…
Browse files Browse the repository at this point in the history
… not include images
  • Loading branch information
laurent22 committed Feb 8, 2024
1 parent b1877fc commit 11e1a49
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { fileUriToPath } from '@joplin/utils/url';
import { MarkupLanguage } from '@joplin/renderer';
import { HtmlToMarkdownHandler, MarkupToHtmlHandler } from './types';
import markupRenderOptions from './markupRenderOptions';
import { fileExtension, filename, safeFileExtension, safeFilename } from '@joplin/utils/path';
const joplinRendererUtils = require('@joplin/renderer').utils;
const { clipboard } = require('electron');
const mimeUtils = require('@joplin/lib/mime-utils.js').mime;
Expand Down Expand Up @@ -154,7 +155,11 @@ export async function processPastedHtml(html: string, htmlToMd: HtmlToMarkdownHa

const downloadImage = async (imageSrc: string) => {
try {
const filePath = `${Setting.value('tempDir')}/${md5(Date.now() + Math.random())}`;
const fileExt = safeFileExtension(fileExtension(imageSrc));
const name = safeFilename(filename(imageSrc));
const pieces = [name ? name : md5(Date.now() + Math.random())];
if (fileExt) pieces.push(fileExt);
const filePath = `${Setting.value('tempDir')}/${pieces.join('.')}`;
await shim.fetchBlob(imageSrc, { path: filePath });
const createdResource = await shim.createResourceFromPath(filePath);
await shim.fsDriver().remove(filePath);
Expand Down

0 comments on commit 11e1a49

Please sign in to comment.