Skip to content

Commit 36350bd

Browse files
committed
Merge branch 'main' of https://github.com/TriliumNext/Trilium into feat/ui/note-color
2 parents e53a225 + 63d430c commit 36350bd

File tree

85 files changed

+1811
-1230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1811
-1230
lines changed

_regroup/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@
3636
},
3737
"devDependencies": {
3838
"@playwright/test": "1.56.1",
39-
"@stylistic/eslint-plugin": "5.5.0",
39+
"@stylistic/eslint-plugin": "5.6.1",
4040
"@types/express": "5.0.5",
4141
"@types/node": "24.10.1",
4242
"@types/yargs": "17.0.35",
43-
"@vitest/coverage-v8": "3.2.4",
43+
"@vitest/coverage-v8": "4.0.10",
4444
"eslint": "9.39.1",
4545
"eslint-plugin-simple-import-sort": "12.1.1",
4646
"esm": "3.2.25",
4747
"jsdoc": "4.0.5",
4848
"lorem-ipsum": "2.0.8",
4949
"rcedit": "5.0.1",
50-
"rimraf": "6.1.0",
50+
"rimraf": "6.1.2",
5151
"tslib": "2.8.1"
5252
},
5353
"optionalDependencies": {

apps/client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"draggabilly": "3.0.0",
4545
"force-graph": "1.51.0",
4646
"globals": "16.5.0",
47-
"i18next": "25.6.2",
47+
"i18next": "25.6.3",
4848
"i18next-http-backend": "3.0.2",
4949
"jquery": "3.7.1",
5050
"jquery.fancytree": "2.38.5",
@@ -54,13 +54,13 @@
5454
"leaflet": "1.9.4",
5555
"leaflet-gpx": "2.2.0",
5656
"mark.js": "8.11.1",
57-
"marked": "16.4.2",
57+
"marked": "17.0.0",
5858
"mermaid": "11.12.1",
5959
"mind-elixir": "5.3.6",
6060
"normalize.css": "8.0.1",
6161
"panzoom": "9.4.3",
6262
"preact": "10.27.2",
63-
"react-i18next": "16.3.3",
63+
"react-i18next": "16.3.5",
6464
"reveal.js": "5.2.1",
6565
"svg-pan-zoom": "3.6.2",
6666
"tabulator-tables": "6.3.1",

apps/client/src/components/tab_manager.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,32 @@ export default class TabManager extends Component {
647647
...this.noteContexts.slice(-noteContexts.length),
648648
...this.noteContexts.slice(lastClosedTab.position, -noteContexts.length)
649649
];
650-
this.noteContextReorderEvent({ ntxIdsInOrder: ntxsInOrder.map((nc) => nc.ntxId).filter((id) => id !== null) });
650+
651+
// Update mainNtxId if the restored pane is the main pane in the split pane
652+
const { oldMainNtxId, newMainNtxId } = (() => {
653+
if (noteContexts.length !== 1) {
654+
return { oldMainNtxId: undefined, newMainNtxId: undefined };
655+
}
656+
657+
const mainNtxId = noteContexts[0]?.mainNtxId;
658+
const index = this.noteContexts.findIndex(c => c.ntxId === mainNtxId);
659+
660+
// No need to update if the restored position is after mainNtxId
661+
if (index === -1 || lastClosedTab.position > index) {
662+
return { oldMainNtxId: undefined, newMainNtxId: undefined };
663+
}
664+
665+
return {
666+
oldMainNtxId: this.noteContexts[index].ntxId ?? undefined,
667+
newMainNtxId: noteContexts[0]?.ntxId ?? undefined
668+
};
669+
})();
670+
671+
this.triggerCommand("noteContextReorder", {
672+
ntxIdsInOrder: ntxsInOrder.map((nc) => nc.ntxId).filter((id) => id !== null),
673+
oldMainNtxId,
674+
newMainNtxId
675+
});
651676

652677
let mainNtx = noteContexts.find((nc) => nc.isMainContext());
653678
if (mainNtx) {

apps/client/src/print.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import FNote from "./entities/fnote";
22
import { render } from "preact";
3-
import { CustomNoteList } from "./widgets/collections/NoteList";
3+
import { CustomNoteList, useNoteViewType } from "./widgets/collections/NoteList";
44
import { useCallback, useLayoutEffect, useRef } from "preact/hooks";
5-
import content_renderer from "./services/content_renderer";
5+
import content_renderer, { applyInlineMermaid } from "./services/content_renderer";
66

77
interface RendererProps {
88
note: FNote;
@@ -71,6 +71,11 @@ function SingleNoteRenderer({ note, onReady }: RendererProps) {
7171
})
7272
);
7373

74+
// Initialize mermaid.
75+
if (note.type === "text") {
76+
await applyInlineMermaid(container);
77+
}
78+
7479
// Check custom CSS.
7580
await loadCustomCss(note);
7681
}
@@ -85,7 +90,9 @@ function SingleNoteRenderer({ note, onReady }: RendererProps) {
8590
}
8691

