Compare commits

...

12 Commits

Author SHA1 Message Date
Romain DEP.
afd4cf0575
Merge a1c03143342078c68301cc7bc51a68ce4840c5dc into 32c16021c420ce10f630d98b00f8735f0bf2fdd7 2025-12-01 01:01:11 +00:00
Adorian Doran
32c16021c4 style/calendar collection: refactor
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on linux-arm64 (push) Waiting to run
playwright / E2E tests on linux-x64 (push) Waiting to run
2025-12-01 03:00:38 +02:00
Adorian Doran
7713c1173a style/calendar collection: tweak the color of the today column / cell 2025-12-01 02:40:07 +02:00
Adorian Doran
8018f400c3 style/calendar collection: correct a hover color 2025-12-01 02:26:16 +02:00
Adorian Doran
79c8293881 style/calendar collection: handle dot events as normal events 2025-12-01 02:21:19 +02:00
Adorian Doran
db5652623b style/calendar collection: fix broken background color for events without a hue 2025-12-01 02:04:26 +02:00
Adorian Doran
0f7a48b323 style/calendar collection: add basic support for the legacy theme 2025-12-01 01:55:03 +02:00
Adorian Doran
415d2826c6 style/calendar collection: tweak dark theme colors 2025-11-30 23:30:30 +02:00
Adorian Doran
7787e7085e style/calendar collection: tweak dark theme colors 2025-11-30 23:22:41 +02:00
Elian Doran
4ab8417168
feat(forge): add safeguard for ARM64 better-sqlite3 binary 2025-11-30 22:57:14 +02:00
Romain DEP.
a1c0314334 chore(sorting): add test cases for previous commit and increase test coverage 2025-11-28 23:28:14 +01:00
Romain DEP.
3ecdcd9ea0 fix(sorting): BC! give precedence to #top notes over #sortFolderFirst 2025-11-28 23:22:20 +01:00
10 changed files with 180 additions and 44 deletions

View File

@ -27,6 +27,9 @@
--bs-body-bg: var(--main-background-color) !important;
--ck-mention-list-max-height: 500px;
--tn-modal-max-height: 90vh;
--tree-item-light-theme-max-color-lightness: 50;
--tree-item-dark-theme-min-color-lightness: 75;
}
body#trilium-app.motion-disabled *,
@ -2579,4 +2582,12 @@ iframe.print-iframe {
position: relative;
flex-grow: 1;
width: 100%;
}
/* Calendar collection */
.calendar-view a.fc-timegrid-event,
.calendar-view a.fc-daygrid-event {
/* Workaround: set font weight only if the theme-next is not active */
font-weight: var(--root-background, 800);
}

View File

