mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-18 20:16:34 +02:00
Desktop: Fixes #10733: Fix not-yet-created images lost while editing with the Rich Text Editor (#10734)
This commit is contained in:
@@ -3,7 +3,7 @@ import { attributesHtml } from '../../htmlUtils';
|
||||
import * as utils from '../../utils';
|
||||
|
||||
function renderImageHtml(before: string, src: string, after: string, ruleOptions: RuleOptions) {
|
||||
const r = utils.imageReplacement(ruleOptions.ResourceModel, src, ruleOptions.resources, ruleOptions.resourceBaseUrl, ruleOptions.itemIdToUrl);
|
||||
const r = utils.imageReplacement(ruleOptions.ResourceModel, { src, before, after }, ruleOptions.resources, ruleOptions.resourceBaseUrl, ruleOptions.itemIdToUrl);
|
||||
if (typeof r === 'string') return r;
|
||||
if (r) return `<img ${before} ${attributesHtml(r)} ${after}/>`;
|
||||
return `[Image: ${src}]`;
|
||||
|
||||
@@ -17,7 +17,8 @@ function plugin(markdownIt: any, ruleOptions: RuleOptions) {
|
||||
|
||||
if (!Resource.isResourceUrl(src) || ruleOptions.plainResourceRendering) return defaultRender(tokens, idx, options, env, self);
|
||||
|
||||
const r = utils.imageReplacement(ruleOptions.ResourceModel, src, ruleOptions.resources, ruleOptions.resourceBaseUrl, ruleOptions.itemIdToUrl);
|
||||
const alt = token.content;
|
||||
const r = utils.imageReplacement(ruleOptions.ResourceModel, { src, alt, title }, ruleOptions.resources, ruleOptions.resourceBaseUrl, ruleOptions.itemIdToUrl);
|
||||
if (typeof r === 'string') return r;
|
||||
if (r) {
|
||||
const id = r['data-resource-id'];
|
||||
@@ -35,7 +36,7 @@ function plugin(markdownIt: any, ruleOptions: RuleOptions) {
|
||||
destroyEditPopupSyntax: ruleOptions.destroyEditPopupSyntax,
|
||||
}, null);
|
||||
|
||||
return `<img data-from-md ${attributesHtml({ ...r, title: title, alt: token.content })} ${js}/>`;
|
||||
return `<img data-from-md ${attributesHtml({ ...r, title: title, alt })} ${js}/>`;
|
||||
}
|
||||
return defaultRender(tokens, idx, options, env, self);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user