mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 11:42:26 +08:00
client: Fix rendering notes if hljs is not loaded
This commit is contained in:
parent
2048a30aa5
commit
29e83b97e6
@ -371,7 +371,8 @@ class NoteListRenderer {
|
|||||||
$content.append($renderedContent);
|
$content.append($renderedContent);
|
||||||
$content.addClass(`type-${type}`);
|
$content.addClass(`type-${type}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Caught error while rendering note '${note.noteId}' of type '${note.type}': ${e.message}, stack: ${e.stack}`);
|
console.warn(`Caught error while rendering note '${note.noteId}' of type '${note.type}'`);
|
||||||
|
console.error(e);
|
||||||
|
|
||||||
$content.append("rendering error");
|
$content.append("rendering error");
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,7 @@ export function getStylesheetUrl(theme) {
|
|||||||
export async function applySyntaxHighlight($container) {
|
export async function applySyntaxHighlight($container) {
|
||||||
if (!isSyntaxHighlightEnabled()) {
|
if (!isSyntaxHighlightEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await library_loader.requireLibrary(library_loader.HIGHLIGHT_JS);
|
|
||||||
|
|
||||||
const codeBlocks = $container.find("pre code");
|
const codeBlocks = $container.find("pre code");
|
||||||
for (const codeBlock of codeBlocks) {
|
for (const codeBlock of codeBlocks) {
|
||||||
@ -48,6 +46,10 @@ export async function applySingleBlockSyntaxHighlight($codeBlock, normalizedMime
|
|||||||
$codeBlock.parent().toggleClass("hljs");
|
$codeBlock.parent().toggleClass("hljs");
|
||||||
const text = $codeBlock.text();
|
const text = $codeBlock.text();
|
||||||
|
|
||||||
|
if (!window.hljs) {
|
||||||
|
await library_loader.requireLibrary(library_loader.HIGHLIGHT_JS);
|
||||||
|
}
|
||||||
|
|
||||||
let highlightedText = null;
|
let highlightedText = null;
|
||||||
if (normalizedMimeType === mime_types.MIME_TYPE_AUTO) {
|
if (normalizedMimeType === mime_types.MIME_TYPE_AUTO) {
|
||||||
highlightedText = hljs.highlightAuto(text);
|
highlightedText = hljs.highlightAuto(text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user