@ -76,6 +76,9 @@
--mermaid-theme: dark;
--native-titlebar-background: #00000000;
--calendar-coll-event-background-saturation: 30%;
--calendar-coll-event-background-lightness: 30%;
}
body ::-webkit-calendar-picker-indicator {

View File

@ -80,6 +80,9 @@ html {
--mermaid-theme: default;
--native-titlebar-background: #ffffff00;
--calendar-coll-event-background-lightness: 95%;
--calendar-coll-event-background-saturation: 80%;
}
#left-pane .fancytree-node.tinted {

View File

@ -271,11 +271,12 @@
--ck-editor-toolbar-button-on-shadow: 1px 1px 2px rgba(0, 0, 0, .75);
--ck-editor-toolbar-dropdown-button-open-background: #ffffff14;
--calendar-coll-event-background-saturation: 12%;
--calendar-coll-event-background-lightness: 21%;
--calendar-coll-event-background-saturation: 25%;
--calendar-coll-event-background-lightness: 20%;
--calendar-coll-event-background-color: #3c3c3c;
--calendar-coll-event-text-color: white;
--calendar-cell-event-hover-filter: brightness(1.25);
--calendar-coll-today-background-color: #ffffff08;
}
/*

View File

@ -274,6 +274,7 @@
--calendar-coll-event-background-color: #eaeaea;
--calendar-coll-event-text-color: black;
--calendar-cell-event-hover-filter: brightness(.95) saturate(1.25);
--calendar-coll-today-background-color: #00000006;
}
#left-pane .fancytree-node.tinted {

View File

@ -81,7 +81,6 @@ export async function buildEventsForCalendar(note: FNote, e: EventSourceFuncArg)
export async function buildEvent(note: FNote, { startDate, endDate, startTime, endTime, isArchived }: Event) {
const customTitleAttributeName = note.getLabelValue("calendar:title");
const titles = await parseCustomTitle(customTitleAttributeName, note);
const color = note.getLabelValue("calendar:color") ?? note.getLabelValue("color");
const colorClass = note.getColorClass();
const events: EventInput[] = [];
@ -110,7 +109,6 @@ export async function buildEvent(note: FNote, { startDate, endDate, startTime, e
start: startDate,
url: `#${note.noteId}?popup`,
noteId: note.noteId,
color: color ?? undefined,
iconClass: note.getLabelValue("iconClass"),
promotedAttributes: displayedAttributesData,
className: clsx({archived: isArchived}, colorClass)

View File

@ -1,8 +1,19 @@
:root {
/* Default values to be overridden by themes */
--calendar-coll-event-background-lightness: 95%;
--calendar-coll-event-background-saturation: 80%;
--calendar-coll-event-background-color: var(--accented-background-color);
--calendar-coll-event-text-color: var(--primary-button-text-color);
--calendar-cell-event-hover-filter: none;
--calendar-coll-today-background-color: var(--more-accented-background-color);
}
.calendar-view {
--fc-event-border-color: var(--calendar-coll-event-text-color);
--fc-event-bg-color: var(--calendar-coll-event-background-color);
--fc-event-text-color: var(--calendar-coll-event-text-color);
--fc-event-selected-overlay-color: transparent;
--fc-today-bg-color: var(--calendar-coll-today-background-color);
overflow: hidden;
position: relative;
@ -12,8 +23,9 @@
padding: 10px;
}
.calendar-view a {
color: unset;
.calendar-view a,
:root .calendar-view a.fc-daygrid-event:hover {
color: var(--fc-event-text-color);
}
.search-result-widget-content .calendar-view {
@ -85,17 +97,25 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
/* #region Events */
.calendar-view a.fc-timegrid-event,
.calendar-view a.fc-daygrid-event {
.calendar-view a.fc-daygrid-event,
.fc-daygrid-dot-event .fc-event-title {
font-weight: 500;
}
.calendar-view a.fc-timegrid-event,
.calendar-view a.fc-daygrid-event:not(.fc-daygrid-dot-event) {
--border-color: transparent;
.calendar-view a.fc-timegrid-event:focus-visible,
.calendar-view a.fc-daygrid-event:focus-visible {
outline: none;
}
border-width: 2px 2px 2px 4px;
.calendar-view a.fc-timegrid-event,
.calendar-view a.fc-daygrid-event {
--border-color: transparent;
border: 2px solid;
border-left-width: 4px;
border-color: var(--border-color) var(--border-color) var(--border-color)
var(--fc-event-text-color) !important;
background: var(--fc-event-bg-color) !important;
padding-left: 8px;
}
@ -115,8 +135,8 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
color: currentColor;
}
.fc-timegrid-event.with-hue,
.fc-daygrid-event:not(.fc-daygrid-dot-event).with-hue {
.calendar-view .fc-timegrid-event.with-hue,
.calendar-view .fc-daygrid-event.with-hue {
--fc-event-text-color: var(--custom-color);
background: hsl(var(--custom-color-hue),
@ -124,8 +144,12 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
var(--calendar-coll-event-background-lightness)) !important;
}
.fc-event-time {
.calendar-view .fc-event-time {
opacity: .75;
}
.fc-daygrid-event-dot {
display: none;
}
/* #endregion */

View File

@ -1,8 +1,9 @@
import path from "path";
import path, { join } from "path";
import fs from "fs-extra";
import { LOCALES } from "@triliumnext/commons";
import { PRODUCT_NAME } from "../src/app-info.js";
import type { ForgeConfig } from "@electron-forge/shared-types";
import { existsSync } from "fs";
const ELECTRON_FORGE_DIR = __dirname;
@ -228,8 +229,22 @@ const config: ForgeConfig = {
// Ensure all locales that should be kept are actually present.
for (const locale of localesToKeep) {
if (!keptLocales.has(locale)) {
console.error(`Locale ${locale} was not found in the packaged app.`);
process.exit(1);
throw new Error(`Locale ${locale} was not found in the packaged app.`);
}
}
// Check that the bettersqlite3 binary has the right architecture.
if (packageResult.platform === "linux" && packageResult.arch === "arm64") {
for (const outputPath of packageResult.outputPaths) {
const binaryPath = join(outputPath, "resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node");
if (!existsSync(binaryPath)) {
throw new Error(`[better-sqlite3] Unable to find .node file at ${binaryPath}`);
}
const actualArch = getELFArch(binaryPath);
if (actualArch !== "ARM64") {
throw new Error(`[better-sqlite3] Expected ARM64 architecture but got ${actualArch} at: ${binaryPath}`);
}
}
}
},
@ -284,4 +299,20 @@ function getExtraResourcesForPlatform() {
return resources;
}
function getELFArch(file: string) {
const buf = fs.readFileSync(file);
if (buf[0] !== 0x7f || buf[1] !== 0x45 || buf[2] !== 0x4c || buf[3] !== 0x46) {
throw new Error("Not an ELF file");
}
const eiClass = buf[4]; // 1=32-bit, 2=64-bit
const eiMachine = buf[18]; // architecture code
if (eiMachine === 0x3E) return 'x86-64';
if (eiMachine === 0xB7) return 'ARM64';
return 'other';
}
export default config;

View File

@ -1,11 +1,11 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { note, NoteBuilder } from "../test/becca_mocking.js";
import {beforeEach, describe, expect, it, vi} from "vitest";
import {note, NoteBuilder} from "../test/becca_mocking.js";
import becca from "../becca/becca.js";
import BBranch from "../becca/entities/bbranch.js";
import BNote from "../becca/entities/bnote.js";
import tree from "./tree.js";
import cls from "./cls.js";
import { buildNote } from "../test/becca_easy_mocking.js";
import {buildNote} from "../test/becca_easy_mocking.js";
describe("Tree", () => {
let rootNote!: NoteBuilder;
@ -48,6 +48,23 @@ describe("Tree", () => {
};
});
});
it("sorts notes by title (base case)", () => {
const note = buildNote({
children: [
{title: "1"},
{title: "2"},
{title: "3"},
],
"#sorted": "",
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual(["1", "2", "3"]);
}
)
it("custom sort order is idempotent", () => {
rootNote.label("sorted", "order");
@ -56,13 +73,15 @@ describe("Tree", () => {
for (let i = 0; i <= 5; i++) {
rootNote.child(note(String(i)).label("order", String(i)));
}
rootNote.child(note("top").label("top"));
rootNote.child(note("bottom").label("bottom"));
// Add a few values which have no defined order.
for (let i = 6; i < 10; i++) {
rootNote.child(note(String(i)));
}
const expectedOrder = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ];
const expectedOrder = ["top", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "bottom"];
// Sort a few times to ensure that the resulting order is the same.
for (let i = 0; i < 5; i++) {
@ -78,12 +97,12 @@ describe("Tree", () => {
it("pins to the top and bottom", () => {
const note = buildNote({
children: [
{ title: "bottom", "#bottom": "" },
{ title: "5" },
{ title: "3" },
{ title: "2" },
{ title: "1" },
{ title: "top", "#top": "" }
{title: "bottom", "#bottom": ""},
{title: "5"},
{title: "3"},
{title: "2"},
{title: "1"},
{title: "top", "#top": ""}
],
"#sorted": ""
});
@ -91,18 +110,18 @@ describe("Tree", () => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual([ "top", "1", "2", "3", "5", "bottom" ]);
expect(orderedTitles).toStrictEqual(["top", "1", "2", "3", "5", "bottom"]);
});
it("pins to the top and bottom in reverse order", () => {
const note = buildNote({
children: [
{ title: "bottom", "#bottom": "" },
{ title: "1" },
{ title: "2" },
{ title: "3" },
{ title: "5" },
{ title: "top", "#top": "" }
{title: "bottom", "#bottom": ""},
{title: "1"},
{title: "2"},
{title: "3"},
{title: "5"},
{title: "top", "#top": ""}
],
"#sorted": "",
"#sortDirection": "desc"
@ -111,6 +130,50 @@ describe("Tree", () => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual([ "top", "5", "3", "2", "1", "bottom" ]);
expect(orderedTitles).toStrictEqual(["top", "5", "3", "2", "1", "bottom"]);
});
it("keeps folder notes on top when #sortFolderFirst is set, but not above #top", () => {
const note = buildNote({
children: [
{title: "bottom", "#bottom": ""},
{title: "1"},
{title: "2"},
{title: "p1", children: [{title: "1.1"}, {title: "1.2"}]},
{title: "p2", children: [{title: "2.1"}, {title: "2.2"}]},
{title: "3"},
{title: "5"},
{title: "top", "#top": ""}
],
"#sorted": "",
"#sortFoldersFirst": ""
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual(["top", "p1", "p2", "1", "2", "3", "5", "bottom"]);
});
it("sorts notes accordingly when #sortNatural is set", () => {
const note = buildNote({
children: [
{title: "bottom", "#bottom": ""},
{title: "1"},
{title: "2"},
{title: "10"},
{title: "20"},
{title: "3"},
{title: "top", "#top": ""}
],
"#sorted": "",
"#sortNatural": ""
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual(["top", "1", "2", "3", "10", "20", "bottom"]);
}
)
});

View File

@ -98,15 +98,6 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
}
notes.sort((a, b) => {
if (foldersFirst) {
const aHasChildren = a.hasChildren();
const bHasChildren = b.hasChildren();
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
// exactly one note of the two is a directory, so the sorting will be done based on this status
return aHasChildren ? -1 : 1;
}
}
function fetchValue(note: BNote, key: string) {
let rawValue: string | null;
@ -154,6 +145,16 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
}
if (foldersFirst) {
const aHasChildren = a.hasChildren();
const bHasChildren = b.hasChildren();
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
// exactly one note of the two is a directory, so the sorting will be done based on this status
return aHasChildren ? -1 : 1;
}
}
const customAEl = fetchValue(a, customSortBy) ?? fetchValue(a, "title") as string;
const customBEl = fetchValue(b, customSortBy) ?? fetchValue(b, "title") as string;