You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Desktop: Fixes #9511: HTML notes are not readable in dark mode
This commit is contained in:
@@ -3,6 +3,8 @@ import linkReplacement from './MdToHtml/linkReplacement';
|
||||
import utils, { ItemIdToUrlHandler } from './utils';
|
||||
import InMemoryCache from './InMemoryCache';
|
||||
import { RenderResult } from './MarkupToHtml';
|
||||
import noteStyle, { whiteBackgroundNoteStyle } from './noteStyle';
|
||||
import { Options as NoteStyleOptions } from './noteStyle';
|
||||
const md5 = require('md5');
|
||||
|
||||
// Renderered notes can potentially be quite large (for example
|
||||
@@ -39,6 +41,7 @@ interface RenderOptions {
|
||||
enableLongPress: boolean;
|
||||
itemIdToUrl?: ItemIdToUrlHandler;
|
||||
allowedFilePrefixes?: string[];
|
||||
whiteBackgroundNoteRendering?: boolean;
|
||||
}
|
||||
|
||||
// https://github.com/es-shims/String.prototype.trimStart/blob/main/implementation.js
|
||||
@@ -81,14 +84,22 @@ export default class HtmlToHtml {
|
||||
return this.fsDriver_;
|
||||
}
|
||||
|
||||
public async allAssets(/* theme*/): Promise<any[]> {
|
||||
return []; // TODO
|
||||
public async allAssets(theme: any, noteStyleOptions: NoteStyleOptions = null) {
|
||||
let cssStrings: string[] = [];
|
||||
|
||||
if (noteStyleOptions.whiteBackgroundNoteRendering) {
|
||||
cssStrings = [whiteBackgroundNoteStyle()];
|
||||
} else {
|
||||
cssStrings = [noteStyle(theme, noteStyleOptions).join('\n')];
|
||||
}
|
||||
|
||||
return [await this.fsDriver().cacheCssToFile(cssStrings)];
|
||||
}
|
||||
|
||||
// Note: the "theme" variable is ignored and instead the light theme is
|
||||
// always used for HTML notes.
|
||||
// See: https://github.com/laurent22/joplin/issues/3698
|
||||
public async render(markup: string, _theme: any, options: RenderOptions): Promise<RenderResult> {
|
||||
public async render(markup: string, theme: any, options: RenderOptions): Promise<RenderResult> {
|
||||
options = {
|
||||
splitted: false,
|
||||
postMessageSyntax: 'postMessage',
|
||||
@@ -152,9 +163,7 @@ export default class HtmlToHtml {
|
||||
};
|
||||
}
|
||||
|
||||
// const lightTheme = themeStyle(Setting.THEME_LIGHT);
|
||||
// let cssStrings = noteStyle(lightTheme);
|
||||
let cssStrings: string[] = [];
|
||||
let cssStrings = options.whiteBackgroundNoteRendering ? [whiteBackgroundNoteStyle()] : noteStyle(theme);
|
||||
|
||||
if (options.splitted) {
|
||||
const splitted = splitHtml(html);
|
||||
|
||||
Reference in New Issue
Block a user