8792
function CollectionRenderer({ note, onReady }: RendererProps) {
93+
const viewType = useNoteViewType(note);
8894
return <CustomNoteList
95+
viewType={viewType}
8996
isEnabled
9097
note={note}
9198
notePath={note.getBestNotePath().join("/")}

apps/client/src/services/branches.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,6 @@ async function moveNodeUpInHierarchy(node: Fancytree.FancytreeNode) {
176176
toastService.showError(resp.message);
177177
return;
178178
}
179-
180-
if (!hoistedNoteService.isTopLevelNode(node) && node.getParent().getChildren().length <= 1) {
181-
node.getParent().folder = false;
182-
node.getParent().renderTitle();
183-
}
184179
}
185180

186181
function filterSearchBranches(branchIds: string[]) {

apps/client/src/services/content_renderer.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import FNote from "../entities/fnote.js";
1010
import FAttachment from "../entities/fattachment.js";
1111
import imageContextMenuService from "../menus/image_context_menu.js";
1212
import { applySingleBlockSyntaxHighlight, formatCodeBlocks } from "./syntax_highlight.js";
13-
import { loadElkIfNeeded, postprocessMermaidSvg } from "./mermaid.js";
13+
import { getMermaidConfig, loadElkIfNeeded, postprocessMermaidSvg } from "./mermaid.js";
1414
import renderDoc from "./doc_renderer.js";
1515
import { t } from "../services/i18n.js";
1616
import WheelZoom from 'vanilla-js-wheel-zoom';
@@ -136,6 +136,7 @@ async function renderText(note: FNote | FAttachment, $renderedContent: JQuery<HT
136136
await linkService.loadReferenceLinkTitle($(el));
137137
}
138138

139+
await rewriteMermaidDiagramsInContainer($renderedContent[0] as HTMLDivElement);
139140
await formatCodeBlocks($renderedContent);
140141
} else if (note instanceof FNote && !options.noChildrenList) {
141142
await renderChildrenList($renderedContent, note);
@@ -370,6 +371,34 @@ function getRenderingType(entity: FNote | FAttachment) {
370371
return type;
371372
}
372373

374+
/** Rewrite the code block from <pre><code> to <div> in order not to apply a codeblock style to it. */
375+
export async function rewriteMermaidDiagramsInContainer(container: HTMLDivElement) {
376+
const mermaidBlocks = container.querySelectorAll('pre:has(code[class="language-mermaid"])');
377+
if (!mermaidBlocks.length) return;
378+
const nodes: HTMLElement[] = [];
379+
380+
for (const mermaidBlock of mermaidBlocks) {
381+
const div = document.createElement("div");
382+
div.classList.add("mermaid-diagram");
383+
div.innerHTML = mermaidBlock.querySelector("code")?.innerHTML ?? "";
384+
mermaidBlock.replaceWith(div);
385+
nodes.push(div);
386+
}
387+
}
388+
389+
export async function applyInlineMermaid(container: HTMLDivElement) {
390+
// Initialize mermaid
391+
const mermaid = (await import("mermaid")).default;
392+
mermaid.initialize(getMermaidConfig());
393+
const nodes = Array.from(container.querySelectorAll<HTMLElement>("div.mermaid-diagram"));
394+
console.log("Got nodes", nodes);
395+
try {
396+
await mermaid.run({ nodes });
397+
} catch (e) {
398+
console.log(e);
399+
}
400+
}
401+
373402
export default {
374403
getRenderedContent
375404
};

apps/client/src/services/link.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -467,28 +467,30 @@ function getReferenceLinkTitleSync(href: string) {
467467
}
468468
}
469469

