You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Chore: Fix build (#13050)
This commit is contained in:
@@ -10,24 +10,6 @@ import convertHtmlToMarkdown from './convertHtmlToMarkdown';
|
|||||||
import { ExportedWebViewGlobals as MarkdownEditorWebViewGlobals } from '../../markdownEditorBundle/types';
|
import { ExportedWebViewGlobals as MarkdownEditorWebViewGlobals } from '../../markdownEditorBundle/types';
|
||||||
import { EditorEventType } from '@joplin/editor/events';
|
import { EditorEventType } from '@joplin/editor/events';
|
||||||
|
|
||||||
const postprocessHtml = (html: HTMLElement) => {
|
|
||||||
// Fix resource URLs
|
|
||||||
const resources = html.querySelectorAll<HTMLImageElement>('img[data-resource-id]');
|
|
||||||
for (const resource of resources) {
|
|
||||||
const resourceId = resource.getAttribute('data-resource-id');
|
|
||||||
resource.src = `:/${resourceId}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore HREFs
|
|
||||||
const links = html.querySelectorAll<HTMLAnchorElement>('a[href="#"][data-original-href]');
|
|
||||||
for (const link of links) {
|
|
||||||
link.href = link.getAttribute('data-original-href');
|
|
||||||
link.removeAttribute('data-original-href');
|
|
||||||
}
|
|
||||||
|
|
||||||
return html;
|
|
||||||
};
|
|
||||||
|
|
||||||
const wrapHtmlForMarkdownConversion = (html: HTMLElement) => {
|
const wrapHtmlForMarkdownConversion = (html: HTMLElement) => {
|
||||||
// Add a container element -- when converting to HTML, Turndown
|
// Add a container element -- when converting to HTML, Turndown
|
||||||
// sometimes doesn't process the toplevel element in the same way
|
// sometimes doesn't process the toplevel element in the same way
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ const removeListItemWrapperParagraphs = (container: HTMLElement) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const restoreOriginalLinks = (container: HTMLElement) => {
|
||||||
|
// Restore HREFs
|
||||||
|
const links = container.querySelectorAll<HTMLAnchorElement>('a[href="#"][data-original-href]');
|
||||||
|
for (const link of links) {
|
||||||
|
link.href = link.getAttribute('data-original-href');
|
||||||
|
link.removeAttribute('data-original-href');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const postprocessEditorOutput = (node: Node|DocumentFragment) => {
|
const postprocessEditorOutput = (node: Node|DocumentFragment) => {
|
||||||
// By default, if `src` is specified on an image, the browser will try to load the image, even if it isn't added
|
// By default, if `src` is specified on an image, the browser will try to load the image, even if it isn't added
|
||||||
// to the DOM. (A similar problem is described here: https://stackoverflow.com/q/62019538).
|
// to the DOM. (A similar problem is described here: https://stackoverflow.com/q/62019538).
|
||||||
@@ -40,6 +50,7 @@ const postprocessEditorOutput = (node: Node|DocumentFragment) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fixResourceUrls(html);
|
fixResourceUrls(html);
|
||||||
|
restoreOriginalLinks(html);
|
||||||
removeListItemWrapperParagraphs(html);
|
removeListItemWrapperParagraphs(html);
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
|||||||
Reference in New Issue
Block a user