You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-09-16 08:56:40 +02:00
Desktop: Fixes #9304: Fix HTML resource links lost when editing notes in the rich text editor (#9435)
This commit is contained in:
@@ -38,6 +38,7 @@ interface RenderOptions {
|
||||
postMessageSyntax: string;
|
||||
enableLongPress: boolean;
|
||||
itemIdToUrl?: ItemIdToUrlHandler;
|
||||
allowedFilePrefixes?: string[];
|
||||
}
|
||||
|
||||
// https://github.com/es-shims/String.prototype.trimStart/blob/main/implementation.js
|
||||
@@ -99,7 +100,9 @@ export default class HtmlToHtml {
|
||||
let html = this.cache_.value(cacheKey);
|
||||
|
||||
if (!html) {
|
||||
html = htmlUtils.sanitizeHtml(markup);
|
||||
html = htmlUtils.sanitizeHtml(markup, {
|
||||
allowedFilePrefixes: options.allowedFilePrefixes,
|
||||
});
|
||||
|
||||
html = htmlUtils.processImageTags(html, (data: any) => {
|
||||
if (!data.src) return null;
|
||||
|
@@ -192,6 +192,10 @@ export interface RuleOptions {
|
||||
vendorDir?: string;
|
||||
itemIdToUrl?: ItemIdToUrlHandler;
|
||||
|
||||
// Passed to the HTML sanitizer: Allows file:// URLs with
|
||||
// paths with the included prefixes.
|
||||
allowedFilePrefixes?: string[];
|
||||
|
||||
platformName?: string;
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,13 @@ export default {
|
||||
// So the sanitizeHtml function must handle this kind of non-valid HTML.
|
||||
|
||||
if (!sanitizedContent) {
|
||||
sanitizedContent = htmlUtils.sanitizeHtml(token.content, { addNoMdConvClass: true });
|
||||
sanitizedContent = htmlUtils.sanitizeHtml(
|
||||
token.content,
|
||||
{
|
||||
addNoMdConvClass: true,
|
||||
allowedFilePrefixes: ruleOptions.allowedFilePrefixes,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
token.content = sanitizedContent;
|
||||
|
@@ -189,10 +189,12 @@ class HtmlUtils {
|
||||
// If true, adds a "jop-noMdConv" class to all the tags.
|
||||
// It can be used afterwards to restore HTML tags in Markdown.
|
||||
addNoMdConvClass: false,
|
||||
allowedFilePrefixes: [],
|
||||
...options,
|
||||
};
|
||||
|
||||
// If options.allowedFilePrefixes is `undefined`, default to [].
|
||||
options.allowedFilePrefixes ??= [];
|
||||
|
||||
const output: string[] = [];
|
||||
|
||||
const tagStack: string[] = [];
|
||||
|
Reference in New Issue
Block a user