470-
// TODO: Check why the event is not supported.
471-
//@ts-ignore
472-
$(document).on("click", "a", goToLink);
473-
// TODO: Check why the event is not supported.
474-
//@ts-ignore
475-
$(document).on("auxclick", "a", goToLink); // to handle the middle button
476-
// TODO: Check why the event is not supported.
477-
//@ts-ignore
478-
$(document).on("contextmenu", "a", linkContextMenu);
479-
// TODO: Check why the event is not supported.
480-
//@ts-ignore
481-
$(document).on("dblclick", "a", goToLink);
482-
483-
$(document).on("mousedown", "a", (e) => {
484-
if (e.which === 2) {
485-
// prevent paste on middle click
486-
// https://github.com/zadam/trilium/issues/2995
487-
// https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event#preventing_default_actions
488-
e.preventDefault();
489-
return false;
490-
}
491-
});
470+
if (glob.device !== "print") {
471+
// TODO: Check why the event is not supported.
472+
//@ts-ignore
473+
$(document).on("click", "a", goToLink);
474+
// TODO: Check why the event is not supported.
475+
//@ts-ignore
476+
$(document).on("auxclick", "a", goToLink); // to handle the middle button
477+
// TODO: Check why the event is not supported.
478+
//@ts-ignore
479+
$(document).on("contextmenu", "a", linkContextMenu);
480+
// TODO: Check why the event is not supported.
481+
//@ts-ignore
482+
$(document).on("dblclick", "a", goToLink);
483+
484+
$(document).on("mousedown", "a", (e) => {
485+
if (e.which === 2) {
486+
// prevent paste on middle click
487+
// https://github.com/zadam/trilium/issues/2995
488+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event#preventing_default_actions
489+
e.preventDefault();
490+
return false;
491+
}
492+
});
493+
}
492494

493495
export default {
494496
getNotePathFromUrl,

apps/client/src/services/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function resolveNotePathToSegments(notePath: string, hoistedNoteId = "root
8989

9090
effectivePathSegments.reverse();
9191

92-
if (effectivePathSegments.includes(hoistedNoteId)) {
92+
if (effectivePathSegments.includes(hoistedNoteId) && effectivePathSegments.includes('root')) {
9393
return effectivePathSegments;
9494
} else {
9595
const noteId = getNoteIdFromUrl(notePath);

apps/client/src/stylesheets/style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,15 @@ footer.webview-footer button {
24382438
.admonition.caution::before { content: "\eac7"; }
24392439
.admonition.warning::before { content: "\eac5"; }
24402440

2441+
.ck-content ul.todo-list li span.todo-list__label__description {
2442+
transition: opacity 200ms ease;
2443+
}
2444+
2445+
.ck-content ul.todo-list li:has(input[type="checkbox"]:checked) span.todo-list__label__description {
2446+
text-decoration: line-through;
2447+
opacity: 0.6;
2448+
}
2449+
24412450
.chat-options-container {
24422451
display: flex;
24432452
margin: 5px 0;

apps/client/src/translations/cn/translation.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,8 @@
20192019
"add-column-placeholder": "请输入列名...",
20202020
"edit-note-title": "点击编辑笔记标题",
20212021
"edit-column-title": "点击编辑列标题",
2022-
"remove-from-board": "从看板上移除"
2022+
"remove-from-board": "从看板上移除",
2023+
"column-already-exists": "此列已在看板上。"
20232024
},
20242025
"command_palette": {
20252026
"tree-action-name": "树形:{{name}}",

0 commit comments

Comments
 (0)